/[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.9 by tjl, Tue Dec 17 14:11:18 2002 UTC revision 1.10 by tjl, Wed Dec 18 10:01:15 2002 UTC
# Line 58  class Scene: Line 58  class Scene:
58    
59              outs main(              outs main(
60                      float4 orig : POSITION,                      float4 orig : POSITION,
61                      float4 texcoord : TEXCOORD0,                      float4 texcoord : TEXCOORD0, // if on circle, texcoord.x = angle
62                      float4 color : COLOR,                      float4 color : COLOR,
63                      uniform float4 p : C0,                      uniform float4 p : C0,
64                      uniform float4 origin : C1                      uniform float4 origin : C1,
65                        uniform float rad : C2,
66                        uniform float oncircle : C3
67                      ) {                      ) {
68                  outs o;                  outs o;
                 cfloat rad = 400;  
69                  float2 anchor = anchorPlace(orig);                  float2 anchor = anchorPlace(orig);
70    
71                  float2 ap = anchor.xy - p.xy;                  float2 ap = anchor.xy - p.xy;
# Line 75  class Scene: Line 76  class Scene:
76                  float2 apnor = ap / aplen;                  float2 apnor = ap / aplen;
77                  float2 opnor = normalize(origin.xy - p.xy);                  float2 opnor = normalize(origin.xy - p.xy);
78    
79                  float outside = smoothstep(.9, 1, aolen /rad);                  float outside = smoothstep(.8, 1.2, aolen /rad);
80                  // float outside = 1;                  // float outside = 1;
81    
82                  // component of a..origin perpendicular to                  // component of a..origin perpendicular to
# Line 83  class Scene: Line 84  class Scene:
84    
85                  float2 yperp = ao - dot(ao,opnor) * opnor;                  float2 yperp = ao - dot(ao,opnor) * opnor;
86    
87                    float2 ccenter = origin.xy + outside * yperp;
88    
89                  // float vrad = rad * (1 - .25 * (2 - aplen/rad));                  // float vrad = rad * (1 - .25 * (2 - aplen/rad));
90                  float vrad = rad + .1 * outside * aolen; // rad;                  float vrad = lerp(rad, 20 + distance(anchor, ccenter), outside);
91    
92    
93    
94                  float2 projected = project2circle(anchor.xy,                  float2 projected = project2circle(anchor.xy,
95                          p.xy + outside * yperp, origin.xy + outside * yperp, vrad);                          p.xy + outside * yperp,
96                            ccenter,
97                            vrad);
98    
99    
100    
101    
102                  float4 buoy;                  float4 buoy;
103                  buoy.xy = (orig.z > 0 ?                  buoy.xy = (oncircle > 0 ?
104                        ccenter + vrad * float2(sin(texcoord.x), cos(texcoord.x))
105                        : (orig.z > 0 ?
106                          projected                          projected
107                          // lerp(anchor + opnor * 20 , projected, 1-outside)                          // lerp(anchor + opnor * 20 , projected, 1-outside)
108                              : anchor);                              : anchor));
109                  buoy.z = 1-orig.z;                  buoy.z = 1-orig.z;
110                  buoy.w = 1;                  buoy.w = 1;
111    
# Line 354  class Scene: Line 361  class Scene:
361                      Vertex %(x)s %(y)s 0 1                      Vertex %(x)s %(y)s 0 1
362                      Vertex %(x)s %(y)s 1 1                      Vertex %(x)s %(y)s 1 1
363                  """ % locals())                  """ % locals())
364                vert.append("""
365                    Color 1 1 1 1
366                    Vertex 0 0 0 1
367                    Vertex 0 0 1 1
368                """)
369          vert = " ".join(vert)          vert = " ".join(vert)
370    
371          vert2 = []          vert2 = []
# Line 366  class Scene: Line 378  class Scene:
378              """ % locals())              """ % locals())
379          vert2 = " ".join(vert2)          vert2 = " ".join(vert2)
380    
381            vert3 = " ".join([
382                """TexCoord %s 0
383                   Vertex 0 0 1 1
384                """ % x
385                for x in floats(0, 2*3.15, 50)
386                ])
387    
388          self.pointlist = getDList("""          self.pointlist = getDList("""
389              PointSize 10              PointSize 10
390              Disable TEXTURE_2D              Disable TEXTURE_2D
# Line 375  class Scene: Line 394  class Scene:
394              Begin LINES              Begin LINES
395              %(vert)s              %(vert)s
396              End              End
397    
398                ProgramLocalParameter VERTEX_PROGRAM_ARB 3 1 0 0 0
399                Begin LINE_STRIP
400                %(vert3)s
401                End
402                ProgramLocalParameter VERTEX_PROGRAM_ARB 3 0 0 0 0
403          """ % locals())          """ % locals())
404    
405          self.linep = getDList("""          self.linep = getDList("""
# Line 441  class Scene: Line 466  class Scene:
466              vs.map.put(GLRen.createSetMatrix("MATRIX0_ARB"), cs)              vs.map.put(GLRen.createSetMatrix("MATRIX0_ARB"), cs)
467    
468              putnoc(vs, getDListNocoords("""              putnoc(vs, getDListNocoords("""
469                  ProgramLocalParameter VERTEX_PROGRAM_ARB 0 100 350 0 0                  ProgramLocalParameter VERTEX_PROGRAM_ARB 0 200 350 0 0
470                  ProgramLocalParameter VERTEX_PROGRAM_ARB 1 500 350 0 0                  ProgramLocalParameter VERTEX_PROGRAM_ARB 1 400 350 0 0
471                    ProgramLocalParameter VERTEX_PROGRAM_ARB 2 150 0 0 0
472              """))              """))
473              vs.map.put(self.pointlist, 0)              vs.map.put(self.pointlist, 0)
474              if 0:              if 0:

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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