gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob include/vob/Transform.hxx include/vob/Ve...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob include/vob/Transform.hxx include/vob/Ve...
Date: Tue, 01 Apr 2003 10:06:52 -0500

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

Modified files:
        include/vob    : Transform.hxx Vec23.hxx 
        include/vob/trans: Primitives.hxx 
        include/vob/vobs: Paper.hxx 
        src/trans      : Coorder.cxx 

Log message:
        Vertex arrays

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Transform.hxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Vec23.hxx.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/Primitives.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Paper.hxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/trans/Coorder.cxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: libvob/include/vob/Transform.hxx
diff -u libvob/include/vob/Transform.hxx:1.10 
libvob/include/vob/Transform.hxx:1.11
--- libvob/include/vob/Transform.hxx:1.10       Mon Mar 10 04:49:31 2003
+++ libvob/include/vob/Transform.hxx    Tue Apr  1 10:06:52 2003
@@ -61,6 +61,10 @@
         */
        virtual void vertex(const ZPt &p) const = 0;
 
+       /** Whether the transformation is nonlinear.
+        */
+       virtual bool isNonlinear() const = 0;
+
        /** How nonlinear is the coordinate system at the given point.
         * The return value is 1/l where l would be a reasonable length 
         * for dicing.
@@ -129,6 +133,9 @@
        virtual bool canPerformGL() const { return true; }
        virtual bool performGL() const {
            return true;
+       }
+       virtual bool isNonlinear() const {
+           return false;
        }
        virtual float nonlinearity(const ZPt &p, float radius) const { 
            return 0;
Index: libvob/include/vob/Vec23.hxx
diff -u libvob/include/vob/Vec23.hxx:1.5 libvob/include/vob/Vec23.hxx:1.6
--- libvob/include/vob/Vec23.hxx:1.5    Tue Apr  1 06:03:54 2003
+++ libvob/include/vob/Vec23.hxx        Tue Apr  1 10:06:52 2003
@@ -55,6 +55,10 @@
         */
        template<class F>
            Vector(const Vector3<F> &v) : x(v.x), y(v.y) { }
+
+       /** Create from an array.
+        */
+       Vector(T *v) : x(v[0]), y(v[1]) { }
        /** Multiplication by scalar.
         */
        Vector operator*(const double &s) const { return Vector(s * x, s * y); }
Index: libvob/include/vob/trans/Primitives.hxx
diff -u libvob/include/vob/trans/Primitives.hxx:1.1 
libvob/include/vob/trans/Primitives.hxx:1.2
--- libvob/include/vob/trans/Primitives.hxx:1.1 Tue Apr  1 06:03:54 2003
+++ libvob/include/vob/trans/Primitives.hxx     Tue Apr  1 10:06:52 2003
@@ -173,6 +173,13 @@
            return true;
        }
 
+       bool isNonlinear(const NonlinearPrimitiveTransform *_) const {
+           return true;
+       }
+       bool isNonlinear(const void *_) const {
+           return super->isNonlinear();
+       }
+
        float selfNonlinearity(NonlinearPrimitiveTransform &t,
                    const ZPt &p, float radius) const {
            return t.nonlinearity(p, radius);
@@ -232,6 +239,8 @@
            return Pt(1,1);
        }
 
+       virtual bool isNonlinear() const { return isNonlinear(&t); }
+
     };
 
     /** A type of transform which exposes a vector of
@@ -290,6 +299,13 @@
            return true;
        }
 
+       bool isNonlinear(const NonlinearPrimitiveTransform *_) const {
+           return true;
+       }
+       bool isNonlinear(const void *_) const {
+           return super->isNonlinear();
+       }
+
        float selfNonlinearity(const NonlinearPrimitiveTransform *_,
                    const ZPt &p, float radius) const {
            return t.nonlinearity(p, radius);
@@ -383,9 +399,12 @@
            super->vertex(mp);
        }
 
+
        virtual bool performGL() const { return performGL(&t); }
 
        virtual bool canPerformGL() const { return canPerformGL(&t); }
+
+       virtual bool isNonlinear() const { return isNonlinear(&t); }
 
        virtual float nonlinearity(const ZPt &p, float radius) const {
            float s = selfNonlinearity(&t, p, radius);
Index: libvob/include/vob/vobs/Paper.hxx
diff -u libvob/include/vob/vobs/Paper.hxx:1.2 
libvob/include/vob/vobs/Paper.hxx:1.3
--- libvob/include/vob/vobs/Paper.hxx:1.2       Tue Apr  1 06:03:54 2003
+++ libvob/include/vob/vobs/Paper.hxx   Tue Apr  1 10:06:52 2003
@@ -28,6 +28,78 @@
 
 PREDBGVAR(dbg_paperquad);
 
+namespace PaperPriv {
+
+struct Verts {
+    const Transform &t;
+    Verts(const Transform &t) : t(t) { }
+
+    struct T2V3Vert {
+       Pt orig;
+       ZPt final;
+       T2V3Vert() { }
+       T2V3Vert(Pt p, ZPt z) : orig(p), final(z) {
+       }
+    };
+    vector<T2V3Vert> points;
+
+    int append(Pt p) {
+       DBG(dbg_paperquad) << "DiceTester append "<<p<<"\n";
+       int ind = points.size();
+       points.push_back(T2V3Vert(p, 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].orig, points[j].orig, fract) );
+    }
+
+
+    float dicelen;
+    float split(int i, int j) const {
+       float ret = (points[i].final - points[j].final).xylength() / 
(float)dicelen - 1;
+       DBG(dbg_paperquad) << "Split "<<i<<" "<<j<<" "<<
+               points[i].final<<" "<<points[j].final<<" "<<ret<<"\n";
+       return ret;
+    }
+
+    void startT2V3Operation() {
+       glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+       glInterleavedArrays(GL_T2F_V3F, 5*sizeof(float), &(points[0]));
+       glLockArraysEXT(0, points.size());
+    }
+    void endT2V3Operation() {
+       glUnlockArraysEXT();
+       glPopClientAttrib();
+    }
+};
+
+/** A set of triangles.
+ */
+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);
+    }
+    void draw() {
+       glDrawElements(GL_TRIANGLES, tris.size()*3, GL_UNSIGNED_INT,
+                   &(tris[0]));
+    }
+};
+
+}
+
 class DiceTester {
 public:
     enum { NTrans = 1 };
@@ -39,55 +111,11 @@
     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); }
+    static float split(PaperPriv::Verts &v, int i, int j) { 
+       return v.split(i,j); }
 
     template<class T> void render(const T &coords) const {
+       using namespace PaperPriv;
        ::Vob::Dicer::InitialDicedTriangle<__gnu_cxx::slist<int> > tri;
        Triangler triangler;
        Verts verts(coords);
@@ -104,6 +132,11 @@
        tri.dice(verts, triangler,
                      bind(split, ref(verts), _1, _2), maxdepth);
 
+       verts.startT2V3Operation();
+           triangler.draw();
+       verts.endT2V3Operation();
+
+       /*
        glBegin(GL_TRIANGLES);
                        
        int ind = 0;
@@ -120,6 +153,7 @@
                VecGL::glVertex( verts.finalPoints[(*i).v[j]] );
        }
        glEnd();
+       */
     }
 
 };
@@ -130,6 +164,31 @@
 const int PAPERQUAD_USE_VERTEX_PROGRAM = 2;
 const int PAPERQUAD_NONL_MAXLEN = 4;
 
+/** A paperquad with no separation between paper and object coordinates.
+ */
+class FixedPaperQuad {
+public:
+    enum { NTrans = 2 };
+    ::Vob::Paper::Paper *paper;
+    float x0,y0,x1,y1;
+    int flags;
+
+    float diceLength;
+    int diceDepth;
+
+    template<class F> void params(F &f) {
+       f(paper, x0, y0, x1, y1, flags, diceLength, diceDepth);
+    }
+
+
+    template<class T> void render(const T &coords) const {
+       GLERR
+       
+       
+    }
+
+};
+
 /**
 # PaperQuad is a bit complicated: there are three coordinate
 # systems here: the window cs, the object cs and the paper cs.
@@ -359,6 +418,7 @@
 
     
 };
+
 
 VOB_DEFINED(PaperQuad);
 
Index: libvob/src/trans/Coorder.cxx
diff -u libvob/src/trans/Coorder.cxx:1.3 libvob/src/trans/Coorder.cxx:1.4
--- libvob/src/trans/Coorder.cxx:1.3    Sun Mar 23 15:15:58 2003
+++ libvob/src/trans/Coorder.cxx        Tue Apr  1 10:06:52 2003
@@ -36,6 +36,9 @@
                    << res<<"\n";
        return res;
     }
+    virtual bool isNonlinear() const {
+       return cs1.isNonlinear() || cs2.isNonlinear();
+    }
     virtual float nonlinearity(const ZPt &p, float radius) const { 
        return lerp(cs1.nonlinearity(p, radius), 
                cs2.nonlinearity(p, radius), fract);




reply via email to

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