/[libvob]/libvob/include/vob/vobs/Paper.hxx
ViewVC logotype

Diff of /libvob/include/vob/vobs/Paper.hxx

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

revision 1.10 by tjl, Fri May 16 15:13:10 2003 UTC revision 1.11 by tjl, Mon Jun 9 15:04:36 2003 UTC
# Line 92  struct Verts { Line 92  struct Verts {
92      }      }
93  };  };
94    
 /** A set of triangles.  
  */  
 struct Triangler {  
     struct Tri {  
         int v[3];  
     };  
     vector<Tri> tris;  
     void operator()(int i, int j, int k) {  
         DBG(dbg_paperquad) << "Triangler: "<<i<<" "<<j<<" "<<k<<"\n";  
         Tri t;  
         t.v[0] = i;  
         t.v[1] = j;  
         t.v[2] = k;  
         tris.push_back(t);  
     }  
     void draw() {  
         glDrawElements(GL_TRIANGLES, tris.size()*3, GL_UNSIGNED_INT,  
                     &(tris[0]));  
     }  
 };  
   
95  inline float split(Verts &v, float dicelen, int i, int j) {  inline float split(Verts &v, float dicelen, int i, int j) {
96      float ret = (v.points[i].final - v.points[j].final).xylength()      float ret = (v.points[i].final - v.points[j].final).xylength()
97                      / dicelen - 1;                      / dicelen - 1;
# Line 121  inline float split(Verts &v, float dicel Line 100  inline float split(Verts &v, float dicel
100      return ret;      return ret;
101  }  }
102    
103    inline void addToAccum(LOD::TexAccum *acc, Verts &v,
104                    int v0, int v1, int v2) {
105        acc->add(
106                v.points[v0].final,
107                v.points[v1].final,
108                v.points[v2].final,
109                v.points[v0].orig,
110                v.points[v1].orig,
111                v.points[v2].orig);
112    }
113    
114  inline int splitTri(Verts &v, float dicelen1, float dicelen2, int i, int j, int k) {  inline int splitTri(Verts &v, float dicelen1, float dicelen2, int i, int j, int k) {
115      DBG(dbg_paperquad) << "SplitTri "<<i<<" "<<j<<" "<<k<<" "<<      DBG(dbg_paperquad) << "SplitTri "<<i<<" "<<j<<" "<<k<<" "<<
116              v.points[i].orig<<" "<<              v.points[i].orig<<" "<<
# Line 208  public: Line 198  public:
198      float diceLength, diceLength2;      float diceLength, diceLength2;
199      int diceDepth;      int diceDepth;
200    
201        LOD::TexAccum *texAccum;
202    
203      template<class F> void params(F &f) {      template<class F> void params(F &f) {
204          f(paper, x0, y0, x1, y1, flags, diceLength, diceLength2, diceDepth);          f(paper, x0, y0, x1, y1, flags, diceLength, diceLength2, diceDepth,
205                    texAccum);
206      }      }
207    
208    
# Line 231  public: Line 224  public:
224                  triangler.add(0, 1, 3);                  triangler.add(0, 1, 3);
225                  triangler.add(0, 3, 2);                  triangler.add(0, 3, 2);
226              DBG(dbg_paperquad) << "dice\n";              DBG(dbg_paperquad) << "dice\n";
227    
228                if(texAccum) {
229                    // First, dice roughly for the texture magnification
230                    // accumulator
231                    triangler.dice(bind(splitTri, ref(verts),
232                                diceLength*2, diceLength2*2, _1, _2, _3));
233                    // Then, calculate the texture surface estimates
234                    triangler.iterateTriangles(
235                            bind(addToAccum, texAccum, ref(verts), _1, _2, _3));
236                }
237    
238                // Dice to finish
239              triangler.dice(bind(splitTri, ref(verts), diceLength, diceLength2, _1, _2, _3));              triangler.dice(bind(splitTri, ref(verts), diceLength, diceLength2, _1, _2, _3));
240              DBG(dbg_paperquad) << "diced\n";              DBG(dbg_paperquad) << "diced\n";
241          }          }

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

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