fenfire-commits
[Top][All Lists]
Advanced

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

[ff-cvs] libvob/vob demo/multifil/randgraph.py fillet/li...


From: Janne V. Kujala
Subject: [ff-cvs] libvob/vob demo/multifil/randgraph.py fillet/li...
Date: Wed, 27 Aug 2003 08:38:33 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/08/27 08:38:33

Modified files:
        vob/demo/multifil: randgraph.py 
        vob/fillet     : light3d.py 
        vob/usertest   : fillet2.py 

Log message:
        better perspective

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/randgraph.py.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.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/usertest/fillet2.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: libvob/vob/demo/multifil/randgraph.py
diff -u libvob/vob/demo/multifil/randgraph.py:1.32 
libvob/vob/demo/multifil/randgraph.py:1.33
--- libvob/vob/demo/multifil/randgraph.py:1.32  Wed Aug 27 06:14:59 2003
+++ libvob/vob/demo/multifil/randgraph.py       Wed Aug 27 08:38:32 2003
@@ -63,11 +63,12 @@
            SlideLin("seed", 42, 1, "seed number", "A", "a"),
            SlideLin("seed2", 42, 1, "highlihght seed number", "Z", "z"),
            Toggle("path2", 0, "length-2 path", "2"),
+           Toggle("perspective", 0, "perspective", "F"),
             *light3d.commonkeys
        )
         self.list = None
-
         self.box = 800
+        self.hl_only = 0
 
         class Listener(RelativeAxisListener):
             def __init__(self, changed):
@@ -145,6 +146,7 @@
                                 nodes)
 
                 if 1:
+                    # path2 = direct neighbor
                     if self.path2:
                         nodes2 = filter(lambda y: y["cs"] in x["conns"], nodes)
                     else:
@@ -168,6 +170,12 @@
             x, y = None, None
 
        def pc(conns, cs):
+            if self.hl_only:
+                vs.put(getDListNocoords("Color 1 0 0"))
+                if x != None: vs.put(conns, cs + [x["cs"]])
+                if y != None: vs.put(conns, cs + [y["cs"]])
+                return
+                
             for node in nodes:
                 if node in [x, y]:
                     vs.put(getDListNocoords("Color 1 0 0"))
@@ -198,13 +206,33 @@
     def scene(self, vs):
        vs.put( background((.5,1,.2)))
 
-        cs = vs.scaleCS(0, "cs", 1, 1, 1)
         size = vs.getSize()
+
+        cs = 0
+        if self.perspective:
+            fov = 45
+            zmin = 1
+            zmax = 2500
+            dist = 1500
+
+            y = zmin * math.tan(fov * math.pi / 360)
+            aspect = float(size.width) / size.height
+            
+            vs.put(getDListNocoords("""
+            MatrixMode PROJECTION
+            LoadIdentity
+            Frustum %s %s %s %s %s %s
+            Scale 1 -1 -1
+            Translate -%s -%s %s
+            MatrixMode MODELVIEW
+            """ % (-aspect * y, aspect * y, -y, y, zmin, zmax,
+                   0.5 * size.width, 0.5 * size.height, dist)))
+
         cs = vs.translateCS(cs, "Trans",
                             0.5 * size.width,
                             0.5 * size.height,
                             0.5 * self.box);
-
+        
         cs = vs.coords.rotateQuaternion(cs,  *self.rot)
         vs.matcher.add(cs, "Rot")
 
Index: libvob/vob/fillet/light3d.py
diff -u libvob/vob/fillet/light3d.py:1.42 libvob/vob/fillet/light3d.py:1.43
--- libvob/vob/fillet/light3d.py:1.42   Tue Aug 26 10:28:37 2003
+++ libvob/vob/fillet/light3d.py        Wed Aug 27 08:38:32 2003
@@ -250,7 +250,6 @@
            Toggle("fillet3d", 1, "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"),
            SlideLin("dicelen", 100, 5, "Dice length", "G", "g"),
            SlideLin("tblsize", 20, 1, "Table size", "<", ">"),
@@ -341,7 +340,7 @@
 
             thick = vs.coords.rational1D22(0,
                                            2*self.thick, self.thick,
-                                           .05, 2, 1, 1);
+                                           .1, 2, 1, 1);
             
             angle = vs.coords.power1D2(0, self.angle, 1/3., 1, -1);
         else:
@@ -371,18 +370,6 @@
                 TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
                 Enable TEXTURE_2D
                 """ % tex.getTexId()))
-
-            if self.perspective:
-                vs.put(getDListNocoords("""
-                MatrixMode PROJECTION
-                LoadIdentity
-                Frustum -400 400 -400 400 500 2500
-                Scale 1 1 -1
-                MatrixMode MODELVIEW
-                LoadIdentity
-                Scale 1 1 -1
-                uLookAt 400 400 -1000 400 400 400 0 -1 0
-                """))
 
             if self.blend3d and self.fillets:
                 vs.put(getDListNocoords("Color .2 .2 1"))
Index: libvob/vob/usertest/fillet2.py
diff -u libvob/vob/usertest/fillet2.py:1.1 libvob/vob/usertest/fillet2.py:1.2
--- libvob/vob/usertest/fillet2.py:1.1  Wed Aug 27 04:21:57 2003
+++ libvob/vob/usertest/fillet2.py      Wed Aug 27 08:38:33 2003
@@ -56,9 +56,9 @@
     vs0.put(background((.5,1,.2)))
 
     graphs = []
-    for i in range(0,6):
+    for i in range(0,3):
         for path2 in (0,1):
-            for N in (6,24,42,60):#(24,48,96):#(9,15,21):
+            for N in [ 3 * n for n in range(2,10) ]:
                 graphs.append( (r.nextInt(), r.nextInt(), path2, N) )
 
     trials = []
@@ -71,13 +71,6 @@
 
     t0 = java.lang.System.currentTimeMillis()
     while trials:
-
-        #sc.seed = r.nextInt()
-        #sc.seed2 = r.nextInt()
-        #sc.path2 = r.nextBoolean()
-        #sc.N = 3 * r.nextInt(4) + 9
-        #sc.fillets = r.nextBoolean()
-
        render(vs0)
 
         sc.seed, sc.seed2, sc.path2, sc.N, fillets = trials.pop()
@@ -86,11 +79,13 @@
         else:
             sc.rot = (0,0,0,1)
 
+        sc.hl_only = 1
         sc.fillets = 0
         sc.thick = 0
         vs1 = getvs()
         sc.scene(vs1)
 
+        sc.hl_only = 0
         sc.fillets = fillets
         sc.thick = 1
         vs2 = getvs()
@@ -102,7 +97,7 @@
 
         warn = ""
         t1 = java.lang.System.currentTimeMillis()
-        t = 2000 - (t1 - t0)
+        t = 1500 - (t1 - t0)
         if t > 0:
             Thread.sleep(t)
         else:
@@ -114,7 +109,7 @@
         t0 = java.lang.System.currentTimeMillis()
         renderOnly(vs2)
         t1 = java.lang.System.currentTimeMillis()
-        t = 1500 - (t1 - t0)
+        t = 1000 - (t1 - t0)
         if t > 0:
             Thread.sleep(t)
         else:




reply via email to

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