gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob ctest/test.cxx include/vob/Coorder.hxx i...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob ctest/test.cxx include/vob/Coorder.hxx i...
Date: Tue, 01 Apr 2003 06:03:55 -0500

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/01 06:03:54

Modified files:
        ctest          : test.cxx 
        include/vob    : Coorder.hxx Vec23.hxx 
        include/vob/jni: Generate.hxx 
        include/vob/vobs: Paper.hxx 
        src/jni        : Makefile jnivobs.hxx 
        src/main       : Renderer.cxx 
        src/paper      : Paper.cxx 
Added files:
        include/vob/poly: Dicer.hxx 
        include/vob/trans: DisablablePrimitives.hxx 
                           FisheyePrimitives.hxx 
                           FunctionalPrimitives.hxx LinearPrimitives.hxx 
                           Primitives.hxx 
Removed files:
        include/vob    : DisablablePrimitives.hxx FisheyePrimitives.hxx 
                         FunctionalPrimitives.hxx LinearPrimitives.hxx 
                         Primitives.hxx 

Log message:
        Flexible dicing testing; reorg primitives

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/ctest/test.cxx.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Coorder.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Vec23.hxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Generate.hxx.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/poly/Dicer.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/DisablablePrimitives.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/FisheyePrimitives.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/FunctionalPrimitives.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/LinearPrimitives.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/Primitives.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Paper.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Makefile.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/jnivobs.hxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/main/Renderer.cxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/paper/Paper.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: libvob/ctest/test.cxx
diff -u libvob/ctest/test.cxx:1.5 libvob/ctest/test.cxx:1.6
--- libvob/ctest/test.cxx:1.5   Mon Mar 10 11:02:04 2003
+++ libvob/ctest/test.cxx       Tue Apr  1 06:03:54 2003
@@ -28,8 +28,8 @@
 #include <boost/test/floating_point_comparison.hpp>
 
 #include "vob/Transform.hxx"
-#include "vob/Primitives.hxx"
-#include "vob/LinearPrimitives.hxx"
+#include "vob/trans/Primitives.hxx"
+#include "vob/trans/LinearPrimitives.hxx"
 
 using namespace Vob::Primitives;
 using namespace Vob;
Index: libvob/include/vob/Coorder.hxx
diff -u libvob/include/vob/Coorder.hxx:1.3 libvob/include/vob/Coorder.hxx:1.4
--- libvob/include/vob/Coorder.hxx:1.3  Wed Mar 12 08:37:57 2003
+++ libvob/include/vob/Coorder.hxx      Tue Apr  1 06:03:54 2003
@@ -5,7 +5,7 @@
 
 #include <vector>
 #include <vob/Transform.hxx>
-#include <vob/Primitives.hxx>
+#include <vob/trans/Primitives.hxx>
 
 namespace Vob {
 
Index: libvob/include/vob/Vec23.hxx
diff -u libvob/include/vob/Vec23.hxx:1.4 libvob/include/vob/Vec23.hxx:1.5
--- libvob/include/vob/Vec23.hxx:1.4    Sun Mar 23 15:15:58 2003
+++ libvob/include/vob/Vec23.hxx        Tue Apr  1 06:03:54 2003
@@ -178,6 +178,9 @@
        /** Length of this vector.
         */
        double length() const { return hypot(hypot(x, y), z); }
+       /** Length of this vector in xy plane.
+        */
+       double xylength() const { return hypot(x, y); }
        /** Cross-product with another vector.
         */
        Vector3 crossp(const Vector3<T> &v) const {
Index: libvob/include/vob/jni/Generate.hxx
diff -u libvob/include/vob/jni/Generate.hxx:1.17 
libvob/include/vob/jni/Generate.hxx:1.18
--- libvob/include/vob/jni/Generate.hxx:1.17    Thu Mar 27 06:11:24 2003
+++ libvob/include/vob/jni/Generate.hxx Tue Apr  1 06:03:54 2003
@@ -50,7 +50,7 @@
 #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
 #include <boost/preprocessor/iteration/local.hpp>
 
-#include <vob/Primitives.hxx>
+#include <vob/trans/Primitives.hxx>
 #include <vob/Transform.hxx>
 
 #include <vob/jni/Types.hxx>
Index: libvob/include/vob/vobs/Paper.hxx
diff -u libvob/include/vob/vobs/Paper.hxx:1.1 
libvob/include/vob/vobs/Paper.hxx:1.2
--- libvob/include/vob/vobs/Paper.hxx:1.1       Wed Mar 26 09:40:21 2003
+++ libvob/include/vob/vobs/Paper.hxx   Tue Apr  1 06:03:54 2003
@@ -7,19 +7,128 @@
 #define VOB_DEFINED(x)
 #endif
 
+#include <boost/lambda/bind.hpp>
+
+#include <algorithm>
+
+#include <ext/slist>
+
 #include <vob/glerr.hxx>
 #include <vob/Debug.hxx>
 #include <vob/Transform.hxx>
 
 #include <vob/paper/Paper.hxx>
 
+#include <vob/VecGL.hxx>
+
+#include <vob/poly/Dicer.hxx>
+
 namespace Vob {
 namespace Vobs {
 
 PREDBGVAR(dbg_paperquad);
 
+class DiceTester {
+public:
+    enum { NTrans = 1 };
+
+    float dicelen;
+    int flags;
+    int maxdepth;
+
+    template<class F> void params(F &f) {
+       f(dicelen, flags, maxdepth);
+    }
+
+    struct Verts {
+       const Transform &t;
+       Verts(const Transform &t) : t(t) { }
+       vector<ZPt> finalPoints;
+       vector<Pt> points;
+
+       float dicelen;
+
+       int append(Pt p) {
+           DBG(dbg_paperquad) << "DiceTester append "<<p<<"\n";
+           int ind = points.size();
+           points.push_back(p);
+           finalPoints.push_back(t.transform(p));
+           DBG(dbg_paperquad) << "DiceTester append ret "<<ind<<"\n";
+           return ind;
+       }
+
+       int operator() (int i, int j, float fract = .5) {
+           DBG(dbg_paperquad) << "New vertex "<<i<<" "<<j<<" "<<fract<<"\n";
+           return append(lerp(points[i], points[j], fract) );
+       }
+
+       float split(int i, int j) const {
+           float ret = (finalPoints[i] - finalPoints[j]).xylength() / 
(float)dicelen - 1;
+           DBG(dbg_paperquad) << "Split "<<i<<" "<<j<<" "<<
+                   finalPoints[i]<<" "<<finalPoints[j]<<" "<<ret<<"\n";
+           return ret;
+       }
+    };
+
+    struct Triangler {
+       struct Tri { 
+           int v[3];
+       };
+       vector<Tri> tris;
+       void operator()(int i, int j, int k) {
+           DBG(dbg_paperquad) << "Triangler: "<<i<<" "<<j<<" "<<k<<"\n";
+           Tri t;
+           t.v[0] = i;
+           t.v[1] = j;
+           t.v[2] = k;
+           tris.push_back(t);
+       }
+    };
+
+    static float split(Verts &v, int i, int j) { return v.split(i,j); }
+
+    template<class T> void render(const T &coords) const {
+       ::Vob::Dicer::InitialDicedTriangle<__gnu_cxx::slist<int> > tri;
+       Triangler triangler;
+       Verts verts(coords);
+       verts.append(Pt(0,0));
+       verts.append(Pt(1,0));
+       verts.append(Pt(1,1));
+       verts.dicelen = dicelen;
+       using namespace boost;
+       using namespace boost::lambda;
+       DBG(dbg_paperquad) << "Set_and_initial\n";
+       tri.set_and_initial_dice(verts,
+                    0, 1, 2, bind(split, ref(verts), _1, _2), maxdepth);
+       DBG(dbg_paperquad) << "dice\n";
+       tri.dice(verts, triangler,
+                     bind(split, ref(verts), _1, _2), maxdepth);
+
+       glBegin(GL_TRIANGLES);
+                       
+       int ind = 0;
+       for(vector<Triangler::Tri>::iterator i=triangler.tris.begin(); 
+                       i != triangler.tris.end(); i++) {
+           DBG(dbg_paperquad) << "tri \n";
+           if(flags & 1) {
+               glColor3f(.5 + .5 * sin(.1 * ind),
+                         .5 + .5 * cos(.08751 * ind),
+                         .5 + .5 * sin(.07751 * ind));
+           }
+           ind ++;
+           for(int j=0; j<3; j++)
+               VecGL::glVertex( verts.finalPoints[(*i).v[j]] );
+       }
+       glEnd();
+    }
+
+};
+
+VOB_DEFINED(DiceTester);
+
 const int PAPERQUAD_CS2_TO_SCREEN = 1;
 const int PAPERQUAD_USE_VERTEX_PROGRAM = 2;
+const int PAPERQUAD_NONL_MAXLEN = 4;
 
 /**
 # PaperQuad is a bit complicated: there are three coordinate
@@ -94,13 +203,35 @@
                    ;
            GLERR
 
-           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);
-           
-           int dice = (int)(len * nonl * dicefactor) + 2;
+
+           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";
-           if(dice < 0 || dice > 100) dice = 100;
+           // Cap it at a ridiculous value
+           if( dice > 100) dice = 100;
+           if(dice < 2 ) dice = 2;
 
            float *vertices = new float[dice * dice * 5];
 
Index: libvob/src/jni/Makefile
diff -u libvob/src/jni/Makefile:1.21 libvob/src/jni/Makefile:1.22
--- libvob/src/jni/Makefile:1.21        Thu Mar 27 03:00:37 2003
+++ libvob/src/jni/Makefile     Tue Apr  1 06:03:54 2003
@@ -1,6 +1,6 @@
 include ../../rules.mk
 
-sources = Gen.cxx GLRen.gen.cxx Main.cxx Strings.cxx Transform.cxx Render.cxx 
Font.cxx Paper.cxx
+sources = GLRen.gen.cxx Main.cxx Strings.cxx Transform.cxx Render.cxx Font.cxx 
Paper.cxx
 
 CALLGL=../../../callgl
 CALLGLOBJS=$(CALLGL)/src/glwrapper/GL_wrapper.o $(CALLGL)/src/callgl.o
@@ -35,21 +35,21 @@
 GLRen.gen.cxx: Gen GLRen.template.java
        (cd ../..; src/jni/Gen)
 
-GLRen.gen.o: org_nongnu_libvob_gl_GLRen.h
-Main.o: org_nongnu_libvob_gl_GL.h
+GLRen.gen.o: made_org_nongnu_libvob_gl_GLRen.h
+Main.o: made_org_nongnu_libvob_gl_GL.h
 
 libvobjni.so: $(JNIOBJS) Makefile
        $(CXXLINK) -rdynamic -fpic -o libvobjni.so $(SHARED) $(CXXFLAGS) 
$(JNIOBJS) $(LIBS)
 
-$(sources:.cxx=.dep) $(OBJS): org_nongnu_libvob_gl_GL.h 
org_nongnu_libvob_gl_GLRen.h org_nongnu_libvob_gl_Paper.h
+$(sources:.cxx=.dep) $(OBJS): made_org_nongnu_libvob_gl_GL.h 
made_org_nongnu_libvob_gl_GLRen.h made_org_nongnu_libvob_gl_Paper.h
 
 include $(sources:.cxx=.dep)
 
 
 
-org_nongnu_libvob_gl_GL.h: ../../CLASSES/org/nongnu/libvob/gl/GL.class
-       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.GL
-org_nongnu_libvob_gl_GLRen.h: ../../CLASSES/org/nongnu/libvob/gl/GLRen.class
-       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.GLRen
-org_nongnu_libvob_gl_Paper.h: ../../CLASSES/org/nongnu/libvob/gl/Paper.class
-       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.Paper
+made_org_nongnu_libvob_gl_GL.h: ../../CLASSES/org/nongnu/libvob/gl/GL.class
+       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.GL && 
touch made_org_nongnu_libvob_gl_GL.h
+made_org_nongnu_libvob_gl_GLRen.h: 
../../CLASSES/org/nongnu/libvob/gl/GLRen.class
+       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.GLRen 
&& touch made_org_nongnu_libvob_gl_GLRen.h
+made_org_nongnu_libvob_gl_Paper.h: 
../../CLASSES/org/nongnu/libvob/gl/Paper.class 
+       javah -classpath $(CLASSPATH):../../CLASSES org.nongnu.libvob.gl.Paper 
&& touch made_org_nongnu_libvob_gl_Paper.h
Index: libvob/src/jni/jnivobs.hxx
diff -u libvob/src/jni/jnivobs.hxx:1.4 libvob/src/jni/jnivobs.hxx:1.5
--- libvob/src/jni/jnivobs.hxx:1.4      Thu Mar 27 04:44:08 2003
+++ libvob/src/jni/jnivobs.hxx  Tue Apr  1 06:03:54 2003
@@ -15,7 +15,7 @@
 #include <vob/vobs/Paper.hxx>
 #include <vob/vobs/Irregu.hxx>
 
-#include <vob/LinearPrimitives.hxx>
-#include <vob/FunctionalPrimitives.hxx>
-#include <vob/DisablablePrimitives.hxx>
-#include <vob/FisheyePrimitives.hxx>
+#include <vob/trans/LinearPrimitives.hxx>
+#include <vob/trans/FunctionalPrimitives.hxx>
+#include <vob/trans/DisablablePrimitives.hxx>
+#include <vob/trans/FisheyePrimitives.hxx>
Index: libvob/src/main/Renderer.cxx
diff -u libvob/src/main/Renderer.cxx:1.3 libvob/src/main/Renderer.cxx:1.4
--- libvob/src/main/Renderer.cxx:1.3    Thu Mar 27 04:44:08 2003
+++ libvob/src/main/Renderer.cxx        Tue Apr  1 06:03:54 2003
@@ -19,6 +19,14 @@
        DBGVAR(dbg_irregularquad, "Irregularquad");
     }
 
+    namespace Dicer {
+       DBGVAR(dbg, "Dicer");
+    }
+
+    namespace Vobs {
+       DBGVAR(dbg_paperquad, "Paperquad");
+    }
+
 namespace CurrentFPS {
     // bool showFPS;
     double current_fps;
Index: libvob/src/paper/Paper.cxx
diff -u libvob/src/paper/Paper.cxx:1.2 libvob/src/paper/Paper.cxx:1.3
--- libvob/src/paper/Paper.cxx:1.2      Wed Mar 26 09:00:42 2003
+++ libvob/src/paper/Paper.cxx  Tue Apr  1 06:03:54 2003
@@ -27,7 +27,6 @@
  */
 
 #include "vob/paper/Paper.hxx"
-#include "vob/vobs/Paper.hxx"
 
 
 /** The matrix that maps v[TEX0] into o[TEXi] is stored 
@@ -35,11 +34,6 @@
  */
 #define tex_addr_base 60
 
-namespace Vob {
-namespace Vobs {
-    DBGVAR(dbg_paperquad, "Paperquad");
-}
-}
 
 namespace Vob {
 namespace Paper {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]