You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(116) |
May
(220) |
Jun
(52) |
Jul
(30) |
Aug
(35) |
Sep
(24) |
Oct
(49) |
Nov
(44) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(21) |
Feb
(30) |
Mar
(9) |
Apr
(44) |
May
(2) |
Jun
|
Jul
(10) |
Aug
(20) |
Sep
(25) |
Oct
(12) |
Nov
(16) |
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(10) |
2006 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
2007 |
Jan
(4) |
Feb
(57) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Elmer G. <ega...@us...> - 2004-11-04 03:11:38
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18306/sampleData Modified Files: testNu.rib Added Files: testNu2.rib Log Message: Fixed two nurbs bug and cleaned the code. Index: testNu.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/testNu.rib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testNu.rib 18 Apr 2004 20:04:49 -0000 1.1 --- testNu.rib 4 Nov 2004 03:11:28 -0000 1.2 *************** *** 1,21 **** ! Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 400 300 1 PixelSamples 4 4 Exposure 1 2.2 ! Projection "perspective" "fov" [20] WorldBegin ! Translate 0 0 20 ! Rotate 205 1 0 0 ! LightSource "ambientlight" 1 "intensity" [0.2] ! LightSource "distantlight" 2 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ShadingRate .25 ! # Surface "paintedplastic" "texturename" "checkerboard.txr" ! ! NuPatch 9 3 [ 0 0 0 1 1 2 2 3 3 4 4 4 ] 0 4 ! 2 2 [ 0 0 1 1 ] 0 1 ! "Pw" ! [ 1 0 0 1 1 1 0 1 0 2 0 2 -1 1 0 1 -1 0 0 1 -1 -1 0 1 0 -2 0 2 1 -1 0 1 1 0 0 1 ! 1 0 -3 1 1 1 -3 1 0 2 -6 2 -1 1 -3 1 -1 0 -3 1 -1 -1 -3 1 0 -2 -6 2 1 -1 -3 1 1 0 -3 1 ] WorldEnd --- 1,16 ---- ! Display "testNu" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 300 300 1 PixelSamples 4 4 Exposure 1 2.2 ! Projection "perspective" "fov" [40] WorldBegin ! Translate 0 0 40 ! Rotate 210 1 0 0 ! LightSource "distantlight" 1 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ShadingRate .25 ! Color .3 .5 1 ! #Surface "paintedplastic" "texturename" "checkerboard.txr" ! ReadArchive "vase.rib" WorldEnd --- NEW FILE: testNu2.rib --- Display "testNu" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 Format 300 300 1 PixelSamples 4 4 Exposure 1 2.2 Projection "perspective" "fov" [10] WorldBegin Translate 0 0 10 #Rotate 90 0 0 1 Rotate 230 1 0 0 LightSource "distantlight" 1 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ShadingRate .25 Color .3 .5 1 # Surface "paintedplastic" "texturename" "checkerboard.txr" NuPatch 9 3 [ 0 0 0 1 1 2 2 3 3 4 4 4 ] 0 4 2 2 [ 0 0 1 1 ] 0 1 "Pw" [ 1 0 0 1 1 1 0 1 0 2 0 2 -1 1 0 1 -1 0 0 1 -1 -1 0 1 0 -2 0 2 1 -1 0 1 1 0 0 1 1 0 -3 1 1 1 -3 1 0 2 -6 2 -1 1 -3 1 -1 0 -3 1 -1 -1 -3 1 0 -2 -6 2 1 -1 -3 1 1 0 -3 1 ] WorldEnd |
From: Gerardo H. <ma...@us...> - 2004-10-24 21:14:47
|
Update of /cvsroot/jrman/drafts/src/org/jrman/maps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21363/src/org/jrman/maps Modified Files: ShadowMap.java MipMap.java Log Message: Bug fixes. 1. Shadowmaps & mipmaps read/write from current directory (same as .rib file) 2. Closing last render frame doesn't exit jrmangui Index: ShadowMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/ShadowMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ShadowMap.java 27 Nov 2003 15:50:34 -0000 1.6 --- ShadowMap.java 24 Oct 2004 21:14:38 -0000 1.7 *************** *** 23,26 **** --- 23,27 ---- import java.io.DataInputStream; import java.io.DataOutputStream; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; *************** *** 42,45 **** --- 43,48 ---- private static Map map = new HashMap(); + + private static String currentDirectory; private FloatBuffer data; *************** *** 101,104 **** --- 104,111 ---- } + + public static void setCurrentDirectory(String currentDir) { + currentDirectory = currentDir; + } public static void writeShadowMap( *************** *** 111,114 **** --- 118,123 ---- throws IOException { Transform worldToRaster = cameraToRaster.concat(worldToCamera); + if (currentDirectory != null) + filename = currentDirectory + File.separator + filename; FileOutputStream fos = new FileOutputStream(filename); BufferedOutputStream bos = new BufferedOutputStream(fos); *************** *** 145,148 **** --- 154,159 ---- private ShadowMap(String filename) throws IOException { try { + if (currentDirectory != null) + filename = currentDirectory + File.separator + filename; FileInputStream fis = new FileInputStream(filename); DataInputStream dis = new DataInputStream(fis); Index: MipMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/MipMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MipMap.java 11 Sep 2004 17:36:27 -0000 1.6 --- MipMap.java 24 Oct 2004 21:14:38 -0000 1.7 *************** *** 55,58 **** --- 55,60 ---- private static Map map = new HashMap(); + + private static String currentDirectory; private ByteBuffer data; *************** *** 125,128 **** --- 127,134 ---- } + + public static void setCurrentDirectory(String currentDir) { + currentDirectory = currentDir; + } private static byte[] scaleDown( *************** *** 158,161 **** --- 164,169 ---- while (size < largerSide) size *= 2; + if (currentDirectory != null) + filename = currentDirectory + File.separator + filename; FileOutputStream fos = new FileOutputStream(filename); BufferedOutputStream bos = new BufferedOutputStream(fos); *************** *** 206,209 **** --- 214,219 ---- throws IOException { flushMipMap(filename); + if (currentDirectory != null) + imageFilename = currentDirectory + File.separator + imageFilename; File file = new File(imageFilename); BufferedImage image = ImageIO.read(file); *************** *** 234,237 **** --- 244,249 ---- private MipMap(String filename) throws IOException { + if (currentDirectory != null) + filename = currentDirectory + File.separator + filename; FileInputStream fis = new FileInputStream(filename); FileChannel fc = fis.getChannel(); |
From: Gerardo H. <ma...@us...> - 2004-10-24 21:14:47
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21363/src/org/jrman/parser Modified Files: Parser.java Log Message: Bug fixes. 1. Shadowmaps & mipmaps read/write from current directory (same as .rib file) 2. Closing last render frame doesn't exit jrmangui Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** Parser.java 13 Oct 2004 06:18:11 -0000 1.99 --- Parser.java 24 Oct 2004 21:14:38 -0000 1.100 *************** *** 199,203 **** this.currentDirectory = currentDirectory; } ! public void parse(String filename) throws Exception { if (currentDirectory != null) --- 199,207 ---- this.currentDirectory = currentDirectory; } ! ! public String getCurrentDirectory() { ! return currentDirectory; ! } ! public void parse(String filename) throws Exception { if (currentDirectory != null) |
From: Gerardo H. <ma...@us...> - 2004-10-24 21:14:47
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21363/src/org/jrman/render Modified Files: RendererHidden.java Log Message: Bug fixes. 1. Shadowmaps & mipmaps read/write from current directory (same as .rib file) 2. Closing last render frame doesn't exit jrmangui Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** RendererHidden.java 20 Sep 2004 21:09:06 -0000 1.66 --- RendererHidden.java 24 Oct 2004 21:14:38 -0000 1.67 *************** *** 477,482 **** if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { String name = frame.getDisplay().getName(); String ext = name.substring(name.lastIndexOf('.') + 1); ! File file = new File(frame.getDisplay().getName()); ImageIO.write(imageStore.getImage(), ext, file); } else if (displayMode == Display.Mode.Z) --- 477,485 ---- if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { String name = frame.getDisplay().getName(); + String currentDirectory = parser.getCurrentDirectory(); + if (currentDirectory != null) + name = currentDirectory + File.separator + name; String ext = name.substring(name.lastIndexOf('.') + 1); ! File file = new File(name); ImageIO.write(imageStore.getImage(), ext, file); } else if (displayMode == Display.Mode.Z) |
From: Gerardo H. <ma...@us...> - 2004-10-24 21:14:47
|
Update of /cvsroot/jrman/drafts/src/org/jrman/main In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21363/src/org/jrman/main Modified Files: JrManGUI.java JRMan.java Log Message: Bug fixes. 1. Shadowmaps & mipmaps read/write from current directory (same as .rib file) 2. Closing last render frame doesn't exit jrmangui Index: JrManGUI.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/main/JrManGUI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JrManGUI.java 11 Sep 2004 18:10:00 -0000 1.2 --- JrManGUI.java 24 Oct 2004 21:14:37 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- import java.awt.Frame; + import org.jrman.ui.Framebuffer; import org.jrman.ui.MainFrame; *************** *** 37,40 **** --- 38,42 ---- } */ + Framebuffer.dontExit(); MainFrame gui= new MainFrame(); centerOnScreen(gui); Index: JRMan.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/main/JRMan.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** JRMan.java 11 Sep 2004 18:10:00 -0000 1.9 --- JRMan.java 24 Oct 2004 21:14:37 -0000 1.10 *************** *** 29,32 **** --- 29,34 ---- import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; + import org.jrman.maps.MipMap; + import org.jrman.maps.ShadowMap; import org.jrman.parser.Parser; import org.jrman.util.Format; *************** *** 72,76 **** parser.begin(filename); File file = new File(filename); ! parser.setCurrentDirectory(file.getParent()); parser.parse(file.getName()); parser.end(); --- 74,81 ---- parser.begin(filename); File file = new File(filename); ! String directory = file.getParent(); ! parser.setCurrentDirectory(directory); ! MipMap.setCurrentDirectory(directory); ! ShadowMap.setCurrentDirectory(directory); parser.parse(file.getName()); parser.end(); |
From: Elmer G. <ega...@us...> - 2004-10-13 06:18:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13656/src/org/jrman/primitive Modified Files: Nurbs.java Log Message: Added Nurbs dice_p. Now renders some image. But is not rendering correctly. Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Nurbs.java 7 Oct 2004 05:21:16 -0000 1.3 --- Nurbs.java 13 Oct 2004 06:18:11 -0000 1.4 *************** *** 1,2 **** --- 1,21 ---- + /* + Nurbs.java + Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer Garduno Hernandez + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + package org.jrman.primitive; *************** *** 76,81 **** private SurfSample cnn = new SurfSample(); ! private static Point4f P = new Point4f(); //public Nurbs() { --- 95,102 ---- private SurfSample cnn = new SurfSample(); + + private static Point3f tmp = new Point3f(); ! // private static Point4f P = new Point4f(); //public Nurbs() { *************** *** 183,187 **** } ! public void updatePointsSize() { points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { --- 204,208 ---- } ! private void updatePointsSize() { points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { *************** *** 196,202 **** private int splitPt; ! private float max(float a, float b) { return (a > b) ? a : b; ! } private int max(int a, int b) { --- 217,223 ---- private int splitPt; ! /* private float max(float a, float b) { return (a > b) ? a : b; ! }*/ private int max(int a, int b) { *************** *** 680,684 **** } ! private void lineTriangle(SurfSample v0, SurfSample v1, SurfSample v2) { //moveTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); --- 701,705 ---- } ! // private void lineTriangle(SurfSample v0, SurfSample v1, SurfSample v2) { //moveTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); *************** *** 689,715 **** //lineTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); ! } ! private void emitTriangles(Nurbs n) { Point3f vecnn = new Point3f(); ! Point3f vec0n = new Point3f(); /* Diagonal vectors */ ! /* ! * Measure the distance along the two diagonals to decide the best way ! * to cut the rectangle into triangles. ! */ v3Sub(n.c00.point, n.cnn.point, vecnn); v3Sub(n.c0n.point, n.cn0.point, vec0n); ! float len2nn = v3SquaredLength(vecnn); /* Use these to reject triangles */ ! float len20n = v3SquaredLength(vec0n); /* that are too small to render */ if (max(len2nn, len20n) < EPSILON) ! return; /* Triangles are too small to render */ ! /* ! * Assign the texture coordinates ! */ float u0 = n.uknot[n.uorder - 1]; float un = n.uknot[n.nu]; --- 710,736 ---- //lineTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); ! // } ! /* private void emitTriangles(Nurbs n) { Point3f vecnn = new Point3f(); ! Point3f vec0n = new Point3f(); // Diagonal vectors ! // ! // Measure the distance along the two diagonals to decide the best way ! // to cut the rectangle into triangles. ! // v3Sub(n.c00.point, n.cnn.point, vecnn); v3Sub(n.c0n.point, n.cn0.point, vec0n); ! float len2nn = v3SquaredLength(vecnn); // Use these to reject triangles ! float len20n = v3SquaredLength(vec0n); // that are too small to render if (max(len2nn, len20n) < EPSILON) ! return; // Triangles are too small to render ! // ! // Assign the texture coordinates ! // float u0 = n.uknot[n.uorder - 1]; float un = n.uknot[n.nu]; *************** *** 725,731 **** n.cnn.v = vn; ! /* ! * If any normals are sick, fix them now. ! */ if ((n.c00.normLen == 0.0) || (n.cnn.normLen == 0.0) || (n.cn0.normLen == 0.0)) --- 746,752 ---- n.cnn.v = vn; ! // ! // If any normals are sick, fix them now. ! // if ((n.c00.normLen == 0.0) || (n.cnn.normLen == 0.0) || (n.cn0.normLen == 0.0)) *************** *** 742,746 **** } } ! private float v3SquaredLength(Point3f a) { return ((a.x * a.x) + (a.y * a.y) + (a.z * a.z)); --- 763,767 ---- } } ! */ private float v3SquaredLength(Point3f a) { return ((a.x * a.x) + (a.y * a.y) + (a.z * a.z)); *************** *** 899,903 **** return i; } ! /* * Sampled point on a surface. This contains the point, normal and surface --- 920,924 ---- return i; } ! /* * Sampled point on a surface. This contains the point, normal and surface *************** *** 955,973 **** protected void dice_P(ShaderVariables shaderVariables) { int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); Point3fGrid P = shaderVariables.P; ! System.out.println(P); for (int u = 0; u < uSize; u++) { for (int v = 0; v < vSize; v++) { ! // P.set(u, v, tmp); } } } ! protected void dice_Ng(ShaderVariables shaderVariables) { ! shaderVariables.Ng.set(shaderVariables.P); } /*public Primitive[] split() { Primitive[] result = new Primitive[2]; --- 976,1035 ---- protected void dice_P(ShaderVariables shaderVariables) { + /* + * If any normals are sick, fix them now. + */ + if ((c00.normLen == 0.0) || (cnn.normLen == 0.0) + || (cn0.normLen == 0.0)) + fixNormals(c00, cnn, cn0); + if (c0n.normLen == 0.0) + fixNormals(c00, c0n, cnn); + int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); Point3fGrid P = shaderVariables.P; ! ! /* Compute points on curve */ ! for (int u = 0; u < uSize; u++) { + float vPos = ( u /(float) uSize) + * (vknot[nv] - vknot[vorder - 1]) + + vknot[vorder - 1]; for (int v = 0; v < vSize; v++) { + float uPos = (v / (float) vSize) + * (uknot[nu] - uknot[uorder - 1]) + + uknot[uorder - 1]; + + Point3f n = new Point3f(); + Point3f utan = new Point3f(); + Point3f vtan = new Point3f(); ! calcPoint( uPos, vPos, tmp, utan, vtan ); ! P.set(u, v, tmp); ! /*v3Cross(utan, vtan, n ); ! float d = v3Length( n ); ! if (d != 0.0) ! { ! n.x /= d; ! n.y /= d; ! n.z /= d; ! } ! else ! { ! n.x = 0; ! n.y = 0; ! n.z = 0; ! } ! pts[i][j].normLen = d; ! pts[i][j].normal = n;*/ ! //pts[i][j].u = u; ! //pts[i][j].v = v; } } } ! protected void dice_Ng(ShaderVariables sv) { ! sv.Ng.cross(sv.dPdu, sv.dPdv); } + /*public Primitive[] split() { Primitive[] result = new Primitive[2]; *************** *** 1000,1003 **** --- 1062,1191 ---- return result; }*/ + + + + /* + * Compute Bi,k(u), for i = 0..k. + * u is the parameter of the spline to find the basis functions for + * brkPoint is the start of the knot interval ("segment") + * kv is the knot vector + * k is the order of the curve + * bvals is the array of returned basis values. + * + * (From Bartels, Beatty & Barsky, p.387) + */ + private void basisFunctions( float u, int brkPoint, + float[] kv, int k, float[] bvals ) { + bvals[0] = 1.0F; + for (int r = 2; r <= k; r++) + { + int i = brkPoint - r + 1; + bvals[r - 1] = 0.0F; + for (int s = r-2; s >= 0; s--) + { + i++; + + float omega = 0; + if (i >= 0) + omega = (u - kv[i]) / (kv[i + r - 1] - kv[i]); + bvals[s + 1] = bvals[s + 1] + (1 - omega) * bvals[s]; + bvals[s] = omega * bvals[s]; + } + } + } + + /* + * Compute derivatives of the basis functions Bi,k(u)' + */ + private void basisDerivatives( float u, int brkPoint, + float[] kv, int k, float[] dvals ) { + basisFunctions( u, brkPoint, kv, k - 1, dvals ); + + dvals[k - 1] = 0.0F; // BasisFunctions misses this + + float knotScale = kv[brkPoint + 1] - kv[brkPoint]; + + int i = brkPoint - k + 1; + for (int s = k - 2; s >= 0; s--) { + i++; + float omega = knotScale * (k - 1.0F) / (kv[i + k - 1] - kv[i]); + dvals[s + 1] += -omega * dvals[s]; + dvals[s] *= omega; + } + } + + private void calcPoint(float u, float v, Point3f p, Point3f utan, Point3f vtan) { + float[] bu = new float[uorder]; + float[] buprime = new float[uorder]; + float[] bv = new float[vorder]; + float[] bvprime = new float[vorder]; + Point4f r = new Point4f(); + Point4f rutan = new Point4f(); + Point4f rvtan = new Point4f(); + + // Evaluate non-uniform basis functions (and derivatives) + + int ubrkPoint = findBreakPoint( u, uknot, nu - 1, uorder ); + int ufirst = ubrkPoint - uorder + 1; + basisFunctions( u, ubrkPoint, uknot, uorder, bu ); + if (utan != null) + basisDerivatives( u, ubrkPoint, uknot, uorder, buprime ); + + int vbrkPoint = findBreakPoint( v, vknot, nv - 1, vorder ); + int vfirst = vbrkPoint - vorder + 1; + basisFunctions( v, vbrkPoint, vknot, vorder, bv ); + if (vtan != null) + basisDerivatives( v, vbrkPoint, vknot, vorder, bvprime ); + // Weight control points against the basis functions + + for (int i = 0; i < vorder; i++) + for (int j = 0; j < vorder; j++) + { + int ri = vorder - 1 - i; + int rj = uorder - 1 - j; + + float tmp = bu[rj] * bv[ri]; + Point4f cp = points[i + vfirst][j + ufirst]; + r.x += cp.x * tmp; + r.y += cp.y * tmp; + r.z += cp.z * tmp; + r.w += cp.w * tmp; + + if (utan != null) + { + tmp = buprime[rj] * bv[ri]; + rutan.x += cp.x * tmp; + rutan.y += cp.y * tmp; + rutan.z += cp.z * tmp; + rutan.w += cp.w * tmp; + } + if (vtan != null) + { + tmp = bu[rj] * bvprime[ri]; + rvtan.x += cp.x * tmp; + rvtan.y += cp.y * tmp; + rvtan.z += cp.z * tmp; + rvtan.w += cp.w * tmp; + } + } + + // Project tangents, using the quotient rule for differentiation + + float wsqrdiv = 1.0F / (r.w * r.w); + if (utan != null) { + utan.x = (r.w * rutan.x - rutan.w * r.x) * wsqrdiv; + utan.y = (r.w * rutan.y - rutan.w * r.y) * wsqrdiv; + utan.z = (r.w * rutan.z - rutan.w * r.z) * wsqrdiv; + } + if (vtan != null) { + vtan.x = (r.w * rvtan.x - rvtan.w * r.x) * wsqrdiv; + vtan.y = (r.w * rvtan.y - rvtan.w * r.y) * wsqrdiv; + vtan.z = (r.w * rvtan.z - rvtan.w * r.z) * wsqrdiv; + } + + p.x = r.x / r.w; + p.y = r.y / r.w; + p.z = r.z / r.w; + } } \ No newline at end of file |
From: Elmer G. <ega...@us...> - 2004-10-13 06:18:51
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13656/src/org/jrman/parser Modified Files: Parser.java Log Message: Added Nurbs dice_p. Now renders some image. But is not rendering correctly. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** Parser.java 7 Oct 2004 05:21:18 -0000 1.98 --- Parser.java 13 Oct 2004 06:18:11 -0000 1.99 *************** *** 24,32 **** import java.io.IOException; import java.io.StreamTokenizer; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; - import java.util.Iterator; - import java.util.List; import java.util.Map; import java.util.Set; --- 24,29 ---- *************** *** 37,41 **** import javax.vecmath.Matrix4f; import javax.vecmath.Point3f; - import javax.vecmath.Point4f; import javax.vecmath.Vector3f; --- 34,37 ---- *************** *** 73,77 **** import org.jrman.parameters.VaryingArrayFloat; import org.jrman.parameters.VaryingScalarFloat; - import org.jrman.parameters.VaryingScalarHPoint; import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.parser.keywords.AbstractKeywordParser; --- 69,72 ---- *************** *** 147,152 **** private int lastFrame = -1; - - private static Point4f P = new Point4f(); private int sphereCount; --- 142,145 ---- |
From: Elmer G. <ega...@us...> - 2004-10-07 05:22:39
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14777/src/org/jrman/primitive Modified Files: Nurbs.java Log Message: more updates to nurbs Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Nurbs.java 6 Oct 2004 14:02:22 -0000 1.2 --- Nurbs.java 7 Oct 2004 05:21:16 -0000 1.3 *************** *** 14,17 **** --- 14,18 ---- import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.render.ShaderVariables; + import org.jrman.util.Calc; public class Nurbs extends Primitive { *************** *** 78,84 **** private static Point4f P = new Point4f(); ! public Nurbs() { ! ! } public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, --- 79,84 ---- private static Point4f P = new Point4f(); ! //public Nurbs() { ! //} public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, *************** *** 118,127 **** } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); ! parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { ! paramHp.getValue((i * nu) + j, P); ! points[i][j] = P; } } --- 118,128 ---- } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); ! //parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { ! Point4f p = new Point4f(); ! paramHp.getValue((i * nu) + j, p); ! points[i][j] = p; } } *************** *** 923,927 **** */ } ! public Primitive[] split() { Nurbs[] result = new Nurbs[2]; --- 924,928 ---- */ } ! public Primitive[] split() { Nurbs[] result = new Nurbs[2]; *************** *** 939,944 **** dirflag = true; } ! result[0] = new Nurbs(); ! result[1] = new Nurbs(); splitSurface(result[0], result[1], dirflag); //doSubdivision(left, tolerance, dirflag, level + 1); --- 940,947 ---- dirflag = true; } ! result[0] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, parameters, attributes); ! result[1] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, parameters, attributes); splitSurface(result[0], result[1], dirflag); //doSubdivision(left, tolerance, dirflag, level + 1); *************** *** 951,977 **** } ! /*protected void dice_P(ShaderVariables shaderVariables) { int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); - float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); - float phiDelta = (phiMax - phiMin) / (vSize - 1); Point3fGrid P = shaderVariables.P; ! float theta = thetaMin; for (int u = 0; u < uSize; u++) { - float cosTheta = (float) Math.cos(theta); - float sinTheta = (float) Math.sin(theta); - float phi = phiMin; for (int v = 0; v < vSize; v++) { ! float cosPhi = (float) Math.cos(phi); ! float sinPhi = (float) Math.sin(phi); ! tmp.x = radius * cosTheta * cosPhi; ! tmp.y = radius * sinTheta * cosPhi; ! tmp.z = radius * sinPhi; ! P.set(u, v, tmp); ! phi += phiDelta; } - theta += thetaDelta; } ! }*/ protected void dice_Ng(ShaderVariables shaderVariables) { --- 954,969 ---- } ! protected void dice_P(ShaderVariables shaderVariables) { int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); Point3fGrid P = shaderVariables.P; ! System.out.println(P); for (int u = 0; u < uSize; u++) { for (int v = 0; v < vSize; v++) { ! ! // P.set(u, v, tmp); } } ! } protected void dice_Ng(ShaderVariables shaderVariables) { |
From: Elmer G. <ega...@us...> - 2004-10-07 05:22:23
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14777/src/org/jrman/parser Modified Files: Parser.java Log Message: more updates to nurbs Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** Parser.java 17 Sep 2004 06:33:46 -0000 1.97 --- Parser.java 7 Oct 2004 05:21:18 -0000 1.98 *************** *** 84,87 **** --- 84,88 ---- import org.jrman.primitive.Disk; import org.jrman.primitive.Hyperboloid; + import org.jrman.primitive.Nurbs; import org.jrman.primitive.ObjectInstance; import org.jrman.primitive.Paraboloid; *************** *** 1245,1375 **** final float vmin, final float vmax, ! final ParameterList parameters) { if (inAreaLightSource) return; ! float[] points = extractPoints(nu * nv, parameters); ! float[] ualfa = insert(uknot, uorder, nu); ! float[] valfa = insert(vknot, vorder, nv); ! int mu = ualfa.length / nu; ! int mv = valfa.length / nv; ! float[] tmp = new float[mu * nv * 4]; ! for (int i = 0; i < nv; i++) { ! divideu(ualfa, points, nu, i, tmp, mu); ! } ! float[] result = new float[mu * mv * 4]; ! for (int i = 0; i < mu; i++) { ! dividev(valfa, tmp, nv, i, result, mv, mu); ! } ! parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), result)); ! pushAttributes(); ! setBasis(Basis.BEZIER, 3, Basis.BEZIER, 3); ! addBicubicPatchMesh(mu, "nonperiodic", mv, "nonperiodic", parameters); ! popAttributes(); ! } ! ! private float[] insert(float[] x, int order, int n) { ! List l = new ArrayList(); ! float prev = x[0]; ! for (int i = 0; i < x.length; i++) { ! if (x[i] != prev) { ! insert(l, prev, order); ! prev = x[i]; ! } ! } ! insert(l, prev, order); ! float[] y = new float[l.size()]; ! int c = 0; ! for (Iterator it = l.iterator(); it.hasNext(); c++) { ! y[c] = ((Float) it.next()).floatValue(); ! } ! int m = y.length - order; ! float[] result = new float[m * n]; ! for (int j = 0; j < m; j++) { ! for (int i = 0; i < n; i++) { ! float alfa = evaluate(x, y, i, j, order); ! result[(j * n) + i] = alfa; ! } ! } ! return result; ! } ! ! private void divideu( ! float[] alfa, ! float[] points, ! int nu, ! int row, ! float[] result, ! int mu) { ! int srcOffset = nu * row * 4; ! int dstOffet = mu * row * 4; ! for (int j = 0; j < mu; j++) { ! for (int i = 0; i < nu; i++) { ! float a = alfa[(j * nu) + i]; ! result[dstOffet + j * 4] += points[srcOffset + i * 4] * a; ! result[dstOffet + j * 4 + 1] += points[srcOffset + i * 4 + 1] * a; ! result[dstOffet + j * 4 + 2] += points[srcOffset + i * 4 + 2] * a; ! result[dstOffet + j * 4 + 3] += points[srcOffset + i * 4 + 3] * a; ! } ! } ! } ! ! private void dividev( ! float[] alfa, ! float[] points, ! int nv, ! int column, ! float[] result, ! int mv, ! int mu) { ! for (int j = 0; j < mv; j++) { ! for (int i = 0; i < nv; i++) { ! float a = alfa[(j * nv) + i]; ! result[j * mu * 4 + column * 4] += points[i * mu * 4 + column * 4] * a; ! result[j * mu * 4 + column * 4 + 1] += points[i * mu * 4 + column * 4 + 1] * a; ! result[j * mu * 4 + column * 4 + 2] += points[i * mu * 4 + column * 4 + 2] * a; ! result[j * mu * 4 + column * 4 + 3] += points[i * mu * 4 + column * 4 + 3] * a; ! } ! } ! } ! ! private float evaluate(float[] x, float[] y, int i, int j, int k) { ! if (k == 1) ! if (x[i] <= y[j] && y[j] < x[i + 1]) ! return 1; ! else ! return 0; ! float a1 = evaluate(x, y, i, j, k - 1); ! float a2 = evaluate(x, y, i + 1, j, k - 1); ! return (a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) ! + (a2 != 0 ? ((x[i + k] - y[j + k - 1]) / (x[i + k] - x[i + 1])) : 0); ! } ! ! private void insert(List l, float x, int order) { ! Float f = new Float(x); ! for (int c = 0; c < order; c++) ! l.add(f); ! } ! ! private float[] extractPoints(int points, ParameterList parameters) { ! VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); ! if (param3f != null) { ! parameters.removeParameter("P"); ! parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); ! } ! VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); ! parameters.removeParameter("Pw"); ! float[] controlPoints = new float[points * 4]; ! for (int i = 0; i < points; i++) { ! paramHp.getValue(i, P); ! controlPoints[(4 * i)] = P.x; ! controlPoints[(4 * i) + 1] = P.y; ! controlPoints[(4 * i) + 2] = P.z; ! controlPoints[(4 * i) + 3] = P.w; } - return controlPoints; } public void addPointsPolygons( final int[] nVertices, --- 1246,1292 ---- final float vmin, final float vmax, ! final ParameterList parameters) { if (inAreaLightSource) return; ! if (!inObject) { ! renderer.addPrimitive( ! new Nurbs( ! nu, ! uorder, ! uknot, ! umin, ! umax, ! nv, ! vorder, ! vknot, ! vmin, ! vmax, ! parameters, ! getAttributes())); ! } else { ! final Transform transform = currentAttributes.getTransform(); ! currentObjectInstanceList ! .addPrimitiveCreator(new ObjectInstanceList.PrimitiveCreator() { ! public Primitive create(Attributes attributes) { ! hyperboloidCount++; ! return new Nurbs( ! nu, ! uorder, ! uknot, ! umin, ! umax, ! nv, ! vorder, ! vknot, ! vmin, ! vmax, ! parameters, ! createAttributes(transform, attributes)); ! } ! }); } } + public void addPointsPolygons( final int[] nVertices, |
From: Elmer G. <ega...@us...> - 2004-10-06 14:03:58
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30256/src/org/jrman/primitive Modified Files: Nurbs.java Log Message: More nurbs changes Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Nurbs.java 5 Oct 2004 13:45:31 -0000 1.1 --- Nurbs.java 6 Oct 2004 14:02:22 -0000 1.2 *************** *** 7,14 **** --- 7,17 ---- import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; + import org.jrman.grid.Grid; + import org.jrman.grid.Point3fGrid; import org.jrman.parameters.Declaration; import org.jrman.parameters.ParameterList; import org.jrman.parameters.VaryingScalarHPoint; import org.jrman.parameters.VaryingScalarTuple3f; + import org.jrman.render.ShaderVariables; public class Nurbs extends Primitive { *************** *** 218,223 **** } ! private Point4f getPoint(int i, int crvInd, boolean dirflag, Nurbs n) { ! return dirflag ? n.points[crvInd][i] : n.points[i][crvInd]; } --- 221,226 ---- } ! private Point4f getPoint(int i, int crvInd, boolean dirflag) { ! return dirflag ? points[crvInd][i] : points[i][crvInd]; } *************** *** 353,357 **** /* Construct new corners on the boundry between the two kids */ ! makeNewCorners(this, kid0, kid1, dirflag); } --- 356,360 ---- /* Construct new corners on the boundry between the two kids */ ! makeNewCorners(kid0, kid1, dirflag); } *************** *** 360,364 **** * the surface along with the normal. Prevent cracks that may occur. */ ! private void makeNewCorners(Nurbs parent, Nurbs kid0, Nurbs kid1, boolean dirflag) { divW(kid0.points[(kid0.nv - 1)][(kid0.nu - 1)], kid0.cnn.point); --- 363,367 ---- * the surface along with the normal. Prevent cracks that may occur. */ ! private void makeNewCorners(Nurbs kid0, Nurbs kid1, boolean dirflag) { divW(kid0.points[(kid0.nv - 1)][(kid0.nu - 1)], kid0.cnn.point); *************** *** 384,393 **** * normals) */ ! if (parent.strV0) ! projectToLine(parent.c00.point, parent.c0n.point, ! kid0.c0n.point); ! if (parent.strVn) ! projectToLine(parent.cn0.point, parent.cnn.point, ! kid0.cnn.point); kid1.c00.point = kid0.c0n.point; --- 387,394 ---- * normals) */ ! if (strV0) ! projectToLine(c00.point, c0n.point, kid0.c0n.point); ! if (strVn) ! projectToLine(cn0.point, cnn.point, kid0.cnn.point); kid1.c00.point = kid0.c0n.point; *************** *** 404,412 **** getNormal(0, (kid1.nu - 1)); ! if (parent.strU0) ! projectToLine(parent.c00.point, parent.cn0.point, kid0.cn0.point); ! if (parent.strUn) ! projectToLine(parent.c0n.point, parent.cnn.point, kid0.cnn.point); --- 405,413 ---- getNormal(0, (kid1.nu - 1)); ! if (strU0) ! projectToLine(c00.point, cn0.point, kid0.cn0.point); ! if (strUn) ! projectToLine(c0n.point, cnn.point, kid0.cnn.point); *************** *** 504,508 **** * straight (from the parent surface) it is assumed it will stay that way. */ ! private boolean testFlat(Nurbs n, float tolerance) { Point3f cp00 = new Point3f(); //by reference Point3f cp0n = new Point3f(); --- 505,509 ---- * straight (from the parent surface) it is assumed it will stay that way. */ ! private boolean testFlat(float tolerance) { Point3f cp00 = new Point3f(); //by reference Point3f cp0n = new Point3f(); *************** *** 513,554 **** /* Check edge straightness */ ! if (!n.strU0) ! n.strU0 = isCurveStraight(n, tolerance, 0, false); ! if (!n.strUn) ! n.strUn = isCurveStraight(n, tolerance, (n.nu - 1), false); ! if (!n.strV0) ! n.strV0 = isCurveStraight(n, tolerance, 0, true); ! if (!n.strVn) ! n.strVn = isCurveStraight(n, tolerance, (n.nv - 1), true); /* Test to make sure control points are straight in U and V */ boolean straight = true; ! if (!n.flatU && n.strV0 && n.strVn) ! for (int i = 1; (i < (n.nv - 1)) ! && (straight = isCurveStraight(n, tolerance, i, true)); i++) ! ; ! if (straight && n.strV0 && n.strVn) ! n.flatU = true; straight = true; ! if (!n.flatV && n.strU0 && n.strUn) ! for (int i = 1; (i < (n.nu - 1)) ! && (straight = isCurveStraight(n, tolerance, i, false)); i++) ; ! if (straight && n.strU0 && n.strUn) ! n.flatV = true; ! if (!n.flatV || !n.flatU) return false; /* The surface can pass the above tests but still be twisted. */ ! screenProject(n.points[0][0], cp00); ! screenProject(n.points[0][(n.nu - 1)], cp0n); ! screenProject(n.points[(n.nv - 1)][0], cpn0); ! screenProject(n.points[(n.nv - 1)][(n.nu - 1)], cpnn); v3Sub(cp0n, cp00, cp0n); /* Make edges into vectors */ --- 514,554 ---- /* Check edge straightness */ ! if (!strU0) ! strU0 = isCurveStraight(tolerance, 0, false); ! if (!strUn) ! strUn = isCurveStraight(tolerance, (nu - 1), false); ! if (!strV0) ! strV0 = isCurveStraight(tolerance, 0, true); ! if (!strVn) ! strVn = isCurveStraight(tolerance, (nv - 1), true); /* Test to make sure control points are straight in U and V */ boolean straight = true; ! if (!flatU && strV0 && strVn) ! for (int i = 1; (i < (nv - 1)) ! && (straight = isCurveStraight(tolerance, i, true)); i++); ! if (straight && strV0 && strVn) ! flatU = true; straight = true; ! if (!flatV && strU0 && strUn) ! for (int i = 1; (i < (nu - 1)) ! && (straight = isCurveStraight(tolerance, i, false)); i++) ; ! if (straight && strU0 && strUn) ! flatV = true; ! if (!flatV || !flatU) return false; /* The surface can pass the above tests but still be twisted. */ ! screenProject(points[0][0], cp00); ! screenProject(points[0][(nu - 1)], cp0n); ! screenProject(points[(nv - 1)][0], cpn0); ! screenProject(points[(nv - 1)][(nu - 1)], cpnn); v3Sub(cp0n, cp00, cp0n); /* Make edges into vectors */ *************** *** 571,575 **** } ! private boolean isCurveStraight(Nurbs n, double tolerance, int crvInd, boolean dirflag) /* If true, test in U direction, else test in V */ --- 571,575 ---- } ! private boolean isCurveStraight(double tolerance, int crvInd, boolean dirflag) /* If true, test in U direction, else test in V */ *************** *** 582,590 **** /* Special case: lines are automatically straight. */ ! if ((dirflag ? n.nu : n.nv) == 2) return true; ! int last = (dirflag ? n.nu : n.nv) - 1; ! screenProject(getPoint(0, crvInd, dirflag, n), e0); /* --- 582,590 ---- /* Special case: lines are automatically straight. */ ! if ((dirflag ? nu : nv) == 2) return true; ! int last = (dirflag ? nu : nv) - 1; ! screenProject(getPoint(0, crvInd, dirflag), e0); /* *************** *** 595,599 **** float linelen = 0.0F; for (int i = last; (i > 0) && (linelen < EPSILON); i--) { ! screenProject(getPoint(i, crvInd, dirflag, n), cp); v3Sub(cp, e0, vec); --- 595,599 ---- float linelen = 0.0F; for (int i = last; (i > 0) && (linelen < EPSILON); i--) { ! screenProject(getPoint(i, crvInd, dirflag), cp); v3Sub(cp, e0, vec); *************** *** 613,617 **** * the line. */ ! screenProject(getPoint(i, crvInd, dirflag, n), cp); v3Sub(cp, e0, p); --- 613,617 ---- * the line. */ ! screenProject(getPoint(i, crvInd, dirflag), cp); v3Sub(cp, e0, p); *************** *** 929,932 **** --- 929,933 ---- // emitTriangles(n); // } else { + testFlat(SUBDIV_TOLERANCE); if ((!flatV && !flatU) || (flatV && flatU)) dirflag = !dirflag; /* If twisted or curved in both directions, */ *************** *** 950,953 **** --- 951,981 ---- } + /*protected void dice_P(ShaderVariables shaderVariables) { + int uSize = Grid.getUSize(); + int vSize = Grid.getVSize(); + float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); + float phiDelta = (phiMax - phiMin) / (vSize - 1); + Point3fGrid P = shaderVariables.P; + float theta = thetaMin; + for (int u = 0; u < uSize; u++) { + float cosTheta = (float) Math.cos(theta); + float sinTheta = (float) Math.sin(theta); + float phi = phiMin; + for (int v = 0; v < vSize; v++) { + float cosPhi = (float) Math.cos(phi); + float sinPhi = (float) Math.sin(phi); + tmp.x = radius * cosTheta * cosPhi; + tmp.y = radius * sinTheta * cosPhi; + tmp.z = radius * sinPhi; + P.set(u, v, tmp); + phi += phiDelta; + } + theta += thetaDelta; + } + }*/ + + protected void dice_Ng(ShaderVariables shaderVariables) { + shaderVariables.Ng.set(shaderVariables.P); + } /*public Primitive[] split() { Primitive[] result = new Primitive[2]; |
From: Elmer G. <ega...@us...> - 2004-10-05 13:46:39
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2503/src/org/jrman/primitive Added Files: Nurbs.java Log Message: Added Nurbs Primitive --- NEW FILE: Nurbs.java --- package org.jrman.primitive; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; import org.jrman.parameters.Declaration; import org.jrman.parameters.ParameterList; import org.jrman.parameters.VaryingScalarHPoint; import org.jrman.parameters.VaryingScalarTuple3f; public class Nurbs extends Primitive { /* Size, in pixels of facets produced */ private final static float SUBDIV_TOLERANCE = 2.0F; /* Used to determine when things are too small. */ private final static float EPSILON = 0.0000001F; /* Number of Points in the U and V directions, respectivly */ private int nu; private int nv; /* Order of the surface in U and V (must be >= 2, < MAXORDER) */ private int uorder; private int vorder; /* Knot vectors, indexed as [0..numU+orderU-1] and [0..numV+orderV-1] */ private float[] uknot; private float[] vknot; private float umin; private float umax; private float vmin; private float vmax; private boolean dirflag = true; /* Control points, indexed as points[0..numV-1][0..numU-1] */ /* Note the w values are *premultiplied* with the x, y and z values */ private Point4f[][] points; /* These fields are added to support subdivision */ private boolean strV0; private boolean strVn; /* Edge straightness flags for subdivision */ private boolean strU0; private boolean strUn; /* Surface flatness flags for subdivision */ private boolean flatV; private boolean flatU; /* Corner data structures for subdivision */ private SurfSample c00 = new SurfSample(); private SurfSample c0n = new SurfSample(); private SurfSample cn0 = new SurfSample(); private SurfSample cnn = new SurfSample(); private static Point4f P = new Point4f(); public Nurbs() { } public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, int nv, int vorder, float[] vknot, float vmin, float vmax, ParameterList parameters, Attributes attributes) { super(parameters, attributes); this.nu = nu; this.uorder = uorder; this.uknot = uknot; this.umin = umin; this.umax = umax; this.nv = nv; this.vorder = vorder; this.vknot = vknot; this.vmin = vmin; this.vmax = vmax; extractPoints(parameters); } public BoundingVolume getBoundingVolume() { ConvexHull3f ch = new ConvexHull3f(); for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { ch.addHpoint(points[i][j]); } } return ch; } private void extractPoints(ParameterList parameters) { VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { parameters.removeParameter("P"); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { paramHp.getValue((i * nu) + j, P); points[i][j] = P; } } /* * Initialize the projected corners of the surface and the normals. */ divW(points[0][0], c00.point); divW(points[0][nu - 1], c0n.point); divW(points[nv - 1][0], cn0.point); divW(points[nv - 1][nu - 1], cnn.point); getNormal(0, 0); getNormal(0, (nu - 1)); getNormal((nv - 1), 0); getNormal((nv - 1), (nu - 1)); } public Nurbs(Nurbs parent) { copy(parent); } public void copy(Nurbs parent) { nu = parent.nu; nv = parent.nv; uorder = parent.uorder; vorder = parent.vorder; uknot = new float[nu + uorder]; vknot = new float[nv + vorder]; points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { points[i][j] = new Point4f(); } } strV0 = parent.strV0; strVn = parent.strVn; strU0 = parent.strU0; strUn = parent.strUn; flatV = parent.flatV; flatU = parent.flatU; //c00 = new SurfSample(parent.c00); //c0n = new SurfSample(parent.c0n); //cn0 = new SurfSample(parent.cn0); //cnn = new SurfSample(parent.cnn); } public void updatePointsSize() { points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { for (int j = 0; j < nu; j++) { points[i][j] = new Point4f(); } } } private float[] newkv; private int splitPt; private float max(float a, float b) { return (a > b) ? a : b; } private int max(int a, int b) { return (a > b) ? a : b; } private int min(int a, int b) { return (a < b) ? a : b; } private final static int MAXORDER = 20; private void divW(Point4f rpt, Point3f pt) { pt.x = rpt.x / rpt.w; pt.y = rpt.y / rpt.w; pt.z = rpt.z / rpt.w; } private void divPoint(Point3f p, float dn) { p.x /= dn; p.y /= dn; p.z /= dn; } private Point4f getPoint(int i, int crvInd, boolean dirflag, Nurbs n) { return dirflag ? n.points[crvInd][i] : n.points[i][crvInd]; } private void screenProject(Point4f worldPt, Point3f screenPt) { screenPt.x = worldPt.x / worldPt.w * 100 + 200; screenPt.y = worldPt.y / worldPt.w * 100 + 200; screenPt.z = worldPt.z / worldPt.w * 100 + 200; } /* * Compute the normal of a corner point of a mesh. The base is the value of * the point at the corner, indU and indV are the mesh indices of that point * (either 0 or numU|numV). */ private void getNormal(int indV, int indU) { Point3f tmpL = new Point3f(); Point3f tmpR = new Point3f(); /* "Left" and "Right" of the base point */ SurfSample crnr; if (((indU != 0) && (indV != 0)) || ((indU == 0) && (indV == 0))) { if (indU != 0) crnr = cnn; else crnr = c00; divW(points[indV][((indU != 0) ? (indU - 1) : 1)], tmpL); divW(points[((indV != 0) ? (indV - 1) : 1)][indU], tmpR); } else { if (indU != 0) crnr = c0n; else crnr = cn0; divW(points[indV][((indU != 0) ? (indU - 1) : 1)], tmpR); divW(points[((indV != 0) ? (indV - 1) : 1)][indU], tmpL); } v3Sub(tmpL, crnr.point, tmpL); v3Sub(tmpR, crnr.point, tmpR); v3Cross(tmpL, tmpR, crnr.normal); adjustNormal(crnr); } /* * Normalize the normal in a sample. If it's degenerate, flag it as such by * setting the normLen to 0.0 */ private void adjustNormal(SurfSample samp) { /* If it's not degenerate, do the normalization now */ samp.normLen = v3Length(samp.normal); if (samp.normLen < EPSILON) samp.normLen = 0.0F; else divPoint(samp.normal, samp.normLen); } /* * Split a surface into two halves. First inserts multiplicity k knots in * the center of the parametric range. After refinement, the two resulting * surfaces are copied into separate data structures. If the parent surface * had straight edges, the points of the children are projected onto those * edges. */ /* * If true subdivided in U, else in V */ private void splitSurface(Nurbs kid0, Nurbs kid1, boolean dirflag) { /* * Add a multiplicty k knot to the knot vector in the direction * specified by dirflag, and refine the surface. This creates two * adjacent surfaces with c0 discontinuity at the seam. */ Nurbs tmp = new Nurbs(this); if (dirflag) { tmp.nu = nu + splitKV(uknot, (nu - 1), uorder); tmp.uknot = newkv; for (int i = 0; i < nv + tmp.vorder; i++) tmp.vknot[i] = vknot[i]; } else { tmp.nv = nv + splitKV(vknot, (nv - 1), vorder); tmp.vknot = newkv; for (int i = 0; i < tmp.nu + tmp.uorder; i++) tmp.uknot[i] = uknot[i]; } tmp.updatePointsSize(); refineSurface(tmp, dirflag); /* * Build the two child surfaces, and copy the data from the refined * version of the parent (tmp) into the two children */ /* First half */ kid0.copy(this); /* copy various edge flags and orders */ kid0.nu = dirflag ? splitPt + 1 : nu; kid0.nv = dirflag ? nv : splitPt + 1; for (int i = 0; i < kid0.nv; i++) /* Copy the point and kv data */ for (int j = 0; j < kid0.nu; j++) kid0.points[i][j] = tmp.points[i][j]; for (int i = 0; i < kid0.uorder + kid0.nu; i++) kid0.uknot[i] = tmp.uknot[i]; for (int i = 0; i < kid0.vorder + kid0.nv; i++) kid0.vknot[i] = tmp.vknot[i]; /* Second half */ splitPt++; kid1.copy(this); kid1.nu = dirflag ? tmp.nu - splitPt : nu; kid1.nv = dirflag ? nv : tmp.nv - splitPt; for (int i = 0; i < kid1.nv; i++) /* Copy the point and kv data */ for (int j = 0; j < kid1.nu; j++) kid1.points[i][j] = tmp.points[dirflag ? i : (i + splitPt)] [dirflag ? (j + splitPt) : j]; for (int i = 0; i < kid1.uorder + kid1.nu; i++) kid1.uknot[i] = tmp.uknot[dirflag ? (i + splitPt) : i]; for (int i = 0; i < kid1.vorder + kid1.nv; i++) kid1.vknot[i] = tmp.vknot[dirflag ? i : (i + splitPt)]; /* Construct new corners on the boundry between the two kids */ makeNewCorners(this, kid0, kid1, dirflag); } /* * Build the new corners in the two new surfaces, computing both point on * the surface along with the normal. Prevent cracks that may occur. */ private void makeNewCorners(Nurbs parent, Nurbs kid0, Nurbs kid1, boolean dirflag) { divW(kid0.points[(kid0.nv - 1)][(kid0.nu - 1)], kid0.cnn.point); getNormal((kid0.nv - 1), (kid0.nu - 1)); if (dirflag) { kid0.strUn = false; /* Must re-test new edge straightness */ divW(kid0.points[0][(kid0.nu - 1)], kid0.c0n.point); getNormal(0, (kid0.nu - 1)); /* * Normals must be re-calculated for kid1 in case the surface was * split at a c1 (or c0!) discontinutiy */ kid1.c00.point = kid0.c0n.point; getNormal(0, 0); kid1.cn0.point = kid0.cnn.point; getNormal((kid1.nv - 1), 0); /* * Prevent cracks from forming by forcing the points on the seam to * lie along any straight edges. (Must do this BEFORE finding * normals) */ if (parent.strV0) projectToLine(parent.c00.point, parent.c0n.point, kid0.c0n.point); if (parent.strVn) projectToLine(parent.cn0.point, parent.cnn.point, kid0.cnn.point); kid1.c00.point = kid0.c0n.point; kid1.cn0.point = kid0.cnn.point; kid1.strU0 = false; } else { kid0.strVn = false; divW(kid0.points[(kid0.nv - 1)][0], kid0.cn0.point); getNormal((kid0.nv - 1), 0); kid1.c00.point = kid0.cn0.point; getNormal(0, 0); kid1.c0n.point = kid0.cnn.point; getNormal(0, (kid1.nu - 1)); if (parent.strU0) projectToLine(parent.c00.point, parent.cn0.point, kid0.cn0.point); if (parent.strUn) projectToLine(parent.c0n.point, parent.cnn.point, kid0.cnn.point); kid1.c00.point = kid0.cn0.point; kid1.c0n.point = kid0.cnn.point; kid1.strV0 = false; } } /* * Given a line defined by firstPt and lastPt, project midPt onto that line. * Used for fixing "cracks". */ private void projectToLine(Point3f firstPt, Point3f lastPt, Point3f midPt) { Point3f v0 = new Point3f(); Point3f vm = new Point3f(); Point3f base = firstPt; v3Sub(lastPt, base, v0); v3Sub(midPt, base, vm); float denom = v3SquaredLength(v0); float fraction = (denom == 0.0) ? 0.0F : (v3Dot(v0, vm) / denom); midPt.x = base.x + fraction * v0.x; midPt.y = base.y + fraction * v0.y; midPt.z = base.z + fraction * v0.z; } /* * Split a knot vector at the center, by adding multiplicity k knots near * the middle of the parameter range. Tries to start with an existing knot, * but will add a new knot value if there's nothing in "the middle" (e.g., a * Bezier curve). */ private int splitKV(float[] srckv, int m, int k) { int extra = 0; int last = (m + k); int middex = last / 2; float midVal = srckv[middex]; /* Search forward and backward to see if multiple knot is already there */ int i = middex + 1; int same = 1; while ((i < last) && (srckv[i] == midVal)) { i++; same++; } i = middex - 1; while ((i > 0) && (srckv[i] == midVal)) { i--; middex--; /* middex is start of multiple knot */ same++; } if (i <= 0) /* No knot in middle, must create it */ { midVal = (srckv[0] + srckv[last]) / 2.0F; middex = last / 2; while (srckv[middex + 1] < midVal) middex++; same = 0; } extra = k - same; newkv = new float[m + k + extra + 1]; if (same < k) /* Must add knots */ { for (i = 0; i <= middex; i++) newkv[i] = srckv[i]; for (i = middex + 1; i <= middex + extra; i++) newkv[i] = midVal; for (i = middex + k - same + 1; i <= m + k + extra; i++) newkv[i] = srckv[i - extra]; } else { for (i = 0; i <= m + k; i++) newkv[i] = srckv[i]; } splitPt = (extra < k) ? middex - 1 : middex; return extra; } /* * Check to see if a surface is flat. Tests are only performed on edges and * directions that aren't already straight. If an edge is flagged as * straight (from the parent surface) it is assumed it will stay that way. */ private boolean testFlat(Nurbs n, float tolerance) { Point3f cp00 = new Point3f(); //by reference Point3f cp0n = new Point3f(); Point3f cpn0 = new Point3f(); Point3f cpnn = new Point3f(); Point3f planeEqn = new Point3f(); /* Check edge straightness */ if (!n.strU0) n.strU0 = isCurveStraight(n, tolerance, 0, false); if (!n.strUn) n.strUn = isCurveStraight(n, tolerance, (n.nu - 1), false); if (!n.strV0) n.strV0 = isCurveStraight(n, tolerance, 0, true); if (!n.strVn) n.strVn = isCurveStraight(n, tolerance, (n.nv - 1), true); /* Test to make sure control points are straight in U and V */ boolean straight = true; if (!n.flatU && n.strV0 && n.strVn) for (int i = 1; (i < (n.nv - 1)) && (straight = isCurveStraight(n, tolerance, i, true)); i++) ; if (straight && n.strV0 && n.strVn) n.flatU = true; straight = true; if (!n.flatV && n.strU0 && n.strUn) for (int i = 1; (i < (n.nu - 1)) && (straight = isCurveStraight(n, tolerance, i, false)); i++) ; if (straight && n.strU0 && n.strUn) n.flatV = true; if (!n.flatV || !n.flatU) return false; /* The surface can pass the above tests but still be twisted. */ screenProject(n.points[0][0], cp00); screenProject(n.points[0][(n.nu - 1)], cp0n); screenProject(n.points[(n.nv - 1)][0], cpn0); screenProject(n.points[(n.nv - 1)][(n.nu - 1)], cpnn); v3Sub(cp0n, cp00, cp0n); /* Make edges into vectors */ v3Sub(cpn0, cp00, cpn0); /* * Compute the plane equation from two adjacent sides, and measure the * distance from the far point to the plane. If it's larger than * tolerance, the surface is twisted. */ v3Cross(cpn0, cp0n, planeEqn); v3Normalize(planeEqn); /* Normalize to keep adds in sync w/ mults */ float d = v3Dot(planeEqn, cp00); float dist = Math.abs(v3Dot(planeEqn, cpnn) - d); return (dist > tolerance) ? false : true; /* Surface is twisted */ } private boolean isCurveStraight(Nurbs n, double tolerance, int crvInd, boolean dirflag) /* If true, test in U direction, else test in V */ { Point3f p = new Point3f(); Point3f vec = new Point3f(); Point3f prod = new Point3f(); Point3f cp = new Point3f(); // by reference Point3f e0 = new Point3f(); /* Special case: lines are automatically straight. */ if ((dirflag ? n.nu : n.nv) == 2) return true; int last = (dirflag ? n.nu : n.nv) - 1; screenProject(getPoint(0, crvInd, dirflag, n), e0); /* * Form an initial line to test the other points against (skiping degen * lines) */ float linelen = 0.0F; for (int i = last; (i > 0) && (linelen < EPSILON); i--) { screenProject(getPoint(i, crvInd, dirflag, n), cp); v3Sub(cp, e0, vec); linelen = v3Length(vec); } divPoint(vec, linelen); if (linelen > EPSILON) /* * If no non-degenerate lines found, it's all * degen */ for (int i = 1; i <= last; i++) { /* * The cross product of the vector defining the initial line * with the vector of the current point gives the distance to * the line. */ screenProject(getPoint(i, crvInd, dirflag, n), cp); v3Sub(cp, e0, p); v3Cross(p, vec, prod); float dist = v3Length(prod); if (dist > tolerance) return false; } return true; } /* * If a normal has collapsed to zero (normLen == 0.0) then try and fix it by * looking at its neighbors. If all the neighbors are sick, then re-compute * them from the plane they form. If that fails too, then we give up... */ private void fixNormals(SurfSample s0, SurfSample s1, SurfSample s2) { boolean goodnorm = false; SurfSample[] V = new SurfSample[3]; Point3f norm = new Point3f(); int ok; V[0] = s0; V[1] = s1; V[2] = s2; /* Find a reasonable normal */ for (ok = 0; (ok < 3) && !(goodnorm = (V[ok].normLen > 0.0)); ok++) ; if (!goodnorm) /* All provided normals are zilch, try and invent one */ { norm.x = 0.0F; norm.y = 0.0F; norm.z = 0.0F; for (int i = 0; i < 3; i++) { int j = (i + 1) % 3; norm.x += (V[i].point.y - V[j].point.y) * (V[i].point.z + V[j].point.z); norm.y += (V[i].point.z - V[j].point.z) * (V[i].point.x + V[j].point.x); norm.z += (V[i].point.x - V[j].point.x) * (V[i].point.y + V[j].point.y); } float dist = v3Length(norm); if (dist == 0.0) return; /* This sucker's hopeless... */ divPoint(norm, dist); for (int i = 0; i < 3; i++) { V[i].normal = norm; V[i].normLen = dist; } } else /* Replace a sick normal with a healthy one nearby */ { for (int i = 0; i < 3; i++) if ((i != ok) && (V[i].normLen == 0.0)) V[i].normal = V[ok].normal; } return; } private void lineTriangle(SurfSample v0, SurfSample v1, SurfSample v2) { //moveTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); //lineTo((int) (v1.point.x * 100 + 200), (int) (v1.point.y * 100 + // 200)); //lineTo((int) (v2.point.x * 100 + 200), (int) (v2.point.y * 100 + // 200)); //lineTo((int) (v0.point.x * 100 + 200), (int) (v0.point.y * 100 + // 200)); } private void emitTriangles(Nurbs n) { Point3f vecnn = new Point3f(); Point3f vec0n = new Point3f(); /* Diagonal vectors */ /* * Measure the distance along the two diagonals to decide the best way * to cut the rectangle into triangles. */ v3Sub(n.c00.point, n.cnn.point, vecnn); v3Sub(n.c0n.point, n.cn0.point, vec0n); float len2nn = v3SquaredLength(vecnn); /* Use these to reject triangles */ float len20n = v3SquaredLength(vec0n); /* that are too small to render */ if (max(len2nn, len20n) < EPSILON) return; /* Triangles are too small to render */ /* * Assign the texture coordinates */ float u0 = n.uknot[n.uorder - 1]; float un = n.uknot[n.nu]; float v0 = n.vknot[n.vorder - 1]; float vn = n.vknot[n.nv]; n.c00.u = u0; n.c00.v = v0; n.c0n.u = un; n.c0n.v = v0; n.cn0.u = u0; n.cn0.v = vn; n.cnn.u = un; n.cnn.v = vn; /* * If any normals are sick, fix them now. */ if ((n.c00.normLen == 0.0) || (n.cnn.normLen == 0.0) || (n.cn0.normLen == 0.0)) fixNormals(n.c00, n.cnn, n.cn0); if (n.c0n.normLen == 0.0) fixNormals(n.c00, n.c0n, n.cnn); if (len2nn < len20n) { lineTriangle(n.c00, n.cnn, n.cn0); lineTriangle(n.c00, n.c0n, n.cnn); } else { lineTriangle(n.c0n, n.cnn, n.cn0); lineTriangle(n.c0n, n.cn0, n.c00); } } private float v3SquaredLength(Point3f a) { return ((a.x * a.x) + (a.y * a.y) + (a.z * a.z)); } private float v3Length(Point3f a) { return (float) Math.sqrt(v3SquaredLength(a)); } private float v3Dot(Point3f a, Point3f b) { return ((a.x * b.x) + (a.y * b.y) + (a.z * b.z)); } private void v3Normalize(Point3f v) { float len = v3Length(v); if (len != 0.0) { v.x /= len; v.y /= len; v.z /= len; } } private void v3Cross(Point3f a, Point3f b, Point3f c) { c.x = (a.y * b.z) - (a.z * b.y); c.y = (a.z * b.x) - (a.x * b.z); c.z = (a.x * b.y) - (a.y * b.x); } private void v3Sub(Point3f a, Point3f b, Point3f c) { c.x = a.x - b.x; c.y = a.y - b.y; c.z = a.z - b.z; } /* * Given the original knot vector ukv, and a new knotvector vkv, compute the * "alpha matrix" used to generate the corresponding new control points. * This routines allocates the alpha matrix if it isn't allocated already. * * This is from Bartels, Beatty & Barsky, p. 407 */ private float[][] calcAlpha(float[] ukv, float[] wkv, int m, int n, int k) { float[] aval = new float[MAXORDER]; float[][] alpha = new float[k + 1][m + n + 1]; for (int j = 0; j <= m + n; j++) { int brkPoint = findBreakPoint(wkv[j], ukv, m, k); aval[0] = 1.0F; for (int r = 2; r <= k; r++) { int rm1 = r - 1; int last = min(rm1, brkPoint); int i = brkPoint - last; if (last < rm1) aval[last] = aval[last] * (wkv[j + r - 1] - ukv[i]) / (ukv[i + r - 1] - ukv[i]); else aval[last] = 0.0F; for (int s = last - 1; s >= 0; s--) { i++; float omega = (wkv[j + r - 1] - ukv[i]) / (ukv[i + r - 1] - ukv[i]); aval[s + 1] = aval[s + 1] + (1 - omega) * aval[s]; aval[s] = omega * aval[s]; } } int last = min(k - 1, brkPoint); for (int i = 0; i <= k; i++) alpha[i][j] = 0.0F; for (int s = 0; s <= last; s++) alpha[last - s][j] = aval[s]; } return alpha; } /* * Apply the alpha matrix computed above to the rows (or columns) of the * surface. If dirflag is true do the U's (row), else do V's (col). */ private void refineSurface(Nurbs dest, boolean dirflag) { int maxj; int maxout; float[][] alpha; /* * Compute the alpha matrix and indexing variables for the requested * direction */ if (dirflag) { alpha = calcAlpha(uknot, dest.uknot, nu - 1, dest.nu - nu, uorder); maxj = dest.nu; maxout = dest.nv; //nv?? } else { alpha = calcAlpha(vknot, dest.vknot, nv - 1, dest.nv - nv, vorder); maxj = dest.nv; maxout = dest.nu; } /* * Apply the alpha matrix to the original control points, generating new * ones */ for (int out = 0; out < maxout; out++) for (int j = 0; j < maxj; j++) { int brkPoint; int i1; Point4f dp; Point4f sp; if (dirflag) { dp = dest.points[out][j]; brkPoint = findBreakPoint(dest.uknot[j], uknot, nu - 1, uorder); i1 = max(brkPoint - uorder + 1, 0); sp = points[out][i1]; } else { dp = dest.points[j][out]; brkPoint = findBreakPoint(dest.vknot[j], vknot, nv - 1, vorder); i1 = max(brkPoint - vorder + 1, 0); sp = points[i1][out]; } dp.x = 0.0F; dp.y = 0.0F; dp.z = 0.0F; dp.w = 0.0F; for (int i = i1; i <= brkPoint; i++) { double tmp = alpha[i - i1][j]; sp = (dirflag ? points[out][i] : points[i][out]); dp.x += tmp * sp.x; dp.y += tmp * sp.y; dp.z += tmp * sp.z; dp.w += tmp * sp.w; } } } /* * Return the current knot the parameter u is less than or equal to. Find * this "breakpoint" allows the evaluation routines to concentrate on only * those control points actually effecting the curve around u.] * * m is the number of points on the curve (or surface direction) k is the * order of the curve (or surface direction) kv is the knot vector * ([0..m+k-1]) to find the break point in. */ private int findBreakPoint(float u, float[] kv, int m, int k) { if (u == kv[m + 1]) /* Special case for closed interval */ return m; int i = m + k; while ((u < kv[i]) && (i > 0)) i--; return i; } /* * Sampled point on a surface. This contains the point, normal and surface * coordinates (u,v). This structure is passed to the rendering code for * shading, etc. */ private final static class SurfSample { /* Point on surface, normal at that point */ Point3f point = new Point3f(); Point3f normal = new Point3f(); /* Used for normalizing normals */ float normLen; /* Parameters, e.g., used for texture mapping. */ float u; float v; /* * Note the parameter's range is determined by the surface's knot * vector, i.e., u goes from kvU[orderU-1] to kvU[numU], and likewise * for v */ } public Primitive[] split() { Nurbs[] result = new Nurbs[2]; // if (testFlat(n, tolerance)) { // emitTriangles(n); // } else { if ((!flatV && !flatU) || (flatV && flatU)) dirflag = !dirflag; /* If twisted or curved in both directions, */ else /* then alternate subdivision direction */ { if (flatU) /* Only split in directions that aren't flat */ dirflag = false; else dirflag = true; } result[0] = new Nurbs(); result[1] = new Nurbs(); splitSurface(result[0], result[1], dirflag); //doSubdivision(left, tolerance, dirflag, level + 1); //doSubdivision(right, tolerance, dirflag, level + 1); //} //doSubdivision(this, SUBDIV_TOLERANCE, true, 0); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); return result; } /*public Primitive[] split() { Primitive[] result = new Primitive[2]; extractPoints(); vtmp.sub(P30, P00); float l1 = vtmp.length(); vtmp.sub(P33, P03); float l2 = vtmp.length(); float ul = (l1 + l2) / 2f; vtmp.sub(P03, P00); l1 = vtmp.length(); vtmp.sub(P33, P30); l2 = vtmp.length(); float vl = (l1 + l2) / 2f; if (ul > vl) { result[0] = new BicubicPatch(bezierInterpolateParameters(0f, .5f, 0f, 1f), attributes, false); result[1] = new BicubicPatch(bezierInterpolateParameters(.5f, 1f, 0f, 1f), attributes, false); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); } else { result[0] = new BicubicPatch(bezierInterpolateParameters(0f, 1f, 0f, .5f), attributes, false); result[1] = new BicubicPatch(bezierInterpolateParameters(0f, 1f, .5f, 1f), attributes, false); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); } return result; }*/ } |
From: Elmer G. <ega...@us...> - 2004-10-05 13:46:39
|
Update of /cvsroot/jrman/drafts/nurbtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2503/nurbtest Removed Files: Main.java Nurbs.java NurbSubdiv.java SurfSample.java Log Message: Added Nurbs Primitive --- NurbSubdiv.java DELETED --- --- Main.java DELETED --- --- Nurbs.java DELETED --- --- SurfSample.java DELETED --- |
From: Elmer G. <ega...@us...> - 2004-10-05 13:46:38
|
Update of /cvsroot/jrman/drafts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2503 Modified Files: .classpath Log Message: Added Nurbs Primitive Index: .classpath =================================================================== RCS file: /cvsroot/jrman/drafts/.classpath,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** .classpath 13 Feb 2004 06:46:23 -0000 1.8 --- .classpath 5 Oct 2004 13:45:30 -0000 1.9 *************** *** 1,10 **** <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="lib/vecmath.jar"/> ! <classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/> ! <classpathentry kind="lib" path="lib/forms-1.0.3.jar"/> ! <classpathentry kind="lib" path="lib/looks-1.2.0.jar"/> ! <classpathentry kind="output" path="build"/> </classpath> --- 1,10 ---- <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="lib/vecmath.jar"/> ! <classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/> ! <classpathentry kind="lib" path="lib/forms-1.0.3.jar"/> ! <classpathentry kind="lib" path="lib/looks-1.2.0.jar"/> ! <classpathentry kind="output" path="build"/> </classpath> |
From: Gerardo H. <ma...@us...> - 2004-09-20 21:09:17
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4439/src/org/jrman/render Modified Files: Bucket.java MemoryBucket.java RendererHidden.java Sampler.java Micropolygon.java Log Message: Fixed occlusion culling bug. Misc optimizations. Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Sampler.java 11 Sep 2004 17:36:27 -0000 1.22 --- Sampler.java 20 Sep 2004 21:09:06 -0000 1.23 *************** *** 60,65 **** private MaskElement[] pixelsVisibility; - private boolean modified; - private int samplesPerPixel; --- 60,63 ---- *************** *** 73,87 **** public static class MaskElement { ! float z; ! boolean opaque; - boolean modified; - int count; void reset() { ! z = Constants.INFINITY; opaque = false; count = 0; --- 71,83 ---- public static class MaskElement { ! float z; ! boolean opaque; int count; void reset() { ! z = -Constants.INFINITY; opaque = false; count = 0; *************** *** 133,138 **** pixelsVisibility[i].reset(); hasSamples = false; - modified = false; - rootVisibility.z = -Constants.INFINITY; } --- 129,132 ---- *************** *** 222,229 **** public void updateDepth(int offset, float z, boolean firstTime) { MaskElement me = pixelsVisibility[offset]; ! if (z < me.z) { ! me.z = z; ! rootVisibility.z = Calc.max(rootVisibility.z, z); ! } if (firstTime) { me.count++; --- 216,220 ---- public void updateDepth(int offset, float z, boolean firstTime) { MaskElement me = pixelsVisibility[offset]; ! me.z = Calc.max(me.z, z); if (firstTime) { me.count++; *************** *** 231,234 **** --- 222,226 ---- me.opaque = true; rootVisibility.count++; + rootVisibility.z = Calc.max(rootVisibility.z, z); if (rootVisibility.count == pixelsPerBucket) rootVisibility.opaque = true; Index: Bucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Bucket.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Bucket.java 2 Feb 2004 19:30:05 -0000 1.10 --- Bucket.java 20 Sep 2004 21:09:06 -0000 1.11 *************** *** 39,42 **** --- 39,44 ---- void sortPrimitives(); + + void sortMicropolygons(); } Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** RendererHidden.java 16 Sep 2004 04:16:42 -0000 1.65 --- RendererHidden.java 20 Sep 2004 21:09:06 -0000 1.66 *************** *** 362,365 **** --- 362,366 ---- shaderVariables.transform(cameraToRaster); shaderVariables.getMicropolygons(this); + bucket.sortMicropolygons(); sampler.sampleBucket(bucket); } else { Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MemoryBucket.java 16 Sep 2004 05:07:09 -0000 1.7 --- MemoryBucket.java 20 Sep 2004 21:09:06 -0000 1.8 *************** *** 37,40 **** --- 37,42 ---- private boolean primitivesModified; + private boolean micropolygonsModified; + public MemoryBucket() { } *************** *** 61,67 **** --- 63,77 ---- } } + + public void sortMicropolygons() { + if (micropolygonsModified) { + Collections.sort(micropolygons); + micropolygonsModified = false; + } + } public void addMicropolygon(Micropolygon mp) { micropolygons.add(mp); + micropolygonsModified = true; } Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Micropolygon.java 8 Feb 2004 08:54:55 -0000 1.19 --- Micropolygon.java 20 Sep 2004 21:09:06 -0000 1.20 *************** *** 22,26 **** import org.jrman.util.Constants; ! public abstract class Micropolygon { public static int count; --- 22,26 ---- import org.jrman.util.Constants; ! public abstract class Micropolygon implements Comparable{ public static int count; *************** *** 57,60 **** --- 57,69 ---- return minZ; } + + public int compareTo(Object other) { + Micropolygon mp = (Micropolygon) other; + if (minZ > mp.minZ) + return -1; + if (minZ < mp.minZ) + return 1; + return 0; + } } |
From: Gerardo H. <ma...@us...> - 2004-09-20 21:09:16
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4439/sampleData Modified Files: testBicubic.rib cubeScene.rib unit.rib Added Files: hidden.rib Log Message: Fixed occlusion culling bug. Misc optimizations. Index: testBicubic.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/testBicubic.rib,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** testBicubic.rib 18 Sep 2004 21:19:41 -0000 1.6 --- testBicubic.rib 20 Sep 2004 21:09:06 -0000 1.7 *************** *** 1,5 **** Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 2000 1500 1 PixelSamples 4 4 Exposure 1 2.2 --- 1,5 ---- Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 800 600 1 PixelSamples 4 4 Exposure 1 2.2 --- NEW FILE: hidden.rib --- Display "hidden" "framebuffer" "rgb" Format 256 256 1 PixelSamples 4 4 Exposure 1 1.8 ScreenWindow -128 127 -128 127 Projection "orthographic" Translate 0 0 20 WorldBegin AttributeBegin Color 1 1 1 Patch "bilinear" "P" [-100 -100 2 -100 100 2 100 -100 2 100 100 2] AttributeEnd AttributeBegin Color 1 0 0 Patch "bilinear" "P" [-50 -50 1 -50 50 1 50 -50 1 50 50 1] AttributeEnd WorldEnd Index: cubeScene.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/cubeScene.rib,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cubeScene.rib 12 Sep 2004 23:26:57 -0000 1.7 --- cubeScene.rib 20 Sep 2004 21:09:06 -0000 1.8 *************** *** 1,3 **** ! Format 4000 3000 1 PixelSamples 4 4 Exposure 1 2.2 --- 1,3 ---- ! Format 2000 1500 1 PixelSamples 4 4 Exposure 1 2.2 Index: unit.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/unit.rib,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** unit.rib 12 Sep 2004 23:26:57 -0000 1.7 --- unit.rib 20 Sep 2004 21:09:06 -0000 1.8 *************** *** 1,6 **** ! AttributeBegin ! Rotate 90 0 1 0 ! Scale .05 .05 .05 ! Procedural "DelayedReadArchive" ["bikeData.rib"] [-8 8 -8 8 -8 8] ! AttributeEnd ! #ObjectInstance 1 --- 1,6 ---- ! #AttributeBegin ! #Rotate 90 0 1 0 ! #Scale .05 .05 .05 ! #Procedural "DelayedReadArchive" ["bikeData.rib"] [-8 8 -8 8 -8 8] ! #AttributeEnd ! ReadArchive "torusUnit.rib" |
From: Gerardo H. <ma...@us...> - 2004-09-20 21:09:16
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4439/src/org/jrman/geom Modified Files: AffineTransform.java PerspectiveTransform.java ConvexHull3f.java Log Message: Fixed occlusion culling bug. Misc optimizations. Index: AffineTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/AffineTransform.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AffineTransform.java 24 Sep 2003 03:26:03 -0000 1.14 --- AffineTransform.java 20 Sep 2004 21:09:05 -0000 1.15 *************** *** 147,151 **** protected AffineTransform(Matrix4f matrix) { ! this.matrix = new Matrix4f(matrix); } --- 147,151 ---- protected AffineTransform(Matrix4f matrix) { ! this.matrix = matrix; } Index: PerspectiveTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/PerspectiveTransform.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PerspectiveTransform.java 20 Aug 2003 20:41:21 -0000 1.10 --- PerspectiveTransform.java 20 Sep 2004 21:09:05 -0000 1.11 *************** *** 32,36 **** public class PerspectiveTransform extends AffineTransform { ! private Point4f hpoint = new Point4f(); private float near; --- 32,36 ---- public class PerspectiveTransform extends AffineTransform { ! private static Point4f hpoint = new Point4f(); private float near; Index: ConvexHull3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/ConvexHull3f.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ConvexHull3f.java 28 Jan 2004 07:27:44 -0000 1.14 --- ConvexHull3f.java 20 Sep 2004 21:09:05 -0000 1.15 *************** *** 76,83 **** public void addHpoint(Point4f hpoint) { ! Point3f p = new Point3f(); ! p.project(hpoint); ! add(p); ! minZ = Math.min(minZ, p.z); } --- 76,82 ---- public void addHpoint(Point4f hpoint) { ! tmpPoint.project(hpoint); ! add(tmpPoint); ! minZ = Math.min(minZ, tmpPoint.z); } |
From: Gerardo H. <ma...@us...> - 2004-09-18 21:19:51
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19913/sampleData Modified Files: testBicubic.rib Log Message: test Index: testBicubic.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/testBicubic.rib,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testBicubic.rib 16 Apr 2004 05:11:28 -0000 1.5 --- testBicubic.rib 18 Sep 2004 21:19:41 -0000 1.6 *************** *** 1,8 **** Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 800 600 1 PixelSamples 4 4 Exposure 1 2.2 ! Projection "perspective" "fov" [20] WorldBegin Translate 0 0 20 --- 1,8 ---- Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 ! Format 2000 1500 1 PixelSamples 4 4 Exposure 1 2.2 ! Projection "perspective" "fov" [5] WorldBegin Translate 0 0 20 *************** *** 17,22 **** AttributeEnd ShadingRate .25 ! Surface "paintedplastic" "texturename" "checkerboard.txr" "uniform float blur" 0 ! Basis "bezier" 2 "bezier" 2 Patch "bicubic" "Pw" [ --- 17,22 ---- AttributeEnd ShadingRate .25 ! #Surface "paintedplastic" "texturename" "checkerboard.txr" "uniform float blur" 0 ! Basis "b-spline" 2 "b-spline" 2 Patch "bicubic" "Pw" [ *************** *** 26,31 **** -3 3 0 1 -1 3 0 1 1 3 -1 1 3 3 0 1 ] ! # "s" [0 3.99 0 3.99] ! # "t" [0 0 3.99 3.99] WorldEnd --- 26,31 ---- -3 3 0 1 -1 3 0 1 1 3 -1 1 3 3 0 1 ] ! "s" [0 3.99 0 3.99] ! "t" [0 0 3.99 3.99] WorldEnd |
From: Gerardo H. <ma...@us...> - 2004-09-18 21:19:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19795/src/org/jrman/primitive Modified Files: BicubicPatch.java Log Message: Fixed applyBasis() & small optimization. Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BicubicPatch.java 18 Apr 2004 20:04:50 -0000 1.13 --- BicubicPatch.java 18 Sep 2004 21:19:05 -0000 1.14 *************** *** 109,116 **** private static Point4f PV1 = new Point4f(); ! public BicubicPatch(ParameterList parameters, Attributes attributes) { super(parameters, attributes); ! applyBasis(); } --- 109,121 ---- private static Point4f PV1 = new Point4f(); ! public BicubicPatch(ParameterList parameters, Attributes attributes) { + this(parameters, attributes, true); + } + + private BicubicPatch(ParameterList parameters, Attributes attributes, boolean apply) { super(parameters, attributes); ! if (apply) ! applyBasis(); } *************** *** 121,125 **** parameters.removeParameter("P"); parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); --- 126,132 ---- parameters.removeParameter("P"); parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", ! Declaration.StorageClass.VERTEX, ! Declaration.Type.HPOINT, 1), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); *************** *** 252,265 **** if (ul > vl) { result[0] = ! new BicubicPatch(bezierInterpolateParameters(0f, .5f, 0f, 1f), attributes); result[1] = ! new BicubicPatch(bezierInterpolateParameters(.5f, 1f, 0f, 1f), attributes); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); } else { result[0] = ! new BicubicPatch(bezierInterpolateParameters(0f, 1f, 0f, .5f), attributes); result[1] = ! new BicubicPatch(bezierInterpolateParameters(0f, 1f, .5f, 1f), attributes); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); --- 259,272 ---- if (ul > vl) { result[0] = ! new BicubicPatch(bezierInterpolateParameters(0f, .5f, 0f, 1f), attributes, false); result[1] = ! new BicubicPatch(bezierInterpolateParameters(.5f, 1f, 0f, 1f), attributes, false); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); } else { result[0] = ! new BicubicPatch(bezierInterpolateParameters(0f, 1f, 0f, .5f), attributes, false); result[1] = ! new BicubicPatch(bezierInterpolateParameters(0f, 1f, .5f, 1f), attributes, false); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); *************** *** 276,280 **** extractPoints(); VaryingScalarHPoint sparam = ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), new float[16 * 4]); if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); --- 283,289 ---- extractPoints(); VaryingScalarHPoint sparam = ! new VaryingScalarHPoint( ! new Declaration("Pw", Declaration.StorageClass.VERTEX, ! Declaration.Type.HPOINT, 1), new float[16 * 4]); if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); |
From: Gerardo H. <ma...@us...> - 2004-09-17 06:33:55
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11185/src/org/jrman/parser Modified Files: Tokenizer.java Parser.java Log Message: New tokenizer. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** Parser.java 12 Sep 2004 00:10:48 -0000 1.96 --- Parser.java 17 Sep 2004 06:33:46 -0000 1.97 *************** *** 211,215 **** FileReader fr = new FileReader(filename); Tokenizer st = new Tokenizer(new BufferedReader(fr)); ! st.commentChar('#'); int tk; while ((tk = st.nextToken()) != StreamTokenizer.TT_EOF) { --- 211,215 ---- FileReader fr = new FileReader(filename); Tokenizer st = new Tokenizer(new BufferedReader(fr)); ! // st.commentChar('#'); int tk; while ((tk = st.nextToken()) != StreamTokenizer.TT_EOF) { Index: Tokenizer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Tokenizer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Tokenizer.java 7 Apr 2003 08:24:33 -0000 1.1 --- Tokenizer.java 17 Sep 2004 06:33:46 -0000 1.2 *************** *** 1,19 **** /* ! Tokenizer.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ --- 1,19 ---- /* ! Tokenizer.java ! Copyright (C) 2004 Gerardo Horvilleur Martinez ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ *************** *** 25,124 **** public class Tokenizer { ! ! private StreamTokenizer st; ! ! public int ttype; ! ! public double nval; ! public String sval; ! private boolean pushedBack; ! ! public Tokenizer(Reader reader) { ! st = new StreamTokenizer(reader); } ! ! public void commentChar(int ch) { ! st.commentChar(ch); } ! ! public void eolIsSignificant(boolean flag) { ! st.eolIsSignificant(flag); } ! ! public int lineno() { ! return st.lineno(); } ! ! public void lowerCaseMode(boolean fl) { ! st.lowerCaseMode(fl); } ! public int nextToken() throws IOException { ! // This is a horrible hack. We should write our own tokenizer.... ! if (!pushedBack) { ! ttype = st.nextToken(); ! nval = st.nval; ! sval = st.sval; ! } else pushedBack = false; ! if (ttype == StreamTokenizer.TT_NUMBER) { ! double value = st.nval; ! int nextToken = st.nextToken(); ! if (nextToken == StreamTokenizer.TT_WORD ! && (st.sval.charAt(0) == 'e' || st.sval.charAt(0) == 'E') ! && (Character.isDigit(st.sval.charAt(1)) || st.sval.charAt(1) == '-')) { ! double exp = Double.parseDouble(st.sval.substring(1)); ! nval = value * Math.pow(10.0, exp); ! } else ! st.pushBack(); } ! return ttype; ! } ! ! public void ordinaryChar(int ch) { ! st.ordinaryChar(ch); ! } ! ! public void ordinaryChars(int low, int hi) { ! st.ordinaryChars(low, hi); ! } ! ! public void parseNumbers() { ! st.parseNumbers(); } ! public void pushBack() { pushedBack = true; } ! public void quoteChar(int ch) { ! st.quoteChar(ch); ! } ! ! public void resetSyntax() { ! st.resetSyntax(); ! } ! ! public void slashSlashComments(boolean flag) { ! st.slashSlashComments(flag); ! } ! ! public void slashStarComments(boolean flag) { ! st.slashStarComments(flag); ! } ! ! public String toString() { ! return st.toString(); ! } ! ! public void whitespaceChars(int low, int hi) { ! st.whitespaceChars(low, hi); ! } ! ! public void wordChars(int low, int hi) { ! st.wordChars(low, hi); } ! } --- 25,169 ---- public class Tokenizer { ! public String sval; ! ! public float nval; ! ! private Reader reader; ! ! private char ch; ! ! private char[] buffer = new char[200]; ! ! private int pos; ! ! private int lineno = 1; ! ! private int token; ! private boolean pushedBack; ! ! public Tokenizer(Reader reader) throws IOException { ! this.reader = reader; ! nextChar(); } ! ! private void nextChar() throws IOException { ! ch = (char) reader.read(); } ! ! private void bufferReset() { ! pos = 0; } ! ! private void bufferAdd() throws IOException { ! if (pos == buffer.length) { ! char[] tmp = new char[buffer.length * 2]; ! System.arraycopy(buffer, 0, tmp, 0, buffer.length); ! buffer = tmp; ! } ! buffer[pos++] = ch; ! nextChar(); } ! ! private String bufferToString() { ! return new String(buffer, 0, pos); } ! public int nextToken() throws IOException { ! if (pushedBack) { pushedBack = false; ! return token; } ! while (true) { ! while (Character.isWhitespace(ch)) { ! if (ch == '\n') ! lineno++; ! nextChar(); ! } ! if (ch == '#') { ! while (ch != '\n') ! nextChar(); ! } ! else ! break; ! } ! if (ch == 0xffff) { ! token = StreamTokenizer.TT_EOF; ! return token; ! } ! if (Character.isJavaIdentifierStart(ch)) { ! bufferReset(); ! bufferAdd(); ! while (Character.isJavaIdentifierPart(ch)) ! bufferAdd(); ! sval = bufferToString(); ! token = StreamTokenizer.TT_WORD; ! return token; ! } ! if (ch == '"') { ! bufferReset(); ! nextChar(); ! while (ch != '"') ! bufferAdd(); ! sval = bufferToString(); ! nextChar(); ! token = '"'; ! return token; ! } ! if (Character.isDigit(ch) || ch == '.' || ch == '-' || ch == '+') { ! float negative = 1f; ! float exp = 1f; ! boolean afterPoint = false; ! nval = 0f; ! if (ch == '.') ! afterPoint = true; ! else if (ch == '-') ! negative = -1f; ! else if (ch != '+') ! nval = ch - '0'; ! nextChar(); ! while (Character.isDigit(ch) || ch == '.') { ! if (ch == '.') ! afterPoint = true; ! else { ! nval = nval * 10f + ch - '0'; ! if (afterPoint) ! exp *= 0.1f; ! } ! nextChar(); ! } ! if (ch == 'e' || ch == 'E') { ! float negativeExp = 10f; ! int expVal = 0; ! nextChar(); ! if (ch == '-') { ! negativeExp = 0.1f; ! nextChar(); ! } else if (ch == '+') ! nextChar(); ! while (Character.isDigit(ch)) { ! expVal = expVal * 10 + ch - '0'; ! nextChar(); ! } ! for (int i = 0; i < expVal; i++) ! exp *= negativeExp; ! } ! nval = negative * nval * exp; ! token = StreamTokenizer.TT_NUMBER; ! return token; ! } ! token = ch; ! nextChar(); ! return token; } ! public void pushBack() { pushedBack = true; } ! public int lineno() { ! return lineno; } ! } |
From: Gerardo H. <ma...@us...> - 2004-09-17 06:33:54
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11185/src/org/jrman/parser/keywords Modified Files: AbstractKeywordParser.java KeywordParser.java Log Message: New tokenizer. Index: KeywordParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordParser.java 7 Apr 2003 08:24:21 -0000 1.2 --- KeywordParser.java 17 Sep 2004 06:33:45 -0000 1.3 *************** *** 22,27 **** import java.util.Set; - import org.jrman.parser.Parser; import org.jrman.parser.Tokenizer; public interface KeywordParser { --- 22,27 ---- import java.util.Set; import org.jrman.parser.Tokenizer; + import org.jrman.parser.Parser; public interface KeywordParser { Index: AbstractKeywordParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/AbstractKeywordParser.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AbstractKeywordParser.java 12 Sep 2004 00:10:47 -0000 1.11 --- AbstractKeywordParser.java 17 Sep 2004 06:33:45 -0000 1.12 *************** *** 34,39 **** import org.jrman.parameters.ParameterList; import org.jrman.parser.Global; - import org.jrman.parser.Parser; import org.jrman.parser.Tokenizer; public abstract class AbstractKeywordParser implements KeywordParser { --- 34,39 ---- import org.jrman.parameters.ParameterList; import org.jrman.parser.Global; import org.jrman.parser.Tokenizer; + import org.jrman.parser.Parser; public abstract class AbstractKeywordParser implements KeywordParser { *************** *** 122,141 **** // Expect x min match(st, TK_NUMBER); ! float xMin = (float) st.nval; // Expect x max match(st, TK_NUMBER); ! float xMax = (float) st.nval; // Expect y min match(st, TK_NUMBER); ! float yMin = (float) st.nval; // Expect y max match(st, TK_NUMBER); ! float yMax = (float) st.nval; // Expect z min match(st, TK_NUMBER); ! float zMin = (float) st.nval; // Expect z max match(st, TK_NUMBER); ! float zMax = (float) st.nval; if (array) match(st, TK_RBRACE); --- 122,141 ---- // Expect x min match(st, TK_NUMBER); ! float xMin = st.nval; // Expect x max match(st, TK_NUMBER); ! float xMax = st.nval; // Expect y min match(st, TK_NUMBER); ! float yMin = st.nval; // Expect y max match(st, TK_NUMBER); ! float yMax = st.nval; // Expect z min match(st, TK_NUMBER); ! float zMin = st.nval; // Expect z max match(st, TK_NUMBER); ! float zMax = st.nval; if (array) match(st, TK_RBRACE); *************** *** 149,198 **** // Expect a match(st, TK_NUMBER); ! float a = (float) st.nval; // Expect b match(st, TK_NUMBER); ! float b = (float) st.nval; // Expect c match(st, TK_NUMBER); ! float c = (float) st.nval; // Expect d match(st, TK_NUMBER); ! float d = (float) st.nval; // Expect e match(st, TK_NUMBER); ! float e = (float) st.nval; // Expect f match(st, TK_NUMBER); ! float f = (float) st.nval; // Expect g match(st, TK_NUMBER); ! float g = (float) st.nval; // Expect h match(st, TK_NUMBER); ! float h = (float) st.nval; // Expect i match(st, TK_NUMBER); ! float i = (float) st.nval; // Expect j match(st, TK_NUMBER); ! float j = (float) st.nval; // Expect k match(st, TK_NUMBER); ! float k = (float) st.nval; // Expect l match(st, TK_NUMBER); ! float l = (float) st.nval; // Expect m match(st, TK_NUMBER); ! float m = (float) st.nval; // Expect n match(st, TK_NUMBER); ! float n = (float) st.nval; // Expect o match(st, TK_NUMBER); ! float o = (float) st.nval; // Expect p match(st, TK_NUMBER); ! float p = (float) st.nval; // Expect array end match(st, TK_RBRACE); --- 149,198 ---- // Expect a match(st, TK_NUMBER); ! float a = st.nval; // Expect b match(st, TK_NUMBER); ! float b = st.nval; // Expect c match(st, TK_NUMBER); ! float c = st.nval; // Expect d match(st, TK_NUMBER); ! float d = st.nval; // Expect e match(st, TK_NUMBER); ! float e = st.nval; // Expect f match(st, TK_NUMBER); ! float f = st.nval; // Expect g match(st, TK_NUMBER); ! float g = st.nval; // Expect h match(st, TK_NUMBER); ! float h = st.nval; // Expect i match(st, TK_NUMBER); ! float i = st.nval; // Expect j match(st, TK_NUMBER); ! float j = st.nval; // Expect k match(st, TK_NUMBER); ! float k = st.nval; // Expect l match(st, TK_NUMBER); ! float l = st.nval; // Expect m match(st, TK_NUMBER); ! float m = st.nval; // Expect n match(st, TK_NUMBER); ! float n = st.nval; // Expect o match(st, TK_NUMBER); ! float o = st.nval; // Expect p match(st, TK_NUMBER); ! float p = st.nval; // Expect array end match(st, TK_RBRACE); *************** *** 212,222 **** // Expect red match(st, TK_NUMBER); ! float red = (float) st.nval; // Expect green match(st, TK_NUMBER); ! float green = (float) st.nval; // Expect blue match(st, TK_NUMBER); ! float blue = (float) st.nval; if (array) match(st, TK_RBRACE); --- 212,222 ---- // Expect red match(st, TK_NUMBER); ! float red = st.nval; // Expect green match(st, TK_NUMBER); ! float green = st.nval; // Expect blue match(st, TK_NUMBER); ! float blue = st.nval; if (array) match(st, TK_RBRACE); *************** *** 235,239 **** // Expect a variable length sequence of numbers while (st.nextToken() == TK_NUMBER) ! floats.add(new Float((float) st.nval)); st.pushBack(); float[] result = new float[floats.size()]; --- 235,239 ---- // Expect a variable length sequence of numbers while (st.nextToken() == TK_NUMBER) ! floats.add(new Float(st.nval)); st.pushBack(); float[] result = new float[floats.size()]; *************** *** 284,288 **** numbers = tmp; } ! numbers[arraySize++] = (float) st.nval; break; case TK_STRING : --- 284,288 ---- numbers = tmp; } ! numbers[arraySize++] = st.nval; break; case TK_STRING : *************** *** 347,351 **** parseArray(st); } else if (token == TK_NUMBER) { ! numbers[0] = (float) st.nval; arraySize = 1; } else if (token == TK_STRING) { --- 347,351 ---- parseArray(st); } else if (token == TK_NUMBER) { ! numbers[0] = st.nval; arraySize = 1; } else if (token == TK_STRING) { |
From: Gerardo H. <ma...@us...> - 2004-09-16 05:07:18
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5375/src/org/jrman/shaders Modified Files: SurfaceShader.java Log Message: More optimizations. Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SurfaceShader.java 16 Sep 2004 04:16:42 -0000 1.19 --- SurfaceShader.java 16 Sep 2004 05:07:09 -0000 1.20 *************** *** 59,65 **** static Color3fGrid _cg1 = new Color3fGrid(); ! protected abstract class Statement { public abstract void execute(ShaderVariables sv, LightShader ls); } public static SurfaceShader createShader( --- 59,145 ---- static Color3fGrid _cg1 = new Color3fGrid(); ! protected static abstract class Statement { public abstract void execute(ShaderVariables sv, LightShader ls); } + + private DiffuseStatement diffuseStatement = new DiffuseStatement(); + + private SpecularStatement specularStatement = new SpecularStatement(); + + private static class DiffuseStatement extends Statement { + + private Vector3fGrid Nn; + + private Color3fGrid out; + + public void setNn(Vector3fGrid nn) { + Nn = nn; + } + public void setOut(Color3fGrid out) { + this.out = out; + } + + public void execute(ShaderVariables sv, LightShader ls) { + FloatGrid nondiff = _fg1; + nondiff.set(0f); + ls.messagePassing("__nondiffuse", nondiff); + _vg1.normalize(sv.L); + _fg2.dot(Nn, _vg1); + nondiff.sub(1f, nondiff); + _fg2.mul(_fg2, nondiff); + _cg1.set(_fg2); + sv.Cl.mul(sv.Cl, _cg1); + out.add(out, sv.Cl); + } + + } + + private static class SpecularStatement extends Statement { + + private Vector3fGrid Nn; + + private Vector3fGrid V; + + private float roughness; + + private Color3fGrid out; + + public void setNn(Vector3fGrid nn) { + Nn = nn; + } + + private void setV(Vector3fGrid V) { + this.V = V; + } + + private void setRoughness(float roughness) { + this.roughness = roughness; + } + + public void setOut(Color3fGrid out) { + this.out = out; + } + + public void execute(ShaderVariables sv, LightShader ls) { + FloatGrid nonspec = _fg1; + nonspec.set(0f); + ls.messagePassing("__nonspecular", nonspec); + _vg1.normalize(sv.L); + _vg1.add(_vg1, V); + _vg1.normalize(_vg1); + Vector3fGrid H = _vg1; + _fg2.dot(Nn, H); + _fg2.max(_fg2, 0f); + if (betterHighlights) + _fg2.pow(_fg2, 10f / roughness); + else + _fg2.simulPow(_fg2, 25f / roughness); + nonspec.sub(1, nonspec); + _fg2.mul(_fg2, nonspec); + _cg1.set(_fg2); + sv.Cl.mul(sv.Cl, _cg1); + out.add(out, sv.Cl); + } + } public static SurfaceShader createShader( *************** *** 114,164 **** } ! protected void diffuse(ShaderVariables sv, final Vector3fGrid Nn, final Color3fGrid out) { out.set(BLACK); ! illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, new Statement() { ! public void execute(ShaderVariables sv, LightShader ls) { ! FloatGrid nondiff = _fg1; ! nondiff.set(0f); ! ls.messagePassing("__nondiffuse", nondiff); ! _vg1.normalize(sv.L); ! _fg2.dot(Nn, _vg1); ! nondiff.sub(1f, nondiff); ! _fg2.mul(_fg2, nondiff); ! _cg1.set(_fg2); ! sv.Cl.mul(sv.Cl, _cg1); ! out.add(out, sv.Cl); ! } ! }); } protected void specular( ShaderVariables sv, ! final Vector3fGrid Nn, ! final Vector3fGrid V, ! final float roughness, ! final Color3fGrid out) { out.set(BLACK); ! illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, new Statement() { ! public void execute(ShaderVariables sv, LightShader ls) { ! FloatGrid nonspec = _fg1; ! nonspec.set(0f); ! ls.messagePassing("__nonspecular", nonspec); ! _vg1.normalize(sv.L); ! _vg1.add(_vg1, V); ! _vg1.normalize(_vg1); ! Vector3fGrid H = _vg1; ! _fg2.dot(Nn, H); ! _fg2.max(_fg2, 0f); ! if (betterHighlights) ! _fg2.pow(_fg2, 10f / roughness); ! else ! _fg2.simulPow(_fg2, 25f / roughness); ! nonspec.sub(1, nonspec); ! _fg2.mul(_fg2, nonspec); ! _cg1.set(_fg2); ! sv.Cl.mul(sv.Cl, _cg1); ! out.add(out, sv.Cl); ! } ! }); } --- 194,216 ---- } ! protected void diffuse(ShaderVariables sv, Vector3fGrid Nn, Color3fGrid out) { out.set(BLACK); ! diffuseStatement.setNn(Nn); ! diffuseStatement.setOut(out); ! illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, diffuseStatement); } protected void specular( ShaderVariables sv, ! Vector3fGrid Nn, ! Vector3fGrid V, ! float roughness, ! Color3fGrid out) { out.set(BLACK); ! specularStatement.setNn(Nn); ! specularStatement.setV(V); ! specularStatement.setRoughness(roughness); ! specularStatement.setOut(out); ! illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, specularStatement); } |
From: Gerardo H. <ma...@us...> - 2004-09-16 05:07:17
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5375/src/org/jrman/util Added Files: NullList.java Removed Files: NullStack.java Log Message: More optimizations. --- NEW FILE: NullList.java --- /* NullList.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.util; import java.util.ArrayList; public class NullList extends ArrayList { public boolean add(Object item) { // Doesn't do anything (discards object) return false; } } --- NullStack.java DELETED --- |
From: Gerardo H. <ma...@us...> - 2004-09-16 05:07:17
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5375/src/org/jrman/render Modified Files: MemoryBucket.java Log Message: More optimizations. Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MemoryBucket.java 2 Feb 2004 19:30:05 -0000 1.6 --- MemoryBucket.java 16 Sep 2004 05:07:09 -0000 1.7 *************** *** 23,37 **** import java.util.Collections; import java.util.List; - import java.util.Stack; import org.jrman.primitive.Primitive; ! import org.jrman.util.NullStack; public class MemoryBucket implements Bucket { private List primitives = new ArrayList(50); ! private Stack micropolygons = new Stack(); private boolean primitivesModified; --- 23,37 ---- import java.util.Collections; import java.util.List; import org.jrman.primitive.Primitive; ! import org.jrman.util.NullList; public class MemoryBucket implements Bucket { + private final static List NULL_LIST = new NullList(); private List primitives = new ArrayList(50); ! private List micropolygons = new ArrayList(200); private boolean primitivesModified; *************** *** 63,67 **** public void addMicropolygon(Micropolygon mp) { ! micropolygons.push(mp); } --- 63,67 ---- public void addMicropolygon(Micropolygon mp) { ! micropolygons.add(mp); } *************** *** 71,80 **** public Micropolygon getNextMicropolygon() { ! return (Micropolygon) micropolygons.pop(); } public void flush() { primitives = new ArrayList(); ! micropolygons = new NullStack(); } --- 71,83 ---- public Micropolygon getNextMicropolygon() { ! int n = micropolygons.size() - 1; ! Micropolygon mp = (Micropolygon) micropolygons.get(n); ! micropolygons.remove(n); ! return mp; } public void flush() { primitives = new ArrayList(); ! micropolygons = NULL_LIST; } |
From: Gerardo H. <ma...@us...> - 2004-09-16 04:16:52
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29936/src/org/jrman/shaders Modified Files: LightPointlight.java LightDistantlight.java SurfaceShader.java LightShadowspotlight.java LightShadowdistantlight.java LightSpotlight.java LightShader.java Log Message: Some memory optimizations. Index: LightShadowdistantlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightShadowdistantlight.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LightShadowdistantlight.java 9 Dec 2003 04:51:52 -0000 1.5 --- LightShadowdistantlight.java 16 Sep 2004 04:16:42 -0000 1.6 *************** *** 53,56 **** --- 53,102 ---- static Color3fGrid cg = new Color3fGrid(); + private DistantShadowLightStatement statement = new DistantShadowLightStatement(); + + private static class DistantShadowLightStatement extends Statement { + + private float intensity; + + private float bias; + + private String shadowmap; + + private float blur; + + private float samples; + + public void setIntensity(float intensity) { + this.intensity = intensity; + } + + public void setBias(float bias) { + this.bias = bias; + } + public void setBlur(float blur) { + this.blur = blur; + } + public void setSamples(float samples) { + this.samples = samples; + } + public void setShadowmap(String shadowmap) { + this.shadowmap = shadowmap; + } + public void execute(ShaderVariables sv) { + c1.x *= intensity; + c1.y *= intensity; + c1.z *= intensity; + sv.Cl.set(c1, tmpCond1); + if (!shadowmap.equals("")) { + pg.transform(sv.P, sv.cameraToWorld); + fg.shadow(shadowmap, pg, bias, samples, blur); + fg.sub(1f, fg); + cg.set(fg); + sv.Cl.mul(sv.Cl, cg); + } + } + + } + protected void initDefaults() { defaultParameters.addParameter( *************** *** 77,81 **** public boolean shade( ! final ShaderVariables sv, Point3fGrid P, Vector3fGrid N, --- 123,127 ---- public boolean shade( ! ShaderVariables sv, Point3fGrid P, Vector3fGrid N, *************** *** 83,87 **** super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! final float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); --- 129,133 ---- super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); *************** *** 98,124 **** vtmp.sub(to, from); UniformScalarFloat paramBias = (UniformScalarFloat) getParameter(sv, "bias"); ! final float bias = paramBias.getValue(); UniformScalarString paramShadowmap = (UniformScalarString) getParameter(sv, "shadowmap"); ! final String shadowmap = paramShadowmap.getValue(); UniformScalarFloat paramSamples = (UniformScalarFloat) getParameter(sv, "samples"); ! final float samples = paramSamples.getValue(); UniformScalarFloat paramBlur = (UniformScalarFloat) getParameter(sv, "blur"); ! final float blur = paramBlur.getValue(); ! return solar(sv, P, N, angle, vtmp, 0f, new Statement() { ! public void execute(ShaderVariables sv) { ! c1.x *= intensity; ! c1.y *= intensity; ! c1.z *= intensity; ! sv.Cl.set(c1, tmpCond1); ! if (!shadowmap.equals("")) { ! pg.transform(sv.P, sv.cameraToWorld); ! fg.shadow(shadowmap, pg, bias, samples, blur); ! fg.sub(1f, fg); ! cg.set(fg); ! sv.Cl.mul(sv.Cl, cg); ! } ! } ! }); } } --- 144,161 ---- vtmp.sub(to, from); UniformScalarFloat paramBias = (UniformScalarFloat) getParameter(sv, "bias"); ! float bias = paramBias.getValue(); UniformScalarString paramShadowmap = (UniformScalarString) getParameter(sv, "shadowmap"); ! String shadowmap = paramShadowmap.getValue(); UniformScalarFloat paramSamples = (UniformScalarFloat) getParameter(sv, "samples"); ! float samples = paramSamples.getValue(); UniformScalarFloat paramBlur = (UniformScalarFloat) getParameter(sv, "blur"); ! float blur = paramBlur.getValue(); ! statement.setIntensity(intensity); ! statement.setBias(bias); ! statement.setShadowmap(shadowmap); ! statement.setSamples(samples); ! statement.setBlur(blur); ! return solar(sv, P, N, angle, vtmp, 0f, statement); } } Index: LightShadowspotlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightShadowspotlight.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LightShadowspotlight.java 9 Dec 2003 04:51:52 -0000 1.4 --- LightShadowspotlight.java 16 Sep 2004 04:16:42 -0000 1.5 *************** *** 61,64 **** --- 61,145 ---- static Color3fGrid cg = new Color3fGrid(); + private ShadowSpotLightStatement statement = new ShadowSpotLightStatement(); + + private static class ShadowSpotLightStatement extends Statement { + + private float intensity; + + private float coneangle; + + private float conedeltaangle; + + private float beamdistribution; + + private Vector3f A; + + private float bias; + + private String shadowmap; + + private float blur; + + private float samples; + + public void setIntensity(float intensity) { + this.intensity = intensity; + } + + public void setA(Vector3f a) { + A = a; + } + public void setBeamdistribution(float beamdistribution) { + this.beamdistribution = beamdistribution; + } + public void setConeangle(float coneangle) { + this.coneangle = coneangle; + } + public void setConedeltaangle(float conedeltaangle) { + this.conedeltaangle = conedeltaangle; + } + + public void setBias(float bias) { + this.bias = bias; + } + public void setBlur(float blur) { + this.blur = blur; + } + public void setSamples(float samples) { + this.samples = samples; + } + public void setShadowmap(String shadowmap) { + this.shadowmap = shadowmap; + } + + public void execute(ShaderVariables sv) { + fg1.dot(sv.L, A); + fg2.length(sv.L); + fg1.div(fg1, fg2); + FloatGrid cosangle = fg1; + fg2.dot(sv.L, sv.L); + fg3.pow(cosangle, beamdistribution); + fg3.div(fg3, fg2); + FloatGrid atten = fg3; + fg2.smoothstep( + (float) Math.cos(coneangle), + (float) Math.cos(coneangle - conedeltaangle), + cosangle); + atten.mul(atten, fg2); + fg2.mul(atten, intensity); + cg1.set(fg2); + sv.Cl.set(lightcolor, tmpCond1); + sv.Cl.mul(sv.Cl, cg1, tmpCond1); + if (!shadowmap.equals("")) { + pg.transform(sv.P, sv.cameraToWorld); + fg.shadow(shadowmap, pg, bias, samples, blur); + fg.sub(1f, fg); + cg.set(fg); + sv.Cl.mul(sv.Cl, cg); + } + } + + } + protected void initDefaults() { defaultParameters.addParameter( *************** *** 95,99 **** public boolean shade( ! final ShaderVariables sv, Point3fGrid P, Vector3fGrid N, --- 176,180 ---- public boolean shade( ! ShaderVariables sv, Point3fGrid P, Vector3fGrid N, *************** *** 101,105 **** super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! final float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); --- 182,186 ---- super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); *************** *** 115,165 **** shaderTransform.transformPoint(to, to); UniformScalarFloat paramConeangle = (UniformScalarFloat) getParameter(sv, "coneangle"); ! final float coneangle = paramConeangle.getValue(); UniformScalarFloat paramConedeltaangle = (UniformScalarFloat) getParameter(sv, "conedeltaangle"); ! final float conedeltaangle = paramConedeltaangle.getValue(); UniformScalarFloat paramBeamdistribution = (UniformScalarFloat) getParameter(sv, "beamdistribution"); ! final float beamdistribution = paramBeamdistribution.getValue(); UniformScalarFloat paramBias = (UniformScalarFloat) getParameter(sv, "bias"); ! final float bias = paramBias.getValue(); UniformScalarString paramShadowmap = (UniformScalarString) getParameter(sv, "shadowmap"); ! final String shadowmap = paramShadowmap.getValue(); UniformScalarFloat paramSamples = (UniformScalarFloat) getParameter(sv, "samples"); ! final float samples = paramSamples.getValue(); UniformScalarFloat paramBlur = (UniformScalarFloat) getParameter(sv, "blur"); ! final float blur = paramBlur.getValue(); vtmp.sub(to, from); ! final Vector3f A = vtmp; A.normalize(); ! return illuminate(sv, P, N, angle, from, A, coneangle, new Statement() { ! public void execute(ShaderVariables sv) { ! fg1.dot(sv.L, A); ! fg2.length(sv.L); ! fg1.div(fg1, fg2); ! FloatGrid cosangle = fg1; ! fg2.dot(sv.L, sv.L); ! fg3.pow(cosangle, beamdistribution); ! fg3.div(fg3, fg2); ! FloatGrid atten = fg3; ! fg2.smoothstep( ! (float) Math.cos(coneangle), ! (float) Math.cos(coneangle - conedeltaangle), ! cosangle); ! atten.mul(atten, fg2); ! fg2.mul(atten, intensity); ! cg1.set(fg2); ! sv.Cl.set(lightcolor, tmpCond1); ! sv.Cl.mul(sv.Cl, cg1, tmpCond1); ! if (!shadowmap.equals("")) { ! pg.transform(sv.P, sv.cameraToWorld); ! fg.shadow(shadowmap, pg, bias, samples, blur); ! fg.sub(1f, fg); ! cg.set(fg); ! sv.Cl.mul(sv.Cl, cg); ! } ! } ! }); } } --- 196,228 ---- shaderTransform.transformPoint(to, to); UniformScalarFloat paramConeangle = (UniformScalarFloat) getParameter(sv, "coneangle"); ! float coneangle = paramConeangle.getValue(); UniformScalarFloat paramConedeltaangle = (UniformScalarFloat) getParameter(sv, "conedeltaangle"); ! float conedeltaangle = paramConedeltaangle.getValue(); UniformScalarFloat paramBeamdistribution = (UniformScalarFloat) getParameter(sv, "beamdistribution"); ! float beamdistribution = paramBeamdistribution.getValue(); UniformScalarFloat paramBias = (UniformScalarFloat) getParameter(sv, "bias"); ! float bias = paramBias.getValue(); UniformScalarString paramShadowmap = (UniformScalarString) getParameter(sv, "shadowmap"); ! String shadowmap = paramShadowmap.getValue(); UniformScalarFloat paramSamples = (UniformScalarFloat) getParameter(sv, "samples"); ! float samples = paramSamples.getValue(); UniformScalarFloat paramBlur = (UniformScalarFloat) getParameter(sv, "blur"); ! float blur = paramBlur.getValue(); vtmp.sub(to, from); ! Vector3f A = vtmp; A.normalize(); ! statement.setIntensity(intensity); ! statement.setConeangle(coneangle); ! statement.setConedeltaangle(conedeltaangle); ! statement.setBeamdistribution(beamdistribution); ! statement.setA(A); ! statement.setBias(bias); ! statement.setShadowmap(shadowmap); ! statement.setSamples(samples); ! statement.setBlur(blur); ! return illuminate(sv, P, N, angle, from, A, coneangle, statement); } } Index: LightPointlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightPointlight.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LightPointlight.java 25 Nov 2003 16:34:07 -0000 1.4 --- LightPointlight.java 16 Sep 2004 04:16:42 -0000 1.5 *************** *** 45,48 **** --- 45,68 ---- static Color3f lightcolor = new Color3f(); + private PointLightStatement statement = new PointLightStatement(); + + private static class PointLightStatement extends Statement { + + private float intensity; + + public void setIntensity(float intensity) { + this.intensity = intensity; + } + + public void execute(ShaderVariables sv) { + fg1.dot(sv.L, sv.L); + fg1.div(intensity, fg1); + cg1.set(fg1); + sv.Cl.set(lightcolor, tmpCond1); + sv.Cl.mul(sv.Cl, cg1, tmpCond1); + } + + } + protected void initDefaults() { defaultParameters.addParameter( *************** *** 55,59 **** public boolean shade( ! final ShaderVariables sv, Point3fGrid P, Vector3fGrid N, --- 75,79 ---- public boolean shade( ! ShaderVariables sv, Point3fGrid P, Vector3fGrid N, *************** *** 61,65 **** super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! final float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); --- 81,85 ---- super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); *************** *** 71,83 **** paramFrom.getValue(from); shaderTransform.transformPoint(from, from); ! return illuminate(sv, P, N, angle, from, null, 0f, new Statement() { ! public void execute(ShaderVariables sv) { ! fg1.dot(sv.L, sv.L); ! fg1.div(intensity, fg1); ! cg1.set(fg1); ! sv.Cl.set(lightcolor, tmpCond1); ! sv.Cl.mul(sv.Cl, cg1, tmpCond1); ! } ! }); } } --- 91,96 ---- paramFrom.getValue(from); shaderTransform.transformPoint(from, from); ! statement.setIntensity(intensity); ! return illuminate(sv, P, N, angle, from, null, 0f, statement); } } Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SurfaceShader.java 12 Dec 2003 23:50:19 -0000 1.18 --- SurfaceShader.java 16 Sep 2004 04:16:42 -0000 1.19 *************** *** 22,27 **** import java.util.ArrayList; import java.util.Arrays; - import java.util.Collection; - import java.util.Iterator; import java.util.List; import java.util.Set; --- 22,25 ---- *************** *** 106,112 **** protected void ambient(ShaderVariables sv, Color3fGrid out) { out.set(BLACK); ! Set lights = sv.attributes.getLightSources(); ! for (Iterator iter = lights.iterator(); iter.hasNext();) { ! LightShader ls = (LightShader) iter.next(); if (ls.isAmbient()) { ls.shade(sv, null, null, 0); --- 104,110 ---- protected void ambient(ShaderVariables sv, Color3fGrid out) { out.set(BLACK); ! LightShader[] lights = sv.attributes.getLightSourcesArray(); ! for (int i = 0; i < lights.length; i++) { ! LightShader ls = lights[i]; if (ls.isAmbient()) { ls.shade(sv, null, null, 0); *************** *** 167,177 **** protected void doIlluminance( ShaderVariables sv, ! Collection lights, Point3fGrid P, Vector3fGrid N, float angle, Statement statement) { ! for (Iterator iter = lights.iterator(); iter.hasNext();) { ! LightShader ls = (LightShader) iter.next(); if (ls.isAmbient()) continue; --- 165,175 ---- protected void doIlluminance( ShaderVariables sv, ! LightShader[] lights, Point3fGrid P, Vector3fGrid N, float angle, Statement statement) { ! for (int i = 0; i < lights.length; i++) { ! LightShader ls = lights[i]; if (ls.isAmbient()) continue; *************** *** 188,194 **** float angle, Statement statement) { ! Collection selectedLights; if (categoryList == null) ! selectedLights = sv.attributes.getLightSources(); else selectedLights = getLightsByCategory(sv, categoryList); --- 186,192 ---- float angle, Statement statement) { ! LightShader[] selectedLights; if (categoryList == null) ! selectedLights = sv.attributes.getLightSourcesArray(); else selectedLights = getLightsByCategory(sv, categoryList); *************** *** 196,200 **** } ! protected Collection getLightsByCategory(ShaderVariables sv, String categoryList) { boolean inverse = false; if (categoryList.startsWith("-")) { --- 194,198 ---- } ! protected LightShader[] getLightsByCategory(ShaderVariables sv, String categoryList) { boolean inverse = false; if (categoryList.startsWith("-")) { *************** *** 205,211 **** categories.addAll(Arrays.asList(SEPARATOR.split(categoryList))); List result = new ArrayList(); ! Set lights = sv.attributes.getLightSources(); ! for (Iterator iter = lights.iterator(); iter.hasNext();) { ! LightShader ls = (LightShader) iter.next(); if (ls.isAmbient()) continue; --- 203,209 ---- categories.addAll(Arrays.asList(SEPARATOR.split(categoryList))); List result = new ArrayList(); ! LightShader[] lights = sv.attributes.getLightSourcesArray(); ! for (int i = 0; i < lights.length; i++) { ! LightShader ls = lights[i]; if (ls.isAmbient()) continue; *************** *** 222,226 **** */ } ! return result; } --- 220,224 ---- */ } ! return (LightShader[]) result.toArray(new LightShader[result.size()]); } Index: LightDistantlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightDistantlight.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LightDistantlight.java 25 Nov 2003 16:34:08 -0000 1.4 --- LightDistantlight.java 16 Sep 2004 04:16:42 -0000 1.5 *************** *** 41,46 **** private static Point3f to = new Point3f(); ! static Color3f c1 = new Color3f(); protected void initDefaults() { --- 41,65 ---- private static Point3f to = new Point3f(); + + private static Color3f c1 = new Color3f(); + + private DistantLightStatement statement = new DistantLightStatement(); ! private static class DistantLightStatement extends Statement { ! ! private float intensity; ! ! public void setIntensity(float intensity) { ! this.intensity = intensity; ! } ! ! public void execute(ShaderVariables sv) { ! c1.x *= intensity; ! c1.y *= intensity; ! c1.z *= intensity; ! sv.Cl.set(c1, tmpCond1); ! } ! ! } protected void initDefaults() { *************** *** 60,64 **** public boolean shade( ! final ShaderVariables sv, Point3fGrid P, Vector3fGrid N, --- 79,83 ---- public boolean shade( ! ShaderVariables sv, Point3fGrid P, Vector3fGrid N, *************** *** 66,70 **** super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! final float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); --- 85,89 ---- super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); *************** *** 80,91 **** shaderTransform.transformPoint(to, to); vtmp.sub(to, from); ! return solar(sv, P, N, angle, vtmp, 0f, new Statement() { ! public void execute(ShaderVariables sv) { ! c1.x *= intensity; ! c1.y *= intensity; ! c1.z *= intensity; ! sv.Cl.set(c1, tmpCond1); ! } ! }); } } --- 99,105 ---- shaderTransform.transformPoint(to, to); vtmp.sub(to, from); ! statement.setIntensity(intensity); ! return solar(sv, P, N, angle, vtmp, 0f, statement); } + } Index: LightSpotlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightSpotlight.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LightSpotlight.java 25 Nov 2003 16:34:08 -0000 1.3 --- LightSpotlight.java 16 Sep 2004 04:16:42 -0000 1.4 *************** *** 54,57 **** --- 54,110 ---- static Color3f lightcolor = new Color3f(); + private SpotLightStatement statement = new SpotLightStatement(); + + private static class SpotLightStatement extends Statement { + + private float intensity; + + private float coneangle; + + private float conedeltaangle; + + private float beamdistribution; + + private Vector3f A; + + public void setIntensity(float intensity) { + this.intensity = intensity; + } + + public void setA(Vector3f a) { + A = a; + } + public void setBeamdistribution(float beamdistribution) { + this.beamdistribution = beamdistribution; + } + public void setConeangle(float coneangle) { + this.coneangle = coneangle; + } + public void setConedeltaangle(float conedeltaangle) { + this.conedeltaangle = conedeltaangle; + } + + public void execute(ShaderVariables sv) { + fg1.dot(sv.L, A); + fg2.length(sv.L); + fg1.div(fg1, fg2); + FloatGrid cosangle = fg1; + fg2.dot(sv.L, sv.L); + fg3.pow(cosangle, beamdistribution); + fg3.div(fg3, fg2); + FloatGrid atten = fg3; + fg2.smoothstep( + (float) Math.cos(coneangle), + (float) Math.cos(coneangle - conedeltaangle), + cosangle); + atten.mul(atten, fg2); + fg2.mul(atten, intensity); + cg1.set(fg2); + sv.Cl.set(lightcolor, tmpCond1); + sv.Cl.mul(sv.Cl, cg1, tmpCond1); + } + + } + protected void initDefaults() { defaultParameters.addParameter( *************** *** 80,84 **** public boolean shade( ! final ShaderVariables sv, Point3fGrid P, Vector3fGrid N, --- 133,137 ---- public boolean shade( ! ShaderVariables sv, Point3fGrid P, Vector3fGrid N, *************** *** 86,90 **** super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! final float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); --- 139,143 ---- super.shade(sv, P, N, angle); UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); ! float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = (UniformScalarTuple3f) getParameter(sv, "lightcolor"); *************** *** 100,134 **** shaderTransform.transformPoint(to, to); UniformScalarFloat paramConeangle = (UniformScalarFloat) getParameter(sv, "coneangle"); ! final float coneangle = paramConeangle.getValue(); UniformScalarFloat paramConedeltaangle = (UniformScalarFloat) getParameter(sv, "conedeltaangle"); ! final float conedeltaangle = paramConedeltaangle.getValue(); UniformScalarFloat paramBeamdistribution = (UniformScalarFloat) getParameter(sv, "beamdistribution"); ! final float beamdistribution = paramBeamdistribution.getValue(); vtmp.sub(to, from); ! final Vector3f A = vtmp; A.normalize(); ! return illuminate(sv, P, N, angle, from, A, coneangle, new Statement() { ! public void execute(ShaderVariables sv) { ! fg1.dot(sv.L, A); ! fg2.length(sv.L); ! fg1.div(fg1, fg2); ! FloatGrid cosangle = fg1; ! fg2.dot(sv.L, sv.L); ! fg3.pow(cosangle, beamdistribution); ! fg3.div(fg3, fg2); ! FloatGrid atten = fg3; ! fg2.smoothstep( ! (float) Math.cos(coneangle), ! (float) Math.cos(coneangle - conedeltaangle), ! cosangle); ! atten.mul(atten, fg2); ! fg2.mul(atten, intensity); ! cg1.set(fg2); ! sv.Cl.set(lightcolor, tmpCond1); ! sv.Cl.mul(sv.Cl, cg1, tmpCond1); ! } ! }); } } --- 153,172 ---- shaderTransform.transformPoint(to, to); UniformScalarFloat paramConeangle = (UniformScalarFloat) getParameter(sv, "coneangle"); ! float coneangle = paramConeangle.getValue(); UniformScalarFloat paramConedeltaangle = (UniformScalarFloat) getParameter(sv, "conedeltaangle"); ! float conedeltaangle = paramConedeltaangle.getValue(); UniformScalarFloat paramBeamdistribution = (UniformScalarFloat) getParameter(sv, "beamdistribution"); ! float beamdistribution = paramBeamdistribution.getValue(); vtmp.sub(to, from); ! Vector3f A = vtmp; A.normalize(); ! statement.setIntensity(intensity); ! statement.setConeangle(coneangle); ! statement.setConedeltaangle(conedeltaangle); ! statement.setBeamdistribution(beamdistribution); ! statement.setA(A); ! return illuminate(sv, P, N, angle, from, A, coneangle, statement); } } Index: LightShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightShader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LightShader.java 25 Nov 2003 16:34:08 -0000 1.10 --- LightShader.java 16 Sep 2004 04:16:42 -0000 1.11 *************** *** 46,50 **** protected static BooleanGrid tmpCond2 = new BooleanGrid(); ! protected abstract class Statement { public abstract void execute(ShaderVariables sv); } --- 46,50 ---- protected static BooleanGrid tmpCond2 = new BooleanGrid(); ! protected abstract static class Statement { public abstract void execute(ShaderVariables sv); } |
From: Gerardo H. <ma...@us...> - 2004-09-16 04:16:51
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29936/src/org/jrman/attributes Modified Files: Attributes.java Log Message: Some memory optimizations. Index: Attributes.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/attributes/Attributes.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Attributes.java 17 Jul 2003 16:35:50 -0000 1.4 --- Attributes.java 16 Sep 2004 04:16:42 -0000 1.5 *************** *** 20,23 **** --- 20,24 ---- package org.jrman.attributes; + import java.util.Iterator; import java.util.Set; *************** *** 27,30 **** --- 28,32 ---- import org.jrman.geom.Transform; import org.jrman.shaders.DisplacementShader; + import org.jrman.shaders.LightShader; import org.jrman.shaders.SurfaceShader; import org.jrman.shaders.VolumeShader; *************** *** 40,43 **** --- 42,47 ---- protected Set lightSources; + + protected LightShader[] lightSourcesArray; protected SurfaceShader surface; *************** *** 139,142 **** --- 143,156 ---- return lightSources; } + + public LightShader[] getLightSourcesArray() { + if (lightSourcesArray == null) { + lightSourcesArray = new LightShader[lightSources.size()]; + int p = 0; + for (Iterator iter = lightSources.iterator(); iter.hasNext(); ) + lightSourcesArray[p++] = (LightShader) iter.next(); + } + return lightSourcesArray; + } public SurfaceShader getSurface() { |