/[gzz]/gzz/gfx/demo/vpbuoy.py
ViewVC logotype

Diff of /gzz/gfx/demo/vpbuoy.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by tjl, Sun Dec 15 20:08:42 2002 UTC revision 1.6 by tjl, Mon Dec 16 07:03:15 2002 UTC
# Line 25  class Scene: Line 25  class Scene:
25                      float4 texcoord : TEXCOORD0,                      float4 texcoord : TEXCOORD0,
26                      float4 color : COLOR                      float4 color : COLOR
27                      ) {                      ) {
28                  float4 p = { 100, 300, 0, 0 };                  float4 p = { 100, 350, 0, 0 };
29                  float4 origin = { 300, 300, 0, 0};                  float4 origin = { 500, 350, 0, 0};
30                  float rad = 200;                  float rad = 400;
31    
32                  outs o;                  outs o;
33    
34                  float4x4 pmat = glstate.matrix.program[0];                  float4x4 pmat = glstate.matrix.program[0];
35    
36                  float4 anchor = mul(pmat, orig);                  float2 anchor;
37                    anchor.x = dot(pmat[0], orig);
38                    anchor.y = dot(pmat[1], orig);
39    
40                    float w = dot(pmat[3],  orig);
41                    anchor /= w;
42    
43                  float a2o = distance(anchor.xy, origin.xy) / rad;                  float a2o = distance(anchor.xy, origin.xy) / rad;
44                    float2 ap ;
45                    ap.xy = anchor.xy - p.xy;
46                    float a2p = length(ap) / rad;
47    
48                  float4 buoy;                  float4 buoy;
49    
50                  buoy = anchor;                  buoy.xy = anchor + orig.z * .5 * ap * max(0,1-a2o);
51                    buoy.z = 1-orig.z;
52                    buoy.w = 1;
53    
54                  o.pos = mul(glstate.matrix.mvp, buoy);                  o.pos = mul(glstate.matrix.mvp, buoy);
55                  o.color = float4(color.x, color.y, a2o, color.w);                  o.color = float4(1-orig.z, a2o, a2p, color.w);
56                  o.pointsize = float4(15.0, 0, 0, 0);                  o.pointsize = float4(4. + 4. * orig.z, 0, 0, 0);
57    
58                  return o;                  return o;
59              }              }
# Line 216  class Scene: Line 226  class Scene:
226              self.prog = None              self.prog = None
227    
228          vert = []          vert = []
229          if 1:          if 0:
230              n = 45              n = 45
231              for x in floats(0,1,n):              for x in floats(0,1,n):
232                  for y in floats(0,1,n):                  for y in floats(0,1,n):
# Line 226  class Scene: Line 236  class Scene:
236                          Vertex %(x)s %(y)s 1 1                          Vertex %(x)s %(y)s 1 1
237                      """ % locals())                      """ % locals())
238          else:          else:
239              for i in range(0,2000):              for i in range(0,4000):
240                  x, y = java.lang.Math.random(), java.lang.Math.random()                  x, y = java.lang.Math.random(), java.lang.Math.random()
241                  vert.append("""                  vert.append("""
242                      Color %(x)s .0 %(y)s .6                      Color %(x)s .0 %(y)s .6
# Line 293  class Scene: Line 303  class Scene:
303              vs.put(self.linep, "G", 0, 0, 0, 1, 1)              vs.put(self.linep, "G", 0, 0, 0, 1, 1)
304          else:          else:
305              vs.put(GLRen.createSetMatrix("MATRIX0_ARB"), "M", 0,              vs.put(GLRen.createSetMatrix("MATRIX0_ARB"), "M", 0,
306                  -150+Math.random() * 300, -150+Math.random() * 300,                  -300+Math.random() * 300, -300+Math.random() * 300,
307                  700 + Math.random() * 400, 700 + Math.random() * 400,                  1400 + Math.random() * 400, 1400 + Math.random() * 400,
308                  )                  )
309    
310              vs.put(self.pointlist, "F", 0, 0, 0, 1, 1)              vs.put(self.pointlist, "F", 0, 0, 0, 1, 1)

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26