gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob/vob/demo vpmultifil.py


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob/vob/demo vpmultifil.py
Date: Thu, 22 May 2003 09:53:31 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/05/22 09:53:31

Modified files:
        vob/demo       : vpmultifil.py 

Log message:
        Pretty good shape

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/vpmultifil.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: libvob/vob/demo/vpmultifil.py
diff -u libvob/vob/demo/vpmultifil.py:1.1 libvob/vob/demo/vpmultifil.py:1.2
--- libvob/vob/demo/vpmultifil.py:1.1   Thu May 22 05:17:45 2003
+++ libvob/vob/demo/vpmultifil.py       Thu May 22 09:53:31 2003
@@ -1,3 +1,6 @@
+from __future__ import nested_scopes
+import math
+
 import vob
 from org.nongnu.libvob.gl import GL, GLRen
 from vob.putil import cg
@@ -16,81 +19,42 @@
     return float2(-v.y, v.x);
 }
 
-float4 norm2(float4 v) {
-    float2 nv = normalize(v.xy / v.w);
-    return float4(nv.x, nv.y, v.z / v.w, 1);
-}
-
 void main(
     float4 pos: POSITION,
-    uniform float4 boxc: C0,
-    uniform float4 box0: C1,
-    uniform float4 box1: C2,
-    uniform float4 fpar: C3,
+    uniform float2 center: C0,
+    uniform float3 zooms: C1,
+    uniform float3 zs: C2,
+    uniform float3 angles: C3,
+    uniform float3 dists: C4,
+    uniform float4 params: C5,
     out float4 opos: POSITION,
     out float4 col: COLOR
 ) {
-    // The initial calculations are constants over the primitive
-    // and should be done in the special code
-    float4 ctr = float4(.5,.5,0,1);
-    float4 ctr0 = ctr;
-    float4 ctr1 = ctr;
-    ctr.xy *= boxc.xy ;
-    ctr0.xy *= box0.xy ;
-    ctr1.xy *= box1.xy ;
-    float2 o_ctr = mul(glstate.matrix.modelview[0], ctr).xy;
-    float2 o_ctr0 = mul(glstate.matrix.program[0], ctr0).xy;
-    float2 o_ctr1 = mul(glstate.matrix.program[1], ctr1).xy;
-
-    float2 v0 = o_ctr0 - o_ctr;
-    float2 v1 = o_ctr1 - o_ctr;
-
-    // Rotate the 90deg
-
-    float2 r0 = r90(normalize(v0));
-    float2 r1 = rn90(normalize(v1));
-
-    float2 x0 = o_ctr + .5 * v0 + fpar.x * r0.xy;
-    float2 x1 = o_ctr;
 
-    float2 x2 = o_ctr + .5 * v1 + fpar.x * r1.xy;
+    float pi = 3.141592;
 
-    x0 = o_ctr0;
-    x2 = o_ctr1;
+    float ang = pos.x / 2.01;
 
-    // The non-uniform part starts here
-    
+    float curang = lerp(angles.y, angles.z, ang);
+    float curdist = lerp(dists.y, dists.z, ang);
+
+
+    float2 v = float2(sin(curang), cos(curang));
+    float2 dv = angles.x * r90(v);
 
-    float4 coeff = float4(
-       (1-pos.x) * (1-pos.x),
-       2 * pos.x * (1-pos.x),
-       pos.x * pos.x,
-       0
-    );
-    float4 dercoeff = float4(
-       2 * -1 * (1-pos.x),
-       2 * pos.x * -1 + 2 * (1-pos.x) ,
-       2 * pos.x,
-       0
-    );
-
-    float2 dervec = dercoeff.x * x0 +
-           dercoeff.y * x1 +
-           dercoeff.z * x2;
-    dervec = r90(dervec);
-
-    float4 rpos;
-    rpos.xy = 
-       coeff.x * x0 +
-       coeff.y * x1 +
-       coeff.z * x2 +
-       pos.y * fpar.y * normalize(dervec);
-    rpos.z = 0;
-    rpos.w = 1;
+    float sfact = (1-sqrt(sqrt(1-(1-pos.x)*(1-pos.x)*(1-pos.x)*(1-pos.x))));
 
-    opos = mul(glstate.matrix.projection, rpos);
+    float2 rpos = center + 
+       (dists.x + sfact * (curdist-dists.x)) * v +
+       (1-pos.x) * (10 - sfact * ang * pi * curdist ) * dv +
+       // rand offset
+       pos.y * 2 * v + pos.y * 2 * dv;
+
+    float4 rpos4 = float4(0,0,0,1);
+    rpos4.xy = rpos;
+    
+    opos = mul(glstate.matrix.mvp, rpos4);
 
-//     pos.y * rpos + (1-pos.y) * float4(300*pos.x, 0, 0, 1));
     col = pos;
     col.w = .8;
 }
@@ -101,21 +65,13 @@
     def __init__(self):
        self.key = KeyPresses(
             self, 
-           SlideLin("x", 400, 50, "x coord", "Left", "Right"),
-           SlideLin("y", 400, 50, "y coord", "Up", "Down"),
-           SlideLin("a", 0, 15, "Rotation", "Prior", "Next"),
+           SlideLin("l1", 200, 20, "l1", "Left", "Right"),
+           SlideLin("l2", 300, 20, "l2", "Up", "Down"),
+           SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"),
        )
     def scene(self, vs):
        putnoc(vs, background((.2,1,1)))
 
-       vs.put(GLRen.createTransMatrix("MATRIX0_ARB"),
-               vs.orthoCS(0, "A", 0, 200, 200, 1, 1))
-       vs.put(GLRen.createTransMatrix("MATRIX1_ARB"),
-               vs.rotateCS(
-                   vs.orthoCS(0, "B", 0, self.x, self.y, 1, 1),
-                   "R", self.a
-                   ))
-
        vs.put(getDListNocoords("""
         PushAttrib ENABLE_BIT CURRENT_BIT COLOR_BUFFER_BIT TEXTURE_BIT 
 
@@ -124,22 +80,39 @@
        """ % (
            vp[0].getProgId(),
            )))
-    
-       vs.put(GLRen.createProgramLocalParameterARB(
-                   "VERTEX_PROGRAM_ARB", 0),
-                   vs.orthoCS(0, "i0", 0, 100, 100, 0, 0))
-       vs.put(GLRen.createProgramLocalParameterARB(
-                   "VERTEX_PROGRAM_ARB", 1),
-                   vs.orthoCS(0, "i1", 0, 100, 100, 0, 0))
-       vs.put(GLRen.createProgramLocalParameterARB(
-                   "VERTEX_PROGRAM_ARB", 2),
-                   vs.orthoCS(0, "i2", 0, 100, 100, 0, 0))
-       vs.put(GLRen.createProgramLocalParameterARB(
-                   "VERTEX_PROGRAM_ARB", 3),
-                   vs.orthoCS(0, "i3", 0, 5, 5, 0, 0))
 
-       vs.put(GLRen.createQuad(40,40,1), 
-           vs.orthoCS(0, "C", 0, 100, 500, 1, 1))
+       a = []
+
+       def param(i, v1=0, v2=0, v3=0, v4=0):
+           vs.put(GLRen.createProgramLocalParameterARB(
+                       "VERTEX_PROGRAM_ARB", i),
+                       vs.orthoCS(0, str(len(a)), 0, v1, v2, v3, v4))
+           a.append(0)
+
+       param(0, 300, 300)
+
+       q = GLRen.createQuad(500, 2, 1)
+
+       param(3, -1, 3, self.ang)
+       param(4, 30, self.l1, self.l2)
+
+       vs.put(q,  0)
+
+       param(3, 1, self.ang, 3)
+       param(4, 30, self.l2, self.l1)
+
+       vs.put(q, 0)
+
+       param(3, 1, 3, self.ang + 2*math.pi)
+       param(4, 30, self.l1, self.l2)
+
+       vs.put(q,  0)
+
+       param(3, -1, self.ang + 2*math.pi, 3)
+       param(4, 30, self.l2, self.l1)
+
+       vs.put(q, 0)
+
 
         putnoc(vs, getDListNocoords("PopAttrib"))
 




reply via email to

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