/[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.2 by tjl, Sat Dec 14 13:01:50 2002 UTC revision 1.3 by tjl, Sat Dec 14 20:15:17 2002 UTC
# Line 1  Line 1 
1  from gfx.util.misc import *  from gfx.util.misc import *
2  from gfx.util import vparb  from gfx.util import vparb
3    
4    
5  class Scene:  class Scene:
6        """A vertex program version of buoys for exploring
7        1) vertex programs, 2) buoy geometry.
8    
9        Not for real use.
10        """
11      def __init__(self):      def __init__(self):
12            rad = 400.0
13          recrad = 1/400.0          recrad = 1/400.0
14    
15            if 0:
16                func = """
17                    # Shift
18                    TEMP shift;
19                    MUL shift, cent, radius.y;
20                """
21            else:
22                func = """
23                    # Shift
24                    TEMP shift;
25                    TEMP k, b;
26                    MUL shift, amplen, cent;
27    
28                    # See where we fall; 5 line pieces
29    
30                    MUL shift, shift, radius.y;
31                """
32    
33          self.prog = GL.createProgram("""!!ARBvp1.0          self.prog = GL.createProgram("""!!ARBvp1.0
34                            
35              # x,y = coordinates              # x,y = coordinates
# Line 13  class Scene: Line 39  class Scene:
39    
40              PARAM center = { 512, 350, 0, 0 };              PARAM center = { 512, 350, 0, 0 };
41              PARAM p = { 112, 350, 0, 0 };              PARAM p = { 112, 350, 0, 0 };
42              PARAM radius = { %(recrad)s, 0, 0, 0 };              PARAM radius = { %(recrad)s, %(rad)s, 0, 0 };
43              PARAM zeroone = { 0, 1, 5, 0 };              PARAM zeroone = { 0, 1, 5, 0 };
44    
45                PARAM lines[] = {
46                            { -100, -100, 1, 0 },
47                            { 0, 0, .1, 0 },
48                            { .2, .02, 9, 0 },
49                            { .3, .92, .1, 0 },
50                            { .75, 1, 1, 0 }
51                        };
52    
53    
54              PARAM pm[4] = { state.matrix.program[0] };              PARAM pm[4] = { state.matrix.program[0] };
55              PARAM mvp[4] = { state.matrix.mvp };              PARAM mvp[4] = { state.matrix.mvp };
56    
# Line 37  class Scene: Line 72  class Scene:
72              MUL absamo, absamo.x, absamo.y;              MUL absamo, absamo.x, absamo.y;
73              MUL absamo, absamo, radius.x;              MUL absamo, absamo, radius.x;
74    
75              # Scale = 1-|A-O|              # cent = 1-|A-O|
76                TEMP cent;
77                SUB cent, zeroone.y, absamo.x;
78                MAX cent, cent, 0;
79                MIN cent, cent, anchor.z;
80    
81              TEMP scale;              TEMP scale;
82              SUB scale, zeroone.y, absamo.x;              ADD scale, cent, zeroone.y;
             MAX scale, scale, 0;  
             MIN scale, scale, anchor.z;  
             ADD scale, scale, zeroone.y;  
83    
84              TEMP amp;              TEMP amp;
85              SUB amp, anchor, p;              SUB amp, anchor, p;
86    
87                TEMP ampnor;
88                TEMP amplen;
89                DP3 amplen, amp, amp;
90                RSQ ampnor, amplen.x;
91                MUL amplen, amplen.x, ampnor.x;
92                MUL amplen, amplen.x, radius.x;
93                MUL ampnor, ampnor, amp;
94    
95                # Function to determine shift
96                %(func)s
97    
98    
99              # buoy position              # buoy position
100              TEMP buoy;              TEMP buoy;
101              MAD buoy, amp, scale, p;              MAD buoy, ampnor, shift, anchor;
102    
103              MOV buoy.zw, zeroone.xyxy;              MOV buoy.zw, zeroone.xyxy;
104              ADD buoy.z, buoy.z, -scale;              ADD buoy.z, buoy.z, -scale;
# Line 89  class Scene: Line 138  class Scene:
138          """)          """)
139    
140          vert = []          vert = []
141          if 0:          if 1:
142              for x in floats(0,1,15):              n = 45
143                  for y in floats(0,1,15):              for x in floats(0,1,n):
144                    for y in floats(0,1,n):
145                      vert.append("""                      vert.append("""
146                          Color %(x)s .0 %(y)s .6                          Color %(x)s .0 %(y)s .6
147                          Vertex %(x)s %(y)s 0 1                          Vertex %(x)s %(y)s 0 1
# Line 127  class Scene: Line 177  class Scene:
177                  Enable VERTEX_PROGRAM_ARB                  Enable VERTEX_PROGRAM_ARB
178                  Enable VERTEX_PROGRAM_POINT_SIZE_ARB                  Enable VERTEX_PROGRAM_POINT_SIZE_ARB
179                  Enable POINT_SMOOTH                  Enable POINT_SMOOTH
180                    Enable LINE_SMOOTH
181                  Enable BLEND                  Enable BLEND
182          """ % self.prog.getProgId()));          """ % self.prog.getProgId()));
183    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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