gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob include/vob/VecGL.hxx include/vob/vobs/F...


From: Janne V. Kujala
Subject: [Gzz-commits] libvob include/vob/VecGL.hxx include/vob/vobs/F...
Date: Fri, 27 Jun 2003 10:34:23 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/06/27 10:34:23

Modified files:
        include/vob    : VecGL.hxx 
        include/vob/vobs: Fillet.hxx 
        vob/fillet     : light3d.py 

Log message:
        start 3d blending

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/VecGL.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/fillet/light3d.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: libvob/include/vob/VecGL.hxx
diff -u libvob/include/vob/VecGL.hxx:1.3 libvob/include/vob/VecGL.hxx:1.4
--- libvob/include/vob/VecGL.hxx:1.3    Sun Mar 23 15:15:58 2003
+++ libvob/include/vob/VecGL.hxx        Fri Jun 27 10:34:23 2003
@@ -44,6 +44,19 @@
     inline void glVertex(const ZVec &v) { 
        glVertex3f(v.x, v.y, v.z); 
     }
+
+    /** Call glNormal using a Vec23 ZVec.
+     */
+    inline void glNormal(const ZVec &v) { 
+       glNormal3f(v.x, v.y, v.z); 
+    }
+
+    /** Call glTexCoord using a Vec23 ZVec.
+     */
+    inline void glTexCoord(const ZVec &v) { 
+       glTexCoord3f(v.x, v.y, v.z); 
+    }
+
 }
 
 }
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.32 
libvob/include/vob/vobs/Fillet.hxx:1.33
--- libvob/include/vob/vobs/Fillet.hxx:1.32     Fri Jun 27 07:53:14 2003
+++ libvob/include/vob/vobs/Fillet.hxx  Fri Jun 27 10:34:23 2003
@@ -661,6 +661,152 @@
 VOB_DEFINED(Fillet3D);
 
 
+/** Draw a surface of blended fillets ...
+ */
+struct Fillet3DBlend {
+    enum { NTrans = -1 };
+
+    int ndice;
+
+    template<class F> void params(F &f) {
+       f(ndice);
+    }
+
+    template<class T> float crad(const T &t) const {
+       return 0.5 * t.getSqSize().x;
+    }
+
+    struct Conn {
+       const CircularNode *node;
+       float dist;
+       LinearConnectionHalf c;
+       StretchedCircleFillet f;
+       ZVec dir;
+
+       Conn(const CircularNode &node,
+            float d,
+            float th,
+            float a,
+            ZVec dir) :
+           node(&node),
+           c(node, 0, d, th, -1, 0), 
+           f(node, c, a), dir(dir) {
+       }
+
+       Vec trans(ZVec v) const {
+           float x = dir.dot(v);
+           float y = (v - x * dir).length();
+           return Vec(x, y);
+       }
+
+       float rad(ZVec v, bool &success) const {
+           ZVec pt = f.point(trans(v), success);
+           if (success) return pt.length();
+           return node->r;
+       }
+    };
+
+    ZVec blend(Conn *conns[], int N, float r, ZVec pt) const {
+       int num = 0;
+       float sum = 0;
+
+       for (int i = 0; i < N; i++) {
+           bool success;
+           float t = conns[i]->rad(pt, success);
+           if (success) {
+               sum += t - r;
+               num++;
+           }
+       }
+
+       return pt * (1 + sum / r);
+
+    }
+
+    void render(const Transform **t, int n) const {
+       const Transform &thick_t = *t[0];
+       const Transform &angle_t = *t[1];
+
+       const Transform &t0 = *t[2];
+
+       int N = n - 3;
+       ZVec p0 = t0.transform(0.5 * t0.getSqSize());
+       float r = crad(t0);
+       CircularNode node(ZVec(0,0,0), r);
+
+       Conn* conns[N];
+
+       int i, j;
+       for (i = 0; i < N; i++) {
+           const Transform &t1 = *t[3 + i];
+           ZVec p1 = t1.transform(0.5 * t1.getSqSize());
+           float d = (p1 - p0).length() / 2;
+       
+           FilletSpan2::Conn conn(thick_t, angle_t, t0, t1, d);
+
+           conns[i] = new Conn(node, d, conn.th, conn.a, 
+                               (p1 - p0).normalized());
+       }
+
+
+       ZVec pt[ndice + 1][ndice*2];
+       ZVec norm[ndice + 1][ndice*2];
+
+       for (i = 0; i <= ndice; i++) {
+           float a = i * M_PI / ndice;
+           float x = cos(a);
+           float R = sin(a);
+
+           for (j = 0; j < ndice*2; j++) {
+               float b = j * M_PI * 2 / (ndice*2);
+
+               float y = cos(b) * R;
+               float z = sin(b) * R;
+
+               pt[i][j] = r * ZVec(x, y, z);
+           }
+       }
+
+
+       for (i = 0; i <= ndice; i++)
+           for (j = 0; j < ndice*2; j++)
+               pt[i][j] = blend(conns, N, r, pt[i][j]) + p0;
+
+               
+       for (i = 0; i <= ndice; i++) {
+           for (j = 0; j < ndice*2; j++) {
+               ZVec px0 = pt[i==0 ? 0 : i-1][j];
+               ZVec px1 = pt[i==ndice ? ndice : i+1][j];
+               ZVec py0 = pt[i][j==0 ? 0 : j-1];
+               ZVec py1 = pt[i][j==ndice*2-1 ? ndice*2-1 : j+1];
+
+               norm[i][j] = (px1 - px0).crossp(py1 - py0).normalized();
+           }
+       }
+
+       for (i = 0; i < ndice; i++) {
+           glBegin(GL_QUAD_STRIP);
+           for (j = 0; j < ndice*2; j++) {
+               glNormal(norm[i][j]);
+               glVertex(pt[i][j]);
+
+               glNormal(norm[i+1][j]);
+               glVertex(pt[i+1][j]);
+           }
+           glEnd();
+       }
+
+
+       for (i = 0; i < N; i++) {
+           delete conns[i];
+       }
+       
+    }
+       
+};
+
+VOB_DEFINED(Fillet3DBlend);
+
 
 
 }
Index: libvob/vob/fillet/light3d.py
diff -u libvob/vob/fillet/light3d.py:1.10 libvob/vob/fillet/light3d.py:1.11
--- libvob/vob/fillet/light3d.py:1.10   Fri Jun 27 08:09:12 2003
+++ libvob/vob/fillet/light3d.py        Fri Jun 27 10:34:23 2003
@@ -111,6 +111,7 @@
            SlideLin("size", 100, 10, "Node size", "K", "k"),
            SlideLin("dice", 20, 1, "Dice factor", "P", "p"),
            Toggle("fillet3d", 0, "3D fillets", "3"),
+           Toggle("blend3d", 0, "3D fillets blend", "4"),
            SlideLin("linewidth", 2, 1, "line width", "B", "b"),
            Toggle("perspective", 0, "perspective", "F"),
            Toggle("texture", 0, "texture", "x"),
@@ -161,7 +162,7 @@
            GLRen.createFillet3D(border, self.dice, 1),
            2)
 
-        
+        conns3dblend = GLRen.createFillet3DBlend(self.dice);
 
 
 
@@ -198,7 +199,11 @@
                 uLookAt 400 400 -1000 400 400 400 0 -1 0
                 """))
 
-            pc(conns3d)
+            if not self.blend3d:
+                pc(conns3d)
+
+            if self.blend3d:
+                pc(conns3dblend)
 
             vs.put(getDListNocoords("""
             MatrixMode PROJECTION




reply via email to

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