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-05-04 02:34:40
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv32242/src/org/jrman/parser Modified Files: Frame.java Log Message: Fixed FOV bug. Changed sphere.rib to get objects away from projection plane. Index: Frame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Frame.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Frame.java 2 May 2003 02:07:23 -0000 1.4 --- Frame.java 4 May 2003 02:34:36 -0000 1.5 *************** *** 426,430 **** public void setFieldOfView(float f) { fieldOfView = f; - screenWindow = null; } --- 426,429 ---- |
From: <ma...@us...> - 2003-05-03 18:02:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/parser Modified Files: Parser.java Log Message: Fixed many bugs. Can render simple images. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Parser.java 2 May 2003 02:07:23 -0000 1.32 --- Parser.java 3 May 2003 18:02:49 -0000 1.33 *************** *** 237,241 **** public void rotate(float angle, float dx, float dy, float dz) { ! AxisAngle4f axisAngle = new AxisAngle4f(dx, dy, dz, angle); Matrix4f rotation = new Matrix4f(); rotation.set(axisAngle); --- 237,241 ---- public void rotate(float angle, float dx, float dy, float dz) { ! AxisAngle4f axisAngle = new AxisAngle4f(dx, dy, dz, (float) Math.toRadians(angle)); Matrix4f rotation = new Matrix4f(); rotation.set(axisAngle); *************** *** 661,664 **** --- 661,668 ---- parameters, getAttributes())); + } + + public void setShadingRate(float size) { + currentAttributes.setShadingRate(size); } |
From: <ma...@us...> - 2003-05-03 18:02:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/grid In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/grid Modified Files: FloatGrid.java Vector3fGrid.java Log Message: Fixed many bugs. Can render simple images. Index: FloatGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/FloatGrid.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FloatGrid.java 2 May 2003 02:07:22 -0000 1.5 --- FloatGrid.java 3 May 2003 18:02:49 -0000 1.6 *************** *** 1069,1072 **** --- 1069,1104 ---- /* + * dot + */ + + public void dot(Vector3fGrid p1, Vector3f p2) { + Vector3f[] p1data = (Vector3f[]) p1.data; + for (int i = 0; i < data.length; i++) + data[i] = p1data[i].dot(p2); + } + + public void dot(Vector3fGrid p1, Vector3f p2, BooleanGrid cond) { + Vector3f[] p1data = (Vector3f[]) p1.data; + for (int i = 0; i < data.length; i++) + if (cond.data[i]) + data[i] = p1data[i].dot(p2); + } + + public void dot(Vector3fGrid p1, Vector3fGrid p2) { + Vector3f[] p1data = (Vector3f[]) p1.data; + Vector3f[] p2data = (Vector3f[]) p2.data; + for (int i = 0; i < data.length; i++) + data[i] = p1data[i].dot(p2data[i]); + } + + public void dot(Vector3fGrid p1, Vector3fGrid p2, BooleanGrid cond) { + Vector3f[] p1data = (Vector3f[]) p1.data; + Vector3f[] p2data = (Vector3f[]) p2.data; + for (int i = 0; i < data.length; i++) + if (cond.data[i]) + data[i] = p1data[i].dot(p2data[i]); + } + + /* * ptlined */ Index: Vector3fGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/Vector3fGrid.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Vector3fGrid.java 21 Apr 2003 00:09:34 -0000 1.2 --- Vector3fGrid.java 3 May 2003 18:02:49 -0000 1.3 *************** *** 50,54 **** tdata[i].normalize(vdata[i]); } ! /* * vtransform --- 50,54 ---- tdata[i].normalize(vdata[i]); } ! /* * vtransform *************** *** 87,90 **** --- 87,107 ---- if (cond.data[i]) transform.transformNormal(ndata[i], tdata[i]); + } + + /* + * faceforward + */ + + public void faceforward(Vector3fGrid v, Vector3fGrid eye) { + Vector3f[] tdata = (Vector3f[]) data; + Vector3f[] vdata = (Vector3f[]) v.data; + Vector3f[] edata = (Vector3f[]) eye.data; + for (int i = 0; i < tdata.length; i++) { + float d = vdata[i].dot(edata[i]); + if (d < 0) + tdata[i].set(v.data[i]); + else + tdata[i].negate(v.data[i]); + } } |
From: <ma...@us...> - 2003-05-03 18:02:53
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1:/tmp/cvs-serv7988/sampleData Modified Files: sphere.rib Log Message: Fixed many bugs. Can render simple images. Index: sphere.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/sphere.rib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sphere.rib 2 May 2003 05:02:08 -0000 1.2 --- sphere.rib 3 May 2003 18:02:49 -0000 1.3 *************** *** 1,6 **** ! Clipping 1 1000 ! Projection "perspective" Translate 0 0 10 WorldBegin ! Sphere 5 -5 5 360 WorldEnd --- 1,73 ---- ! Format 1200 900 1 ! PixelSamples 4 4 ! Exposure 1 2.5 ! Clipping 1 15 ! Projection "perspective" "fov" 45 ! #ScreenWindow -8 8 -6 6 ! #Projection "orthographic" ! Surface "fakedlight" Translate 0 0 10 WorldBegin ! ShadingRate 1 ! AttributeBegin ! Translate -1.2 0 0 ! Rotate 45 1 1 0 ! Opacity .5 .5 .5 ! Sphere 1 -1 1 360 "Cs" [1 0 0 0 1 0 0 0 1 1 1 0] ! AttributeEnd ! TransformBegin ! Translate 1.2 0 0 ! Rotate 45 1 1 1 ! Sphere 1 -1 1 360 "Cs" [1 0 0 0 1 0 0 0 1 1 1 0] ! TransformEnd ! TransformBegin ! Translate 1.2 3 0 ! Rotate 45 1 0 1 ! Sphere 1 -1 1 360 "Cs" [1 0 0 0 1 0 0 0 1 1 1 0] ! TransformEnd ! TransformBegin ! Translate 1.2 -3 0 ! Rotate 45 1 1 0 ! Sphere 1 -1 1 360 "Cs" [1 0 0 0 1 0 0 0 1 1 1 0] ! TransformEnd ! TransformBegin ! Translate -1.2 3 0 ! Rotate 45 0 1 1 ! Sphere 1 -1 1 360 "Cs" [1 0 0 0 1 0 0 0 1 1 1 0] ! TransformEnd ! TransformBegin ! Translate -1.2 -3 0 ! Rotate 45 1 1 1 ! Sphere 1 -1 1 360 ! TransformEnd ! TransformBegin ! Color 1 1 0 ! Translate 0 0 2 ! Rotate 30 0 1 0 ! Sphere 2 -1 1 360 ! TransformEnd ! TransformBegin ! Translate -3.4 -3 0 ! Color 1 0 0 ! Rotate 45 1 0 0 ! Sphere 1 -1 1 360 ! TransformEnd ! TransformBegin ! Color 0 1 0 ! Translate -3.4 3 0 ! Rotate 45 0 1 0 ! Sphere 1 -1 1 360 ! TransformEnd ! TransformBegin ! Color 0 0 1 ! Translate 3.4 -3 0 ! Rotate 45 1 0 0 ! Sphere 1 -1 1 360 ! TransformEnd ! TransformBegin ! Color 1 0 1 ! Translate 3.4 3 0 ! Rotate 45 1 0 0 ! Sphere 1 -1 1 360 ! TransformEnd WorldEnd |
From: <ma...@us...> - 2003-05-03 18:02:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/shaders Modified Files: SurfaceShader.java Added Files: FakedLightShader.java Log Message: Fixed many bugs. Can render simple images. --- NEW FILE: FakedLightShader.java --- /* FakedLightShader.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; import javax.vecmath.Vector3f; import org.jrman.grid.FloatGrid; import org.jrman.grid.Vector3fGrid; import org.jrman.render.ShaderVariables; public class FakedLightShader extends SurfaceShader { private Vector3fGrid tmpN; private FloatGrid light; public FakedLightShader(String name, Map parameters) { super(name, parameters); } public void shade(ShaderVariables sv) { if (tmpN == null) tmpN = new Vector3fGrid(); if (light == null) light = new FloatGrid(); tmpN.faceforward(sv.N, sv.I); tmpN.normalize(tmpN); light.dot(tmpN, new Vector3f(1f, 1f, -1f)); light.max(light, 0f); light.mul(light, .7f); light.add(light, .2f); light.clamp(light, 0f, 1f); sv.Oi.set(sv.Os); sv.Ci.mul(sv.Os, sv.Cs); tmpN.setxcomp(light); tmpN.setycomp(light); tmpN.setzcomp(light); sv.Ci.mul(sv.Ci, tmpN); } } Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SurfaceShader.java 2 May 2003 05:02:07 -0000 1.4 --- SurfaceShader.java 3 May 2003 18:02:49 -0000 1.5 *************** *** 31,35 **** public static SurfaceShader createShader(String name, Map parameters) { ! return new ConstantShader(name, parameters); // Just for now... } --- 31,37 ---- public static SurfaceShader createShader(String name, Map parameters) { ! if (name.equals("constant")) ! return new ConstantShader(name, parameters); // Just for now... ! return new FakedLightShader(name, parameters); } |
From: <ma...@us...> - 2003-05-03 18:02:53
|
Update of /cvsroot/jrman/drafts/src/org/jrman/options In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/options Modified Files: Quantizer.java Exposure.java Log Message: Fixed many bugs. Can render simple images. Index: Quantizer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/options/Quantizer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Quantizer.java 9 Apr 2003 05:04:58 -0000 1.1 --- Quantizer.java 3 May 2003 18:02:48 -0000 1.2 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.options; + import org.jrman.util.Calc; + public class Quantizer { *************** *** 52,55 **** return one; } ! } --- 54,62 ---- return one; } ! ! public int quantize(float value) { ! int v = (int) Math.round(one * value + ditherAmplitude * Math.random()); ! return Calc.clamp(v, min, max); ! } ! } Index: Exposure.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/options/Exposure.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Exposure.java 9 Apr 2003 05:04:58 -0000 1.1 --- Exposure.java 3 May 2003 18:02:48 -0000 1.2 *************** *** 20,23 **** --- 20,25 ---- package org.jrman.options; + import javax.vecmath.Color3f; + public class Exposure { *************** *** 25,32 **** --- 27,37 ---- private float gamma; + + private float oneOverGamma; public Exposure(float gain, float gamma) { this.gain = gain; this.gamma = gamma; + oneOverGamma = 1f / gamma; } *************** *** 37,40 **** --- 42,52 ---- public float getGamma() { return gamma; + } + + public void expose(Color3f color, Color3f out) { + out.scale(gain, color); + out.x = (float) Math.pow(out.x, oneOverGamma); + out.y = (float) Math.pow(out.y, oneOverGamma); + out.z = (float) Math.pow(out.z, oneOverGamma); } |
From: <ma...@us...> - 2003-05-03 18:02:52
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/util Modified Files: Calc.java Log Message: Fixed many bugs. Can render simple images. Index: Calc.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/util/Calc.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Calc.java 2 May 2003 02:07:23 -0000 1.6 --- Calc.java 3 May 2003 18:02:48 -0000 1.7 *************** *** 24,27 **** --- 24,28 ---- import javax.vecmath.Point3f; import javax.vecmath.Point4f; + import javax.vecmath.Tuple2f; import javax.vecmath.Vector3f; *************** *** 76,79 **** --- 77,84 ---- Point3f tmp = new Point3f(); return depth(p, toCamera, near, far, tmp); + } + + public static void perp(Tuple2f t, Tuple2f out) { + out.set(-t.y, t.x); } |
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/render Modified Files: RendererHidden.java Micropolygon.java Added Files: Sampler.java SamplePoint.java Sample.java RenderCanvas.java Log Message: Fixed many bugs. Can render simple images. --- NEW FILE: Sampler.java --- /* Sampler.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.render; import javax.vecmath.Color3f; import javax.vecmath.Point2f; import org.jrman.geom.Bounds2f; import org.jrman.util.Calc; public class Sampler { Point2f min; private int width; private int height; private float sampleWidth; private float sampleHeight; private SamplePoint[] samplePoints; public Sampler( float samplerX, float samplerY, int bucketWidth, int bucketHeight, float hSamples, float vSamples) { min = new Point2f(samplerX, samplerY); width = (int) Math.ceil(bucketWidth * hSamples); height = (int) Math.ceil(bucketHeight * vSamples); sampleWidth = 1f / hSamples; sampleHeight = 1f / hSamples; samplePoints = new SamplePoint[width * height]; float y = min.y + sampleHeight * .5f; for (int row = 0; row < height; row++) { float x = min.x + sampleWidth * .5f; for (int column = 0; column < width; column++) { samplePoints[row * width + column] = new SamplePoint(x, y); x += sampleWidth; } y += sampleHeight; } } public void sampleBucket(Bucket bucket) { while (bucket.hasMoreMicropolygons()) { Micropolygon mp = bucket.getNextMicropolygon(); sampleMicropolygon(mp); } } public Color3f[] getColors() { Color3f[] result = new Color3f[samplePoints.length]; for (int i = 0; i < samplePoints.length; i++) result[i] = samplePoints[i].getColor(); return result; } private void sampleMicropolygon(Micropolygon mp) { Bounds2f b = mp.getBounds(); Point2f mpMin = b.getMin(); mpMin.sub(min); Point2f mpMax = b.getMax(); mpMax.sub(min); int minColumn = Calc.clamp((int) (mpMin.x / sampleWidth), 0, width - 1); int minRow = Calc.clamp((int) (mpMin.y / sampleHeight), 0, height - 1); int maxColumn = Calc.clamp((int) (mpMax.x / sampleWidth), 0, width - 1); int maxRow = Calc.clamp((int) (mpMax.y / sampleHeight), 0, height - 1); for (int col = minColumn; col <= maxColumn; col++) for (int row = minRow; row <= maxRow; row++) getSamplePoint(col, row).sampleMicropolygon(mp); } private SamplePoint getSamplePoint(int column, int row) { return samplePoints[row * width + column]; } } --- NEW FILE: SamplePoint.java --- /* SamplePoints.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.render; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import javax.vecmath.Color3f; import javax.vecmath.Point2f; public class SamplePoint { private Point2f point; private List samples = new LinkedList(); public SamplePoint(float x, float y) { point = new Point2f(x, y); } public void sampleMicropolygon(Micropolygon mp) { Sample sample = mp.getSample(point); if (sample == null) return; ListIterator it = samples.listIterator(); while (it.hasNext()) { Sample s = (Sample) it.next(); if (s.behind(sample)) { it.previous(); it.add(sample); return; } } samples.add(sample); } public Color3f getColor() { ListIterator it = samples.listIterator(); while (it.hasNext()) { Sample sample = (Sample) it.next(); if (sample.isOpaque()) break; } Color3f result = new Color3f(); while (it.hasPrevious()) { Sample sample = (Sample) it.previous(); Color3f opacity = sample.getOpacity(); result.x *= (1f - opacity.x); result.y *= (1f - opacity.y); result.z *= (1f - opacity.z); Color3f color = sample.getColor(); result.add(color); } return result; } } --- NEW FILE: Sample.java --- /* Sample.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.render; import javax.vecmath.Color3f; public class Sample { private Color3f color; private Color3f opacity; private float z; public Sample(Color3f color, Color3f opacity, float z) { this.color = color; this.opacity = opacity; this.z = z; } public boolean behind(Sample sample) { return z > sample.z; } public boolean isOpaque() { return opacity.x == 1f && opacity.y == 1f && opacity.z == 1f; } public Color3f getColor() { return color; } public Color3f getOpacity() { return opacity; } } --- NEW FILE: RenderCanvas.java --- /* RenderCanvas.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.render; import java.awt.Canvas; import java.awt.Graphics; import java.awt.Image; import java.awt.image.MemoryImageSource; public class RenderCanvas extends Canvas { private int hSize; private int vSize; private int[] buffer; private MemoryImageSource mis; private Image image; public RenderCanvas(int hSize, int vSize) { this.hSize = hSize; this.vSize = vSize; setSize(hSize,vSize); buffer = new int[hSize* vSize]; mis = new MemoryImageSource(hSize, vSize, buffer, 0, hSize); mis.setAnimated(true); image = createImage(mis); } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(image, 0, 0, this); } public void setPixels(int[] pixels, int x, int y, int w, int h) { for (int row = 0; row < h; row++) { if (y + row < 0 || y + row >= vSize) continue; for (int col = 0; col < w; col++) { if (x + col < 0 || x + col >= hSize) continue; int pixel = pixels[row * w + col]; int offset = (y + row) * hSize + x + col; buffer[offset] = pixel; } } mis.newPixels(x, y, w, h); repaint(x, y, w, h); } } Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RendererHidden.java 2 May 2003 05:02:08 -0000 1.7 --- RendererHidden.java 3 May 2003 18:02:48 -0000 1.8 *************** *** 20,26 **** --- 20,32 ---- package org.jrman.render; + import java.awt.BorderLayout; + import java.awt.event.WindowAdapter; + import java.awt.event.WindowEvent; import java.util.Collection; import java.util.Iterator; + import javax.swing.JFrame; + import javax.swing.JScrollPane; + import javax.vecmath.Color3f; import javax.vecmath.Point2f; import javax.vecmath.Point3f; *************** *** 36,39 **** --- 42,46 ---- import org.jrman.grid.Grid; import org.jrman.options.Filter; + import org.jrman.options.Quantizer; import org.jrman.parser.Frame; import org.jrman.parser.Global; *************** *** 65,68 **** --- 72,90 ---- private int bucketHeight; + + public void init(Frame frame, World world) { + super.init(frame, world); + worldToCamera = Global.getTransform("camera"); + Transform cameraToScreen = Global.getTransform("screen"); + Transform screenToRaster = Global.getTransform("raster"); + cameraToRaster = screenToRaster.concat(cameraToScreen); + if (cameraToScreen instanceof PerspectiveTransform) + cameraToRaster = ((PerspectiveTransform) cameraToScreen).preConcat(screenToRaster); + else + cameraToRaster = screenToRaster.concat(cameraToScreen); + eyePlane = Plane.createWithPointAndNormal(new Point3f(), new Vector3f(0f, 0f, -1f)); + createClippingVolume(); + createBuckets(); + } public void addPrimitive(Primitive primitive) { *************** *** 97,103 **** private void placeInBucket(Primitive primitive, BoundingVolume bv) { ! Bounds2f bounds = bv.transform(cameraToRaster).getBoundingBox().toBounds2f(); primitive.setRasterBounds(bounds); Point2f min = bounds.getMin(); int column = Calc.clamp((int) (min.x / bucketWidth), 0, bucketColumns - 1); int row = Calc.clamp((int) (min.y / bucketHeight), 0, bucketRows - 1); --- 119,126 ---- private void placeInBucket(Primitive primitive, BoundingVolume bv) { ! Bounds2f bounds = bv.transform(cameraToRaster).toBounds2f(); primitive.setRasterBounds(bounds); Point2f min = bounds.getMin(); + min.sub(rasterWindow.getMin()); int column = Calc.clamp((int) (min.x / bucketWidth), 0, bucketColumns - 1); int row = Calc.clamp((int) (min.y / bucketHeight), 0, bucketRows - 1); *************** *** 106,113 **** private void addToBuckets(Micropolygon mp) { ! int minColumn = Calc.clamp((int) (mp.minX / bucketWidth), 0, bucketColumns - 1); ! int minRow = Calc.clamp((int) (mp.minY / bucketHeight), 0, bucketRows - 1); ! int maxColumn = Calc.clamp((int) (mp.maxX / bucketWidth), 0, bucketColumns - 1); ! int maxRow = Calc.clamp((int) (mp.maxY / bucketHeight), 0, bucketRows - 1); for (int col = minColumn; col <= maxColumn; col++) for (int row = minRow; row <= maxRow; row++) --- 129,142 ---- private void addToBuckets(Micropolygon mp) { ! Bounds2f b = mp.getBounds(); ! Point2f bmin = b.getMin(); ! Point2f rmin = rasterWindow.getMin(); ! bmin.sub(rmin); ! Point2f bmax = b.getMax(); ! bmax.sub(rmin); ! int minColumn = Calc.clamp((int) (bmin.x / bucketWidth), 0, bucketColumns - 1); ! int minRow = Calc.clamp((int) (bmin.y / bucketHeight), 0, bucketRows - 1); ! int maxColumn = Calc.clamp((int) (bmax.x / bucketWidth), 0, bucketColumns - 1); ! int maxRow = Calc.clamp((int) (bmax.y / bucketHeight), 0, bucketRows - 1); for (int col = minColumn; col <= maxColumn; col++) for (int row = minRow; row <= maxRow; row++) *************** *** 120,123 **** --- 149,163 ---- public void render() { + JFrame jf = new JFrame(); + RenderCanvas rc = + new RenderCanvas(frame.getHorizontalResolution(), frame.getVerticalResolution()); + jf.getContentPane().add(rc, BorderLayout.CENTER); + jf.pack(); + jf.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + jf.setVisible(true); int gridSize = frame.getGridSize(); int gridSide = (int) Math.round(Math.sqrt(gridSize)) + 1; *************** *** 150,155 **** --- 190,222 ---- } } + Point2f rmin = rasterWindow.getMin(); + float samplerX = rmin.x + bucketWidth * column; + float samplerY = rmin.y + bucketHeight * row; + Sampler sampler = + new Sampler( + samplerX, + samplerY, + bucketWidth, + bucketHeight, + frame.getHorizontalSamplingRate(), + frame.getVerticalSamplingRate()); + sampler.sampleBucket(bucket); bucket.flush(); + Color3f[] colors = sampler.getColors(); + int pixels[] = colorsToPixels(colors); + Point2f min = rasterWindow.getMin(); + rc.setPixels( + pixels, + column * bucketWidth + (int) min.x, + row * bucketHeight + (int) min.y, + bucketWidth, + bucketHeight); } + for (int i = 0; i < buckets.length; i++){ + if (buckets[i].hasMorePrimitives()) + System.out.println("More primitives: " + i); + if (buckets[i].hasMoreMicropolygons()) + System.out.println("More micropolygons: " + i); + } long end = System.currentTimeMillis(); float time = (end - start) / 1000f; *************** *** 164,178 **** } ! public void init(Frame frame, World world) { ! super.init(frame, world); ! worldToCamera = Global.getTransform("camera"); ! PerspectiveTransform cameraToScreen = ! (PerspectiveTransform) Global.getTransform("screen"); ! Transform screenToRaster = Global.getTransform("raster"); ! cameraToRaster = screenToRaster.concat(cameraToScreen); ! cameraToRaster = cameraToScreen.preConcat(screenToRaster); ! eyePlane = Plane.createWithPointAndNormal(new Point3f(), new Vector3f(0f, 0f, -1f)); ! createClippingVolume(); ! createBuckets(); } --- 231,257 ---- } ! private int[] colorsToPixels(Color3f[] colors) { ! int pw = (int) frame.getHorizontalSamplingRate(); ! int ph = (int) frame.getVerticalSamplingRate(); ! int[] result = new int[bucketWidth * bucketHeight]; ! Color3f tmp = new Color3f(); ! for (int row = 0; row < bucketHeight; row++) ! for (int col = 0; col < bucketWidth; col++) { ! tmp.set(0f, 0f, 0f); ! for (int r = 0; r < ph; r++) ! for (int c = 0; c < pw; c++) { ! int offset = (row * ph + r) * (bucketWidth * pw) + col * pw + c; ! tmp.add(colors[offset]); ! } ! tmp.scale(1f / (ph * pw)); ! frame.getExposure().expose(tmp, tmp); ! Quantizer qt = frame.getColorQuantizer(); ! int red = qt.quantize(tmp.x); ! int green = qt.quantize(tmp.y); ! int blue = qt.quantize(tmp.z); ! result[row * bucketWidth + col] = ! (255 << 24) | (red << 16) | (green << 8) | blue; ! } ! return result; } Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Micropolygon.java 2 May 2003 05:02:08 -0000 1.1 --- Micropolygon.java 3 May 2003 18:02:48 -0000 1.2 *************** *** 21,49 **** import javax.vecmath.Color3f; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; ! import org.jrman.util.Constants; public class Micropolygon { ! Point3f a; ! ! Point3f b; ! ! Point3f c; ! Color3f color; ! Color3f opacity; ! float minX = Constants.INFINITY; ! float minY = Constants.INFINITY; ! float maxX = -Constants.INFINITY; - float maxY = -Constants.INFINITY; - public Micropolygon(Point3f pa, Point3f pb, Point3f pc, Color3f color, Color3f opacity) { --- 21,47 ---- import javax.vecmath.Color3f; + import javax.vecmath.Point2f; import javax.vecmath.Point3f; + import javax.vecmath.Vector2f; import javax.vecmath.Vector3f; ! import org.jrman.geom.Bounds2f; ! import org.jrman.geom.MutableBounds2f; ! import org.jrman.util.Calc; public class Micropolygon { ! private Point3f a; ! private Point3f b; ! private Point3f c; ! private Color3f color; ! private Color3f opacity; ! private MutableBounds2f bounds; public Micropolygon(Point3f pa, Point3f pb, Point3f pc, Color3f color, Color3f opacity) { *************** *** 53,69 **** this.color = color; this.opacity = opacity; ! setMinMax(a); ! setMinMax(b); ! setMinMax(c); faceScreen(); } ! private void setMinMax(Point3f a) { ! minX = Math.min(minX, a.x); ! maxX = Math.max(maxX, a.x); ! minY = Math.min(minY, a.y); ! maxY = Math.max(maxY, a.y); } ! private void faceScreen() { Vector3f ab = new Vector3f(); --- 51,65 ---- this.color = color; this.opacity = opacity; ! setBounds(); faceScreen(); } ! private void setBounds() { ! bounds = new MutableBounds2f(); ! bounds.addPoint(a.x, a.y); ! bounds.addPoint(b.x, b.y); ! bounds.addPoint(c.x, c.y); } ! private void faceScreen() { Vector3f ab = new Vector3f(); *************** *** 78,81 **** --- 74,100 ---- c = tmp; } + } + + public Bounds2f getBounds() { + return bounds; + } + + public Sample getSample(Point2f point) { + Vector2f v1 = new Vector2f(b.x - a.x , b.y - a.y); + Calc.perp(v1, v1); + Vector2f v2 = new Vector2f(point.x - a.x, point.y - a.y); + if (v1.dot(v2) > 0f) + return null; + v1.set(c.x - b.x, c.y - b.y); + Calc.perp(v1, v1); + v2.set(point.x - b.x, point.y - b.y); + if (v1.dot(v2) > 0f) + return null; + v1.set(a.x - c.x, a.y - c.y); + Calc.perp(v1, v1); + v2.set(point.x - c.x, point.y - c.y); + if (v1.dot(v2) > 0f) + return null; + return new Sample(color, opacity, (a.z + b.z + c.z) / 3f); } |
From: <ma...@us...> - 2003-05-03 18:02:52
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/primitive Modified Files: Sphere.java Quadric.java Log Message: Fixed many bugs. Can render simple images. Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Sphere.java 2 May 2003 05:02:08 -0000 1.12 --- Sphere.java 3 May 2003 18:02:48 -0000 1.13 *************** *** 27,37 **** import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; ! import org.jrman.geom.ConvexHull3f; import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; import org.jrman.render.ShaderVariables; ! public class Sphere extends Quadric ! { private float radius; --- 27,36 ---- import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; ! import org.jrman.geom.Bounds3f; import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; import org.jrman.render.ShaderVariables; ! public class Sphere extends Quadric { private float radius; *************** *** 52,57 **** float thetaMax, Map parameters, ! Attributes attributes) ! { super(parameters, attributes); this.radius = radius; --- 51,55 ---- float thetaMax, Map parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; *************** *** 62,67 **** } ! public String toString() ! { StringBuffer sb = new StringBuffer(); sb.append("Sphere,"); --- 60,64 ---- } ! public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Sphere,"); *************** *** 72,106 **** } ! public BoundingVolume internalGetBoundingVolume() ! { float zMin = (float) Math.sin(phiMin) * radius; float zMax = (float) Math.sin(phiMax) * radius; ! float r = radius * 1.415f; ! if (phiMax < 0) ! r = (float) Math.cos(phiMax) * r; ! else if (phiMin > 0) ! r = (float) Math.cos(phiMin) * r; ! ConvexHull3f ch = new ConvexHull3f(); ! int sides = 4; ! float thetaDelta = thetaMax - thetaMin; ! if (thetaDelta < Math.PI / 4) ! sides = 1; ! else if (thetaDelta < Math.PI / 2) ! sides = 2; ! else if (thetaDelta < Math.PI * 3f / 4) ! sides = 3; ! float incr = thetaDelta / sides; ! for (float angle = thetaMin; angle <= thetaMax; angle += incr) ! { ! float x = (float) Math.cos(angle) * r; ! float y = (float) Math.sin(angle) * r; ! ch.addPoint(x, y, zMin); ! ch.addPoint(x, y, zMax); } ! return ch; } ! public Primitive[] split() ! { Primitive[] result = new Primitive[4]; result[0] = --- 69,124 ---- } ! public BoundingVolume internalGetBoundingVolume() { float zMin = (float) Math.sin(phiMin) * radius; float zMax = (float) Math.sin(phiMax) * radius; ! float rMin; ! float rMax; ! float cosPhiMaxR = (float) Math.cos(phiMax) * radius; ! float cosPhiMinR = (float) Math.cos(phiMin) * radius; ! if (phiMin < 0 && phiMax > 0) ! rMax = radius; ! else ! rMax = Math.max(cosPhiMaxR, cosPhiMinR); ! rMin = Math.min(cosPhiMaxR, cosPhiMinR); ! float cosThetaMin = (float) Math.cos(thetaMin); ! float sinThetaMin = (float) Math.sin(thetaMin); ! float cosThetaMax = (float) Math.cos(thetaMax); ! float sinThetaMax = (float) Math.sin(thetaMax); ! float xMin; ! float xMax = cosThetaMin * rMin; ! xMax = Math.max(xMax, cosThetaMin * rMax); ! xMax = Math.max(xMax, cosThetaMax * rMin); ! xMax = Math.max(xMax, cosThetaMax * rMax); ! float yMin; ! float yMax; ! if (thetaMin < Math.PI && thetaMax > Math.PI) ! xMin = -rMax; ! else { ! xMin = cosThetaMin * rMin; ! xMin = Math.min(xMin, cosThetaMin * rMax); ! xMin = Math.min(xMin, cosThetaMax * rMin); ! xMin = Math.min(xMin, cosThetaMax * rMax); } ! if (thetaMin < Math.PI / 2 && thetaMax > Math.PI / 2) ! yMax = rMax; ! else { ! yMax = sinThetaMin * rMin; ! yMax = Math.max(yMax, sinThetaMin * rMax); ! yMax = Math.max(yMax, sinThetaMax * rMin); ! yMax = Math.max(yMax, sinThetaMax * rMax); ! } ! if (thetaMin < Math.PI * 3 / 2 && thetaMax > Math.PI * 3 / 2) ! yMin = -rMax; ! else { ! yMin = sinThetaMin * rMin; ! yMin = Math.min(yMin, sinThetaMin * rMax); ! yMin = Math.min(yMin, sinThetaMax * rMin); ! yMin = Math.min(yMin, sinThetaMax * rMax); ! } ! Bounds3f result = new Bounds3f(xMin, xMax, yMin, yMax, zMin, zMax); ! return result; } ! public Primitive[] split() { Primitive[] result = new Primitive[4]; result[0] = *************** *** 148,152 **** float width = max.x - min.x; float height = max.y - min.y; ! boolean ready = width * height <= gridSize; return ready; } --- 166,170 ---- float width = max.x - min.x; float height = max.y - min.y; ! boolean ready = width * height <= gridSize * attributes.getShadingRate(); return ready; } *************** *** 155,162 **** int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / uSize; ! float phiDelta = (phiMax - phiMin) / vSize; Point3fGrid P = shaderVariables.P; ! Point3f tmp = new Point3f(); float theta = thetaMin; for (int u = 0; u < uSize; u++) { --- 173,184 ---- int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); ! if (thetaDelta <= 0) ! System.out.println("thetaDelta: " + thetaDelta); ! float phiDelta = (phiMax - phiMin) / (vSize - 1); ! if (phiDelta <= 0) ! System.out.println("phiDelta: " + phiDelta); Point3fGrid P = shaderVariables.P; ! Point3f tmp = new Point3f(); float theta = thetaMin; for (int u = 0; u < uSize; u++) { *************** *** 171,182 **** tmp.z = radius * sinPhi; P.set(u, v, tmp); ! phi += phiDelta; } theta += thetaDelta; } } protected void dice_Ng(ShaderVariables shaderVariables) { ! shaderVariables.Ng.set(shaderVariables.P); } --- 193,206 ---- tmp.z = radius * sinPhi; P.set(u, v, tmp); ! phi += phiDelta; ! phi = Math.min(phi, phiMax); } theta += thetaDelta; + theta = Math.min(theta, thetaMax); } } protected void dice_Ng(ShaderVariables shaderVariables) { ! shaderVariables.Ng.set(shaderVariables.P); } Index: Quadric.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Quadric.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Quadric.java 2 May 2003 05:02:08 -0000 1.5 --- Quadric.java 3 May 2003 18:02:48 -0000 1.6 *************** *** 149,159 **** int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / uSize; ! float vStep = 1f / vSize; float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); v += vStep; } --- 149,159 ---- int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / (uSize - 1); ! float vStep = 1f / (vSize - 1); float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv10, uv01, uv11, u, v)); v += vStep; } *************** *** 170,180 **** int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / uSize; ! float vStep = 1f / vSize; float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); v += vStep; } --- 170,180 ---- int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / (uSize - 1); ! float vStep = 1f / (vSize - 1); float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv10, uv01, uv11, u, v)); v += vStep; } *************** *** 191,201 **** int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / uSize; ! float vStep = 1f / vSize; float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); v += vStep; } --- 191,201 ---- int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / (uSize - 1); ! float vStep = 1f / (vSize - 1); float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv10, uv01, uv11, u, v)); v += vStep; } *************** *** 212,222 **** int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / uSize; ! float vStep = 1f / vSize; float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); v += vStep; } --- 212,222 ---- int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); ! float uStep = 1f / (uSize - 1); ! float vStep = 1f / (vSize - 1); float u = 0f; for (int iu = 0; iu < uSize; iu++) { float v = 0f; for (int iv = 0; iv < vSize; iv++) { ! g.set(iu, iv, Calc.interpolate(uv00, uv10, uv01, uv11, u, v)); v += vStep; } *************** *** 247,252 **** v[3] = new float[1]; v[0][0] = 0f; ! v[1][0] = 1f; ! v[2][0] = 0f; v[3][0] = 1f; parameters.put("v", new Parameter(V_DECL, v)); --- 247,252 ---- v[3] = new float[1]; v[0][0] = 0f; ! v[1][0] = 0f; ! v[2][0] = 1f; v[3][0] = 1f; parameters.put("v", new Parameter(V_DECL, v)); |
From: <ma...@us...> - 2003-05-03 18:02:52
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/geom Modified Files: BoundingVolume.java Bounds2f.java ConvexHull3f.java Bounds3f.java Log Message: Fixed many bugs. Can render simple images. Index: BoundingVolume.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/BoundingVolume.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoundingVolume.java 14 Apr 2003 04:41:25 -0000 1.1 --- BoundingVolume.java 3 May 2003 18:02:47 -0000 1.2 *************** *** 27,30 **** --- 27,32 ---- Bounds3f getBoundingBox(); + + Bounds2f toBounds2f(); } Index: Bounds2f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds2f.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bounds2f.java 15 Apr 2003 13:07:56 -0000 1.6 --- Bounds2f.java 3 May 2003 18:02:48 -0000 1.7 *************** *** 55,59 **** return true; } ! public Bounds2f transform(Transform transform) { MutableBounds2f mb = new MutableBounds2f(); --- 55,59 ---- return true; } ! public Bounds2f transform(Transform transform) { MutableBounds2f mb = new MutableBounds2f(); *************** *** 81,85 **** return new Point2f(min); } ! public String toString() { StringBuffer sb = new StringBuffer(); --- 81,85 ---- return new Point2f(min); } ! public String toString() { StringBuffer sb = new StringBuffer(); Index: ConvexHull3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/ConvexHull3f.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConvexHull3f.java 2 May 2003 02:07:23 -0000 1.6 --- ConvexHull3f.java 3 May 2003 18:02:48 -0000 1.7 *************** *** 80,83 **** --- 80,92 ---- return result; } + + public Bounds2f toBounds2f() { + MutableBounds2f result = new MutableBounds2f(); + for (Iterator iter = points.iterator(); iter.hasNext(); ) { + Point3f p = (Point3f) iter.next(); + result.addPoint(p.x, p.y); + } + return result; + } public String toString() { Index: Bounds3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds3f.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bounds3f.java 15 Apr 2003 13:07:56 -0000 1.6 --- Bounds3f.java 3 May 2003 18:02:48 -0000 1.7 *************** *** 79,82 **** --- 79,98 ---- } + public boolean contains(Point3f p) { + if (p.x < min.x) + return false; + if (p.x > max.x) + return false; + if (p.y < min.y) + return false; + if (p.y > max.y) + return false; + if (p.z < min.z) + return false; + if (p.z > max.z) + return false; + return true; + } + public Bounds3f transformToBounds3f(Transform transform) { MutableBounds3f mb = new MutableBounds3f(); *************** *** 218,222 **** public String toString() { StringBuffer sb = new StringBuffer(); ! sb.append("Bounds2f"); sb.append(", min: ").append(min); sb.append(", max: ").append(max); --- 234,238 ---- public String toString() { StringBuffer sb = new StringBuffer(); ! sb.append("Bounds3f"); sb.append(", min: ").append(min); sb.append(", max: ").append(max); |
From: <ma...@us...> - 2003-05-03 18:02:51
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1:/tmp/cvs-serv7988/src/org/jrman/parser/keywords Modified Files: KeywordRotate.java KeywordShadingRate.java Log Message: Fixed many bugs. Can render simple images. Index: KeywordRotate.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordRotate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordRotate.java 7 Apr 2003 08:24:22 -0000 1.2 --- KeywordRotate.java 3 May 2003 18:02:48 -0000 1.3 *************** *** 27,31 **** // Expect angle match(st, TK_NUMBER); ! float angle = (float) (st.nval * 180.0 / Math.PI); // Expect dx --- 27,31 ---- // Expect angle match(st, TK_NUMBER); ! float angle = (float) st.nval; // Expect dx Index: KeywordShadingRate.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordShadingRate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordShadingRate.java 7 Apr 2003 08:24:31 -0000 1.2 --- KeywordShadingRate.java 3 May 2003 18:02:48 -0000 1.3 *************** *** 27,31 **** // Expect size match(st, TK_NUMBER); ! } --- 27,32 ---- // Expect size match(st, TK_NUMBER); ! float size = (float) st.nval; ! parser.setShadingRate(size); } |
From: <ma...@us...> - 2003-05-02 05:02:12
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1:/tmp/cvs-serv17506/sampleData Modified Files: sphere.rib Log Message: Started implementing micropolygons (triangles). Index: sphere.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/sphere.rib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sphere.rib 2 May 2003 02:07:24 -0000 1.1 --- sphere.rib 2 May 2003 05:02:08 -0000 1.2 *************** *** 3,6 **** Translate 0 0 10 WorldBegin ! Sphere 9 -9 9 360 WorldEnd --- 3,6 ---- Translate 0 0 10 WorldBegin ! Sphere 5 -5 5 360 WorldEnd |
From: <ma...@us...> - 2003-05-02 05:02:12
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv17506/src/org/jrman/shaders Modified Files: ConstantShader.java SurfaceShader.java Removed Files: ShaderVariables.java Log Message: Started implementing micropolygons (triangles). Index: ConstantShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/ConstantShader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConstantShader.java 2 May 2003 02:07:21 -0000 1.1 --- ConstantShader.java 2 May 2003 05:02:07 -0000 1.2 *************** *** 22,25 **** --- 22,27 ---- import java.util.Map; + import org.jrman.render.*; + public class ConstantShader extends SurfaceShader { Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SurfaceShader.java 2 May 2003 02:07:22 -0000 1.3 --- SurfaceShader.java 2 May 2003 05:02:07 -0000 1.4 *************** *** 22,25 **** --- 22,27 ---- import java.util.Map; + import org.jrman.render.*; + public abstract class SurfaceShader { --- ShaderVariables.java DELETED --- |
From: <ma...@us...> - 2003-05-02 05:02:12
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv17506/src/org/jrman/primitive Modified Files: Primitive.java Quadric.java Sphere.java Log Message: Started implementing micropolygons (triangles). Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Primitive.java 2 May 2003 02:07:22 -0000 1.5 --- Primitive.java 2 May 2003 05:02:08 -0000 1.6 *************** *** 25,29 **** import org.jrman.geom.BoundingVolume; import org.jrman.geom.Bounds2f; ! import org.jrman.shaders.ShaderVariables; public abstract class Primitive { --- 25,29 ---- import org.jrman.geom.BoundingVolume; import org.jrman.geom.Bounds2f; ! import org.jrman.render.ShaderVariables; public abstract class Primitive { Index: Quadric.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Quadric.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Quadric.java 2 May 2003 02:07:22 -0000 1.4 --- Quadric.java 2 May 2003 05:02:08 -0000 1.5 *************** *** 39,43 **** import org.jrman.parser.Global; import org.jrman.parser.Parameter; ! import org.jrman.shaders.ShaderVariables; import org.jrman.util.Calc; --- 39,43 ---- import org.jrman.parser.Global; import org.jrman.parser.Parameter; ! import org.jrman.render.ShaderVariables; import org.jrman.util.Calc; Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Sphere.java 2 May 2003 02:07:22 -0000 1.11 --- Sphere.java 2 May 2003 05:02:08 -0000 1.12 *************** *** 30,34 **** import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; ! import org.jrman.shaders.ShaderVariables; public class Sphere extends Quadric --- 30,34 ---- import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; ! import org.jrman.render.ShaderVariables; public class Sphere extends Quadric |
From: <ma...@us...> - 2003-05-02 05:02:12
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv17506/src/org/jrman/render Modified Files: Bucket.java RendererHidden.java Added Files: ShaderVariables.java Micropolygon.java Log Message: Started implementing micropolygons (triangles). --- NEW FILE: ShaderVariables.java --- /* ShaderVariables.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.render; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.vecmath.Color3f; import javax.vecmath.Point3f; import org.jrman.geom.Transform; import org.jrman.grid.Color3fGrid; import org.jrman.grid.FloatGrid; import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; public class ShaderVariables { public Point3fGrid P = new Point3fGrid(); public Vector3fGrid N = new Vector3fGrid(); public Vector3fGrid Ng = new Vector3fGrid(); public Vector3fGrid I = new Vector3fGrid(); public Color3fGrid Cs = new Color3fGrid(); public Color3fGrid Os = new Color3fGrid(); public FloatGrid u = new FloatGrid(); public FloatGrid v = new FloatGrid(); public FloatGrid s = new FloatGrid(); public FloatGrid t = new FloatGrid(); public Vector3fGrid dPdu = new Vector3fGrid(); public Vector3fGrid dPdv = new Vector3fGrid(); public FloatGrid du = new FloatGrid(); public FloatGrid dv = new FloatGrid(); public Vector3fGrid L = new Vector3fGrid(); public Color3fGrid Cl = new Color3fGrid(); public Point3fGrid Ps = new Point3fGrid(); public Color3fGrid Ci = new Color3fGrid(); public Color3fGrid Oi = new Color3fGrid(); public Point3f E = new Point3f(); private Map map = new HashMap(); public void set(String name, Grid grid) { map.put(name, grid); } public Grid get(String name) { return (Grid) map.get(name); } public void transform(Transform objectToCamera) { P.transform(P, objectToCamera); N.ntransform(N, objectToCamera); Ng.ntransform(Ng, objectToCamera); dPdu.vtransform(dPdu, objectToCamera); dPdv.vtransform(dPdv, objectToCamera); } public Collection getMicropolygons() { int columns = Grid.getUSize(); int rows = Grid.getVSize(); List result = new ArrayList(); Point3fGrid pg = new Point3fGrid(); pg.set(P); Point3f[] p = (Point3f[]) pg.data; Color3fGrid cg = new Color3fGrid(); cg.set(Ci); Color3f[] c = (Color3f[]) cg.data; Color3fGrid og = new Color3fGrid(); og.set(Oi); Color3f[] o = (Color3f[]) og.data; for (int col = 0; col < columns - 1; col++) for (int row = 0; row < rows - 1; row++) { int offset = row * columns + col; result.add( new Micropolygon( p[offset], p[offset + 1], p[offset + columns], c[offset], o[offset])); result.add( new Micropolygon( p[offset + columns + 1], p[offset + 1], p[offset + columns], c[offset + columns + 1], o[offset + columns + 1])); } return result; } } --- NEW FILE: Micropolygon.java --- /* Micropolygon.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.render; import javax.vecmath.Color3f; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; import org.jrman.util.Constants; public class Micropolygon { Point3f a; Point3f b; Point3f c; Color3f color; Color3f opacity; float minX = Constants.INFINITY; float minY = Constants.INFINITY; float maxX = -Constants.INFINITY; float maxY = -Constants.INFINITY; public Micropolygon(Point3f pa, Point3f pb, Point3f pc, Color3f color, Color3f opacity) { a = pa; b = pb; c = pc; this.color = color; this.opacity = opacity; setMinMax(a); setMinMax(b); setMinMax(c); faceScreen(); } private void setMinMax(Point3f a) { minX = Math.min(minX, a.x); maxX = Math.max(maxX, a.x); minY = Math.min(minY, a.y); maxY = Math.max(maxY, a.y); } private void faceScreen() { Vector3f ab = new Vector3f(); ab.sub(b, a); Vector3f ac = new Vector3f(); ac.sub(c, a); Vector3f cp = new Vector3f(); cp.cross(ab, ac); if (cp.z > 0) { Point3f tmp = b; b = c; c = tmp; } } } Index: Bucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Bucket.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Bucket.java 15 Apr 2003 10:15:14 -0000 1.1 --- Bucket.java 2 May 2003 05:02:08 -0000 1.2 *************** *** 27,30 **** --- 27,32 ---- private Stack primitives = new Stack(); + + private Stack micropolygons = new Stack(); public void addPrimitive(Primitive primitive) { *************** *** 38,41 **** --- 40,60 ---- public Primitive getNextPrimitive() { return (Primitive) primitives.pop(); + } + + public void addMicropolygon(Micropolygon mp) { + micropolygons.push(mp); + } + + public boolean hasMoreMicropolygons() { + return !micropolygons.isEmpty(); + } + + public Micropolygon getNextMicropolygon() { + return (Micropolygon) micropolygons.pop(); + } + + public void flush() { + primitives = new Stack(); + micropolygons = new Stack(); } Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RendererHidden.java 2 May 2003 02:07:23 -0000 1.6 --- RendererHidden.java 2 May 2003 05:02:08 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- package org.jrman.render; + import java.util.Collection; + import java.util.Iterator; + import javax.vecmath.Point2f; import javax.vecmath.Point3f; *************** *** 37,41 **** import org.jrman.parser.World; import org.jrman.primitive.Primitive; - import org.jrman.shaders.ShaderVariables; import org.jrman.util.Calc; --- 40,43 ---- *************** *** 103,106 **** --- 105,118 ---- } + private void addToBuckets(Micropolygon mp) { + int minColumn = Calc.clamp((int) (mp.minX / bucketWidth), 0, bucketColumns - 1); + int minRow = Calc.clamp((int) (mp.minY / bucketHeight), 0, bucketRows - 1); + int maxColumn = Calc.clamp((int) (mp.maxX / bucketWidth), 0, bucketColumns - 1); + int maxRow = Calc.clamp((int) (mp.maxY / bucketHeight), 0, bucketRows - 1); + for (int col = minColumn; col <= maxColumn; col++) + for (int row = minRow; row <= maxRow; row++) + getBucket(col, row).addMicropolygon(mp); + } + private Bucket getBucket(int column, int row) { return buckets[row * bucketColumns + column]; *************** *** 113,116 **** --- 125,129 ---- ShaderVariables shaderVariables = new ShaderVariables(); int gridCount = 0; + long start = System.currentTimeMillis(); for (int row = 0; row < bucketRows; row++) for (int column = 0; column < bucketColumns; column++) { *************** *** 127,130 **** --- 140,147 ---- shaderVariables.I.set(shaderVariables.P); attr.getSurface().shade(shaderVariables); + shaderVariables.transform(cameraToRaster); + Collection c = shaderVariables.getMicropolygons(); + for (Iterator it = c.iterator(); it.hasNext();) + addToBuckets((Micropolygon) it.next()); } else { Primitive[] sub = p.split(); *************** *** 133,138 **** } } } ! System.out.println("gridCount = " + gridCount); } --- 150,165 ---- } } + bucket.flush(); } ! long end = System.currentTimeMillis(); ! float time = (end - start) / 1000f; ! System.out.println( ! "gridCount = " ! + gridCount ! + " in " ! + time ! + " seconds\n" ! + gridCount / time ! + "grids/second"); } *************** *** 140,144 **** super.init(frame, world); worldToCamera = Global.getTransform("camera"); ! PerspectiveTransform cameraToScreen = (PerspectiveTransform) Global.getTransform("screen"); Transform screenToRaster = Global.getTransform("raster"); cameraToRaster = screenToRaster.concat(cameraToScreen); --- 167,172 ---- super.init(frame, world); worldToCamera = Global.getTransform("camera"); ! PerspectiveTransform cameraToScreen = ! (PerspectiveTransform) Global.getTransform("screen"); Transform screenToRaster = Global.getTransform("raster"); cameraToRaster = screenToRaster.concat(cameraToScreen); |
From: <ma...@us...> - 2003-05-02 02:07:56
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/shaders Modified Files: SurfaceShader.java ShaderVariables.java Added Files: ConstantShader.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... --- NEW FILE: ConstantShader.java --- /* ConstantShader.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 ConstantShader extends SurfaceShader { public ConstantShader(String name, Map parameters) { super(name, parameters); } public void shade(ShaderVariables sv) { sv.Oi.set(sv.Os); sv.Ci.mul(sv.Os, sv.Cs); } } Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SurfaceShader.java 12 Apr 2003 06:10:31 -0000 1.2 --- SurfaceShader.java 2 May 2003 02:07:22 -0000 1.3 *************** *** 22,26 **** import java.util.Map; ! public class SurfaceShader { protected Map parameters; --- 22,26 ---- import java.util.Map; ! public abstract class SurfaceShader { protected Map parameters; *************** *** 29,33 **** public static SurfaceShader createShader(String name, Map parameters) { ! return new SurfaceShader(name, parameters); // Just for now... } --- 29,33 ---- public static SurfaceShader createShader(String name, Map parameters) { ! return new ConstantShader(name, parameters); // Just for now... } *************** *** 36,39 **** --- 36,41 ---- this.parameters = parameters; } + + public abstract void shade(ShaderVariables shaderVariables); } Index: ShaderVariables.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/ShaderVariables.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ShaderVariables.java 23 Apr 2003 04:44:09 -0000 1.1 --- ShaderVariables.java 2 May 2003 02:07:22 -0000 1.2 *************** *** 25,28 **** --- 25,29 ---- import javax.vecmath.Point3f; + import org.jrman.geom.Transform; import org.jrman.grid.Color3fGrid; import org.jrman.grid.FloatGrid; *************** *** 81,84 **** --- 82,93 ---- public Grid get(String name) { return (Grid) map.get(name); + } + + public void transform(Transform objectToCamera) { + P.transform(P, objectToCamera); + N.ntransform(N, objectToCamera); + Ng.ntransform(Ng, objectToCamera); + dPdu.vtransform(dPdu, objectToCamera); + dPdv.vtransform(dPdv, objectToCamera); } |
From: <ma...@us...> - 2003-05-02 02:07:55
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/primitive Modified Files: Primitive.java Sphere.java Quadric.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Primitive.java 23 Apr 2003 04:44:08 -0000 1.4 --- Primitive.java 2 May 2003 02:07:22 -0000 1.5 *************** *** 57,60 **** --- 57,62 ---- public abstract void dice(ShaderVariables shaderVariables); + + public abstract boolean isReadyToBeDiced(int gridSize); public void setRasterBounds(Bounds2f bounds) { Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Sphere.java 23 Apr 2003 04:44:08 -0000 1.10 --- Sphere.java 2 May 2003 02:07:22 -0000 1.11 *************** *** 22,28 **** --- 22,33 ---- import java.util.Map; + import javax.vecmath.Point2f; + import javax.vecmath.Point3f; + import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; + import org.jrman.grid.Grid; + import org.jrman.grid.Point3fGrid; import org.jrman.shaders.ShaderVariables; *************** *** 138,144 **** } ! public void dice(ShaderVariables shaderVariables) ! { ! // TODO Auto-generated method stub } --- 143,182 ---- } ! public boolean isReadyToBeDiced(int gridSize) { ! Point2f min = rasterBounds.getMin(); ! Point2f max = rasterBounds.getMax(); ! float width = max.x - min.x; ! float height = max.y - min.y; ! boolean ready = width * height <= gridSize; ! return ready; ! } ! ! protected void dice_P(ShaderVariables shaderVariables) { ! int uSize = Grid.getUSize(); ! int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / uSize; ! float phiDelta = (phiMax - phiMin) / vSize; ! Point3fGrid P = shaderVariables.P; ! Point3f tmp = new Point3f(); ! float theta = thetaMin; ! for (int u = 0; u < uSize; u++) { ! float cosTheta = (float) Math.cos(theta); ! float sinTheta = (float) Math.sin(theta); ! float phi = phiMin; ! for (int v = 0; v < vSize; v++) { ! float cosPhi = (float) Math.cos(phi); ! float sinPhi = (float) Math.sin(phi); ! tmp.x = radius * cosTheta * cosPhi; ! tmp.y = radius * sinTheta * cosPhi; ! tmp.z = radius * sinPhi; ! P.set(u, v, tmp); ! phi += phiDelta; ! } ! theta += thetaDelta; ! } ! } ! ! protected void dice_Ng(ShaderVariables shaderVariables) { ! shaderVariables.Ng.set(shaderVariables.P); } Index: Quadric.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Quadric.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Quadric.java 16 Apr 2003 09:19:33 -0000 1.3 --- Quadric.java 2 May 2003 02:07:22 -0000 1.4 *************** *** 26,41 **** --- 26,285 ---- import javax.vecmath.Color3f; import javax.vecmath.Matrix4f; + import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.Vector3f; import org.jrman.attributes.Attributes; + import org.jrman.grid.Color3fGrid; + import org.jrman.grid.FloatGrid; + import org.jrman.grid.Grid; + import org.jrman.grid.Point3fGrid; + import org.jrman.grid.Vector3fGrid; import org.jrman.parser.Declaration; + import org.jrman.parser.Global; import org.jrman.parser.Parameter; + import org.jrman.shaders.ShaderVariables; import org.jrman.util.Calc; public abstract class Quadric extends Primitive { + private static Declaration U_DECL = new Declaration("u", "vertex float"); + + private static Declaration V_DECL = new Declaration("v", "vertex float"); + public Quadric(Map parameters, Attributes attributes) { super(parameters, attributes); + setDefaultParameters(); + } + + public void dice(ShaderVariables shaderVariables) { + dice_P(shaderVariables); + dice_Ng(shaderVariables); + dice_N(shaderVariables); + dice_Cs(shaderVariables); + dice_Os(shaderVariables); + dice_u(shaderVariables); + dice_v(shaderVariables); + dice_s(shaderVariables); + dice_t(shaderVariables); + dice_du(shaderVariables); + dice_dv(shaderVariables); + dice_dPdu(shaderVariables); + dice_dPdv(shaderVariables); + dice_others(shaderVariables); + } + + protected abstract void dice_P(ShaderVariables shaderVariables); + + protected abstract void dice_Ng(ShaderVariables shaderVariables); + + protected void dice_N(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("N"); + if (parameter != null) { + Vector3f[][] data = (Vector3f[][]) parameter.getData(); + diceVector3f(shaderVariables.N, data[0][0], data[1][0], data[2][0], data[3][0]); + } else + shaderVariables.N.set(shaderVariables.Ng); + } + + protected void dice_Cs(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("Cs"); + if (parameter != null) { + Color3f[][] data = (Color3f[][]) parameter.getData(); + diceColor3f(shaderVariables.Cs, data[0][0], data[1][0], data[2][0], data[3][0]); + } else + shaderVariables.Cs.set(attributes.getColor()); + } + + protected void dice_Os(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("Os"); + if (parameter != null) { + Color3f[][] data = (Color3f[][]) parameter.getData(); + diceColor3f(shaderVariables.Os, data[0][0], data[1][0], data[2][0], data[3][0]); + } else + shaderVariables.Os.set(attributes.getOpacity()); + } + + protected void dice_u(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("u"); + float[][] data = (float[][]) parameter.getData(); + diceFloat(shaderVariables.u, data[0][0], data[1][0], data[2][0], data[3][0]); + } + + protected void dice_v(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("v"); + float[][] data = (float[][]) parameter.getData(); + diceFloat(shaderVariables.v, data[0][0], data[1][0], data[2][0], data[3][0]); + } + + protected void dice_s(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("s"); + float[][] data = (float[][]) parameter.getData(); + diceFloat(shaderVariables.s, data[0][0], data[1][0], data[2][0], data[3][0]); + } + + protected void dice_t(ShaderVariables shaderVariables) { + Parameter parameter = (Parameter) parameters.get("t"); + float[][] data = (float[][]) parameter.getData(); + diceFloat(shaderVariables.t, data[0][0], data[1][0], data[2][0], data[3][0]); + } + + protected void dice_du(ShaderVariables shaderVariables) { + shaderVariables.du.du(shaderVariables.u); + } + + protected void dice_dv(ShaderVariables shaderVariables) { + shaderVariables.dv.dv(shaderVariables.v); + } + + protected void dice_dPdu(ShaderVariables shaderVariables) { + shaderVariables.dPdu.Du(shaderVariables.P, shaderVariables.du); + } + + protected void dice_dPdv(ShaderVariables shaderVariables) { + shaderVariables.dPdv.Dv(shaderVariables.P, shaderVariables.dv); + } + + protected void dice_others(ShaderVariables shaderVariables) { + // TODO Auto-generated method stub + + } + + protected void diceFloat(FloatGrid g, float uv00, float uv10, float uv01, float uv11) { + int uSize = Grid.getUSize(); + int vSize = Grid.getVSize(); + float uStep = 1f / uSize; + float vStep = 1f / vSize; + float u = 0f; + for (int iu = 0; iu < uSize; iu++) { + float v = 0f; + for (int iv = 0; iv < vSize; iv++) { + g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); + v += vStep; + } + u += uStep; + } + } + + protected void dicePoint3f( + Point3fGrid g, + Point3f uv00, + Point3f uv10, + Point3f uv01, + Point3f uv11) { + int uSize = Grid.getUSize(); + int vSize = Grid.getVSize(); + float uStep = 1f / uSize; + float vStep = 1f / vSize; + float u = 0f; + for (int iu = 0; iu < uSize; iu++) { + float v = 0f; + for (int iv = 0; iv < vSize; iv++) { + g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); + v += vStep; + } + u += uStep; + } + } + + protected void diceVector3f( + Vector3fGrid g, + Vector3f uv00, + Vector3f uv10, + Vector3f uv01, + Vector3f uv11) { + int uSize = Grid.getUSize(); + int vSize = Grid.getVSize(); + float uStep = 1f / uSize; + float vStep = 1f / vSize; + float u = 0f; + for (int iu = 0; iu < uSize; iu++) { + float v = 0f; + for (int iv = 0; iv < vSize; iv++) { + g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); + v += vStep; + } + u += uStep; + } + } + + protected void diceColor3f( + Color3fGrid g, + Color3f uv00, + Color3f uv10, + Color3f uv01, + Color3f uv11) { + int uSize = Grid.getUSize(); + int vSize = Grid.getVSize(); + float uStep = 1f / uSize; + float vStep = 1f / vSize; + float u = 0f; + for (int iu = 0; iu < uSize; iu++) { + float v = 0f; + for (int iv = 0; iv < vSize; iv++) { + g.set(iu, iv, Calc.interpolate(uv00, uv01, uv10, uv11, u, v)); + v += vStep; + } + u += uStep; + } + } + + protected void setDefaultParameters() { + Parameter parameter = (Parameter) parameters.get("u"); + if (parameter == null) { + float[][] u = new float[4][]; + u[0] = new float[1]; + u[1] = new float[1]; + u[2] = new float[1]; + u[3] = new float[1]; + u[0][0] = 0f; + u[1][0] = 1f; + u[2][0] = 0f; + u[3][0] = 1f; + parameters.put("u", new Parameter(U_DECL, u)); + } + parameter = (Parameter) parameters.get("v"); + if (parameter == null) { + float[][] v = new float[4][]; + v[0] = new float[1]; + v[1] = new float[1]; + v[2] = new float[1]; + v[3] = new float[1]; + v[0][0] = 0f; + v[1][0] = 1f; + v[2][0] = 0f; + v[3][0] = 1f; + parameters.put("v", new Parameter(V_DECL, v)); + } + parameter = (Parameter) parameters.get("s"); + if (parameter == null) { + float[][] s = new float[4][]; + s[0] = new float[1]; + s[1] = new float[1]; + s[2] = new float[1]; + s[3] = new float[1]; + Parameter uParam = (Parameter) parameters.get("u"); + float[][] u = (float[][]) uParam.getData(); + s[0][0] = u[0][0]; + s[1][0] = u[1][0]; + s[2][0] = u[2][0]; + s[3][0] = u[3][0]; + parameters.put("s", new Parameter(Global.getDeclaration("s"), s)); + } + parameter = (Parameter) parameters.get("t"); + if (parameter == null) { + float[][] t = new float[4][]; + t[0] = new float[1]; + t[1] = new float[1]; + t[2] = new float[1]; + t[3] = new float[1]; + Parameter vParam = (Parameter) parameters.get("v"); + float[][] v = (float[][]) vParam.getData(); + t[0][0] = v[0][0]; + t[1][0] = v[1][0]; + t[2][0] = v[2][0]; + t[3][0] = v[3][0]; + parameters.put("t", new Parameter(Global.getDeclaration("t"), t)); + } } *************** *** 70,73 **** --- 314,336 ---- 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, new Parameter(declaration, sparam)); + } else if (type == Declaration.Type.POINT) { + Point3f[][] param = (Point3f[][]) parameter.getData(); + Point3f[][] sparam = new Point3f[4][]; + int count = declaration.getCount(); + sparam[0] = new Point3f[count]; + sparam[1] = new Point3f[count]; + sparam[2] = new Point3f[count]; + sparam[3] = new Point3f[count]; + for (int i = 0; i < count; i++) { + Point3f uv00 = param[0][i]; + Point3f uv10 = param[1][i]; + Point3f uv01 = param[2][i]; + Point3f 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); |
From: <ma...@us...> - 2003-05-02 02:07:27
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/parser Modified Files: Frame.java Parser.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: Frame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Frame.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Frame.java 18 Apr 2003 04:51:36 -0000 1.3 --- Frame.java 2 May 2003 02:07:23 -0000 1.4 *************** *** 47,51 **** private float pixelAspectRatio; ! private Bounds2f cropWindow; --- 47,51 ---- private float pixelAspectRatio; ! private Bounds2f cropWindow; *************** *** 177,187 **** frameAspectRatio = (horizontalResolution * pixelAspectRatio) / verticalResolution; if (screenWindow == null) { - float h = (float) Math.tan(Math.toRadians(fieldOfView / 2f)); 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(); --- 177,186 ---- frameAspectRatio = (horizontalResolution * pixelAspectRatio) / verticalResolution; if (screenWindow == null) { if (frameAspectRatio >= 1f) screenWindow = ! new Bounds2f(-frameAspectRatio, frameAspectRatio, -1f, 1f); else screenWindow = ! new Bounds2f(-1f, 1f, -1f / frameAspectRatio, 1f / frameAspectRatio); } else { Point2f min = screenWindow.getMin(); Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Parser.java 18 Apr 2003 04:51:36 -0000 1.31 --- Parser.java 2 May 2003 02:07:23 -0000 1.32 *************** *** 33,37 **** import javax.vecmath.Color3f; import javax.vecmath.Matrix4f; - import javax.vecmath.Point2f; import javax.vecmath.Vector3f; --- 33,36 ---- *************** *** 259,263 **** public void perspective(float fov) { PerspectiveTransform perspective = ! PerspectiveTransform.createWithFOV(fov, 1f, Constants.INFINITY); Transform current = currentAttributes.getTransform(); currentAttributes.setTransform(perspective.preConcat(current)); --- 258,262 ---- public void perspective(float fov) { PerspectiveTransform perspective = ! PerspectiveTransform.createWithFov(fov, 1f, Constants.INFINITY); Transform current = currentAttributes.getTransform(); currentAttributes.setTransform(perspective.preConcat(current)); *************** *** 463,488 **** float[][] fovParam = (float[][]) parameter.getData(); 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(); - float deltaX = Math.abs(max.x - (max.x + min.x) / 2f); - float deltaY = Math.abs(max.y - (max.y + min.y) / 2f); - float h = Math.min(deltaX, deltaY); - currentAttributes.setTransform( - PerspectiveTransform.createWithH( - h, - frame.getNearClipping(), - frame.getFarClipping())); } } else if (cameraProjection == CameraProjection.ORTHOGRAPHIC) { - frame.defineScreen(); currentAttributes.setTransform( AffineTransform.createOrthographic( --- 462,472 ---- float[][] fovParam = (float[][]) parameter.getData(); frame.setFieldOfView(fovParam[0][0]); } + currentAttributes.setTransform( + PerspectiveTransform.createWithFov( + frame.getFieldOfView(), + frame.getNearClipping(), + frame.getFarClipping())); } else if (cameraProjection == CameraProjection.ORTHOGRAPHIC) { currentAttributes.setTransform( AffineTransform.createOrthographic( *************** *** 490,497 **** 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" } --- 474,481 ---- frame.getFarClipping())); } + frame.defineScreen(); 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-05-02 02:07:27
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1:/tmp/cvs-serv27634/sampleData Added Files: sphere.rib Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... --- NEW FILE: sphere.rib --- Clipping 1 1000 Projection "perspective" Translate 0 0 10 WorldBegin Sphere 9 -9 9 360 WorldEnd |
From: <ma...@us...> - 2003-05-02 02:07:27
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/util Modified Files: Calc.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: Calc.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/util/Calc.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Calc.java 19 Apr 2003 04:57:23 -0000 1.5 --- Calc.java 2 May 2003 02:07:23 -0000 1.6 *************** *** 203,206 **** --- 203,210 ---- alphaV); } + + public static float fovToFocalLength(float fov) { + return (float) (1 / Math.tan(Math.toRadians(fov / 2))); + } } |
From: <ma...@us...> - 2003-05-02 02:07:26
|
Update of /cvsroot/jrman/drafts/src/org/jrman/grid In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/grid Modified Files: BooleanGrid.java Tuple3fGrid.java Grid.java FloatGrid.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: BooleanGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/BooleanGrid.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BooleanGrid.java 21 Apr 2003 00:09:34 -0000 1.3 --- BooleanGrid.java 2 May 2003 02:07:22 -0000 1.4 *************** *** 29,39 **** data = new boolean[uSize * vSize]; } - public int getUSize() { - return uSize; - } - - public int getVSize() { - return vSize; - } public boolean get(int i) { --- 29,32 ---- Index: Tuple3fGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/Tuple3fGrid.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Tuple3fGrid.java 23 Apr 2003 04:44:09 -0000 1.4 --- Tuple3fGrid.java 2 May 2003 02:07:22 -0000 1.5 *************** *** 31,42 **** } - public int getUSize() { - return uSize; - } - - public int getVSize() { - return vSize; - } - public void get(int i, Tuple3f out) { out.set(data[i]); --- 31,34 ---- *************** *** 479,483 **** public void Du(Tuple3fGrid t, FloatGrid du) { for (int i = 0; i < data.length; i += uSize) { ! for (int j = 0; j < uSize; j++) { data[i + j].sub(t.data[i + j + 1], t.data[i + j]); data[i + j].scale(1f / du.data[i + j]); --- 471,475 ---- public void Du(Tuple3fGrid t, FloatGrid du) { for (int i = 0; i < data.length; i += uSize) { ! for (int j = 0; j < uSize - 1; j++) { data[i + j].sub(t.data[i + j + 1], t.data[i + j]); data[i + j].scale(1f / du.data[i + j]); Index: Grid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/Grid.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Grid.java 21 Apr 2003 00:09:34 -0000 1.1 --- Grid.java 2 May 2003 02:07:22 -0000 1.2 *************** *** 33,36 **** --- 33,44 ---- protected Grid() { } + + public static int getUSize() { + return uSize; + } + + public static int getVSize() { + return vSize; + } } Index: FloatGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/FloatGrid.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FloatGrid.java 23 Apr 2003 04:44:09 -0000 1.4 --- FloatGrid.java 2 May 2003 02:07:22 -0000 1.5 *************** *** 34,45 **** } - public int getUSize() { - return uSize; - } - - public int getVSize() { - return vSize; - } - public float get(int i) { return data[i]; --- 34,37 ---- |
From: <ma...@us...> - 2003-05-02 02:07:26
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/geom Modified Files: PerspectiveTransform.java ConvexHull3f.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: PerspectiveTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/PerspectiveTransform.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PerspectiveTransform.java 18 Apr 2003 04:51:36 -0000 1.5 --- PerspectiveTransform.java 2 May 2003 02:07:22 -0000 1.6 *************** *** 24,40 **** import javax.vecmath.Point4f; public class PerspectiveTransform extends AffineTransform { ! ! public static PerspectiveTransform createWithFOV(float fov, float near, float far) { ! return createWithH(fovToH(fov), near, far); ! } ! ! public static PerspectiveTransform createWithH(float h, float near, float far) { ! return new PerspectiveTransform(h, near, far); } ! ! private static float fovToH(float fov) { ! return (float) Math.toRadians(fov / 2f); } --- 24,37 ---- import javax.vecmath.Point4f; + import org.jrman.util.Calc; public class PerspectiveTransform extends AffineTransform { ! ! public static PerspectiveTransform createWithFov(float fov, float near, float far) { ! return createWithFocalLength(Calc.fovToFocalLength(fov), near, far); } ! ! public static PerspectiveTransform createWithFocalLength(float focalLength, float near, float far) { ! return new PerspectiveTransform(focalLength, near, far); } *************** *** 43,66 **** } ! private PerspectiveTransform(float h, float near, float far) { ! // Assumes centered screen window.... super( new Matrix4f( ! 1f, ! 0f, ! 0f, ! 0f, ! 0f, ! 1f, ! 0f, ! 1f, ! 0f, ! 0f, ! (h * far) / (near * (far - near)), ! h / near, ! 0f, ! 0f, ! - (h * far) / (far - near), ! 0f)); } --- 40,50 ---- } ! private PerspectiveTransform(float fl, float near, float far) { super( new Matrix4f( ! fl, 0f, 0f, 0f, ! 0f, fl, 0f, 0f, ! 0f, 0f, far / (far - near), (far * near) / (near - far), ! 0f, 0f, 1f, 0f)); } *************** *** 80,89 **** return new PerspectiveTransform(matrix); } ! public Transform preConcat(Transform transform) { Transform perspective = new PerspectiveTransform(transform.getMatrix()); return perspective.concat(this); } ! public void transformPoint(Point3f point) { Point4f hpoint = new Point4f(point); --- 64,73 ---- return new PerspectiveTransform(matrix); } ! public Transform preConcat(Transform transform) { Transform perspective = new PerspectiveTransform(transform.getMatrix()); return perspective.concat(this); } ! public void transformPoint(Point3f point) { Point4f hpoint = new Point4f(point); Index: ConvexHull3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/ConvexHull3f.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConvexHull3f.java 16 Apr 2003 09:19:36 -0000 1.5 --- ConvexHull3f.java 2 May 2003 02:07:23 -0000 1.6 *************** *** 47,53 **** 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; --- 47,55 ---- public BoundingVolume transform(Transform transform) { ConvexHull3f result = new ConvexHull3f(); + Point3f tmp = new Point3f(); for (Iterator iter = points.iterator(); iter.hasNext();) { Point3f p = (Point3f) iter.next(); ! transform.transformPoint(p, tmp); ! result.addPoint(tmp); } return result; |
From: <ma...@us...> - 2003-05-02 02:07:26
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv27634/src/org/jrman/render Modified Files: RendererHidden.java Log Message: Started working on dicing ans shading. Fixed MANY transform bugs.... Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RendererHidden.java 16 Apr 2003 09:19:35 -0000 1.5 --- RendererHidden.java 2 May 2003 02:07:23 -0000 1.6 *************** *** 24,32 **** --- 24,35 ---- import javax.vecmath.Vector3f; + import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; import org.jrman.geom.Bounds2f; import org.jrman.geom.ClippingVolume; + import org.jrman.geom.PerspectiveTransform; import org.jrman.geom.Plane; import org.jrman.geom.Transform; + import org.jrman.grid.Grid; import org.jrman.options.Filter; import org.jrman.parser.Frame; *************** *** 34,37 **** --- 37,41 ---- import org.jrman.parser.World; import org.jrman.primitive.Primitive; + import org.jrman.shaders.ShaderVariables; import org.jrman.util.Calc; *************** *** 104,108 **** public void render() { ! // TODO Auto-generated method stub } --- 108,138 ---- public void render() { ! int gridSize = frame.getGridSize(); ! int gridSide = (int) Math.round(Math.sqrt(gridSize)) + 1; ! Grid.setSize(gridSide, gridSide); ! ShaderVariables shaderVariables = new ShaderVariables(); ! int gridCount = 0; ! for (int row = 0; row < bucketRows; row++) ! for (int column = 0; column < bucketColumns; column++) { ! Bucket bucket = getBucket(column, row); ! while (bucket.hasMorePrimitives()) { ! Primitive p = bucket.getNextPrimitive(); ! if (p.isReadyToBeDiced(gridSize)) { ! gridCount++; ! p.dice(shaderVariables); ! Attributes attr = p.getAttributes(); ! Transform objectToWorld = attr.getTransform(); ! Transform objectToCamera = worldToCamera.concat(objectToWorld); ! shaderVariables.transform(objectToCamera); ! shaderVariables.I.set(shaderVariables.P); ! attr.getSurface().shade(shaderVariables); ! } else { ! Primitive[] sub = p.split(); ! for (int i = 0; i < sub.length; i++) ! addPrimitive(sub[i]); ! } ! } ! } ! System.out.println("gridCount = " + gridCount); } *************** *** 110,116 **** super.init(frame, world); worldToCamera = Global.getTransform("camera"); ! Transform cameraToScreen = Global.getTransform("screen"); Transform screenToRaster = Global.getTransform("raster"); cameraToRaster = screenToRaster.concat(cameraToScreen); eyePlane = Plane.createWithPointAndNormal(new Point3f(), new Vector3f(0f, 0f, -1f)); createClippingVolume(); --- 140,147 ---- super.init(frame, world); worldToCamera = Global.getTransform("camera"); ! PerspectiveTransform cameraToScreen = (PerspectiveTransform) Global.getTransform("screen"); Transform screenToRaster = Global.getTransform("raster"); cameraToRaster = screenToRaster.concat(cameraToScreen); + cameraToRaster = cameraToScreen.preConcat(screenToRaster); eyePlane = Plane.createWithPointAndNormal(new Point3f(), new Vector3f(0f, 0f, -1f)); createClippingVolume(); |
From: <ma...@us...> - 2003-04-23 04:44:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv15977/src/org/jrman/primitive Modified Files: Primitive.java Sphere.java Log Message: Small fixes in grid implementations. Implemented ShaderVariables. Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Primitive.java 15 Apr 2003 10:15:14 -0000 1.3 --- Primitive.java 23 Apr 2003 04:44:08 -0000 1.4 *************** *** 25,28 **** --- 25,29 ---- import org.jrman.geom.BoundingVolume; import org.jrman.geom.Bounds2f; + import org.jrman.shaders.ShaderVariables; public abstract class Primitive { *************** *** 55,59 **** public abstract Primitive[] split(); ! public abstract Map dice(); public void setRasterBounds(Bounds2f bounds) { --- 56,60 ---- public abstract Primitive[] split(); ! public abstract void dice(ShaderVariables shaderVariables); public void setRasterBounds(Bounds2f bounds) { Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Sphere.java 18 Apr 2003 04:51:36 -0000 1.9 --- Sphere.java 23 Apr 2003 04:44:08 -0000 1.10 *************** *** 25,28 **** --- 25,29 ---- import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; + import org.jrman.shaders.ShaderVariables; public class Sphere extends Quadric *************** *** 137,144 **** } ! public Map dice() { // TODO Auto-generated method stub - return null; } --- 138,144 ---- } ! public void dice(ShaderVariables shaderVariables) { // TODO Auto-generated method stub } |
From: <ma...@us...> - 2003-04-23 04:44:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv15977/src/org/jrman/shaders Added Files: ShaderVariables.java Log Message: Small fixes in grid implementations. Implemented ShaderVariables. --- NEW FILE: ShaderVariables.java --- /* ShaderVariables.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.HashMap; import java.util.Map; import javax.vecmath.Point3f; import org.jrman.grid.Color3fGrid; import org.jrman.grid.FloatGrid; import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; public class ShaderVariables { public Point3fGrid P = new Point3fGrid(); public Vector3fGrid N = new Vector3fGrid(); public Vector3fGrid Ng = new Vector3fGrid(); public Vector3fGrid I = new Vector3fGrid(); public Color3fGrid Cs = new Color3fGrid(); public Color3fGrid Os = new Color3fGrid(); public FloatGrid u = new FloatGrid(); public FloatGrid v = new FloatGrid(); public FloatGrid s = new FloatGrid(); public FloatGrid t = new FloatGrid(); public Vector3fGrid dPdu = new Vector3fGrid(); public Vector3fGrid dPdv = new Vector3fGrid(); public FloatGrid du = new FloatGrid(); public FloatGrid dv = new FloatGrid(); public Vector3fGrid L = new Vector3fGrid(); public Color3fGrid Cl = new Color3fGrid(); public Point3fGrid Ps = new Point3fGrid(); public Color3fGrid Ci = new Color3fGrid(); public Color3fGrid Oi = new Color3fGrid(); public Point3f E = new Point3f(); private Map map = new HashMap(); public void set(String name, Grid grid) { map.put(name, grid); } public Grid get(String name) { return (Grid) map.get(name); } } |