/[gzz]/gzz/gfx/libpaper/texcoords.py
ViewVC logotype

Diff of /gzz/gfx/libpaper/texcoords.py

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

revision 1.2 by jvk, Sat Aug 31 05:42:32 2002 UTC revision 1.3 by tjl, Sat Aug 31 05:43:33 2002 UTC
# Line 1  Line 1 
1  # Texture coordinates  # Texture coordinates
2    
3  class TexCoords:  class TexCoords:
4      def _create2DXYVectors(rnd):      def _create2DXYVectors(self, rnd):
5          """Create the carefully correlated matrix which gives (x,y)          """Create the carefully correlated matrix which gives (x,y)
6             from the texture coordinates (s,t).             from the texture coordinates (s,t).
7    
# Line 44  class TexCoords: Line 44  class TexCoords:
44    
45          return mat          return mat
46    
47      def _invert2Dsimple(mat):      def _invert2Dsimple(self, mat):
48          """Invert 2 4D vectors given by _create2DXYVectors to get the vectors          """Invert 2 4D vectors given by _create2DXYVectors to get the vectors
49          to dot (x,y,0,1) with to get (s,t)          to dot (x,y,0,1) with to get (s,t)
50          """          """
# Line 61  class TexCoords: Line 61  class TexCoords:
61                    
62          return r          return r
63    
64      def _create3DPlane(rnd):      def _create3DPlane(self, rnd):
65          """Get a suitable vector for a plane inside a 3D texture.          """Get a suitable vector for a plane inside a 3D texture.
66    
67          Returns a 4-component vector; the equation is          Returns a 4-component vector; the equation is
# Line 82  class TexCoords: Line 82  class TexCoords:
82    
83          return (i, j, k, shift)          return (i, j, k, shift)
84    
85      def _3DPlaneOrthoVecs(v):      def _3DPlaneOrthoVecs(self, v):
86          """From a 4-vector (a,b,c,d) describing a plane, create two orthonormal          """From a 4-vector (a,b,c,d) describing a plane, create two orthonormal
87          3-vectors plus one 3-offset vector which mean          3-vectors plus one 3-offset vector which mean
88          (s3,t3,r3) = v_1*s2 + v_2*t2 + v_3 where          (s3,t3,r3) = v_1*s2 + v_2*t2 + v_3 where
# Line 123  class TexCoords: Line 123  class TexCoords:
123          return (vec1, vec2, vec3)          return (vec1, vec2, vec3)
124    
125    
126      def get2DTexGenData(rnd):      def get2DTexGenData(self, rnd):
127          """Get the data to pass to texgen for a single, random          """Get the data to pass to texgen for a single, random
128          2D texture coordinate system.          2D texture coordinate system.
129          """          """
130          vectors = _invert2Dsimple(_create2DXYVectors(rnd))          vectors = self._invert2Dsimple(self._create2DXYVectors(rnd))
131          return [          return [
132              vectors[0][0],              vectors[0][0],
133              vectors[0][1],              vectors[0][1],
# Line 140  class TexCoords: Line 140  class TexCoords:
140              0, 0, 0, 0              0, 0, 0, 0
141              ]              ]
142    
143      def get3DTexGenData(rnd):      def get3DTexGenData(self, rnd):
144          """Get the data to pass to texgen for a single, random          """Get the data to pass to texgen for a single, random
145          2D slice of a 3D texture coordinate system.          2D slice of a 3D texture coordinate system.
146          """          """
147          # Get the transformation from (x,y,z) to          # Get the transformation from (x,y,z) to
148          # the virtual 2D texture coordinates (s2, t2)          # the virtual 2D texture coordinates (s2, t2)
149          vectors = _invert2Dsimple(_create2DXYVectors(rnd))          vectors = self._invert2Dsimple(self._create2DXYVectors(rnd))
150    
151          # Then, create the transformation from (s2, t3)          # Then, create the transformation from (s2, t3)
152          # to (s3, t3, r3)          # to (s3, t3, r3)
153          planevec =  _create3DPlane(rnd)          planevec =  self._create3DPlane(rnd)
154    
155          # And finally, concatenate the two by matrix          # And finally, concatenate the two by matrix
156          # multiplication          # multiplication
# Line 180  class TexCoords: Line 180  class TexCoords:
180              vectors[2][3],              vectors[2][3],
181              ]              ]
182    
183      def getCorrelatedTexGenData(tg, rnd):      def getCorrelatedTexGenData(self, tg, rnd):
184          sca = 0.07          sca = 0.07
185          return [          return [
186              tg[0],              tg[0],

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