/[gzz]/gzz/gzz/gfx/gl/GLVobCoorder.java
ViewVC logotype

Diff of /gzz/gzz/gfx/gl/GLVobCoorder.java

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

revision 1.27 by tjl, Mon Sep 23 08:24:25 2002 UTC revision 1.28 by tjl, Wed Sep 25 14:45:43 2002 UTC
# Line 33  public static final String rcsid = "$Id$ Line 33  public static final String rcsid = "$Id$
33      public static boolean dbg = false;      public static boolean dbg = false;
34      private static void pa(String s) { System.err.println(s); }      private static void pa(String s) { System.err.println(s); }
35    
36      float[] coordsys = new float[10000];      float[] floats = new float[10000];
37      int ncoordsys = 7;      int nfloats = 0;
38      Object[] keys = new Object[10000];  
39        int[] inds = new int[5000];
40      public int getCSIndexAt(float x, float y) {      int ninds = 3; // first 3 ignored.
         throw new Error();  
         //      for(int i=0; i<ncoordsys; i += 7)  
         //   ; // XXX  
         //return 0;  
     }  
41    
42      HashMap inds = new HashMap();      public int getCSIndexAt(float x, float y) { return -1; }
43    
44      public int affineCoordsys(      public int affineCoordsys(
45              int into, Object key, float depth,              int into, float depth,
46              float cx, float cy,              float cx, float cy,
47                      float x_x, float x_y,                      float x_x, float x_y,
48                      float y_x, float y_y                      float y_x, float y_y
49                      ) {                      ) {
50          if(dbg) pa("AffineCoordSys "+ncoordsys/7+": "+into+" '"+key+"' "+depth+" --- "+          if(dbg) pa("AffineCoordSys "+ninds/3+": "+into+" '"+depth+" --- "+
                     cx+" "+cy+" "+x_x+" "+x_y+" "+y_x+" "+y_y);  
         if(into != 0) {  
             // Transform us into the other coordsys.  
             // XXX Not sure about the oblique components!!!  
             // XXX This is not the right way to do it, anyway -  
             // interpolation is wrong.  
             int ind = into * 7;  
             /*  
             float ncx = coordsys[ind+2] * cx +  
                           coordsys[ind+3] * cy +  
                           coordsys[ind];  
             float ncy = coordsys[ind+4] * cx +  
                           coordsys[ind+5] * cy +  
                           coordsys[ind+1];  
             float nx_x = coordsys[ind+2] * x_x +  
                           coordsys[ind+3] * y_x;  
             float nx_y = coordsys[ind+2] * x_y +  
                           coordsys[ind+3] * y_y;  
             float ny_x = coordsys[ind+4] * x_x +  
                           coordsys[ind+5] * y_x;  
             float ny_y = coordsys[ind+4] * x_y +  
                           coordsys[ind+5] * y_y;  
               */  
             // Ouch. the AWT implementation just translates -->  
             // so will we, for now.  
             float ncx = cx + coordsys[ind] - coordsys[ind+2];  
             float ncy = cy + coordsys[ind+1] - coordsys[ind+5];  
             float nx_x = x_x;  
             float nx_y = x_y;  
             float ny_x = y_x;  
             float ny_y = y_y;  
             cx = ncx;  
             cy = ncy;  
             x_x = nx_x;  
             x_y = nx_y;  
             y_x = ny_x;  
             y_y = ny_y;  
             depth = depth + coordsys[ind+6];  
             if(dbg) pa("Transformed: "+depth+" --- "+  
51                      cx+" "+cy+" "+x_x+" "+x_y+" "+y_x+" "+y_y);                      cx+" "+cy+" "+x_x+" "+x_y+" "+y_x+" "+y_y);
52    
53              // a REAL kludge          floats[nfloats + 0]     = cx;
54              if(dbg) pa("Passed key: "+key);          floats[nfloats + 1] = cy;
55              key = new Integer(          floats[nfloats + 2] = depth;
56                      mix(key.hashCode(),          floats[nfloats + 3] = x_x;
57                          keys[into] != null ? 1 : 0,          floats[nfloats + 4] = x_y;
58                          keys[into] != null ? keys[into].hashCode() : 0));          floats[nfloats + 5] = y_x;
59              if(dbg) {          floats[nfloats + 6] = y_y;
60                  pa("Old key: "+keys[into]);          int paramInd = nfloats;
61                  pa("New key: "+key);          nfloats += 7;
62              }  
63          }          inds[ninds + 0] = 1; // affine = 1
64          coordsys[ncoordsys]     = cx;          inds[ninds + 1] = into;
65          coordsys[ncoordsys + 1] = cy;          inds[ninds + 2] = paramInd;
         coordsys[ncoordsys + 2] = x_x;  
         coordsys[ncoordsys + 3] = x_y;  
         coordsys[ncoordsys + 4] = y_x;  
         coordsys[ncoordsys + 5] = y_y;  
         coordsys[ncoordsys + 6] = depth;  
         int was = ncoordsys;  
         ncoordsys += 7;  
         was /= 7;  
         keys[was] = key;  
         if(key!=null) inds.put(key, new Integer(was));  
         return was;  
     }  
66    
67      static public int mix(int i1, int i2, int i3) {          int was = ninds / 3;
68          return (i1 * 5124723 + 9812375) % 5350917 +          ninds += 3;
                 (i2 * 127401 + 897124) % 1128501 +  
                 (i3 * 317819 + 1897124) % 12501 ;  
     }  
   
     public Object getKeyAt(VobMap v, float x, float y, float[] internalcoords) {  
         float depth = 100000000;  
         Object key = null;  
         for(int i=0; i<ncoordsys/7; i++) {  
             int ind = i*7;  
             float nx = x - coordsys[ind + 0];  
             float ny = y - coordsys[ind + 1];  
             // XXX Should really invert the matrix...  
             double dx = nx / coordsys[ind + 2];  
             double dy = ny / coordsys[ind + 5];  
             if(Math.abs(dx) <= 1 && Math.abs(dy) <= 1 &&  
                 coordsys[ind+6] < depth ) {  
                 key = keys[i];  
                 depth = coordsys[ind+6];  
                 if(internalcoords != null) {  
                     internalcoords[0] = (float)dx;  
                     internalcoords[1] = (float)dy;  
                 }  
             }  
         }  
         return key;  
     }  
69    
70      public int getCoordsys(Object key) {          return was;
         Integer i = (Integer)inds.get(key);  
         if(i==null) return -1;  
         return i.intValue();  
71      }      }
72    
73      public void dump() {      public void dump() {
74          pa("GLVobCoorder: ");          pa("GLVobCoorder: ");
75          for(int i=0; i<ncoordsys/7; i++) {          for(int i=0; i<ninds/3; i++) {
76              int ind = i*7;              int ind = i*3;
77              String s = "";              String s = "";
78              for(int u = ind; u<ind+7; u++)              for(int u = ind; u<ind+3; u++)
79                  s = s + " " + coordsys[u];                  s = s + " " + inds[u];
80              pa("  cs: "+s+"  Key: "+keys[i]);              pa("  cs: "+s);
81          }          }
82      }      }
83    
84      GLVobCoorder interpListFor;      public void renderInterp(GraphicsAPI.Window into, GLVobMap theVobs, int[] csinds,
     int[] interpList = new int[1000];  
   
     public void makeindexlist(GLVobCoorder other) {  
         if(interpListFor == other) return ;  
         for(int i=0; i<ncoordsys/7; i++) {  
             if(keys[i] == null) continue;  
             int ind = other.getCoordsys(keys[i]);  
             interpList[i] = ind;  
         }  
         interpListFor = other;  
     }  
   
     public void renderInterp(GraphicsAPI.Window into, GLVobMap theVobs,  
85                              GLVobCoorder other, float fract,                              GLVobCoorder other, float fract,
86                              boolean standardcoords, boolean showFinal) {                              boolean standardcoords, boolean showFinal) {
87          renderInterp(((GLScreen)into).getWindow(), theVobs, other, fract,          renderInterp(((GLScreen)into).getWindow(), theVobs, csinds, other, fract,
88                              standardcoords, showFinal);                              standardcoords, showFinal);
89      }      }
90      public void renderInterp(GL.Window into, GLVobMap theVobs,      public void renderInterp(GL.Window into, GLVobMap theVobs, int[] csinds,
91                              GLVobCoorder other, float fract,                              GLVobCoorder other, float fract,
92                              boolean standardcoords, boolean showFinal) {                              boolean standardcoords, boolean showFinal) {
93          if(other == this) {          GL.render(into, ninds, this.inds, this.floats,
94              GL.render(into, theVobs.list, coordsys, null,                      csinds,
95                              coordsys, ncoordsys, fract, standardcoords,                      other.inds, other.floats,
96                                  showFinal);                      theVobs.list, fract, standardcoords, showFinal);
         } else {  
             makeindexlist(other);  
             GL.render(into, theVobs.list, coordsys, interpList,  
                             other.coordsys, ncoordsys, fract,  
                             standardcoords, showFinal);  
         }  
97      }      }
98      public float timeRender(GL.Window into, GLVobMap theVobs,      public float timeRender(GL.Window into, GLVobMap theVobs,
99                             boolean standardcoords, int iters) {                             boolean standardcoords, int iters) {
100          return GL.timeRender(into, theVobs.list,          return GL.timeRender(into, iters,
101                                  coordsys, ncoordsys, standardcoords, iters);                          ninds, inds, floats,
102                            theVobs.list,
103                                    standardcoords);
104      }      }
105    
106      public Vob.RenderInfo getRenderInfo(int cs) {      public Vob.RenderInfo getRenderInfo(int cs) {
107          // XXX          // XXX
108          OrthoRenderInfo ri = new OrthoRenderInfo();          OrthoRenderInfo ri = new OrthoRenderInfo();
109          int ind = cs * 7;          int ind = inds[cs+2];
110          float x = coordsys[ind + 0];          float x = floats[ind + 0];
111          float y = coordsys[ind + 1];          float y = floats[ind + 1];
112          float xs = coordsys[ind + 2];          float xs = floats[ind + 3];
113          float ys = coordsys[ind + 5];          float ys = floats[ind + 6];
114          ri.setCoords(1, x-xs, y-ys, 2*xs, 2*ys, -1, -1, -1, -1);          ri.setCoords(1, x-xs, y-ys, 2*xs, 2*ys, -1, -1, -1, -1);
115          return ri;          return ri;
116      }      }
117    
118      public boolean needInterp(VobCoorder interpTo) {      public boolean needInterp(VobCoorder interpTo, int[] interpList) {
119          // XXX          // XXX
120          return true;          return true;
121      }      }

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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