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: <ma...@us...> - 2003-04-14 08:38:35
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv11358/src/org/jrman/parser Modified Files: Parser.java Global.java Added Files: Declaration.java Log Message: More work on geometry classes for rendering. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Parser.java 12 Apr 2003 20:52:02 -0000 1.25 --- Parser.java 14 Apr 2003 08:38:00 -0000 1.26 *************** *** 38,42 **** import org.jrman.attributes.Attributes; import org.jrman.attributes.Basis; - import org.jrman.attributes.Declaration; import org.jrman.attributes.DetailRange; import org.jrman.attributes.GeometricApproximation; --- 38,41 ---- *************** *** 75,80 **** private Frame frame; - private Global global; - private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; --- 74,77 ---- *************** *** 159,163 **** world = new World(); frame = new Frame(); - global = new Global(); } --- 156,159 ---- *************** *** 234,242 **** public void saveCurrentTransformAs(String name) { ! global.setTransform(name, currentAttributes.getTransform()); } public void setCurrentTransformTo(String name) { ! currentAttributes.setTransform(global.getTransform(name)); } --- 230,238 ---- public void saveCurrentTransformAs(String name) { ! Global.setTransform(name, currentAttributes.getTransform()); } public void setCurrentTransformTo(String name) { ! currentAttributes.setTransform(Global.getTransform(name)); } *************** *** 399,407 **** public Declaration getDeclaration(String name) { ! return global.getDeclaration(name); } public void setDeclaration(String name, String decl) { ! global.setDeclaration(name, decl); } --- 395,403 ---- public Declaration getDeclaration(String name) { ! return Global.getDeclaration(name); } public void setDeclaration(String name, String decl) { ! Global.setDeclaration(name, decl); } *************** *** 411,415 **** String name = (String) list.get(i); List array = (List) list.get(i + 1); ! Declaration declaration = global.getDeclaration(name); if (declaration != null) result.put(name, declaration.translateArray(array)); --- 407,411 ---- String name = (String) list.get(i); List array = (List) list.get(i + 1); ! Declaration declaration = Global.getDeclaration(name); if (declaration != null) result.put(name, declaration.translateArray(array)); *************** *** 490,495 **** saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! global.setTransform("raster", frame.getRasterTransform()); // from "screen" to "raster" ! global.setTransform("NDC", frame.getNDCTransform()); // from "raster" to "NDC" } --- 486,491 ---- saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! Global.setTransform("raster", frame.getRasterTransform()); // from "screen" to "raster" ! Global.setTransform("NDC", frame.getNDCTransform()); // from "raster" to "NDC" } Index: Global.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Global.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Global.java 12 Apr 2003 14:52:50 -0000 1.1 --- Global.java 14 Apr 2003 08:38:00 -0000 1.2 *************** *** 23,36 **** import java.util.Map; - import org.jrman.attributes.Declaration; import org.jrman.geom.Transform; public class Global { ! private Map transforms = new HashMap(); ! private Map declarations = new HashMap(); ! public Global() { declarations.put("fov", new Declaration("fov", "float")); declarations.put("origin", new Declaration("origin", "integer[2]")); --- 23,35 ---- import java.util.Map; import org.jrman.geom.Transform; public class Global { ! private static Map transforms = new HashMap(); ! private static Map declarations = new HashMap(); ! static { declarations.put("fov", new Declaration("fov", "float")); declarations.put("origin", new Declaration("origin", "integer[2]")); *************** *** 70,79 **** declarations.put("st", new Declaration("st", "varying float[2]")); } ! public void setTransform(String name, Transform transform) { transforms.put(name, transform); } ! public Transform getTransform(String name) { Transform result = (Transform) transforms.get(name); if (result == null) --- 69,81 ---- declarations.put("st", new Declaration("st", "varying float[2]")); } + + private Global() { + } ! public static void setTransform(String name, Transform transform) { transforms.put(name, transform); } ! public static Transform getTransform(String name) { Transform result = (Transform) transforms.get(name); if (result == null) *************** *** 82,90 **** } ! public void setDeclaration(String name, String decl) { declarations.put(name, new Declaration(name, decl)); } ! public Declaration getDeclaration(String name) { return (Declaration) declarations.get(name); } --- 84,92 ---- } ! public static void setDeclaration(String name, String decl) { declarations.put(name, new Declaration(name, decl)); } ! public static Declaration getDeclaration(String name) { return (Declaration) declarations.get(name); } |
From: <ma...@us...> - 2003-04-14 08:38:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv11358/src/org/jrman/geom Modified Files: ClippingVolume.java ConvexHull3f.java Log Message: More work on geometry classes for rendering. Index: ClippingVolume.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/ClippingVolume.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClippingVolume.java 14 Apr 2003 04:41:25 -0000 1.1 --- ClippingVolume.java 14 Apr 2003 08:37:59 -0000 1.2 *************** *** 21,30 **** import java.util.ArrayList; import java.util.Iterator; - import java.util.List; public class ClippingVolume { ! private List planes = new ArrayList(); public void addPlane(Plane plane) { --- 21,30 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.Iterator; public class ClippingVolume { ! private Collection planes = new ArrayList(); public void addPlane(Plane plane) { Index: ConvexHull3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/ConvexHull3f.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConvexHull3f.java 14 Apr 2003 04:41:25 -0000 1.1 --- ConvexHull3f.java 14 Apr 2003 08:37:59 -0000 1.2 *************** *** 21,26 **** import java.util.ArrayList; import java.util.Iterator; - import java.util.List; import javax.vecmath.Point3f; --- 21,26 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.Iterator; import javax.vecmath.Point3f; *************** *** 29,33 **** public class ConvexHull3f implements BoundingVolume { ! private List points = new ArrayList(); public void addPoint(Point3f point) { --- 29,33 ---- public class ConvexHull3f implements BoundingVolume { ! private Collection points = new ArrayList(); public void addPoint(Point3f point) { |
From: <ma...@us...> - 2003-04-14 08:38:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv11358/src/org/jrman/primitive Modified Files: Primitive.java Sphere.java Added Files: Quadric.java Log Message: More work on geometry classes for rendering. --- NEW FILE: Quadric.java --- /* Quadric.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.primitive; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.vecmath.Color3f; import javax.vecmath.Matrix4f; import javax.vecmath.Point4f; import javax.vecmath.Vector3f; import org.jrman.attributes.Attributes; import org.jrman.parser.Declaration; import org.jrman.parser.Global; import org.jrman.util.Calc; public abstract class Quadric extends Primitive { public Quadric(Map parameters, Attributes attributes) { super(parameters, attributes); } protected Map interpolateParameters(float uMin, float uMax, float vMin, float vMax) { Map result = new HashMap(); for (Iterator iter = parameters.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); Declaration declaration = Global.getDeclaration(name); Declaration.StorageClass storageClass = declaration.getStorageClass(); if (storageClass == Declaration.StorageClass.CONSTANT || storageClass == Declaration.StorageClass.UNIFORM) { result.put(name, parameters.get(name)); continue; } Declaration.Type type = declaration.getType(); if (type == Declaration.Type.INTEGER || type == Declaration.Type.STRING) { result.put(name, parameters.get(name)); continue; } if (type == Declaration.Type.FLOAT) { float[][] param = (float[][]) parameters.get(name); float[][] sparam = new float[4][]; int count = declaration.getCount(); sparam[0] = new float[count]; sparam[1] = new float[count]; sparam[2] = new float[count]; sparam[3] = new float[count]; for (int i = 0; i < count; i++) { float uv00 = param[0][i]; float uv10 = param[1][i]; float uv01 = param[2][i]; float uv11 = param[3][i]; sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); } result.put(name, sparam); } else if (type == Declaration.Type.COLOR) { Color3f[][] param = (Color3f[][]) parameters.get(name); Color3f[][] sparam = new Color3f[4][]; int count = declaration.getCount(); sparam[0] = new Color3f[count]; sparam[1] = new Color3f[count]; sparam[2] = new Color3f[count]; sparam[3] = new Color3f[count]; for (int i = 0; i < count; i++) { Color3f uv00 = param[0][i]; Color3f uv10 = param[1][i]; Color3f uv01 = param[2][i]; Color3f uv11 = param[3][i]; sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); } result.put(name, sparam); } else if (type == Declaration.Type.VECTOR || type == Declaration.Type.NORMAL) { Vector3f[][] param = (Vector3f[][]) parameters.get(name); Vector3f[][] sparam = new Vector3f[4][]; int count = declaration.getCount(); sparam[0] = new Vector3f[count]; sparam[1] = new Vector3f[count]; sparam[2] = new Vector3f[count]; sparam[3] = new Vector3f[count]; for (int i = 0; i < count; i++) { Vector3f uv00 = param[0][i]; Vector3f uv10 = param[1][i]; Vector3f uv01 = param[2][i]; Vector3f uv11 = param[3][i]; sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); } } else if (type == Declaration.Type.HPOINT) { Point4f[][] param = (Point4f[][]) parameters.get(name); Point4f[][] sparam = new Point4f[4][]; int count = declaration.getCount(); sparam[0] = new Point4f[count]; sparam[1] = new Point4f[count]; sparam[2] = new Point4f[count]; sparam[3] = new Point4f[count]; for (int i = 0; i < count; i++) { Point4f uv00 = param[0][i]; Point4f uv10 = param[1][i]; Point4f uv01 = param[2][i]; Point4f uv11 = param[3][i]; sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); } } else if (type == Declaration.Type.MATRIX) { Matrix4f[][] param = (Matrix4f[][]) parameters.get(name); Matrix4f[][] sparam = new Matrix4f[4][]; int count = declaration.getCount(); sparam[0] = new Matrix4f[count]; sparam[1] = new Matrix4f[count]; sparam[2] = new Matrix4f[count]; sparam[3] = new Matrix4f[count]; for (int i = 0; i < count; i++) { Matrix4f uv00 = param[0][i]; Matrix4f uv10 = param[1][i]; Matrix4f uv01 = param[2][i]; Matrix4f uv11 = param[3][i]; sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); } } } return result; } } Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Primitive.java 12 Apr 2003 07:06:33 -0000 1.1 --- Primitive.java 14 Apr 2003 08:37:55 -0000 1.2 *************** *** 23,28 **** import org.jrman.attributes.Attributes; ! public class Primitive { protected Map parameters; --- 23,29 ---- import org.jrman.attributes.Attributes; + import org.jrman.geom.BoundingVolume; ! public abstract class Primitive { protected Map parameters; *************** *** 34,37 **** --- 35,48 ---- this.attributes = attributes; } + + public Attributes getAttributes() { + return attributes; + } + + public abstract BoundingVolume getBoundingVolume(); + + public abstract Primitive[] split(); + + public abstract Map dice(); } Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Sphere.java 12 Apr 2003 07:06:34 -0000 1.1 --- Sphere.java 14 Apr 2003 08:37:56 -0000 1.2 *************** *** 22,28 **** import java.util.Map; import org.jrman.attributes.Attributes; ! public class Sphere extends Primitive { private float radius; --- 22,32 ---- import java.util.Map; + import javax.vecmath.Point3f; + import org.jrman.attributes.Attributes; + import org.jrman.geom.BoundingVolume; + import org.jrman.geom.Bounds3f; ! public class Sphere extends Quadric { private float radius; *************** *** 36,39 **** --- 40,45 ---- private float thetaMax; + private BoundingVolume boundingVolume; + public Sphere( float radius, *************** *** 44,53 **** Map parameters, Attributes attributes) { ! super(parameters, attributes); ! this.radius = radius; ! this.phiMin = phiMin; ! this.phiMax = phiMax; ! this.thetaMin = thetaMin; ! this.thetaMax = thetaMax; } --- 50,115 ---- Map parameters, Attributes attributes) { ! super(parameters, attributes); ! this.radius = radius; ! this.phiMin = phiMin; ! this.phiMax = phiMax; ! this.thetaMin = thetaMin; ! this.thetaMax = thetaMax; ! } ! ! public BoundingVolume getBoundingVolume() { ! // Should implement a tighter bounding volume ! if (boundingVolume == null) ! boundingVolume = ! new Bounds3f( ! new Point3f(-radius, -radius, -radius), ! new Point3f(radius, radius, radius)); ! return boundingVolume; ! } ! ! public Primitive[] split() { ! Primitive[] result = new Primitive[4]; ! result[0] = ! new Sphere( ! radius, ! phiMin, ! (phiMin + phiMax) / 2f, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! interpolateParameters(0f, .5f, 0f, .5f), ! attributes); ! result[1] = ! new Sphere( ! radius, ! (phiMin + phiMax) / 2f, ! phiMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! interpolateParameters(0f, .5f, .5f, 1f), ! attributes); ! result[2] = ! new Sphere( ! radius, ! phiMin, ! (phiMin + phiMax) / 2f, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! interpolateParameters(.5f, 1f, 0f, .5f), ! attributes); ! result[3] = ! new Sphere( ! radius, ! (phiMin + phiMax) / 2f, ! phiMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! interpolateParameters(.5f, 1f, .5f, 1f), ! attributes); ! return result; ! } ! ! public Map dice() { ! // TODO Auto-generated method stub ! return null; } |
From: <ma...@us...> - 2003-04-14 08:38:05
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1:/tmp/cvs-serv11358/src/org/jrman/util Added Files: Calc.java Log Message: More work on geometry classes for rendering. --- NEW FILE: Calc.java --- /* Calc.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 javax.vecmath.Color3f; import javax.vecmath.Matrix4f; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.Vector3f; public class Calc { private Calc() { } public static float interpolate(float a, float b, float alpha) { return a + (b - a) * alpha; } public static float interpolate( float a00, float a10, float a01, float a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } public static Point3f interpolate(Point3f a, Point3f b, float alpha) { Point3f result = new Point3f(); result.interpolate(a, b, alpha); return result; } public static Point3f interpolate( Point3f a00, Point3f a10, Point3f a01, Point3f a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } public static Point4f interpolate(Point4f a, Point4f b, float alpha) { Point4f result = new Point4f(); result.interpolate(a, b, alpha); return result; } public static Point4f interpolate( Point4f a00, Point4f a10, Point4f a01, Point4f a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } public static Vector3f interpolate(Vector3f a, Vector3f b, float alpha) { Vector3f result = new Vector3f(); result.interpolate(a, b, alpha); return result; } public static Vector3f interpolate( Vector3f a00, Vector3f a10, Vector3f a01, Vector3f a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } public static Color3f interpolate(Color3f a, Color3f b, float alpha) { Color3f result = new Color3f(); result.interpolate(a, b, alpha); return result; } public static Color3f interpolate( Color3f a00, Color3f a10, Color3f a01, Color3f a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } public static Matrix4f interpolate(Matrix4f a, Matrix4f b, float alpha) { return new Matrix4f( interpolate(a.m00, b.m00, alpha), interpolate(a.m01, b.m01, alpha), interpolate(a.m02, b.m02, alpha), interpolate(a.m03, b.m03, alpha), interpolate(a.m10, b.m10, alpha), interpolate(a.m11, b.m11, alpha), interpolate(a.m12, b.m12, alpha), interpolate(a.m13, b.m13, alpha), interpolate(a.m20, b.m20, alpha), interpolate(a.m21, b.m21, alpha), interpolate(a.m22, b.m22, alpha), interpolate(a.m23, b.m23, alpha), interpolate(a.m30, b.m30, alpha), interpolate(a.m31, b.m31, alpha), interpolate(a.m32, b.m32, alpha), interpolate(a.m33, b.m33, alpha)); } public static Matrix4f interpolate( Matrix4f a00, Matrix4f a10, Matrix4f a01, Matrix4f a11, float alphaU, float alphaV) { return interpolate( interpolate(a00, a10, alphaU), interpolate(a01, a11, alphaU), alphaV); } } |
From: <ma...@us...> - 2003-04-14 08:38:02
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1:/tmp/cvs-serv11358/src/org/jrman/attributes Removed Files: Declaration.java Log Message: More work on geometry classes for rendering. --- Declaration.java DELETED --- |
From: <ma...@us...> - 2003-04-14 04:41:28
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv18580/src/org/jrman/geom Modified Files: Bounds3f.java Added Files: BoundingVolume.java ClippingVolume.java ConvexHull3f.java Log Message: Started workning on geometry classes for rendering. --- NEW FILE: BoundingVolume.java --- /* BoundingVolume.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.geom; public interface BoundingVolume { BoundingVolume transform(Transform transform); Plane.Side whichSideOf(Plane plane); Bounds3f getBoundingBox(); } --- NEW FILE: ClippingVolume.java --- /* ClippingVolume.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.geom; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class ClippingVolume { private List planes = new ArrayList(); public void addPlane(Plane plane) { planes.add(plane); } public Plane.Side whereIs(BoundingVolume v) { boolean bothSides = false; for (Iterator iter = planes.iterator(); iter.hasNext();) { Plane plane = (Plane) iter.next(); Plane.Side side = v.whichSideOf(plane); if (side == Plane.Side.OUTSIDE) return Plane.Side.OUTSIDE; if (side == Plane.Side.BOTH_SIDES) bothSides = true; } return bothSides ? Plane.Side.BOTH_SIDES : Plane.Side.INSIDE; } } --- NEW FILE: ConvexHull3f.java --- /* Polyhedron3f.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.geom; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.vecmath.Point3f; import javax.vecmath.Point4f; public class ConvexHull3f implements BoundingVolume { private List points = new ArrayList(); public void addPoint(Point3f point) { points.add(new Point3f(point)); } public void addPoint(float x, float y, float z) { points.add(new Point3f(x, y, z)); } public void addHpoint(Point4f hpoint) { Point3f p = new Point3f(); p.project(hpoint); points.add(p); } public BoundingVolume transform(Transform transform) { ConvexHull3f result = new ConvexHull3f(); for (Iterator iter = points.iterator(); iter.hasNext(); ) { Point3f p = (Point3f) iter.next(); result.addPoint(p); } return result; } public Plane.Side whichSideOf(Plane plane) { boolean inside = false; boolean outside = true; for (Iterator iter = points.iterator(); iter.hasNext(); ) { Point3f p = (Point3f) iter.next(); if (plane.isInside(p)) { inside = true; if (outside) return Plane.Side.BOTH_SIDES; } else { outside = true; if (inside) return Plane.Side.BOTH_SIDES; } } return inside ? Plane.Side.INSIDE : Plane.Side.OUTSIDE; } public Bounds3f getBoundingBox() { MutableBounds3f result = new MutableBounds3f(); for (Iterator iter = points.iterator(); iter.hasNext(); ) result.addPoint((Point3f) iter.next()); return result; } } Index: Bounds3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds3f.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Bounds3f.java 13 Apr 2003 05:15:32 -0000 1.4 --- Bounds3f.java 14 Apr 2003 04:41:25 -0000 1.5 *************** *** 24,28 **** import org.jrman.util.Constants; ! public class Bounds3f { protected Point3f max; --- 24,28 ---- import org.jrman.util.Constants; ! public class Bounds3f implements BoundingVolume { protected Point3f max; *************** *** 79,83 **** } ! public Bounds3f transform(Transform transform) { MutableBounds3f mb = new MutableBounds3f(); Point3f p = new Point3f(); --- 79,83 ---- } ! public Bounds3f transformToBounds3f(Transform transform) { MutableBounds3f mb = new MutableBounds3f(); Point3f p = new Point3f(); *************** *** 109,113 **** } ! public Plane.Side whichSide(Plane plane) { boolean inside = false; boolean outside = false; --- 109,113 ---- } ! public Plane.Side whichSideOf(Plane plane) { boolean inside = false; boolean outside = false; *************** *** 189,192 **** --- 189,209 ---- } return inside ? Plane.Side.INSIDE : Plane.Side.OUTSIDE; + } + + public BoundingVolume transform(Transform transform) { + ConvexHull3f c = new ConvexHull3f(); + c.addPoint(min.x, min.y, min.z); + c.addPoint(min.x, min.y, max.z); + c.addPoint(min.x, max.y, min.z); + c.addPoint(min.x, max.y, max.z); + c.addPoint(max.x, min.y, min.z); + c.addPoint(max.x, min.y, max.z); + c.addPoint(max.x, max.y, min.z); + c.addPoint(max.x, max.y, max.z); + return c.transform(transform); + } + + public Bounds3f getBoundingBox() { + return this; } |
From: <ma...@us...> - 2003-04-13 05:15:36
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1:/tmp/cvs-serv6008/src/org/jrman/attributes Modified Files: MutableAttributes.java Log Message: More geometry code. Index: MutableAttributes.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/attributes/MutableAttributes.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MutableAttributes.java 12 Apr 2003 06:10:30 -0000 1.2 --- MutableAttributes.java 13 Apr 2003 05:15:33 -0000 1.3 *************** *** 47,51 **** shadingInterpolation = ShadingInterpolation.CONSTANT; matte = false; ! detail = new Bounds3f(); geometricApproximation = new GeometricApproximation(GeometricApproximation.Type.FLATNESS, 1f); --- 47,51 ---- shadingInterpolation = ShadingInterpolation.CONSTANT; matte = false; ! detail = Bounds3f.ALL; geometricApproximation = new GeometricApproximation(GeometricApproximation.Type.FLATNESS, 1f); |
From: <ma...@us...> - 2003-04-13 05:15:36
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv6008/src/org/jrman/geom Modified Files: Bounds3f.java Bounds2f.java Plane.java Added Files: MutableBounds3f.java Log Message: More geometry code. --- NEW FILE: MutableBounds3f.java --- /* MutableBounds3f.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.geom; import javax.vecmath.Point3f; import javax.vecmath.Point4f; public class MutableBounds3f extends Bounds3f { public void addPoint(float x, float y, float z) { min.x = Math.min(x, min.x); min.y = Math.min(y, min.y); min.z = Math.min(z, min.z); max.x = Math.max(x, max.x); max.y = Math.max(y, max.y); max.z = Math.max(z, max.z); } public void addPoint(Point3f point) { addPoint(point.x, point.y, point.z); } public void addPoint(Point4f hpoint){ addPoint(hpoint.x / hpoint.w, hpoint.y / hpoint.w, hpoint.z/hpoint.w); } } Index: Bounds3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds3f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Bounds3f.java 13 Apr 2003 02:41:38 -0000 1.3 --- Bounds3f.java 13 Apr 2003 05:15:32 -0000 1.4 *************** *** 26,35 **** public class Bounds3f { ! private Point3f max; ! private Point3f min; ! public Bounds3f() { ! this( -Constants.INFINITY, Constants.INFINITY, --- 26,35 ---- public class Bounds3f { ! protected Point3f max; ! protected Point3f min; ! public static Bounds3f ALL = ! new Bounds3f( -Constants.INFINITY, Constants.INFINITY, *************** *** 38,41 **** --- 38,50 ---- -Constants.INFINITY, Constants.INFINITY); + + protected Bounds3f() { // Empty + this( + Constants.INFINITY, + -Constants.INFINITY, + Constants.INFINITY, + -Constants.INFINITY, + Constants.INFINITY, + -Constants.INFINITY); } *************** *** 48,51 **** --- 57,192 ---- min = new Point3f(newMin); max = new Point3f(newMax); + } + + public Bounds2f toBounds2f() { + return new Bounds2f(min.x, max.x, min.y, max.y); + } + + public boolean intersects(Bounds3f other) { + if (min.x > other.max.x) + return false; + if (max.x < other.min.x) + return false; + if (min.y > other.max.y) + return false; + if (max.y < other.min.y) + return false; + if (min.z > other.max.z) + return false; + if (max.z < other.min.z) + return false; + return true; + } + + public Bounds3f transform(Transform transform) { + MutableBounds3f mb = new MutableBounds3f(); + Point3f p = new Point3f(); + p.set(min.x, min.y, min.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(min.x, min.y, max.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(min.x, max.y, min.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(min.x, max.y, max.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(max.x, min.y, min.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(max.x, min.y, max.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(max.x, max.y, min.z); + transform.transformPoint(p); + mb.addPoint(p); + p.set(max.x, max.y, max.z); + transform.transformPoint(p); + mb.addPoint(p); + return new Bounds3f(mb.min, mb.max); + } + + public Plane.Side whichSide(Plane plane) { + boolean inside = false; + boolean outside = false; + Point3f p = new Point3f(); + p.set(min.x, min.y, min.z); + if (plane.isInside(p)) + inside = true; + else + outside = true; + p.set(min.x, min.y, max.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(min.x, max.y, min.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(min.x, max.y, max.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(max.x, min.y, min.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(max.x, min.y, max.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(max.x, max.y, min.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + p.set(max.x, max.y, max.z); + if (plane.isInside(p)) { + inside = true; + if (outside) + return Plane.Side.BOTH_SIDES; + } else { + outside = true; + if (inside) + return Plane.Side.BOTH_SIDES; + } + return inside ? Plane.Side.INSIDE : Plane.Side.OUTSIDE; } Index: Bounds2f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds2f.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Bounds2f.java 9 Apr 2003 15:50:02 -0000 1.2 --- Bounds2f.java 13 Apr 2003 05:15:32 -0000 1.3 *************** *** 22,27 **** import javax.vecmath.Point2f; - import org.jrman.util.Constants; - public class Bounds2f { --- 22,25 ---- *************** *** 30,37 **** private Point2f min; - public Bounds2f() { - this(-Constants.INFINITY, Constants.INFINITY, -Constants.INFINITY, Constants.INFINITY); - } - public Bounds2f(float xMin, float xMax, float yMin, float yMax) { min = new Point2f(xMin, yMin); --- 28,31 ---- *************** *** 42,45 **** --- 36,51 ---- this.min = new Point2f(min); this.max = new Point2f(max); + } + + public boolean intersects(Bounds2f other) { + if (min.x > other.max.x) + return false; + if (max.x < other.min.x) + return false; + if (min.y > other.max.y) + return false; + if (max.y < other.min.y) + return false; + return true; } Index: Plane.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Plane.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Plane.java 13 Apr 2003 02:41:38 -0000 1.1 --- Plane.java 13 Apr 2003 05:15:32 -0000 1.2 *************** *** 29,32 **** --- 29,52 ---- private Vector3f normal; + + public static class Side { + + public final static Side INSIDE = new Side("INSIDE"); + + public final static Side OUTSIDE = new Side("OUTSIDE"); + + public final static Side BOTH_SIDES = new Side("BOTH_SIDES"); + + private String name; + + private Side(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + } public static Plane createWithPointAndNormal(Point3f point, Vector3f normal) { |
From: <ma...@us...> - 2003-04-13 02:41:41
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv2318/src/org/jrman/geom Modified Files: Bounds3f.java Added Files: Plane.java Log Message: Created Plane. --- NEW FILE: Plane.java --- /* Plane.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.geom; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.Vector3f; public class Plane { private Point3f point; private Vector3f normal; public static Plane createWithPointAndNormal(Point3f point, Vector3f normal) { return new Plane(new Point3f(point), new Vector3f(normal)); } public static Plane createWithThreePoints(Point3f a, Point3f b, Point3f c) { Vector3f v1 = new Vector3f(b); v1.sub(a); Vector3f v2 = new Vector3f(c); v2.sub(a); Vector3f normal = new Vector3f(); normal.cross(v1, v2); return new Plane(new Point3f(a), normal); } protected Plane(Point3f point, Vector3f normal) { this.point = point; this.normal = normal; } public boolean isInside(Point3f p) { Vector3f v = new Vector3f(p); v.sub(point); return v.dot(normal) < 0f; } public boolean isInside(Point4f hp) { Point3f p = new Point3f(); p.project(hp); return isInside(p); } } Index: Bounds3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds3f.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Bounds3f.java 9 Apr 2003 15:50:01 -0000 1.2 --- Bounds3f.java 13 Apr 2003 02:41:38 -0000 1.3 *************** *** 20,24 **** package org.jrman.geom; - import javax.vecmath.Matrix4f; import javax.vecmath.Point3f; --- 20,23 ---- *************** *** 49,60 **** min = new Point3f(newMin); max = new Point3f(newMax); - } - - public Bounds3f transform(Matrix4f transform) { - Point3f newMin = new Point3f(); - Point3f newMax = new Point3f(); - transform.transform(min, newMin); - transform.transform(max, newMax); - return new Bounds3f(newMin, newMax); } --- 48,51 ---- |
From: <ma...@us...> - 2003-04-12 20:52:07
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv23431/src/org/jrman/geom Modified Files: AffineTransform.java Log Message: Small formatting changes. Index: AffineTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/AffineTransform.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AffineTransform.java 12 Apr 2003 01:55:45 -0000 1.4 --- AffineTransform.java 12 Apr 2003 20:52:01 -0000 1.5 *************** *** 66,69 **** --- 66,138 ---- } + public static Transform createRaster( + Bounds2f screenWindow, + float frameAspectRatio, + int horizontalResolution, + int verticalResolution, + float pixelAspectRatio) { + float imageAspectRatio = + (horizontalResolution * pixelAspectRatio) / verticalResolution; + if (imageAspectRatio < frameAspectRatio) + verticalResolution = + (int) ((horizontalResolution * pixelAspectRatio) / frameAspectRatio); + else if (imageAspectRatio > frameAspectRatio) + horizontalResolution = + (int) ((verticalResolution * frameAspectRatio) / pixelAspectRatio); + // Doesn't handle "flipped" screen window + Point2f min = screenWindow.getMin(); + Point2f max = screenWindow.getMax(); + Matrix4f m = new Matrix4f(); + Matrix4f tmp = + new Matrix4f( + horizontalResolution / (max.x - min.x), + 0f, + 0f, + 0f, + 0f, + verticalResolution / (max.y - min.y), + 0f, + 0f, + 0f, + 0f, + 1f, + 0f, + 0f, + 0f, + 0f, + 1f); + m.mul(tmp); + tmp = new Matrix4f(); + tmp.setTranslation(new Vector3f(0f, max.y - min.y, 0f)); + m.mul(tmp); + tmp = new Matrix4f(1f, 0f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f); + m.mul(tmp); + tmp.setTranslation(new Vector3f(-min.x, -min.y, 0f)); + m.mul(tmp); + return new AffineTransform(m); + } + + public static Transform createNDC(int horizontalResolution, int verticalResolution) { + Matrix4f m = + new Matrix4f( + 1f / horizontalResolution, + 0f, + 0f, + 0f, + 0f, + 1f / verticalResolution, + 0f, + 0f, + 0f, + 0f, + 1f, + 0f, + 0f, + 0f, + 0f, + 1f); + return new AffineTransform(m); + } + protected AffineTransform(Matrix4f matrix) { this.matrix = new Matrix4f(matrix); *************** *** 180,238 **** } return inverseNormalsMatrix; - } - - public static Transform createRaster( - Bounds2f screenWindow, - float frameAspectRatio, - int horizontalResolution, - int verticalResolution, - float pixelAspectRatio) { - float imageAspectRatio = - (horizontalResolution * pixelAspectRatio) / verticalResolution; - if (imageAspectRatio < frameAspectRatio) - verticalResolution = - (int) ((horizontalResolution * pixelAspectRatio) / frameAspectRatio); - else if (imageAspectRatio > frameAspectRatio) - horizontalResolution = - (int) ((verticalResolution * frameAspectRatio) / pixelAspectRatio); - // Doesn't handle "flipped" screen window - Point2f min = screenWindow.getMin(); - Point2f max = screenWindow.getMax(); - Matrix4f m = new Matrix4f(); - Matrix4f tmp = - new Matrix4f( - horizontalResolution / (max.x - min.x), - 0f, - 0f, - 0f, - 0f, - verticalResolution / (max.y - min.y), - 0f, - 0f, - 0f, - 0f, - 1f, - 0f, - 0f, - 0f, - 0f, - 1f); - m.mul(tmp); - tmp = new Matrix4f(); - tmp.setTranslation(new Vector3f(0f, max.y - min.y, 0f)); - m.mul(tmp); - tmp = new Matrix4f(1f, 0f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f); - m.mul(tmp); - tmp.setTranslation(new Vector3f(-min.x, -min.y, 0f)); - m.mul(tmp); - return new AffineTransform(m); - } - - public static Transform createNDC(int horizontalResolution, int verticalResolution) { - Matrix4f m = new Matrix4f(1f / horizontalResolution, 0f, 0f, 0f, - 0f, 1f / verticalResolution, 0f, 0f, - 0f, 0f, 1f, 0f, - 0f, 0f, 0f, 1f); - return new AffineTransform(m); } --- 249,252 ---- |
From: <ma...@us...> - 2003-04-12 20:52:07
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv23431/src/org/jrman/parser Modified Files: Parser.java Log Message: Small formatting changes. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Parser.java 12 Apr 2003 17:07:23 -0000 1.24 --- Parser.java 12 Apr 2003 20:52:02 -0000 1.25 *************** *** 88,94 **** private Stack transformStack = new Stack(); ! private Stack worldStack = new Stack(); ! private Stack frameStack = new Stack(); --- 88,94 ---- private Stack transformStack = new Stack(); ! private Stack worldStack = new Stack(); ! private Stack frameStack = new Stack(); *************** *** 416,420 **** else { // Check for inline declaration ! name = name.trim(); /* Just being careful... */ int pos = name.lastIndexOf(' '); if (pos == -1) --- 416,420 ---- else { // Check for inline declaration ! name = name.trim(); // Just being careful... int pos = name.lastIndexOf(' '); if (pos == -1) *************** *** 490,495 **** saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! global.setTransform("raster", frame.getRasterTransform()); ! // from "screen" to "raster" global.setTransform("NDC", frame.getNDCTransform()); // from "raster" to "NDC" } --- 490,494 ---- saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! global.setTransform("raster", frame.getRasterTransform()); // from "screen" to "raster" global.setTransform("NDC", frame.getNDCTransform()); // from "raster" to "NDC" } |
From: <ma...@us...> - 2003-04-12 17:07:26
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv29811/src/org/jrman/parser Modified Files: Parser.java Added Files: Frame.java Log Message: Moved Frame to org.jrman.parser (it now is in the same packager as World and Global). --- NEW FILE: Frame.java --- /* Frame.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.parser; import java.util.Map; import javax.vecmath.Point2f; import org.jrman.geom.AffineTransform; import org.jrman.geom.Bounds2f; import org.jrman.geom.Transform; import org.jrman.options.CameraProjection; import org.jrman.options.Display; import org.jrman.options.Exposure; import org.jrman.options.Filter; import org.jrman.options.Hider; import org.jrman.options.Quantizer; import org.jrman.shaders.Imager; public class Frame { private float[] motionTimes; // Just now to avoid compiler warnings... private int frameNumber; // just now to avoid compiler warnings... private int horizontalResolution; private int verticalResolution; private float pixelAspectRatio; private Bounds2f cropWindow; private float frameAspectRatio; private Bounds2f screenWindow; private CameraProjection cameraProjection; private float fieldOfView; private float nearClipping; private float farClipping; private float fStop; private float focalLength; private float focalDistance; private float shutterOpen; private float shutterClose; private float pixelVariance; private float horizontalSamplingRate; private float verticalSamplingRate; private Filter filter; private Exposure exposure; private Imager imager; private Quantizer colorQuantizer; private Quantizer depthQuantizer; private Display display; private int originX; private int originY; private Hider hider; private Map hiderParameters; private int colorSamples; private float relativeDetail; private int gridSize; private int bucketSizeX; private int bucketSizeY; public Frame() { horizontalResolution = 640; verticalResolution = 480; pixelAspectRatio = 1f; fieldOfView = 90f; cropWindow = new Bounds2f(0f, 1f, 0f, 1f); cameraProjection = CameraProjection.ORTHOGRAPHIC; nearClipping = Float.MIN_VALUE; farClipping = Float.POSITIVE_INFINITY; fStop = Float.POSITIVE_INFINITY; shutterOpen = 0f; shutterClose = 0f; horizontalSamplingRate = 2f; verticalSamplingRate = 2f; filter = new Filter(Filter.Type.GAUSSIAN, 2f, 2f); exposure = new Exposure(1f, 1f); colorQuantizer = new Quantizer(255, 0, 255, 0.5f); depthQuantizer = new Quantizer(Integer.MAX_VALUE, 0, Integer.MAX_VALUE, 0.5f); display = new Display("out.tif", Display.Type.FILE, Display.Mode.RGBA); hider = Hider.HIDDEN; colorSamples = 3; relativeDetail = 1f; } public Frame(Frame other) { motionTimes = other.motionTimes; frameNumber = other.frameNumber; horizontalResolution = other.horizontalResolution; verticalResolution = other.verticalResolution; pixelAspectRatio = other.pixelAspectRatio; cropWindow = other.cropWindow; frameAspectRatio = other.frameAspectRatio; screenWindow = other.screenWindow; cameraProjection = other.cameraProjection; fieldOfView = other.fieldOfView; nearClipping = other.nearClipping; farClipping = other.farClipping; fStop = other.fStop; focalLength = other.focalLength; focalDistance = other.focalDistance; shutterOpen = other.shutterOpen; shutterClose = other.shutterClose; pixelVariance = other.pixelVariance; horizontalSamplingRate = other.horizontalSamplingRate; verticalSamplingRate = other.verticalSamplingRate; filter = other.filter; exposure = other.exposure; imager = other.imager; colorQuantizer = other.colorQuantizer; depthQuantizer = other.depthQuantizer; display = other.display; originX = other.originX; originY = other.originY; hider = other.hider; hiderParameters = other.hiderParameters; colorSamples = other.colorSamples; relativeDetail = other.relativeDetail; gridSize = other.gridSize; bucketSizeX = other.bucketSizeX; bucketSizeY = other.bucketSizeY; } public void defineScreen() { if (frameAspectRatio == 0) frameAspectRatio = (horizontalResolution * pixelAspectRatio) / verticalResolution; if (screenWindow == null) { float h = (float) Math.tan(Math.PI * fieldOfView / 360f); if (frameAspectRatio >= 1f) screenWindow = new Bounds2f(-frameAspectRatio * h, frameAspectRatio * h, -h, h); else screenWindow = new Bounds2f(-h, h, -h / frameAspectRatio, h / frameAspectRatio); } else { Point2f min = screenWindow.getMin(); Point2f max = screenWindow.getMax(); // Doesn't handle "flipped" screen window float width = max.x - min.x; float height = max.y - min.y; frameAspectRatio = width / height; } } public CameraProjection getCameraProjection() { return cameraProjection; } public Quantizer getColorQuantizer() { return colorQuantizer; } public int getColorSamples() { return colorSamples; } public Bounds2f getCropWindow() { return cropWindow; } public Quantizer getDepthQuantizer() { return depthQuantizer; } public Display getDisplay() { return display; } public Exposure getExposure() { return exposure; } public float getFarClipping() { return farClipping; } public Filter getFilter() { return filter; } public float getFocalDistance() { return focalDistance; } public float getFocalLength() { return focalLength; } public float getFrameAspectRatio() { return frameAspectRatio; } public float getFStop() { return fStop; } public Hider getHider() { return hider; } public int getHorizontalResolution() { return horizontalResolution; } public float getHorizontalSamplingRate() { return horizontalSamplingRate; } public Imager getImager() { return imager; } public float getNearClipping() { return nearClipping; } public float getPixelAspectRatio() { return pixelAspectRatio; } public float getPixelVariance() { return pixelVariance; } public float getRelativeDetail() { return relativeDetail; } public Bounds2f getScreenWindow() { return screenWindow; } public float getShutterClose() { return shutterClose; } public float getShutterOpen() { return shutterOpen; } public int getVerticalResolution() { return verticalResolution; } public float getVerticalSamplingRate() { return verticalSamplingRate; } public void setCameraProjection(CameraProjection projection) { cameraProjection = projection; } public void setColorQuantizer(Quantizer quantizer) { colorQuantizer = quantizer; } public void setColorSamples(int i) { colorSamples = i; } public void setCropWindow(Bounds2f bounds2f) { cropWindow = bounds2f; } public void setDepthQuantizer(Quantizer quantizer) { depthQuantizer = quantizer; } public void setDisplay(Display display) { this.display = display; } public void setExposure(Exposure exposure) { this.exposure = exposure; } public void setFarClipping(float f) { farClipping = f; } public void setFilter(Filter filter) { this.filter = filter; } public void setFocalDistance(float f) { focalDistance = f; } public void setFocalLength(float f) { focalLength = f; } public void setFrameAspectRatio(float f) { frameAspectRatio = f; } public void setFStop(float f) { fStop = f; } public void setHider(Hider hider) { this.hider = hider; } public void setHorizontalResolution(int i) { horizontalResolution = i; } public void setHorizontalSamplingRate(float f) { horizontalSamplingRate = f; } public void setImager(Imager imager) { this.imager = imager; } public void setNearClipping(float f) { nearClipping = f; } public void setPixelAspectRatio(float f) { pixelAspectRatio = f; } public void setPixelVariance(float f) { pixelVariance = f; } public void setRelativeDetail(float f) { relativeDetail = f; } public void setScreenWindow(Bounds2f bounds2f) { screenWindow = bounds2f; } public void setShutterClose(float f) { shutterClose = f; } public void setShutterOpen(float f) { shutterOpen = f; } public void setVerticalResolution(int i) { verticalResolution = i; } public void setVerticalSamplingRate(float f) { verticalSamplingRate = f; } public void setFrameNumber(int n) { frameNumber = n; } public void setMotionTimes(float[] times) { this.motionTimes = new float[times.length]; System.arraycopy(times, 0, this.motionTimes, 0, times.length); } public float[] getMotionTimes() { float[] result = new float[motionTimes.length]; System.arraycopy(motionTimes, 0, result, 0, motionTimes.length); return result; } public float getFieldOfView() { return fieldOfView; } public int getFrameNumber() { return frameNumber; } public void setFieldOfView(float f) { fieldOfView = f; screenWindow = null; } public int getOriginX() { return originX; } public int getOriginY() { return originY; } public void setOriginX(int i) { originX = i; } public void setOriginY(int i) { originY = i; } public int getBucketSizeX() { return bucketSizeX; } public int getBucketSizeY() { return bucketSizeY; } public int getGridSize() { return gridSize; } public void setBucketSizeX(int i) { bucketSizeX = i; } public void setBucketSizeY(int i) { bucketSizeY = i; } public void setGridSize(int i) { gridSize = i; } public Map getHiderParameters() { return hiderParameters; } public void setHiderParameters(Map map) { hiderParameters = map; } public Transform getRasterTransform() { return AffineTransform.createRaster( screenWindow, frameAspectRatio, horizontalResolution, verticalResolution, pixelAspectRatio); } public Transform getNDCTransform() { return AffineTransform.createNDC(horizontalResolution, verticalResolution); } } Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Parser.java 12 Apr 2003 15:19:50 -0000 1.23 --- Parser.java 12 Apr 2003 17:07:23 -0000 1.24 *************** *** 56,60 **** import org.jrman.options.Filter; import org.jrman.options.Hider; - import org.jrman.options.Frame; import org.jrman.options.Quantizer; import org.jrman.parser.keywords.KeywordParser; --- 56,59 ---- |
From: <ma...@us...> - 2003-04-12 17:07:26
|
Update of /cvsroot/jrman/drafts/src/org/jrman/options In directory sc8-pr-cvs1:/tmp/cvs-serv29811/src/org/jrman/options Removed Files: Frame.java Log Message: Moved Frame to org.jrman.parser (it now is in the same packager as World and Global). --- Frame.java DELETED --- |
From: <ma...@us...> - 2003-04-12 15:19:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/options In directory sc8-pr-cvs1:/tmp/cvs-serv26920/src/org/jrman/options Modified Files: Frame.java Log Message: Saved and restored state on world/frame begin/end. Index: Frame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/options/Frame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Frame.java 12 Apr 2003 14:52:50 -0000 1.1 --- Frame.java 12 Apr 2003 15:19:50 -0000 1.2 *************** *** 124,127 **** --- 124,165 ---- relativeDetail = 1f; } + + public Frame(Frame other) { + motionTimes = other.motionTimes; + frameNumber = other.frameNumber; + horizontalResolution = other.horizontalResolution; + verticalResolution = other.verticalResolution; + pixelAspectRatio = other.pixelAspectRatio; + cropWindow = other.cropWindow; + frameAspectRatio = other.frameAspectRatio; + screenWindow = other.screenWindow; + cameraProjection = other.cameraProjection; + fieldOfView = other.fieldOfView; + nearClipping = other.nearClipping; + farClipping = other.farClipping; + fStop = other.fStop; + focalLength = other.focalLength; + focalDistance = other.focalDistance; + shutterOpen = other.shutterOpen; + shutterClose = other.shutterClose; + pixelVariance = other.pixelVariance; + horizontalSamplingRate = other.horizontalSamplingRate; + verticalSamplingRate = other.verticalSamplingRate; + filter = other.filter; + exposure = other.exposure; + imager = other.imager; + colorQuantizer = other.colorQuantizer; + depthQuantizer = other.depthQuantizer; + display = other.display; + originX = other.originX; + originY = other.originY; + hider = other.hider; + hiderParameters = other.hiderParameters; + colorSamples = other.colorSamples; + relativeDetail = other.relativeDetail; + gridSize = other.gridSize; + bucketSizeX = other.bucketSizeX; + bucketSizeY = other.bucketSizeY; + } public void defineScreen() { |
From: <ma...@us...> - 2003-04-12 15:19:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv26920/src/org/jrman/parser Modified Files: World.java Parser.java Log Message: Saved and restored state on world/frame begin/end. Index: World.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/World.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** World.java 12 Apr 2003 14:52:50 -0000 1.1 --- World.java 12 Apr 2003 15:19:50 -0000 1.2 *************** *** 30,36 **** public class World { ! private Map lights = new HashMap(); ! private List primitives = new ArrayList(); public void addLight(int sequenceNumber, LightShader light) { --- 30,46 ---- public class World { ! private Map lights; ! private List primitives; ! ! public World() { ! lights = new HashMap(); ! primitives = new ArrayList(); ! } ! ! public World(World other) { ! lights = new HashMap(other.lights); ! primitives = new ArrayList(other.primitives); ! } public void addLight(int sequenceNumber, LightShader light) { Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Parser.java 12 Apr 2003 14:52:50 -0000 1.22 --- Parser.java 12 Apr 2003 15:19:50 -0000 1.23 *************** *** 89,92 **** --- 89,96 ---- private Stack transformStack = new Stack(); + + private Stack worldStack = new Stack(); + + private Stack frameStack = new Stack(); private Stack stateStack = new Stack(); *************** *** 325,328 **** --- 329,334 ---- public void frameBegin(int n) { pushState(State.FRAME); + frameStack.push(new Frame(frame)); + worldStack.push(new World(world)); frame.setFrameNumber(n); } *************** *** 337,340 **** --- 343,348 ---- } public void frameEnd() { + world = (World) worldStack.pop(); + frame = (Frame) frameStack.pop(); popState(); } *************** *** 375,381 **** --- 383,391 ---- saveCurrentTransformAs("camera"); // from "world" to "camera" setIdentity(); + worldStack.push(new World(world)); } public void worldEnd() { + world = (World) worldStack.pop(); popState(); } |
From: <ma...@us...> - 2003-04-12 14:52:55
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv17603/src/org/jrman/parser Modified Files: Parser.java Added Files: World.java Global.java Removed Files: Scene.java Log Message: Renamed: Options -> Frame Scene -> World Extracted declarations and transforms from World into new class Global. --- NEW FILE: World.java --- /* World.java Copyright (C) 2003 Gerardo Horvilleur 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 latre version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILIY 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.parser; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jrman.primitive.Primitive; import org.jrman.shaders.LightShader; public class World { private Map lights = new HashMap(); private List primitives = new ArrayList(); public void addLight(int sequenceNumber, LightShader light) { lights.put(new Integer(sequenceNumber), light); } public LightShader getLight(int sequenceNumber) { LightShader light = (LightShader) lights.get(new Integer(sequenceNumber)); if (light == null) throw new IllegalArgumentException("no such light: " + sequenceNumber); return light; } public void addPrimitive(Primitive primitive) { primitives.add(primitive); // Just for now... } } --- NEW FILE: Global.java --- /* Global.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.parser; import java.util.HashMap; import java.util.Map; import org.jrman.attributes.Declaration; import org.jrman.geom.Transform; public class Global { private Map transforms = new HashMap(); private Map declarations = new HashMap(); public Global() { declarations.put("fov", new Declaration("fov", "float")); declarations.put("origin", new Declaration("origin", "integer[2]")); declarations.put("gridsize", new Declaration("gridsize", "integer")); declarations.put("bucketsize", new Declaration("bucketsize", "integer[2]")); declarations.put("intensity", new Declaration("intensity", "float")); declarations.put("lightcolor", new Declaration("lightcolor", "color")); declarations.put("from", new Declaration("from", "point")); declarations.put("to", new Declaration("to", "point")); declarations.put("coneangle", new Declaration("coneangle", "float")); declarations.put("conedeltaangle", new Declaration("conedeltaangle", "float")); declarations.put("beamdistribution", new Declaration("beamdistribution", "float")); declarations.put("Ka", new Declaration("Ka", "float")); declarations.put("Kd", new Declaration("Kd", "float")); declarations.put("Ks", new Declaration("Ks", "float")); declarations.put("Kr", new Declaration("Kr", "float")); declarations.put("roughness", new Declaration("roughness", "float")); declarations.put("specularcolor", new Declaration("specularcolor", "color")); declarations.put("texturename", new Declaration("texturename", "string")); declarations.put("amplitude", new Declaration("float", "float")); declarations.put("distance", new Declaration("distance", "float")); declarations.put("mindistance", new Declaration("mindistance", "float")); declarations.put("maxdistance", new Declaration("maxdistance", "float")); declarations.put("background", new Declaration("background", "color")); declarations.put("sphere", new Declaration("sphere", "float")); declarations.put("coordinatesystem", new Declaration("coordinatesystem", "string")); declarations.put("name", new Declaration("name", "string")); declarations.put("sense", new Declaration("name", "string")); declarations.put("P", new Declaration("P", "vertex point")); declarations.put("Pz", new Declaration("Pz", "vertex float")); declarations.put("Pw", new Declaration("Pz", "vertex hpoint")); declarations.put("N", new Declaration("N", "varying normal")); declarations.put("Cs", new Declaration("Cs", "varying color")); declarations.put("Pz", new Declaration("Pz", "varying color")); declarations.put("s", new Declaration("s", "varying float")); declarations.put("t", new Declaration("t", "varying float")); declarations.put("st", new Declaration("st", "varying float[2]")); } public void setTransform(String name, Transform transform) { transforms.put(name, transform); } public Transform getTransform(String name) { Transform result = (Transform) transforms.get(name); if (result == null) throw new IllegalArgumentException("no such coordinate system: " + name); return result; } public void setDeclaration(String name, String decl) { declarations.put(name, new Declaration(name, decl)); } public Declaration getDeclaration(String name) { return (Declaration) declarations.get(name); } } Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Parser.java 12 Apr 2003 07:06:34 -0000 1.21 --- Parser.java 12 Apr 2003 14:52:50 -0000 1.22 *************** *** 56,60 **** import org.jrman.options.Filter; import org.jrman.options.Hider; ! import org.jrman.options.Options; import org.jrman.options.Quantizer; import org.jrman.parser.keywords.KeywordParser; --- 56,60 ---- import org.jrman.options.Filter; import org.jrman.options.Hider; ! import org.jrman.options.Frame; import org.jrman.options.Quantizer; import org.jrman.parser.keywords.KeywordParser; *************** *** 72,78 **** private String renderer; ! private Scene scene; ! private Options options; private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; --- 72,80 ---- private String renderer; ! private World world; ! private Frame frame; ! ! private Global global; private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; *************** *** 151,161 **** } ! public Parser(Scene scene, Options options) { ! this.scene = scene; ! this.options = options; } public static void main(String args[]) throws Exception { ! Parser parser = new Parser(new Scene(), new Options()); parser.begin(args[0]); parser.parse(args[0]); --- 153,164 ---- } ! public Parser() { ! world = new World(); ! frame = new Frame(); ! global = new Global(); } public static void main(String args[]) throws Exception { ! Parser parser = new Parser(); parser.begin(args[0]); parser.parse(args[0]); *************** *** 228,236 **** public void saveCurrentTransformAs(String name) { ! scene.setTransform(name, currentAttributes.getTransform()); } public void setCurrentTransformTo(String name) { ! currentAttributes.setTransform(scene.getTransform(name)); } --- 231,239 ---- public void saveCurrentTransformAs(String name) { ! global.setTransform(name, currentAttributes.getTransform()); } public void setCurrentTransformTo(String name) { ! currentAttributes.setTransform(global.getTransform(name)); } *************** *** 322,326 **** public void frameBegin(int n) { pushState(State.FRAME); ! options.setFrameNumber(n); } --- 325,329 ---- public void frameBegin(int n) { pushState(State.FRAME); ! frame.setFrameNumber(n); } *************** *** 339,343 **** public void motionBegin(float[] times) { pushState(State.MOTION); ! options.setMotionTimes(times); } --- 342,346 ---- public void motionBegin(float[] times) { pushState(State.MOTION); ! frame.setMotionTimes(times); } *************** *** 387,395 **** public Declaration getDeclaration(String name) { ! return scene.getDeclaration(name); } public void setDeclaration(String name, String decl) { ! scene.setDeclaration(name, decl); } --- 390,398 ---- public Declaration getDeclaration(String name) { ! return global.getDeclaration(name); } public void setDeclaration(String name, String decl) { ! global.setDeclaration(name, decl); } *************** *** 399,403 **** String name = (String) list.get(i); List array = (List) list.get(i + 1); ! Declaration declaration = scene.getDeclaration(name); if (declaration != null) result.put(name, declaration.translateArray(array)); --- 402,406 ---- String name = (String) list.get(i); List array = (List) list.get(i + 1); ! Declaration declaration = global.getDeclaration(name); if (declaration != null) result.put(name, declaration.translateArray(array)); *************** *** 423,461 **** public void setFormat(int xResolution, int yResolution, float pixelAspectRatio) { if (xResolution > 0) ! options.setHorizontalResolution(xResolution); if (yResolution > 0) ! options.setVerticalResolution(yResolution); if (pixelAspectRatio > 0) ! options.setPixelAspectRatio(pixelAspectRatio); } public void setFrameAspectRatio(float frameAspectRatio) { ! options.setFrameAspectRatio(frameAspectRatio); } public void setScreenWindow(float left, float right, float bottom, float top) { ! options.setScreenWindow(new Bounds2f(left, right, bottom, top)); } public void setCropWindow(float xmin, float xmax, float ymin, float ymax) { ! options.setCropWindow(new Bounds2f(xmin, xmax, ymin, ymax)); } public void setProjection(String name, Map parameters) { CameraProjection cameraProjection = CameraProjection.getNamed(name); ! options.setCameraProjection(cameraProjection); if (cameraProjection == CameraProjection.PERSPECTIVE) { float[][] fovParam = (float[][]) parameters.get("fov"); if (fovParam != null) { ! options.setFieldOfView(fovParam[0][0]); ! options.defineScreen(); currentAttributes.setTransform( PerspectiveTransform.createWithFOV( ! options.getFieldOfView(), ! options.getNearClipping(), ! options.getFarClipping())); } else { ! options.defineScreen(); ! Bounds2f screenWindow = options.getScreenWindow(); Point2f min = screenWindow.getMin(); Point2f max = screenWindow.getMax(); --- 426,464 ---- public void setFormat(int xResolution, int yResolution, float pixelAspectRatio) { if (xResolution > 0) ! frame.setHorizontalResolution(xResolution); if (yResolution > 0) ! frame.setVerticalResolution(yResolution); if (pixelAspectRatio > 0) ! frame.setPixelAspectRatio(pixelAspectRatio); } public void setFrameAspectRatio(float frameAspectRatio) { ! frame.setFrameAspectRatio(frameAspectRatio); } public void setScreenWindow(float left, float right, float bottom, float top) { ! frame.setScreenWindow(new Bounds2f(left, right, bottom, top)); } public void setCropWindow(float xmin, float xmax, float ymin, float ymax) { ! frame.setCropWindow(new Bounds2f(xmin, xmax, ymin, ymax)); } public void setProjection(String name, Map parameters) { CameraProjection cameraProjection = CameraProjection.getNamed(name); ! frame.setCameraProjection(cameraProjection); if (cameraProjection == CameraProjection.PERSPECTIVE) { float[][] fovParam = (float[][]) parameters.get("fov"); if (fovParam != null) { ! frame.setFieldOfView(fovParam[0][0]); ! frame.defineScreen(); currentAttributes.setTransform( PerspectiveTransform.createWithFOV( ! frame.getFieldOfView(), ! frame.getNearClipping(), ! frame.getFarClipping())); } else { ! frame.defineScreen(); ! Bounds2f screenWindow = frame.getScreenWindow(); Point2f min = screenWindow.getMin(); Point2f max = screenWindow.getMax(); *************** *** 466,528 **** PerspectiveTransform.createWithH( h, ! options.getNearClipping(), ! options.getFarClipping())); } } else if (cameraProjection == CameraProjection.ORTHOGRAPHIC) { ! options.defineScreen(); currentAttributes.setTransform( AffineTransform.createOrthographic( ! options.getNearClipping(), ! options.getFarClipping())); } saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! scene.setTransform("raster", options.getRasterTransform()); // from "screen" to "raster" ! scene.setTransform("NDC", options.getNDCTransform()); // from "raster" to "NDC" } public void setClipping(float near, float far) { ! options.setNearClipping(near); ! options.setFarClipping(far); } public void setDepthOfField(float fstop, float focalLength, float focalDistance) { ! options.setFStop(fstop); ! options.setFocalLength(focalLength); ! options.setFocalDistance(focalDistance); } public void setDepthOfField(float fstop) { ! options.setFStop(fstop); } public void setShutter(float min, float max) { ! options.setShutterOpen(min); ! options.setShutterClose(max); } public void setPixelVariance(float variation) { ! options.setPixelVariance(variation); } public void setPixelSamples(float xSamples, float ySamples) { ! options.setHorizontalSamplingRate(xSamples); ! options.setVerticalSamplingRate(ySamples); } public void setPixelFilter(String type, float xWidth, float yWidth) { ! options.setFilter(new Filter(Filter.Type.getNamed(type), xWidth, yWidth)); } public void setExposure(float gain, float gamma) { ! options.setExposure(new Exposure(gain, gamma)); } public void setQuantize(String type, int one, int min, int max, float ditherAmplitude) { if (type.equals("rgba")) { ! options.setColorQuantizer(new Quantizer(one, min, max, ditherAmplitude)); } else if (type.equals("z")) { ! options.setDepthQuantizer(new Quantizer(one, min, max, ditherAmplitude)); } else throw new IllegalArgumentException("no such quantizer: " + type); --- 469,531 ---- PerspectiveTransform.createWithH( h, ! frame.getNearClipping(), ! frame.getFarClipping())); } } else if (cameraProjection == CameraProjection.ORTHOGRAPHIC) { ! frame.defineScreen(); currentAttributes.setTransform( AffineTransform.createOrthographic( ! frame.getNearClipping(), ! frame.getFarClipping())); } saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! global.setTransform("raster", frame.getRasterTransform()); // from "screen" to "raster" ! global.setTransform("NDC", frame.getNDCTransform()); // from "raster" to "NDC" } public void setClipping(float near, float far) { ! frame.setNearClipping(near); ! frame.setFarClipping(far); } public void setDepthOfField(float fstop, float focalLength, float focalDistance) { ! frame.setFStop(fstop); ! frame.setFocalLength(focalLength); ! frame.setFocalDistance(focalDistance); } public void setDepthOfField(float fstop) { ! frame.setFStop(fstop); } public void setShutter(float min, float max) { ! frame.setShutterOpen(min); ! frame.setShutterClose(max); } public void setPixelVariance(float variation) { ! frame.setPixelVariance(variation); } public void setPixelSamples(float xSamples, float ySamples) { ! frame.setHorizontalSamplingRate(xSamples); ! frame.setVerticalSamplingRate(ySamples); } public void setPixelFilter(String type, float xWidth, float yWidth) { ! frame.setFilter(new Filter(Filter.Type.getNamed(type), xWidth, yWidth)); } public void setExposure(float gain, float gamma) { ! frame.setExposure(new Exposure(gain, gamma)); } public void setQuantize(String type, int one, int min, int max, float ditherAmplitude) { if (type.equals("rgba")) { ! frame.setColorQuantizer(new Quantizer(one, min, max, ditherAmplitude)); } else if (type.equals("z")) { ! frame.setDepthQuantizer(new Quantizer(one, min, max, ditherAmplitude)); } else throw new IllegalArgumentException("no such quantizer: " + type); *************** *** 530,548 **** public void setDisplay(String name, String type, String mode, Map parameters) { ! options.setDisplay(new Display(name, type, mode)); int[][] origin = (int[][]) parameters.get("origin"); if (origin != null) { ! options.setOriginX(origin[0][0]); ! options.setOriginY(origin[0][1]); } } public void setHider(String type, Map parameters) { ! options.setHider(Hider.getNamed(type)); ! options.setHiderParameters(parameters); } public void setRelativeDetail(float relativeDetail) { ! options.setRelativeDetail(relativeDetail); } --- 533,551 ---- public void setDisplay(String name, String type, String mode, Map parameters) { ! frame.setDisplay(new Display(name, type, mode)); int[][] origin = (int[][]) parameters.get("origin"); if (origin != null) { ! frame.setOriginX(origin[0][0]); ! frame.setOriginY(origin[0][1]); } } public void setHider(String type, Map parameters) { ! frame.setHider(Hider.getNamed(type)); ! frame.setHiderParameters(parameters); } public void setRelativeDetail(float relativeDetail) { ! frame.setRelativeDetail(relativeDetail); } *************** *** 551,559 **** int[][] gridsize = (int[][]) parameters.get("gridsize"); if (gridsize != null) ! options.setGridSize(gridsize[0][0]); int[][] bucketsize = (int[][]) parameters.get("bucketsize"); if (bucketsize != null) { ! options.setBucketSizeX(bucketsize[0][0]); ! options.setBucketSizeY(bucketsize[0][1]); } } --- 554,562 ---- int[][] gridsize = (int[][]) parameters.get("gridsize"); if (gridsize != null) ! frame.setGridSize(gridsize[0][0]); int[][] bucketsize = (int[][]) parameters.get("bucketsize"); if (bucketsize != null) { ! frame.setBucketSizeX(bucketsize[0][0]); ! frame.setBucketSizeY(bucketsize[0][1]); } } *************** *** 592,596 **** public void setImager(String name, Map parameters) { ! options.setImager(Imager.createImager(name, parameters)); } --- 595,599 ---- public void setImager(String name, Map parameters) { ! frame.setImager(Imager.createImager(name, parameters)); } *************** *** 601,605 **** public void createLightSource(String name, int sequenceNumber, Map parameters) { LightShader light = LightShader.createShader(name, parameters); ! scene.addLight(sequenceNumber, light); turnOnLight(light); } --- 604,608 ---- public void createLightSource(String name, int sequenceNumber, Map parameters) { LightShader light = LightShader.createShader(name, parameters); ! world.addLight(sequenceNumber, light); turnOnLight(light); } *************** *** 618,622 **** public void illuminate(int sequenceNumber, int onOff) { ! LightShader light = scene.getLight(sequenceNumber); if (onOff != 0) turnOnLight(light); --- 621,625 ---- public void illuminate(int sequenceNumber, int onOff) { ! LightShader light = world.getLight(sequenceNumber); if (onOff != 0) turnOnLight(light); *************** *** 642,646 **** float thetaMin = 0f; thetaMax = toRadians(thetaMax); ! scene.addPrimitive( new Sphere( radius, --- 645,649 ---- float thetaMin = 0f; thetaMax = toRadians(thetaMax); ! world.addPrimitive( new Sphere( radius, --- Scene.java DELETED --- |
From: <ma...@us...> - 2003-04-12 14:52:55
|
Update of /cvsroot/jrman/drafts/src/org/jrman/options In directory sc8-pr-cvs1:/tmp/cvs-serv17603/src/org/jrman/options Added Files: Frame.java Removed Files: Options.java Log Message: Renamed: Options -> Frame Scene -> World Extracted declarations and transforms from World into new class Global. --- NEW FILE: Frame.java --- /* Frame.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.options; import java.util.Map; import javax.vecmath.Point2f; import org.jrman.geom.AffineTransform; import org.jrman.geom.Bounds2f; import org.jrman.geom.Transform; import org.jrman.shaders.*; public class Frame { private float[] motionTimes; // Just now to avoid compiler warnings... private int frameNumber; // just now to avoid compiler warnings... private int horizontalResolution; private int verticalResolution; private float pixelAspectRatio; private Bounds2f cropWindow; private float frameAspectRatio; private Bounds2f screenWindow; private CameraProjection cameraProjection; private float fieldOfView; private float nearClipping; private float farClipping; private float fStop; private float focalLength; private float focalDistance; private float shutterOpen; private float shutterClose; private float pixelVariance; private float horizontalSamplingRate; private float verticalSamplingRate; private Filter filter; private Exposure exposure; private Imager imager; private Quantizer colorQuantizer; private Quantizer depthQuantizer; private Display display; private int originX; private int originY; private Hider hider; private Map hiderParameters; private int colorSamples; private float relativeDetail; private int gridSize; private int bucketSizeX; private int bucketSizeY; public Frame() { horizontalResolution = 640; verticalResolution = 480; pixelAspectRatio = 1f; fieldOfView = 90f; cropWindow = new Bounds2f(0f, 1f, 0f, 1f); cameraProjection = CameraProjection.ORTHOGRAPHIC; nearClipping = Float.MIN_VALUE; farClipping = Float.POSITIVE_INFINITY; fStop = Float.POSITIVE_INFINITY; shutterOpen = 0f; shutterClose = 0f; horizontalSamplingRate = 2f; verticalSamplingRate = 2f; filter = new Filter(Filter.Type.GAUSSIAN, 2f, 2f); exposure = new Exposure(1f, 1f); colorQuantizer = new Quantizer(255, 0, 255, 0.5f); depthQuantizer = new Quantizer(Integer.MAX_VALUE, 0, Integer.MAX_VALUE, 0.5f); display = new Display("out.tif", Display.Type.FILE, Display.Mode.RGBA); hider = Hider.HIDDEN; colorSamples = 3; relativeDetail = 1f; } public void defineScreen() { if (frameAspectRatio == 0) frameAspectRatio = (horizontalResolution * pixelAspectRatio) / verticalResolution; if (screenWindow == null) { float h = (float) Math.tan(Math.PI * fieldOfView / 360f); if (frameAspectRatio >= 1f) screenWindow = new Bounds2f(-frameAspectRatio * h, frameAspectRatio * h, -h, h); else screenWindow = new Bounds2f(-h, h, -h / frameAspectRatio, h / frameAspectRatio); } else { Point2f min = screenWindow.getMin(); Point2f max = screenWindow.getMax(); // Doesn't handle "flipped" screen window float width = max.x - min.x; float height = max.y - min.y; frameAspectRatio = width / height; } } public CameraProjection getCameraProjection() { return cameraProjection; } public Quantizer getColorQuantizer() { return colorQuantizer; } public int getColorSamples() { return colorSamples; } public Bounds2f getCropWindow() { return cropWindow; } public Quantizer getDepthQuantizer() { return depthQuantizer; } public Display getDisplay() { return display; } public Exposure getExposure() { return exposure; } public float getFarClipping() { return farClipping; } public Filter getFilter() { return filter; } public float getFocalDistance() { return focalDistance; } public float getFocalLength() { return focalLength; } public float getFrameAspectRatio() { return frameAspectRatio; } public float getFStop() { return fStop; } public Hider getHider() { return hider; } public int getHorizontalResolution() { return horizontalResolution; } public float getHorizontalSamplingRate() { return horizontalSamplingRate; } public Imager getImager() { return imager; } public float getNearClipping() { return nearClipping; } public float getPixelAspectRatio() { return pixelAspectRatio; } public float getPixelVariance() { return pixelVariance; } public float getRelativeDetail() { return relativeDetail; } public Bounds2f getScreenWindow() { return screenWindow; } public float getShutterClose() { return shutterClose; } public float getShutterOpen() { return shutterOpen; } public int getVerticalResolution() { return verticalResolution; } public float getVerticalSamplingRate() { return verticalSamplingRate; } public void setCameraProjection(CameraProjection projection) { cameraProjection = projection; } public void setColorQuantizer(Quantizer quantizer) { colorQuantizer = quantizer; } public void setColorSamples(int i) { colorSamples = i; } public void setCropWindow(Bounds2f bounds2f) { cropWindow = bounds2f; } public void setDepthQuantizer(Quantizer quantizer) { depthQuantizer = quantizer; } public void setDisplay(Display display) { this.display = display; } public void setExposure(Exposure exposure) { this.exposure = exposure; } public void setFarClipping(float f) { farClipping = f; } public void setFilter(Filter filter) { this.filter = filter; } public void setFocalDistance(float f) { focalDistance = f; } public void setFocalLength(float f) { focalLength = f; } public void setFrameAspectRatio(float f) { frameAspectRatio = f; } public void setFStop(float f) { fStop = f; } public void setHider(Hider hider) { this.hider = hider; } public void setHorizontalResolution(int i) { horizontalResolution = i; } public void setHorizontalSamplingRate(float f) { horizontalSamplingRate = f; } public void setImager(Imager imager) { this.imager = imager; } public void setNearClipping(float f) { nearClipping = f; } public void setPixelAspectRatio(float f) { pixelAspectRatio = f; } public void setPixelVariance(float f) { pixelVariance = f; } public void setRelativeDetail(float f) { relativeDetail = f; } public void setScreenWindow(Bounds2f bounds2f) { screenWindow = bounds2f; } public void setShutterClose(float f) { shutterClose = f; } public void setShutterOpen(float f) { shutterOpen = f; } public void setVerticalResolution(int i) { verticalResolution = i; } public void setVerticalSamplingRate(float f) { verticalSamplingRate = f; } public void setFrameNumber(int n) { frameNumber = n; } public void setMotionTimes(float[] times) { this.motionTimes = new float[times.length]; System.arraycopy(times, 0, this.motionTimes, 0, times.length); } public float[] getMotionTimes() { float[] result = new float[motionTimes.length]; System.arraycopy(motionTimes, 0, result, 0, motionTimes.length); return result; } public float getFieldOfView() { return fieldOfView; } public int getFrameNumber() { return frameNumber; } public void setFieldOfView(float f) { fieldOfView = f; screenWindow = null; } public int getOriginX() { return originX; } public int getOriginY() { return originY; } public void setOriginX(int i) { originX = i; } public void setOriginY(int i) { originY = i; } public int getBucketSizeX() { return bucketSizeX; } public int getBucketSizeY() { return bucketSizeY; } public int getGridSize() { return gridSize; } public void setBucketSizeX(int i) { bucketSizeX = i; } public void setBucketSizeY(int i) { bucketSizeY = i; } public void setGridSize(int i) { gridSize = i; } public Map getHiderParameters() { return hiderParameters; } public void setHiderParameters(Map map) { hiderParameters = map; } public Transform getRasterTransform() { return AffineTransform.createRaster( screenWindow, frameAspectRatio, horizontalResolution, verticalResolution, pixelAspectRatio); } public Transform getNDCTransform() { return AffineTransform.createNDC(horizontalResolution, verticalResolution); } } --- Options.java DELETED --- |
From: <ma...@us...> - 2003-04-12 07:06:37
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv19389/src/org/jrman/parser Modified Files: Scene.java Parser.java Log Message: Implemented parsing for sphere. Index: Scene.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Scene.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Scene.java 12 Apr 2003 06:10:29 -0000 1.10 --- Scene.java 12 Apr 2003 07:06:34 -0000 1.11 *************** *** 20,28 **** package org.jrman.parser; import java.util.HashMap; import java.util.Map; ! import org.jrman.attributes.*; ! import org.jrman.geom.*; import org.jrman.shaders.LightShader; --- 20,31 ---- package org.jrman.parser; + import java.util.ArrayList; import java.util.HashMap; + import java.util.List; import java.util.Map; ! import org.jrman.attributes.Declaration; ! import org.jrman.geom.Transform; ! import org.jrman.primitive.Primitive; import org.jrman.shaders.LightShader; *************** *** 34,37 **** --- 37,42 ---- private Map lights = new HashMap(); + + private List primitives = new ArrayList(); public Scene() { *************** *** 102,105 **** --- 107,114 ---- throw new IllegalArgumentException("no such light: " + sequenceNumber); return light; + } + + public void addPrimitive(Primitive primitive) { + primitives.add(primitive); // Just for now... } Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Parser.java 12 Apr 2003 06:10:30 -0000 1.20 --- Parser.java 12 Apr 2003 07:06:34 -0000 1.21 *************** *** 36,43 **** import javax.vecmath.Vector3f; ! import org.jrman.attributes.*; ! import org.jrman.geom.*; ! import org.jrman.options.*; import org.jrman.parser.keywords.KeywordParser; import org.jrman.shaders.Imager; import org.jrman.shaders.LightShader; --- 36,63 ---- import javax.vecmath.Vector3f; ! import org.jrman.attributes.Attributes; ! import org.jrman.attributes.Basis; ! import org.jrman.attributes.Declaration; ! import org.jrman.attributes.DetailRange; ! import org.jrman.attributes.GeometricApproximation; ! import org.jrman.attributes.MutableAttributes; ! import org.jrman.attributes.ObjectInstance; ! import org.jrman.attributes.Orientation; ! import org.jrman.attributes.ShadingInterpolation; ! import org.jrman.attributes.TrimCurveSense; ! import org.jrman.geom.AffineTransform; ! import org.jrman.geom.Bounds2f; ! import org.jrman.geom.Bounds3f; ! import org.jrman.geom.PerspectiveTransform; ! import org.jrman.geom.Transform; ! import org.jrman.options.CameraProjection; ! import org.jrman.options.Display; ! import org.jrman.options.Exposure; ! import org.jrman.options.Filter; ! import org.jrman.options.Hider; ! import org.jrman.options.Options; ! import org.jrman.options.Quantizer; import org.jrman.parser.keywords.KeywordParser; + import org.jrman.primitive.Sphere; import org.jrman.shaders.Imager; import org.jrman.shaders.LightShader; *************** *** 458,462 **** saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! scene.setTransform("raster", options.getRasterTransform()); // from "screen" to "raster" scene.setTransform("NDC", options.getNDCTransform()); // from "raster" to "NDC" } --- 478,483 ---- saveCurrentTransformAs("screen"); // from "camera" to "screen" setIdentity(); ! scene.setTransform("raster", options.getRasterTransform()); ! // from "screen" to "raster" scene.setTransform("NDC", options.getNDCTransform()); // from "raster" to "NDC" } *************** *** 559,579 **** public void setSurface(String name, Map parameters) { ! currentAttributes.setSurface(SurfaceShader.createShader(name, parameters)); } public void setAtmosphere(String name, Map parameters) { ! currentAttributes.setAtmosphere(VolumeShader.createShader(name, parameters)); } public void setExterior(String name, Map parameters) { ! currentAttributes.setExterior(VolumeShader.createShader(name, parameters)); } public void setImager(String name, Map parameters) { ! options.setImager(Imager.createImager(name, parameters)); } public void setInterior(String name, Map parameters) { ! currentAttributes.setInterior(VolumeShader.createShader(name, parameters)); } --- 580,600 ---- public void setSurface(String name, Map parameters) { ! currentAttributes.setSurface(SurfaceShader.createShader(name, parameters)); } public void setAtmosphere(String name, Map parameters) { ! currentAttributes.setAtmosphere(VolumeShader.createShader(name, parameters)); } public void setExterior(String name, Map parameters) { ! currentAttributes.setExterior(VolumeShader.createShader(name, parameters)); } public void setImager(String name, Map parameters) { ! options.setImager(Imager.createImager(name, parameters)); } public void setInterior(String name, Map parameters) { ! currentAttributes.setInterior(VolumeShader.createShader(name, parameters)); } *************** *** 585,597 **** private void turnOnLight(LightShader light) { ! Set lightSources = new HashSet(currentAttributes.getLightSources()); lightSources.add(light); ! currentAttributes.setLightSources(lightSources); } private void turnOffLight(LightShader light) { ! Set lightSources = new HashSet(currentAttributes.getLightSources()); lightSources.remove(light); ! currentAttributes.setLightSources(lightSources); } --- 606,618 ---- private void turnOnLight(LightShader light) { ! Set lightSources = new HashSet(currentAttributes.getLightSources()); lightSources.add(light); ! currentAttributes.setLightSources(lightSources); } private void turnOffLight(LightShader light) { ! Set lightSources = new HashSet(currentAttributes.getLightSources()); lightSources.remove(light); ! currentAttributes.setLightSources(lightSources); } *************** *** 601,610 **** turnOnLight(light); else ! turnOffLight(light); } public void createAreaLightSource(String name, int sequenceNumber, Map parameters) { createLightSource(name, sequenceNumber, parameters); ! inAreaLightSource = true; } --- 622,658 ---- turnOnLight(light); else ! turnOffLight(light); } public void createAreaLightSource(String name, int sequenceNumber, Map parameters) { createLightSource(name, sequenceNumber, parameters); ! inAreaLightSource = true; ! } ! ! public void addSphere( ! float radius, ! float zMin, ! float zMax, ! float thetaMax, ! Map parameters) { ! if (inAreaLightSource) ! return; ! float phiMin = (float) ((zMin <= -radius) ? -Math.PI : Math.asin(zMin / radius)); ! float phiMax = (float) ((zMax >= radius) ? Math.PI : Math.asin(zMax / radius)); ! float thetaMin = 0f; ! thetaMax = toRadians(thetaMax); ! scene.addPrimitive( ! new Sphere( ! radius, ! phiMin, ! phiMax, ! thetaMin, ! thetaMax, ! parameters, ! getAttributes())); ! } ! ! private float toRadians(float angle) { ! return (float) (angle * Math.PI / 180.0); } |
From: <ma...@us...> - 2003-04-12 07:06:37
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1:/tmp/cvs-serv19389/src/org/jrman/parser/keywords Modified Files: KeywordSphere.java Log Message: Implemented parsing for sphere. Index: KeywordSphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordSphere.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordSphere.java 7 Apr 2003 08:24:25 -0000 1.2 --- KeywordSphere.java 12 Apr 2003 07:06:35 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 32,53 **** else st.pushBack(); - // Expect radius match(st, TK_NUMBER); ! // Expect z min match(st, TK_NUMBER); ! // Expect z max match(st, TK_NUMBER); ! // Expect theta max match(st, TK_NUMBER); ! if (array) match(st, TK_RBRACE); - // Expect parameter list ! parseParameterList(st); } --- 34,54 ---- else st.pushBack(); // Expect radius match(st, TK_NUMBER); ! float radius = (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; // Expect theta max match(st, TK_NUMBER); ! float thetaMax = (float) st.nval; if (array) match(st, TK_RBRACE); // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.addSphere(radius, zMin, zMax, thetaMax, parameters); } |
From: <ma...@us...> - 2003-04-12 07:06:37
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv19389/src/org/jrman/primitive Added Files: Primitive.java Sphere.java Log Message: Implemented parsing for sphere. --- NEW FILE: Primitive.java --- /* Primitive.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.primitive; import java.util.Map; import org.jrman.attributes.Attributes; public class Primitive { protected Map parameters; protected Attributes attributes; protected Primitive(Map parameters, Attributes attributes) { this.parameters = parameters; this.attributes = attributes; } } --- NEW FILE: Sphere.java --- /* Sphere.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.primitive; import java.util.Map; import org.jrman.attributes.Attributes; public class Sphere extends Primitive { private float radius; private float phiMin; private float phiMax; private float thetaMin; private float thetaMax; public Sphere( float radius, float phiMin, float phiMax, float thetaMin, float thetaMax, Map parameters, Attributes attributes) { super(parameters, attributes); this.radius = radius; this.phiMin = phiMin; this.phiMax = phiMax; this.thetaMin = thetaMin; this.thetaMax = thetaMax; } } |
From: <ma...@us...> - 2003-04-12 07:06:24
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv19332/src/org/jrman/primitive Log Message: Directory /cvsroot/jrman/drafts/src/org/jrman/primitive added to the repository |
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv5809/src/org/jrman/shaders Modified Files: SurfaceShader.java DisplacementShader.java Imager.java VolumeShader.java Added Files: LightShader.java Log Message: Implemented parsers for all shaders and Illuminate. --- NEW FILE: LightShader.java --- /* LightShader.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.shaders; import java.util.Map; public class LightShader { protected String name; protected Map parameters; public static LightShader createShader(String name, Map parameters) { return new LightShader(name, parameters); // Just for now... } protected LightShader(String name, Map parameters) { this.name = name; this.parameters = parameters; } } Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SurfaceShader.java 9 Apr 2003 05:04:59 -0000 1.1 --- SurfaceShader.java 12 Apr 2003 06:10:31 -0000 1.2 *************** *** 20,24 **** package org.jrman.shaders; ! public interface SurfaceShader { } --- 20,39 ---- package org.jrman.shaders; ! import java.util.Map; ! ! public class SurfaceShader { ! ! protected Map parameters; ! ! protected String name; ! ! public static SurfaceShader createShader(String name, Map parameters) { ! return new SurfaceShader(name, parameters); // Just for now... ! } ! ! protected SurfaceShader(String name, Map parameters) { ! this.name = name; ! this.parameters = parameters; ! } } Index: DisplacementShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/DisplacementShader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DisplacementShader.java 9 Apr 2003 05:04:59 -0000 1.1 --- DisplacementShader.java 12 Apr 2003 06:10:31 -0000 1.2 *************** *** 20,24 **** package org.jrman.shaders; ! public interface DisplacementShader { } --- 20,39 ---- package org.jrman.shaders; ! import java.util.Map; ! ! public class DisplacementShader { ! ! protected String name; ! ! protected Map parameters; ! ! public static DisplacementShader createShader(String name, Map parameters) { ! return new DisplacementShader(name, parameters); // Just for now... ! } ! ! protected DisplacementShader(String name, Map parameters) { ! this.name = name; ! this.parameters = parameters; ! } } Index: Imager.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/Imager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Imager.java 11 Apr 2003 22:23:12 -0000 1.1 --- Imager.java 12 Apr 2003 06:10:31 -0000 1.2 *************** *** 20,24 **** package org.jrman.shaders; ! public interface Imager { } --- 20,39 ---- package org.jrman.shaders; ! import java.util.Map; ! ! public class Imager { ! ! protected String name; ! ! protected Map parameters; ! ! public static Imager createImager(String name, Map parameters) { ! return new Imager(name, parameters); // Just for now... ! } ! ! protected Imager(String name, Map parameters) { ! this.name = name; ! this.parameters = parameters; ! } } Index: VolumeShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/VolumeShader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VolumeShader.java 9 Apr 2003 05:04:59 -0000 1.1 --- VolumeShader.java 12 Apr 2003 06:10:31 -0000 1.2 *************** *** 20,24 **** package org.jrman.shaders; ! public interface VolumeShader { } --- 20,39 ---- package org.jrman.shaders; ! import java.util.Map; ! ! public class VolumeShader { ! ! protected String name; ! ! protected Map parameters; ! ! public static VolumeShader createShader(String name, Map parameters) { ! return new VolumeShader(name, parameters); // Just for now.... ! } ! ! protected VolumeShader(String name, Map parameters) { ! this.name = name; ! this.parameters = parameters; ! } } |
From: <ma...@us...> - 2003-04-12 06:10:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1:/tmp/cvs-serv5809/src/org/jrman/attributes Modified Files: MutableAttributes.java Log Message: Implemented parsers for all shaders and Illuminate. Index: MutableAttributes.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/attributes/MutableAttributes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MutableAttributes.java 9 Apr 2003 05:04:57 -0000 1.1 --- MutableAttributes.java 12 Apr 2003 06:10:30 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- import java.util.Collections; + import java.util.HashMap; import java.util.HashSet; import java.util.Set; *************** *** 38,42 **** textureCoordinates = new TextureCoordinates(0f, 0f, 1f, 0f, 0f, 1f, 1f, 1f); lightSources = Collections.EMPTY_SET; ! surface = null; // new SurfaceShaderConstant(); displacement = null; atmosphere = null; --- 39,43 ---- textureCoordinates = new TextureCoordinates(0f, 0f, 1f, 0f, 0f, 1f, 1f, 1f); lightSources = Collections.EMPTY_SET; ! surface = SurfaceShader.createShader("constant", new HashMap()); displacement = null; atmosphere = null; |
From: <ma...@us...> - 2003-04-12 06:10:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv5809/src/org/jrman/parser Modified Files: Scene.java Parser.java Log Message: Implemented parsers for all shaders and Illuminate. Index: Scene.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Scene.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Scene.java 11 Apr 2003 22:23:08 -0000 1.9 --- Scene.java 12 Apr 2003 06:10:29 -0000 1.10 *************** *** 25,28 **** --- 25,29 ---- import org.jrman.attributes.*; import org.jrman.geom.*; + import org.jrman.shaders.LightShader; public class Scene { *************** *** 32,35 **** --- 33,38 ---- private Map declarations = new HashMap(); + private Map lights = new HashMap(); + public Scene() { declarations.put("fov", new Declaration("fov", "float")); *************** *** 88,91 **** --- 91,105 ---- public Declaration getDeclaration(String name) { return (Declaration) declarations.get(name); + } + + public void addLight(int sequenceNumber, LightShader light) { + lights.put(new Integer(sequenceNumber), light); + } + + public LightShader getLight(int sequenceNumber) { + LightShader light = (LightShader) lights.get(new Integer(sequenceNumber)); + if (light == null) + throw new IllegalArgumentException("no such light: " + sequenceNumber); + return light; } Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Parser.java 12 Apr 2003 01:57:28 -0000 1.19 --- Parser.java 12 Apr 2003 06:10:30 -0000 1.20 *************** *** 24,29 **** --- 24,31 ---- import java.io.StreamTokenizer; import java.util.HashMap; + import java.util.HashSet; import java.util.List; import java.util.Map; + import java.util.Set; import java.util.Stack; *************** *** 38,45 **** --- 40,53 ---- import org.jrman.options.*; import org.jrman.parser.keywords.KeywordParser; + import org.jrman.shaders.Imager; + import org.jrman.shaders.LightShader; + import org.jrman.shaders.SurfaceShader; + import org.jrman.shaders.VolumeShader; import org.jrman.util.Constants; public class Parser { + private boolean inAreaLightSource; + private String renderer; *************** *** 186,189 **** --- 194,198 ---- popAttributes(); popState(); + inAreaLightSource = false; } *************** *** 547,550 **** --- 556,610 ---- currentAttributes.setTrimCurveSense(TrimCurveSense.getNamed(sense[0][0])); } + } + + public void setSurface(String name, Map parameters) { + currentAttributes.setSurface(SurfaceShader.createShader(name, parameters)); + } + + public void setAtmosphere(String name, Map parameters) { + currentAttributes.setAtmosphere(VolumeShader.createShader(name, parameters)); + } + + public void setExterior(String name, Map parameters) { + currentAttributes.setExterior(VolumeShader.createShader(name, parameters)); + } + + public void setImager(String name, Map parameters) { + options.setImager(Imager.createImager(name, parameters)); + } + + public void setInterior(String name, Map parameters) { + currentAttributes.setInterior(VolumeShader.createShader(name, parameters)); + } + + public void createLightSource(String name, int sequenceNumber, Map parameters) { + LightShader light = LightShader.createShader(name, parameters); + scene.addLight(sequenceNumber, light); + turnOnLight(light); + } + + private void turnOnLight(LightShader light) { + Set lightSources = new HashSet(currentAttributes.getLightSources()); + lightSources.add(light); + currentAttributes.setLightSources(lightSources); + } + + private void turnOffLight(LightShader light) { + Set lightSources = new HashSet(currentAttributes.getLightSources()); + lightSources.remove(light); + currentAttributes.setLightSources(lightSources); + } + + public void illuminate(int sequenceNumber, int onOff) { + LightShader light = scene.getLight(sequenceNumber); + if (onOff != 0) + turnOnLight(light); + else + turnOffLight(light); + } + + public void createAreaLightSource(String name, int sequenceNumber, Map parameters) { + createLightSource(name, sequenceNumber, parameters); + inAreaLightSource = true; } |
From: <ma...@us...> - 2003-04-12 06:10:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1:/tmp/cvs-serv5809/src/org/jrman/parser/keywords Modified Files: KeywordInterior.java KeywordExterior.java KeywordAreaLightSource.java KeywordLightSource.java KeywordSurface.java KeywordAtmosphere.java KeywordImager.java KeywordIlluminate.java Log Message: Implemented parsers for all shaders and Illuminate. Index: KeywordInterior.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordInterior.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordInterior.java 7 Apr 2003 08:24:31 -0000 1.2 --- KeywordInterior.java 12 Apr 2003 06:10:28 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,33 **** // Expect shader name match(st, TK_STRING); ! // Expect parameter list ! parseParameterList(st); } --- 29,36 ---- // Expect shader name match(st, TK_STRING); ! String name = st.sval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.setInterior(name, parameters); } Index: KeywordExterior.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordExterior.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordExterior.java 7 Apr 2003 08:24:22 -0000 1.2 --- KeywordExterior.java 12 Apr 2003 06:10:28 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,33 **** // Expect shader name match(st, TK_STRING); ! // Expect parameter list ! parseParameterList(st); } --- 29,36 ---- // Expect shader name match(st, TK_STRING); ! String name = st.sval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.setExterior(name, parameters); } Index: KeywordAreaLightSource.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordAreaLightSource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeywordAreaLightSource.java 11 Apr 2003 22:50:10 -0000 1.3 --- KeywordAreaLightSource.java 12 Apr 2003 06:10:29 -0000 1.4 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,36 **** // Expect name match(st, TK_STRING); ! // Expect sequence number match(st, TK_NUMBER); ! // Expect parameter list ! parseParameterList(st); } --- 29,39 ---- // Expect name match(st, TK_STRING); ! String name = st.sval; // Expect sequence number match(st, TK_NUMBER); ! int sequenceNumber = (int) st.nval; // Expect parameter list ! Map parameters =parseParameterList(st); ! parser.createAreaLightSource(name, sequenceNumber, parameters); } Index: KeywordLightSource.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordLightSource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordLightSource.java 7 Apr 2003 08:24:20 -0000 1.2 --- KeywordLightSource.java 12 Apr 2003 06:10:29 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,36 **** // Expect name match(st, TK_STRING); ! // Expect sequence number match(st, TK_NUMBER); ! // Expect parameter list ! parseParameterList(st); } --- 29,39 ---- // Expect name match(st, TK_STRING); ! String name = st.sval; // Expect sequence number match(st, TK_NUMBER); ! int sequenceNumber = (int) st.nval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.createLightSource(name, sequenceNumber, parameters); } Index: KeywordSurface.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordSurface.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordSurface.java 7 Apr 2003 08:24:31 -0000 1.2 --- KeywordSurface.java 12 Apr 2003 06:10:29 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,33 **** // Expect shader name match(st, TK_STRING); ! // Expect parameter list ! parseParameterList(st); } --- 29,36 ---- // Expect shader name match(st, TK_STRING); ! String name = st.sval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.setSurface(name, parameters); } Index: KeywordAtmosphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordAtmosphere.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordAtmosphere.java 7 Apr 2003 08:24:25 -0000 1.2 --- KeywordAtmosphere.java 12 Apr 2003 06:10:29 -0000 1.3 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,33 **** // Expect shader name match(st, TK_STRING); ! // Expect parameter list ! parseParameterList(st); } --- 29,36 ---- // Expect shader name match(st, TK_STRING); ! String name = st.sval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.setAtmosphere(name, parameters); } Index: KeywordImager.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordImager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeywordImager.java 11 Apr 2003 22:23:11 -0000 1.3 --- KeywordImager.java 12 Apr 2003 06:10:29 -0000 1.4 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.parser.keywords; + import java.util.Map; + import org.jrman.parser.Tokenizer; *************** *** 27,33 **** // Expect name match(st, TK_STRING); ! // Expect parameter list ! parseParameterList(st); } --- 29,36 ---- // Expect name match(st, TK_STRING); ! String name = st.sval; // Expect parameter list ! Map parameters = parseParameterList(st); ! parser.setImager(name, parameters); } Index: KeywordIlluminate.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordIlluminate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordIlluminate.java 7 Apr 2003 08:24:28 -0000 1.2 --- KeywordIlluminate.java 12 Apr 2003 06:10:29 -0000 1.3 *************** *** 27,33 **** // Expect sequence number match(st, TK_NUMBER); ! // Expect on/off match(st, TK_NUMBER); } --- 27,35 ---- // Expect sequence number match(st, TK_NUMBER); ! int sequenceNumber = (int) st.nval; // Expect on/off match(st, TK_NUMBER); + int onOff = (int) st.nval; + parser.illuminate(sequenceNumber, onOff); } |