[Fencommits] libvob: ly yet.
Matti J. Katila
majukati at cc.jyu.fi
Mon Apr 3 20:05:06 EEST 2006
Mon Apr 3 19:32:05 EEST 2006 Matti J. Katila <majukati at cc.jyu.fi>
* ly yet.
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java libvob-new/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java
--- libvob-old/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java 2006-04-03 20:05:03.291267906 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java 2006-04-03 19:39:39.000000000 +0300
@@ -39,6 +39,10 @@
super(-1);
GL11.glGenTextures(textId);
}
+ /** Get the OpenGL texture id of this texture.
+ */
+ public int getTexId() { return textId.get(0); }
+
public void deleteTexture() {
}
public int shade(int w, int h, int d, int comps, String internalFormat, String format, String shaderName, String[] params) {
@@ -75,10 +79,12 @@
buildmipmaps = true;
}
}
-
+
+ value.position(0);
+ s.render(p, w, h, (d==0?1:d), comps, value);
+
int level;
for (level = 0;; level++) {
- s.render(p, w, h, (d==0?1:d), comps, value);
if (buildmipmaps) {
if (d != 0) //assert(d==0); // 3D buildmipmaps not implemented in libutil
@@ -92,6 +98,7 @@
TextureUtils.buildMipmaps(GL11.GL_TEXTURE_2D, CallGL.getToken(internalFormat),
w,h, CallGL.getToken(format), GL11.GL_FLOAT, value);
} else
+ value.flip();
if (d == 0)
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, level, CallGL.getToken(internalFormat),
w, h, 0, CallGL.getToken(format), GL11.GL_FLOAT, value);
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/CallGL.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/CallGL.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/CallGL.java 2006-04-03 20:05:03.313264579 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/CallGL.java 2006-04-03 19:39:39.000000000 +0300
@@ -17,6 +17,7 @@
import org.lwjgl.opengl.ARBProgram;
import org.lwjgl.opengl.ARBVertexProgram;
import org.lwjgl.opengl.EXTSecondaryColor;
+import org.lwjgl.opengl.EXTTextureFilterAnisotropic;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
@@ -560,6 +561,7 @@
NVRegisterCombiners.class,
NVRegisterCombiners2.class,
NVVertexProgram.class,
+ EXTTextureFilterAnisotropic.class,
};
for (int i = 0; i < clzz.length; i++) {
try {
@@ -633,4 +635,9 @@
// pop attrib?
}
+ public void call() {
+ checkGlError("before call list in callgl call");
+ GL11.glCallList(callList);
+ checkGlError("after call list in callgl call");
+ }
}
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/Coorder.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/Coorder.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/Coorder.java 2006-04-03 20:05:03.305265789 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/Coorder.java 2006-04-03 19:39:39.000000000 +0300
@@ -9,6 +9,7 @@
import org.lwjgl.util.vector.Vector3f;
import org.nongnu.libvob.gl.GLVobCoorder;
import org.nongnu.libvob.gl.impl.lwjgl.LwjglRenderer.TransformProxy;
+import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.ScaleTransform;
/**
* A java coorder.
@@ -28,6 +29,9 @@
public Vector3f transform(Vector3f p) {
return p;
}
+ public Vector2f transform(Vector2f p) {
+ return p;
+ }
public void vertex(Vector3f p) {
}
public boolean isNonlinear() {
@@ -47,8 +51,7 @@
return this;
}
public void dump(PrintStream out) {
- System.
- out.print("Root");
+ System.out.print("Root");
}
Vector2f sq = new Vector2f();
@@ -60,8 +63,11 @@
};
private Transform[] tr;
+
+ private TransformProxy transProxy;
public Coorder(GLVobCoorder from, TransformProxy transProxy) {
+ this.transProxy = transProxy;
tr = new Transform[from.ninds];
tr[0] = root;
@@ -93,4 +99,8 @@
return tr[cs0];
}
+ public Transform createTransform(int type) {
+ return transProxy.instantiate(type);;
+ }
+
}
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/LWJGLRen.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/LWJGLRen.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/LWJGLRen.java 2006-04-03 20:05:03.309265184 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/LWJGLRen.java 2006-04-03 19:39:39.000000000 +0300
@@ -4,14 +4,16 @@
import java.awt.Graphics;
+import org.lwjgl.opengl.EXTMultiDrawArrays;
import org.nongnu.libvob.AbstractVob;
import org.nongnu.libvob.TextStyle;
import org.nongnu.libvob.Vob;
import org.nongnu.libvob.VobScene;
-import org.nongnu.libvob.gl.PaperMill.Paper;
+import org.nongnu.libvob.gl.PaperMill;
import org.nongnu.libvob.gl.Ren.PaperQuad;
import org.nongnu.libvob.gl.Ren.Text1;
import org.nongnu.libvob.gl.impl.lwjgl.mosaictext.LWJGL_Text;
+import org.nongnu.libvob.gl.impl.lwjgl.vobs.paper.PaperQuadVob;
import org.nongnu.libvob.gl.impl.lwjgl.vobs.trivial.CallListBoxCoorder;
import org.nongnu.libvob.gl.impl.lwjgl.vobs.trivial.CallListCoorder;
import org.nongnu.libvob.gl.impl.lwjgl.vobs.trivial.NonFilledRectangleVob;
@@ -80,254 +82,14 @@
// ---- NON-STATIC METHODS --------------------------
- public PaperQuad createPaperQuad(Paper paper, float x0, float y0, float x1, float y1, float dicefactor) {
- return new PaperQuadImpl(paper, x0,y0,x1,y1, dicefactor);
+ public PaperQuad createPaperQuad(PaperMill.Paper paper, float x0, float y0, float x1, float y1, float dicefactor) {
+ return new PaperQuadVob(paper, x0,y0,x1,y1, 1f, dicefactor);
}
public Text1 createText1(TextStyle p0, String p1, float p2, int p3) {
return null;
}
-
-
- class PaperQuadImpl extends GLVob implements PaperQuad, Vob3 {
-
- public PaperQuadImpl(Paper paper, float x0, float y0, float x1, float y1, float dicefactor) {
- }
-
- public void render(Transform cs0, Transform cs1, Transform cs2, int callList) {
- // TODO Auto-generated method stub
-
- }
-
-
- /**
- # PaperQuad is a bit complicated: there are three coordinate
- # systems here: the window cs, the object cs and the paper cs.
- # cs1 is object => window,
- # and cs2 is paper => object, unless PAPERQUAD_CS2_TO_SCREEN is set, when it is
- # paper => window
- # Corners give the corners of the quad to render, in object
- # coordinates.
- */
-/*
- class PaperQuad {
- public:
- enum { NTrans = 2 };
-
- ::Vob::Paper::Paper *paper;
- float x0,y0,x1,y1;
- float scale;
- float dicefactor;
- int flags;
-
- template<class F> void params(F &f) {
- f(paper, x0, y0, x1, y1, scale, dicefactor, flags);
- }
-
- template<class T> void render(const T &coords1, const T &coords2) const {
- const int flags = this->flags;
- // object -> paper/window
- const Transform &coords2inv = coords2.getInverse();
-
- GLERR;
-
-
- ZPt paperorigin, paperx, papery;
- if(flags & PAPERQUAD_CS2_TO_SCREEN) {
- const Transform &coords1inv = coords1.getInverse();
- paperorigin = coords1inv.transform(coords2.transform(ZPt(0, 0, 0)));
- paperx = coords1inv.transform(coords2.transform(ZPt(1, 0, 0)))
- - paperorigin;
- papery = coords1inv.transform(coords2.transform(ZPt(0, 1, 0)))
- - paperorigin;
- } else {
- paperorigin = coords2.transform(ZPt(0, 0, 0));
- paperx = coords2.transform(ZPt(1, 0, 0)) - paperorigin;
- papery = coords2.transform(ZPt(0, 1, 0)) - paperorigin;
- }
-
-
- Paper::LightParam lightParam;
-
- // These are now irrelevant
- lightParam.orig = paperorigin-ZPt(0,0,0);
- lightParam.e0 = paperx * scale;
- lightParam.e1 = papery * scale;
- lightParam.e2 = ZVec(0,0,paperx.length()) * scale;
-
- lightParam.Light = ZVec(-1,-1,1);
- lightParam.Light_w = 0.0;
-
- DBG(dbg_paperquad) << "Paperquad: " <<
- lightParam.orig << " " <<
- lightParam.e0 << " " <<
- lightParam.e1 << " " <<
- lightParam.e2 << " " <<
- "\\nCorners" <<
- x0 << " " <<
- y0 << " " <<
- x1 << " " <<
- y1 << " " <<
- "\\n"
- ;
- GLERR;
-
-
- int dice;
-
- if(flags & PAPERQUAD_NONL_MAXLEN) {
- Pt p1 = coords1.transform(Pt(x0,y0));
- Pt p2 = coords1.transform(Pt(x0,y1));
- Pt p3 = coords1.transform(Pt(x1,y0));
- Pt p4 = coords1.transform(Pt(x1,y1));
- float dist[4] = {
- (p2-p1).length(),
- (p3-p1).length(),
- (p4-p2).length(),
- (p4-p3).length()
- };
- float m = *std::max_element(dist, dist+4);
-
- dice = (int)(m / dicefactor) + 2;
- } else { // old way
-
- ZPt ctr = ZPt(lerp(x0, x1, 0.5), lerp(y0, y1, 0.5), 0);
- double len = hypot(x1-x0, y1-y0) / 2;
- double nonl = coords1.nonlinearity(ctr, len);
-
- dice = (int)(len * nonl * dicefactor) + 2;
- }
- DBG(dbg_paperquad) << "Dice: " << dice <<"\\n";
- // Cap it at a ridiculous value
- if( dice > 100) dice = 100;
- if(dice < 2 ) dice = 2;
-
- float *vertices = new float[dice * dice * 5];
-
- int *indices = new int[(dice) * (2*dice)];
-
- #define VERTICES3(x, y, z) vertices[((x)*dice + (y))*5 + (z)]
- #define VERTICES2(x, y) vertices[((x)*dice + (y))*5]
- #define INDICES2(x, y) indices[(x)*2*dice + (y)]
- #define INDICES1(x) indices[(x)*2*dice]
-
- int *indps[dice-1];
- int counts[dice-1];
- for(int ix = 0; ix<dice; ix++) {
- if(ix < dice-1) {
- counts[ix] = 2*dice;
- indps[ix] = &INDICES1(ix);
- }
- for(int iy = 0; iy<dice; iy++) {
- if(ix < dice-1) {
- INDICES2(ix, 2*iy) = dice * ix + iy;
- INDICES2(ix, 2*iy+1) = dice * (ix+1) + iy;
- }
- float x = ix / (dice - 1.0);
- float y = iy / (dice - 1.0);
- ZPt p(lerp(x0, x1, x), lerp(y0, y1, y), 0);
- ZPt v = coords1.transform(p);
- VERTICES3(ix, iy, 2) = v.x;
- VERTICES3(ix, iy, 3) = v.y;
- VERTICES3(ix, iy, 4) = v.z;
- ZPt t;
- if(flags & PAPERQUAD_CS2_TO_SCREEN) {
- t = coords2inv.transform(v);
- } else {
- t = coords2inv.transform(p);
- }
- VERTICES3(ix, iy, 0) = t.x;
- VERTICES3(ix, iy, 1) = t.y;
- DBG(dbg_paperquad) << " vert: " <<
- ix << " " <<
- iy << " : " <<
- VERTICES3(ix, iy, 0) << " " <<
- VERTICES3(ix, iy, 1) << " " <<
- VERTICES3(ix, iy, 2) << " " <<
- VERTICES3(ix, iy, 3) << " " <<
- VERTICES3(ix, iy, 4) << " " <<
- "\\n";
- }
- }
-
- if(flags & PAPERQUAD_USE_VERTEX_PROGRAM) {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- glInterleavedArrays(GL_T2F_V3F, 5*sizeof(float), vertices);
- glLockArraysEXT(0, dice*dice);
-
- for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); ++it) {
-
- DBG(dbg_paperquad) << "Pass\\n";
- GLERR;
- (*it).setUp_VP(&lightParam);
-
- DBG(dbg_paperquad) << "Going to multidraw\\n";
- GLERR;
- glMultiDrawElementsEXT(GL_QUAD_STRIP, counts,
- GL_UNSIGNED_INT, (const GLvoid **)indps, dice-1);
- DBG(dbg_paperquad) << "Teardown\\n";
- GLERR;
- (*it).tearDown_VP();
-
- GLERR;
- DBG(dbg_paperquad) << "Pass over\\n";
-
- }
- glUnlockArraysEXT();
- glPopClientAttrib();
- } else {
- for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); ++it) {
-
- DBG(dbg_paperquad) << "Pass\\n";
- GLERR;
- (*it).setUp_explicit(&lightParam);
-
- DBG(dbg_paperquad) << "Going to set texcoords explicit\\n";
- GLERR;
-
-
- for(int ix = 0; ix<dice-1; ix++) {
- glBegin(GL_QUAD_STRIP);
- for(int iy = 0; iy<dice; iy++) {
-
- float tmp[4] = { VERTICES3(ix, iy, 0), VERTICES3(ix, iy, 1), 0 ,1 };
- DBG(dbg_paperquad) << "to texcoords\\n";
- (*it).texcoords_explicit( tmp );
- DBG(dbg_paperquad) << "to vertex\\n";
- glVertex3fv( (&(VERTICES2(ix, iy))+2) );
-
- float tmp2[4] = { VERTICES3(ix+1, iy, 0), VERTICES3(ix+1, iy, 1), 0 ,1 };
- DBG(dbg_paperquad) << "to texcoords\\n";
- (*it).texcoords_explicit( tmp2 );
- DBG(dbg_paperquad) << "to vertex\\n";
- glVertex3fv( ((&VERTICES2(ix+1, iy))+2) );
- }
- DBG(dbg_paperquad) << "to end\\n";
- glEnd();
- }
-
-
- DBG(dbg_paperquad) << "Teardown\\n";
- GLERR;
- (*it).tearDown_explicit();
-
- GLERR;
- DBG(dbg_paperquad) << "Pass over\\n";
- }
- }
-
- DBG(dbg_paperquad) << "Passes over\\n";
-
- GLERR;
-
- delete [] vertices;
- delete [] indices;
-
- }
-*/
- }
-
}
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/LwjglRenderer.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/LwjglRenderer.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/LwjglRenderer.java 2006-04-03 20:05:03.302266242 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/LwjglRenderer.java 2006-04-03 19:39:39.000000000 +0300
@@ -17,6 +17,7 @@
import org.nongnu.libvob.gl.GLVobCoorder;
import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.BoxTransform;
import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.OrthoBoxTransform;
+import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.OrthoTransform;
import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.ScaleTransform;
import org.nongnu.libvob.gl.impl.lwjgl.trans.linear.TranslateTransform;
import org.nongnu.libvob.impl.lwjgl.LWJGL_VobMap;
@@ -60,6 +61,7 @@
case 7: return new TranslateTransform();
case 8: return new ScaleTransform();
case 12: return new BoxTransform();
+ case 16: return new OrthoTransform();
case 19: return new OrthoBoxTransform();
default:
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/Transform.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/Transform.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/Transform.java 2006-04-03 20:05:03.306265638 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/Transform.java 2006-04-03 19:39:39.000000000 +0300
@@ -6,7 +6,6 @@
-import java.io.OutputStream;
import java.io.PrintStream;
import org.lwjgl.util.vector.Vector2f;
@@ -39,6 +38,7 @@
* a color in the Vector3f always, without regard to the parameter.
*/
Vector3f transform(final Vector3f p);
+ Vector2f transform(final Vector2f p);
/**
* Call glVertex with the given Vector3f transformed into this
@@ -89,6 +89,8 @@
*/
Transform getInverse();
+ //void inverse(Transform toBeInversedTransform);
+
/**
* Print this coordinate system into the given ostream.
*/
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/paper/Paper.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/paper/Paper.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/paper/Paper.java 2006-04-03 20:05:03.295267301 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/paper/Paper.java 2006-04-03 19:39:39.000000000 +0300
@@ -27,13 +27,29 @@
* Written by Tuomas Lukka, ported to Java by Matti J. Katila
*/
package org.nongnu.libvob.gl.impl.lwjgl.paper;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import java.util.ArrayList;
+import org.lwjgl.BufferUtils;
+import org.lwjgl.opengl.ARBFragmentProgram;
+import org.lwjgl.opengl.ARBProgram;
+import org.lwjgl.opengl.ARBVertexProgram;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.NVFloatBuffer;
+import org.lwjgl.opengl.NVVertexProgram;
+import org.lwjgl.opengl.NVVertexProgram2Option;
+import org.lwjgl.opengl.NVVertexProgram3;
import org.lwjgl.util.vector.Matrix4f;
+import org.lwjgl.util.vector.Vector3f;
import org.nongnu.libvob.gl.GL;
import org.nongnu.libvob.gl.impl.lwjgl.CallGL;
import org.nongnu.libvob.gl.PaperMill;
+/** A class for rendering parts
+ * of infinite planes with affine mappings of texture coordinates.
+ */
/** The interface to the paper library.
* For all array-type things (X), there are the methods setNX, getNX
* and also some (possibly different, for using derived
@@ -63,13 +79,6 @@
public Pass getPass(int index) { return (Pass) passes.get(index); }
-
-
-
- /** The identififier to be passed to C for this object.
- */
- private int c_id;
-
/** Put all objects that manage displaylists and textures
* used by this paper here to ensure they don't get
* GCed before this.
@@ -86,63 +95,389 @@
depends.add(o);
}
+
+
+ /** Specifies texture coordinate system and
+ * the parameters of the diffuse light for
+ * lighting the backgrounds using bump mapping.
+ */
+ static public class LightParam {
+ /** Paper coordinate system basis vectors and origin in object
+ * coordinates.
+ * Paper coordinates x, y, (and z) are mapped to
+ * object position (orig + x e0 + y e1 + z e2).
+ * For the eye-linear TexGens, the basis and origin vectors
+ * are transformed
+ * to eye coordinates using the modelview matrix in effect
+ * at the time the
+ * TexGen::setUp method is called.
+ * Thus, after setup, the user can switch to a different coordinate
+ * system for drawing the paper vertices.
+ * e0, e1, and e2 should be orthogonal and the same length. */
+ public Vector3f e0, e1, e2, orig;
+
+ /** Light position in object coordinates.
+ * Light position should be given in the same coordinate system as
+ * the basis vectors above. */
+ public Vector3f Light;
+
+ /** Light position w component.
+ * Basically, Light_w should be 1.0 for finite light and
+ * 0.0 for infinite light */
+ public float Light_w;
+
+ /** Light color */
+ public float color[];
+ };
+
+
+
+
+
+
+
+
+
/** A class representing a single rendering pass
* of a paper.
* A pass contains the two CallGL codes Setupcode and Teardowncode,
* and the following arrays:
* IndirectTextureBinds, TexGens, LightSetups.
*/
+ /** A single rendering pass.
+ * The data members are public to allow modification,
+ * but when using a ready-made PaperPass, _choose one_
+ * (and only one) of the following ways to use it:
+ *
+ * 1) using texgen
+ * - call setUp_texgen() with LightParam to use
+ * - call glVertex*() directly from the context
+ * - teardown_texgen()
+ *
+ * 2) using a vertex program
+ * - call setUp_VP with LightParam to use
+ * - call glTexCoord*() and glVertex*() directly from
+ * the context _or_ call vertex_VP() with position
+ * within the paper in array of 4 floats
+ * - call teardown_VP()
+ *
+ * 3) using explicit coordinates
+ * - call setUp_explicit with LightParam to use
+ * - call texcoords_explicit() with paper coordinates in
+ * arrays of 4 floats and call glVertex*() directly
+ * from the context.
+ * - call teardown_explicit()
+ */
public class Pass {
+
+ /** (internal): an abstract base class
+ * for objects used to set up
+ * the texture blending using the light parameters.
+ */
+ abstract class LightSetup {
+ public abstract void setUp(LightParam param);
+ };
+
+
+
/** Simple, non-lighting-dependent TexGen.
* Transforms paper coordinates into texture coordinates using
* the given matrix.
*/
class TexGen {
- Matrix4f tex_mat = new Matrix4f();
- public void putNormalTexGen(float[] matrix) {
-// this->tex_mat[0] = tex_mat[0];
-// this->tex_mat[1] = tex_mat[1];
-// this->tex_mat[2] = tex_mat[2];
-// this->tex_mat[3] = tex_mat[3];
+
+ /** The matrix that maps v[TEX0] into o[TEXi] is stored
+ * starting at c[tex_addr_base + 4*i].
+ */
+ static protected final int textAddressBase = 60;
+
+ protected Matrix4f tex_mat = new Matrix4f();
+
+ /** Pointer to current translation matrix used in
+ * texcoords_explicit().
+ */
+ Matrix4f explicit_mat = new Matrix4f();
+
+
+ /** Creates a new TexGen.
+ * @param tex_mat A float vector of 12 elements,
+ * components of s, t and r vectors, respectively.
+ */
+ TexGen(float [] matrix)
+ {
tex_mat.m00 = matrix[0];
- tex_mat.m01 = matrix[1];
- tex_mat.m02 = matrix[2];
- tex_mat.m03 = matrix[3];
-
-// this->tex_mat[4] = tex_mat[4];
-// this->tex_mat[5] = tex_mat[5];
-// this->tex_mat[6] = tex_mat[6];
-// this->tex_mat[7] = tex_mat[7];
- tex_mat.m10 = matrix[4];
+ tex_mat.m10 = matrix[1];
+ tex_mat.m20 = matrix[2];
+ tex_mat.m30 = matrix[3];
+
+ tex_mat.m01 = matrix[4];
tex_mat.m11 = matrix[5];
- tex_mat.m12 = matrix[6];
- tex_mat.m13 = matrix[7];
+ tex_mat.m21 = matrix[6];
+ tex_mat.m31 = matrix[7];
-// this->tex_mat[8] = tex_mat[8];
-// this->tex_mat[9] = tex_mat[9];
-// this->tex_mat[10] = tex_mat[10];
-// this->tex_mat[11] = tex_mat[11];
- tex_mat.m20 = matrix[8];
- tex_mat.m21 = matrix[9];
+ tex_mat.m02 = matrix[8];
+ tex_mat.m12 = matrix[9];
tex_mat.m22 = matrix[10];
- tex_mat.m23 = matrix[11];
+ tex_mat.m32 = matrix[11];
-// this->tex_mat[12] = 0;
-// this->tex_mat[13] = 0;
-// this->tex_mat[14] = 0;
-// this->tex_mat[15] = 1;
- tex_mat.m30 = 0;
- tex_mat.m31 = 0;
- tex_mat.m32 = 0;
+ tex_mat.m03 = 0;
+ tex_mat.m13 = 0;
+ tex_mat.m23 = 0;
tex_mat.m33 = 1f;
}
+
+ /** Matrix used to transform paper position into texture coordinates. */
+ // XXX: Currently the last four values are always initialized to 0,0,0,1
+ public String getVPCode(int unit) {
+ StringBuffer b = new StringBuffer();
+ int base = unit * 4 + textAddressBase;
+
+ b.append("DP4 o[TEX");
+ b.append(unit);
+ b.append("].x, c[");
+ b.append(base + 0);
+ b.append("], v[TEX0];\n");
+
+ b.append("DP4 o[TEX");
+ b.append(unit);
+ b.append("].y, c[");
+ b.append(base + 1);
+ b.append("], v[TEX0];\n");
+
+ b.append("DP4 o[TEX");
+ b.append(unit);
+ b.append("].z, c[");
+ b.append(base + 2);
+ b.append("], v[TEX0];\n");
+
+ b.append("DP4 o[TEX");
+ b.append(unit);
+ b.append("].w, c[");
+ b.append(base + 3);
+ b.append("], v[TEX0];\n");
+ return b.toString();
+ }
+
+ public void setUp_VP(int unit, LightParam param) {
+ // XXX: This could also be implemented as CallGL code
+ int base = unit * 4 + textAddressBase;
+ NVVertexProgram.glProgramParameter4fNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 0, tex_mat.m00, tex_mat.m10, tex_mat.m20, tex_mat.m30);
+ NVVertexProgram.glProgramParameter4fNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 1, tex_mat.m01, tex_mat.m11, tex_mat.m21, tex_mat.m31);
+ NVVertexProgram.glProgramParameter4fNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 2, tex_mat.m02, tex_mat.m12, tex_mat.m22, tex_mat.m32);
+ NVVertexProgram.glProgramParameter4fNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 3, tex_mat.m03, tex_mat.m13, tex_mat.m23, tex_mat.m33);
+ }
+
+ public void setUp_explicit(LightParam param) {
+ explicit_mat.load(tex_mat);
+ }
+
+ public void setUp_texgen(LightParam param) {
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+
+ float[] _mat = { param.e0.x, param.e0.y, param.e0.z, 0,
+ param.e1.x, param.e1.y, param.e1.z, 0,
+ param.e2.x, param.e2.y, param.e2.z, 0,
+ param.orig.x, param.orig.y, param.orig.z, 1 };
+ FloatBuffer mat = BufferUtils.createFloatBuffer(16);
+ mat.put(_mat);
+ mat.flip();
+ GL11.glMultMatrix(mat);
+
+ FloatBuffer m0 = BufferUtils.createFloatBuffer(4);
+ m0.put(tex_mat.m00);
+ m0.put(tex_mat.m10);
+ m0.put(tex_mat.m20);
+ m0.put(tex_mat.m30);
+ m0.flip();
+
+ FloatBuffer m1 = BufferUtils.createFloatBuffer(4);
+ m1.put(tex_mat.m01);
+ m1.put(tex_mat.m11);
+ m1.put(tex_mat.m21);
+ m1.put(tex_mat.m31);
+ m1.flip();
+
+ FloatBuffer m2 = BufferUtils.createFloatBuffer(4);
+ m2.put(tex_mat.m02);
+ m2.put(tex_mat.m12);
+ m2.put(tex_mat.m22);
+ m2.put(tex_mat.m32);
+ m2.flip();
+
+
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glTexGenf(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
+ GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, m0);
+ GL11.glTexGenf(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
+ GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, m1);
+ GL11.glTexGenf(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
+ GL11.glTexGen(GL11.GL_R, GL11.GL_EYE_PLANE, m2);
+ GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
+ GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
+ GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
+ GL11.glPopMatrix();
+ }
+ }
+
+ /** TexGen for embossing.
+ * Shifts the texture towards the light by an amount proportional to eps.
+ * Take the difference of the filtered values generated by two emboss
+ * texgens using the same texture with +eps and -eps parameters
+ * to obtain an approximation of the diffuse dot product.
+ */
+ class TexGenEmboss extends TexGen {
+
+ /** Amount to shift the texture towards the light. */
+ protected float eps;
+
+ /** When embossing (depends of LightParam), texcoords_explicit() needs
+ * a different matrix to transform paper position into embossed
+ * texture coordinates.
+ */
+ //float explicit_tmp_mat[16];
+
+
+ /** Creates a new TexGen for embossing.
+ * @param tex_mat A float vector of 12 elements,
+ * components of s, t and r vectors, respectively.
+ * @param eps mount to shift the texture towrds the light
+ */
+ TexGenEmboss(float[] matrix, float eps) {
+ super(matrix);
+ this.eps = eps;
+ }
+
+ public void setUp_VP(int unit, LightParam param) {
+ /** Suppose
+ * x = vertex position
+ * p = paper coordinates
+ * s = texture coordinates
+ * A = paper-to-vertex mapping
+ * E = embossing mapping (translates x towards light)
+ * M = modelview matrix
+ * T = texture matrix
+ *
+ * The usual eye-linear embossing texgen computes
+ * s' = Tp' = T((MEA)^-1 M x) = T(A^-1 E^-1 x)
+ * The usual simple texgen computes
+ * s = Tp = T((MA)^-1 M x) = T(A^-1 x) ==> x = Ap
+ * Thus, the mapping from p to s' is
+ * s' = Tp' = T(A^-1 E^-1 x) = T A^-1 E^-1 A p
+ *
+ * The following code computes T A^-1 E^-1 A and stores it
+ * in place of T in the constant registers.
+ */
+
+ int base = unit * 4 + textAddressBase;
+
+ GL11.glMatrixMode(NVVertexProgram.GL_MATRIX0_NV);
+ GL11.glLoadIdentity();
+
+ Vector3f tmp = new Vector3f(param.orig.x, param.orig.y, param.orig.z);
+ tmp.scale(param.Light_w);
+
+ float eps = this.eps * Vector3f.dot(param.e2, param.e2) / Vector3f.dot(Vector3f.sub(param.Light, tmp, tmp), param.e2);
+
+ GL11.glTranslatef(eps * param.Light.x, eps * param.Light.y, eps * param.Light.z);
+ float s = 1 - param.Light_w * eps;
+ GL11.glScalef(s, s, s);
+
+ float[] _mat = { param.e0.x, param.e0.y, param.e0.z, 0,
+ param.e1.x, param.e1.y, param.e1.z, 0,
+ param.e2.x, param.e2.y, param.e2.z, 0,
+ param.orig.x, param.orig.y, param.orig.z, 1 };
+ FloatBuffer mat = BufferUtils.createFloatBuffer(16);
+ mat.put(_mat);
+ mat.flip();
+ GL11.glMultMatrix(mat);
+
+ // Hack for easily inverting the matrix
+ NVVertexProgram.glTrackMatrixNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base, NVVertexProgram.GL_MATRIX0_NV, NVVertexProgram.GL_INVERSE_NV);
+ NVVertexProgram.glTrackMatrixNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base, GL11.GL_NONE, NVVertexProgram.GL_INVERSE_NV);
+ FloatBuffer foo = BufferUtils.createFloatBuffer(16);
+ NVVertexProgram.glGetProgramParameterNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 0, NVVertexProgram.GL_PROGRAM_PARAMETER_NV, foo);
+ NVVertexProgram.glGetProgramParameterNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 1,
+ NVVertexProgram.GL_PROGRAM_PARAMETER_NV, foo);
+ NVVertexProgram.glGetProgramParameterNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 2,
+ NVVertexProgram.GL_PROGRAM_PARAMETER_NV, foo);
+ NVVertexProgram.glGetProgramParameterNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base + 3,
+ NVVertexProgram.GL_PROGRAM_PARAMETER_NV, foo);
+
+ FloatBuffer tex_mat_ = BufferUtils.createFloatBuffer(16);
+ tex_mat.store(tex_mat_);
+ tex_mat_.flip();
+ GL11.glLoadMatrix(tex_mat_);
+
+ GL11.glMultMatrix(foo);
+
+ GL11.glMultMatrix(mat);
+
+
+ // Load the current matrix in c[base:base+4]
+ NVVertexProgram.glTrackMatrixNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base, NVVertexProgram.GL_MATRIX0_NV, NVVertexProgram.GL_IDENTITY_NV);
+ NVVertexProgram.glTrackMatrixNV(NVVertexProgram.GL_VERTEX_PROGRAM_NV, base, GL11.GL_NONE, NVVertexProgram.GL_IDENTITY_NV);
+
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ }
+
+ public void setUp_texgen(LightParam param) {
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+
+ Vector3f tmp = new Vector3f(param.orig.x, param.orig.y, param.orig.z);
+ tmp.scale(param.Light_w);
+
+ float eps = this.eps * Vector3f.dot(param.e2, param.e2) / Vector3f.dot(Vector3f.sub(param.Light, tmp, tmp), param.e2);
+
+ GL11.glTranslatef(eps * param.Light.x, eps * param.Light.y, eps * param.Light.z);
+ float s = 1 - param.Light_w * eps;
+ GL11.glScalef(s, s, s);
+
+ float[] _mat = { param.e0.x, param.e0.y, param.e0.z, 0,
+ param.e1.x, param.e1.y, param.e1.z, 0,
+ param.e2.x, param.e2.y, param.e2.z, 0,
+ param.orig.x, param.orig.y, param.orig.z, 1 };
+ FloatBuffer mat = BufferUtils.createFloatBuffer(16);
+ mat.put(_mat);
+ mat.flip();
+ GL11.glMultMatrix(mat);
+
+ FloatBuffer m0 = BufferUtils.createFloatBuffer(4);
+ m0.put(tex_mat.m00);
+ m0.put(tex_mat.m10);
+ m0.put(tex_mat.m20);
+ m0.put(tex_mat.m30);
+ m0.flip();
+
+ FloatBuffer m1 = BufferUtils.createFloatBuffer(4);
+ m1.put(tex_mat.m01);
+ m1.put(tex_mat.m11);
+ m1.put(tex_mat.m21);
+ m1.put(tex_mat.m31);
+ m1.flip();
+
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glTexGenf(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
+ GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, m0);
+ GL11.glTexGenf(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
+ GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, m1);
+ GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
+ GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
+ GL11.glPopMatrix();
+ }
+ public void setUp_explicit(LightParam param) {
+ System.out.println("WARNING: no setup explicit implemented.");
+ }
}
+ protected ARB_VertexProgram texgenvp;
private int index;
+
private Pass(int index) { this.index = index; }
// public void setNIndirectTextureBinds(int n) { impl_Pass_setNIndirectTextureBinds(c_id, index, n); }
@@ -155,32 +490,50 @@
public void setNTexGens(int n) {
texGens.ensureCapacity(n);
while (texGens.size() < n)
- texGens.add(new TexGen());
+ texGens.add(null);
}
-//
-// public int getNLightSetups() { return impl_Pass_getNLightSetups(c_id, index); }
-// public void setNLightSetups(int n) { impl_Pass_setNLightSetups(c_id, index, n); }
-//
+
+ ArrayList setupCodes = new ArrayList();
+ public int getNLightSetup() { return setupCodes.size(); }
+ public void setNLightSetup(int n) {
+ setupCodes.ensureCapacity(n);
+ while (setupCodes.size() < n)
+ setupCodes.add(new LightSetup(){
+ public void setUp(LightParam param) {
+ // TODO Auto-generated method stub
+ }
+ });
+ }
+
String setupCode = null, tearDownCode = null;
+ CallGL setupCodeGl = null, tearDownCodeGl = null;
public void setSetupcode(String code) {
- //CallGL.call(code);
+ //p("setup: "+code);
this.setupCode = code;
+ this.setupCodeGl = new CallGL(code);
}
public String getSetupcode() { return setupCode; }
public void setTeardowncode(String code) {
+ //p("teardown: "+code);
this.tearDownCode = code;
+ this.tearDownCodeGl = new CallGL(code);
}
public String getTeardowncode() { return tearDownCode; }
+ /** Explicit version of the PaperPass texcoords.
+ */
+ public void texcoords_explicit(float []ppos) { }
+
+ public void tearDown_explicit() {
+ throw new Error("un impl.");
+ }
public void putNormalTexGen(int ind, float[] matrix) {
- ((TexGen)texGens.get(ind)).putNormalTexGen(matrix);
+ texGens.set(ind, new TexGen(matrix));
+ }
+ public void putEmbossTexGen(int ind, float[] matrix, float eps) {
+ texGens.set(ind, new TexGenEmboss(matrix, eps));
}
-// public void putEmbossTexGen(int ind, float[] matrix, float eps) {
-// if(ind < 0 || ind >= getNTexGens())
-// throw new ArrayIndexOutOfBoundsException();
-// impl_Pass_putEmbossTexGen(c_id, index, ind, matrix, eps);
-// }
/** Put an instruction to bind an indirect texture
* for this pass.
@@ -198,6 +551,8 @@
public void putIndirectTextureBind(int ind,
String activeTexture, String textureTarget,
GL.IndirectTexture indirectTexture) {
+ System.out.println("put indirect text: "+ind+", "+activeTexture+", "+textureTarget+", "+indirectTexture);
+
// if(ind < 0 || ind >= getNIndirectTextureBinds())
// throw new ArrayIndexOutOfBoundsException(ind);
addDepend(indirectTexture);
@@ -206,14 +561,91 @@
// indirectTexture.getIndirectTextureId());
}
- /** Add an object on whose C++ representation this paper
- * depends. For instance, if one of the setup codes uses
- * a texture id of a given GL.Texture object, then that
- * object should be added here.
+
+
+
+ /** Generates and loads the texgen vertex program.
+ * This is automatically called on first setUp_VP
+ * unless it's already loaded.
*/
- public void addDepend(Object o) {
- Paper.this.addDepend(o);
+ private void loadVP() {
+ String code =
+ "!!VP1.1 OPTION NV_position_invariant;\n" +
+ "MOV o[COL0], v[COL0];\n" +
+ "MOV o[COL1], v[COL1];\n";
+
+ int unit = 0;
+ for (int i =0; i < texGens.size(); i++) {
+ if (texGens.get(i) != null)
+ code += ((TexGen)texGens.get(i)).getVPCode(unit);
+ else
+ p("Warning: ignoring null TexGen");
+ unit++;
+ }
+
+ code += "END\n";
+
+ //p("Creating VPCode with the source: "+code);
+ //std::cerr << "Creating VPCode with the source " << code << "\n";
+
+
+ texgenvp = new ARB_VertexProgram(code);
+ }
+
+ /** Call setupcode and indirect texture binds.
+ */
+ protected void independentSetup() {
+ setupCodeGl.call();
+ }
+
+ /** Call teardown and indirect texture binds.
+ */
+ protected void independentTeardown() {
+ tearDownCodeGl.call();
+ }
+
+
+
+
+ private void p(String s) {
+ System.out.println("PaperPass:: "+s);
+ }
+ public void setUp_VP(LightParam param) {
+
+ if (texgenvp == null) loadVP();
+
+ independentSetup();
+
+ /* Set up VP TexGen parameters for each texture unit */
+ int unit = 0;
+ for (int it = 0; it < texGens.size(); ++it) {
+ if (texGens.get(it) != null) ((TexGen)texGens.get(it)).setUp_VP(unit, param);
+ else p("Warning: ignoring null TexGen");
+ unit++;
+ }
+
+ /* Do general parametric setup */
+ for (int it = 0; it < setupCodes.size(); ++it) {
+ if (setupCodes.get(it) != null) ((LightSetup)setupCodes.get(0)).setUp(param);
+ else p("Warning: ignoring null LightSetup");
+ }
+
+ texgenvp.bind(); // Bind vertex program
+
+ GL11.glEnable(NVVertexProgram.GL_VERTEX_PROGRAM_NV);
+
+ }
+ public void tearDown_VP() {
+ independentTeardown();
+ GL11.glDisable(NVVertexProgram.GL_VERTEX_PROGRAM_NV);
}
+
+
+ public void setUp_explicit(LightParam lightParam) {
+ throw new Error("un impl.");
+ }
+
+
}
// public int getNPasses() { return impl_getNPasses(c_id); }
@@ -239,7 +671,92 @@
// c_id = impl_create();
}
- public int getId() { return c_id; }
+ public int getId() { return 0; }
+
+ public int getPassCount() {
+ return passes.size();
+ }
+
+ /** A simple automatic NVIDIA program id object.
+ * Allocates a new program name when created
+ * and deletes the name when destroyed.
+ * No assignment or copying is allowed;
+ * use shared_ptr<NVProgID> for proper value semantics.
+ */
+ static public class ProgID {
+ public final IntBuffer id = BufferUtils.createIntBuffer(1);
+ public ProgID() {
+ ARBProgram.glGenProgramsARB(id);
+ }
+ protected void finalize() throws Throwable {
+ super.finalize();
+ ARBProgram.glDeleteProgramsARB(id);
+ }
+ };
+
+
+ /** An instance of a GL program (e.g. vertex or fragment program)
+ * loaded into the driver.
+ * The Program objects are immutable with value semantics.
+ * Example:
+ * NVProg<GL_VERTEX_PROGRAM_NV> code("!!VP1.0 MOV o[HPOS],v[OPOS];END");
+ */
+ //template <GLuint TARGET>
+ static public class Program {
+ protected ProgID progId = new ProgID();
+ protected String source;
+ protected ByteBuffer codeBuffer;
+ protected int TYPE;
+ protected Program(int TYPE, String source) {
+ this.TYPE = TYPE;
+ byte[] codeBytes = source.getBytes();
+ codeBuffer = BufferUtils.createByteBuffer(codeBytes.length);
+ codeBuffer.put(codeBytes);
+ codeBuffer.flip();
+ compile();
+ }
+ public String getSource() { return source; }
+
+ public IntBuffer getProgId() { return progId.id; }
+
+ public void bind() {
+ NVVertexProgram.glBindProgramNV(TYPE, getProgId().get(0));
+ }
+
+ public void operator(FloatBuffer params) {
+ NVVertexProgram.glExecuteProgramNV(TYPE, getProgId().get(0), params);
+ }
+
+ protected void compile() {
+ NVVertexProgram.glLoadProgramNV(TYPE, getProgId().get(0), codeBuffer);
+ }
+ };
+
+ static public class ARB_VertexProgram extends Program {
+ public ARB_VertexProgram(String src)
+ {
+ super(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, src);
+ }
+ }
+ static public class NV_VertexProgram extends Program {
+ public NV_VertexProgram(String src)
+ {
+ super(NVVertexProgram.GL_VERTEX_PROGRAM_NV,src);
+ }
+ }
+ static public class NV_VertexStateProgram extends Program {
+ public NV_VertexStateProgram(String src)
+ {
+ super(NVVertexProgram.GL_VERTEX_STATE_PROGRAM_NV,src);
+ }
+ }
+ static public class FragmentProgram extends Program {
+ public FragmentProgram(String src)
+ {
+ super(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB,src);
+ }
+ }
+
}
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/texture/NamedTexture.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/texture/NamedTexture.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/texture/NamedTexture.java 2006-04-03 20:05:03.303266091 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/texture/NamedTexture.java 2006-04-03 19:39:39.000000000 +0300
@@ -17,7 +17,7 @@
// if (strcmp(type, "circle") == 0) return new circle;
// if (strcmp(type, "coordinates") == 0) return new coordinates;
// if (strcmp(type, "filereader") == 0) return new filereader;
-// if (strcmp(type, "fnoise") == 0) return new fnoise;
+ if (name.equals("fnoise")) return new FNoiseTex(); //fnoise;
if (name.equals("geometric")) return new GeometricTex(); //param, w,h,d,comps, data);
// if (strcmp(type, "irregu") == 0) return new irregu;
// if (strcmp(type, "irreguedge") == 0) return new irreguedge;
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/texture/TextureParam.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/texture/TextureParam.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/texture/TextureParam.java 2006-04-03 20:05:03.304265940 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/texture/TextureParam.java 2006-04-03 19:39:39.000000000 +0300
@@ -19,4 +19,10 @@
else return ((Float)get(key)).floatValue();
}
+ public long getLong(String key, int i) {
+ if (!containsKey(key))
+ return i;
+ else return ((Float)get(key)).longValue();
+ }
+
}
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/BoxTransform.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/BoxTransform.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/BoxTransform.java 2006-04-03 20:05:03.296267150 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/BoxTransform.java 2006-04-03 19:39:39.000000000 +0300
@@ -14,19 +14,22 @@
public class BoxTransform implements Transform {
+ private Coorder coorder;
+ private int TYPE;
private Transform parent;
private float z,x,y,w,h;
public void setYourself(Coorder base, int index, int[] inds, float[] floats) {
// System.out.println("box");
-
+ this.coorder = base;
int floatInd = inds[index+2];
int parentCS = inds[index+1];
- parent = base.getTransform(parentCS);
+ TYPE = inds[index];
+ parent = coorder.getTransform(parentCS);
z = floats[floatInd];
x = floats[floatInd+1];
y = floats[floatInd+2];
- w = floats[floatInd+5];
- h = floats[floatInd+6];
+ w = floats[floatInd+3];
+ h = floats[floatInd+4];
}
@@ -35,7 +38,17 @@
}
public Vector3f transform(Vector3f p) {
- return null;
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ p.z += z;
+ return p;
+ }
+ public Vector2f transform(Vector2f p) {
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ return p;
}
public void vertex(Vector3f p) {
@@ -61,7 +74,14 @@
}
public Transform getInverse() {
- return null;
+ BoxTransform inv = (BoxTransform) coorder.createTransform(TYPE);
+ inv.x = -x;
+ inv.y = -y;
+ inv.z = -z;
+ inv.w = -w;
+ inv.h = -h;
+ inv.parent = parent.getInverse();
+ return inv;
}
public void dump(PrintStream out) {
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/OrthoBoxTransform.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/OrthoBoxTransform.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/OrthoBoxTransform.java 2006-04-03 20:05:03.298266847 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/OrthoBoxTransform.java 2006-04-03 19:39:39.000000000 +0300
@@ -14,10 +14,14 @@
public class OrthoBoxTransform implements Transform {
+ private Coorder coorder;
+ private int TYPE;
private Transform parent;
private float z,x,y,xs,ys,w,h;
public void setYourself(Coorder base, int index, int[] inds, float[] floats) {
// System.out.println("orthobox");
+ this.coorder = base;
+ this.TYPE = inds[index];
int floatInd = inds[index+2];
int parentCS = inds[index+1];
@@ -36,7 +40,21 @@
}
public Vector3f transform(Vector3f p) {
- return null;
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ p.z += z;
+ p.x *= xs;
+ p.y *= ys;
+ return p;
+ }
+ public Vector2f transform(Vector2f p) {
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ p.x *= xs;
+ p.y *= ys;
+ return p;
}
public void vertex(Vector3f p) {
@@ -55,16 +73,25 @@
}
public boolean performGL() {
- parent.performGL();
+ boolean ret = parent.performGL();
// System.out.println("trans "+x+", "+y+", "+z);
// System.out.println("scale "+xs+", "+ys);
GL11.glTranslatef(x,y,z);
- GL11.glScalef(xs,ys,0);
- return true;
+ GL11.glScalef(xs,ys,1f);
+ return ret;
}
public Transform getInverse() {
- return null;
+ OrthoBoxTransform inv = (OrthoBoxTransform) coorder.createTransform(TYPE);
+ inv.x = -x;
+ inv.y = -y;
+ inv.z = -z;
+ inv.xs = 1f/xs;
+ inv.ys = 1f/xs;
+ inv.w = -w;
+ inv.h = -h;
+ inv.parent = parent.getInverse();
+ return inv;
}
public void dump(PrintStream out) {
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/ScaleTransform.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/ScaleTransform.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/ScaleTransform.java 2006-04-03 20:05:03.299266696 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/ScaleTransform.java 2006-04-03 19:39:39.000000000 +0300
@@ -15,11 +15,15 @@
public class ScaleTransform implements Transform {
private Transform parent;
+ private Coorder coorder;
+ int TYPE;
private float xs, ys, zs;
public void setYourself(Coorder base, int index, int[] inds, float[] floats) {
// System.out.println("scale");
int floatInd = inds[index+2];
int parentCS = inds[index+1];
+ this.coorder = base;
+ this.TYPE = inds[index];
parent = base.getTransform(parentCS);
xs = floats[floatInd];
ys = floats[floatInd+1];
@@ -31,8 +35,17 @@
}
public Vector3f transform(Vector3f p) {
- // TODO Auto-generated method stub
- return null;
+ p = parent.transform(p);
+ p.x *= xs;
+ p.y *= ys;
+ p.z *= zs;
+ return p;
+ }
+ public Vector2f transform(Vector2f p) {
+ p = parent.transform(p);
+ p.x *= xs;
+ p.y *= ys;
+ return p;
}
public void vertex(Vector3f p) {
@@ -58,7 +71,12 @@
}
public Transform getInverse() {
- return null;
+ ScaleTransform inverse = (ScaleTransform) coorder.createTransform(TYPE);
+ inverse.xs = 1f/xs;
+ inverse.ys = 1f/ys;
+ inverse.zs = 1f/zs;
+ inverse.parent = parent.getInverse();
+ return inverse;
}
public void dump(PrintStream out) {
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/TranslateTransform.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/TranslateTransform.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/TranslateTransform.java 2006-04-03 20:05:03.297266998 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/trans/linear/TranslateTransform.java 2006-04-03 19:39:39.000000000 +0300
@@ -14,10 +14,16 @@
public class TranslateTransform implements Transform {
+ private Coorder coorder;
+ private int TYPE;
private Transform parent;
private float x=0, y=0, z=0;
public void setYourself(Coorder base, int index, int[] inds, float[] floats) {
// System.out.println("translate");
+
+ this.coorder = base;
+ this.TYPE = inds[index];
+
int floatInd = inds[index+2];
int parentCS = inds[index+1];
parent = base.getTransform(parentCS);
@@ -31,7 +37,17 @@
}
public Vector3f transform(Vector3f p) {
- return null;
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ p.z += z;
+ return p;
+ }
+ public Vector2f transform(Vector2f p) {
+ p = parent.transform(p);
+ p.x += x;
+ p.y += y;
+ return p;
}
public void vertex(Vector3f p) {
@@ -57,7 +73,12 @@
}
public Transform getInverse() {
- return null;
+ TranslateTransform inv = (TranslateTransform) coorder.createTransform(TYPE);
+ inv.x = -x;
+ inv.y = -y;
+ inv.z = -z;
+ inv.parent = parent.getInverse();
+ return inv;
}
public void dump(PrintStream out) {
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/lwjgl/vobs/trivial/NonFilledRectangleVob.java libvob-new/org/nongnu/libvob/gl/impl/lwjgl/vobs/trivial/NonFilledRectangleVob.java
--- libvob-old/org/nongnu/libvob/gl/impl/lwjgl/vobs/trivial/NonFilledRectangleVob.java 2006-04-03 20:05:03.293267603 +0300
+++ libvob-new/org/nongnu/libvob/gl/impl/lwjgl/vobs/trivial/NonFilledRectangleVob.java 2006-04-03 19:39:39.000000000 +0300
@@ -48,7 +48,7 @@
GL11.glDisable(GL11.GL_TEXTURE_2D);
Vector2f box = t.getSqSize();
-
+ System.out.println("box: "+box);
GL11.glColor4d(r1, g1, b1, a1);
// top strip
More information about the Fencommits
mailing list