2 |
|
|
3 |
#include <vob/Coorder.hxx> |
#include <vob/Coorder.hxx> |
4 |
#include <vob/VecGL.hxx> |
#include <vob/VecGL.hxx> |
5 |
|
#include <vob/Debug.hxx> |
6 |
|
|
|
#define DBG(cname) if(!cname);else (std::cout << "CallGL: ") |
|
7 |
|
|
|
static bool dbg; |
|
8 |
|
|
9 |
namespace Vob { |
namespace Vob { |
10 |
|
DBGVAR(dbg_coorder, "Coorder"); |
11 |
|
|
12 |
|
|
13 |
using namespace VecGL; |
using namespace VecGL; |
14 |
|
|
32 |
ZPt res = lerp(cs1.transform(p), |
ZPt res = lerp(cs1.transform(p), |
33 |
cs2.transform(p), |
cs2.transform(p), |
34 |
fract); |
fract); |
35 |
DBG(dbg) << "PointInterp: "<<p<<": "<<fract<<" "<< |
DBG(dbg_coorder) << "PointInterp: "<<p<<": "<<fract<<" "<< |
36 |
cs1.transform(p) << " " << cs2.transform(p) << " " |
cs1.transform(p) << " " << cs2.transform(p) << " " |
37 |
<< res<<"\n"; |
<< res<<"\n"; |
38 |
return res; |
return res; |
75 |
cs2.performGL(); |
cs2.performGL(); |
76 |
glGetFloatv(GL_MODELVIEW_MATRIX, mat2); |
glGetFloatv(GL_MODELVIEW_MATRIX, mat2); |
77 |
|
|
78 |
DBG(dbg) << "PointInterp PerformGL!\n"; |
DBG(dbg_coorder) << "PointInterp PerformGL!\n"; |
79 |
if(dbg) { |
if(dbg_coorder) { |
80 |
for(int i=0; i<16; i++) DBG(dbg) << mat1[i] << " "; |
for(int i=0; i<16; i++) DBG(dbg_coorder) << mat1[i] << " "; |
81 |
DBG(dbg) << "\n"; |
DBG(dbg_coorder) << "\n"; |
82 |
for(int i=0; i<16; i++) DBG(dbg) << mat2[i] << " "; |
for(int i=0; i<16; i++) DBG(dbg_coorder) << mat2[i] << " "; |
83 |
DBG(dbg) << "\n"; |
DBG(dbg_coorder) << "\n"; |
84 |
} |
} |
85 |
for(int i=0; i<16; i++) |
for(int i=0; i<16; i++) |
86 |
((float *)mat)[i] = lerp(mat1[i], mat2[i], fract); |
((float *)mat)[i] = lerp(mat1[i], mat2[i], fract); |
119 |
transformFactory(fac), cs1_tmp(0), cs2_tmp(0) { |
transformFactory(fac), cs1_tmp(0), cs2_tmp(0) { |
120 |
} |
} |
121 |
Coorder::~Coorder() { |
Coorder::~Coorder() { |
122 |
DBG(dbg) << "Deleting coordset "<<this<<" "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
DBG(dbg_coorder) << "Deleting coordset "<<this<<" "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
123 |
clean(); |
clean(); |
124 |
if(cs1_tmp) { delete cs1_tmp; cs1_tmp = 0; } |
if(cs1_tmp) { delete cs1_tmp; cs1_tmp = 0; } |
125 |
if(cs2_tmp) { delete cs2_tmp; cs2_tmp = 0; } |
if(cs2_tmp) { delete cs2_tmp; cs2_tmp = 0; } |
127 |
|
|
128 |
// Once types are checked, this method checks the parents. |
// Once types are checked, this method checks the parents. |
129 |
bool Coorder::shouldInterpolate(int cs1, int cs2, int nprev) { |
bool Coorder::shouldInterpolate(int cs1, int cs2, int nprev) { |
130 |
DBG(dbg) << "Shouldinterp "<<cs1<<" "<<cs2<<" "<<nprev<<"\n"; |
DBG(dbg_coorder) << "Shouldinterp "<<cs1<<" "<<cs2<<" "<<nprev<<"\n"; |
131 |
for(int i=0; i<nprev; i++) { |
for(int i=0; i<nprev; i++) { |
132 |
int par1 = inds1[cs1+1+i]; |
int par1 = inds1[cs1+1+i]; |
133 |
if(!cs[par1]) return false; |
if(!cs[par1]) return false; |
136 |
int par1interpsto = (par1 > 0 ? interpinds[par1] : 0); |
int par1interpsto = (par1 > 0 ? interpinds[par1] : 0); |
137 |
if(par1interpsto != par2) return false; |
if(par1interpsto != par2) return false; |
138 |
} |
} |
139 |
DBG(dbg) << "DO interpolate\n"; |
DBG(dbg_coorder) << "DO interpolate\n"; |
140 |
return true; |
return true; |
141 |
} |
} |
142 |
|
|
145 |
int *interpinds, |
int *interpinds, |
146 |
int *inds2, float *points2, |
int *inds2, float *points2, |
147 |
float fract, bool show1) { |
float fract, bool show1) { |
148 |
DBG(dbg) << "Set points "<<ninds<<" " |
DBG(dbg_coorder) << "Set points "<<ninds<<" " |
149 |
<< inds1 << " " |
<< inds1 << " " |
150 |
<< points1 << " " |
<< points1 << " " |
151 |
<< interpinds << " " |
<< interpinds << " " |
162 |
ASG(points2) |
ASG(points2) |
163 |
|
|
164 |
params.resize(0); |
params.resize(0); |
165 |
DBG(dbg) << "Resized\n"; |
DBG(dbg_coorder) << "Resized\n"; |
166 |
params.reserve(3*ninds); |
params.reserve(3*ninds); |
167 |
DBG(dbg) << "Reserved\n"; |
DBG(dbg_coorder) << "Reserved\n"; |
168 |
cs.resize(ninds); |
cs.resize(ninds); |
169 |
DBG(dbg) << "Resized2\n"; |
DBG(dbg_coorder) << "Resized2\n"; |
170 |
cs[0] = new RootCoords(); |
cs[0] = new RootCoords(); |
171 |
DBG(dbg) << "setroot\n"; |
DBG(dbg_coorder) << "setroot\n"; |
172 |
int lastIndSize = 1; |
int lastIndSize = 1; |
173 |
|
|
174 |
DBG(dbg) << "Removing tmps "<<this<<" "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
DBG(dbg_coorder) << "Removing tmps "<<this<<" "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
175 |
if(cs1_tmp) { delete cs1_tmp; cs1_tmp = 0; } |
if(cs1_tmp) { delete cs1_tmp; cs1_tmp = 0; } |
176 |
if(cs2_tmp) { delete cs2_tmp; cs2_tmp = 0; } |
if(cs2_tmp) { delete cs2_tmp; cs2_tmp = 0; } |
177 |
|
|
178 |
this->maxcs = ninds; |
this->maxcs = ninds; |
179 |
|
|
180 |
for(int i=1; i<ninds; i+=lastIndSize) { |
for(int i=1; i<ninds; i+=lastIndSize) { |
181 |
DBG(dbg) << "loop "<<i<<"\n"; |
DBG(dbg_coorder) << "loop "<<i<<"\n"; |
182 |
int parind = params.size(); |
int parind = params.size(); |
183 |
|
|
184 |
int tp = inds1[i] & ~CSFLAGS; |
int tp = inds1[i] & ~CSFLAGS; |
199 |
|
|
200 |
ind1 = inds1[i+1+nprev]; |
ind1 = inds1[i+1+nprev]; |
201 |
csind2 = ((interpinds && i < interpinds[0]) ? interpinds[i] : -1); |
csind2 = ((interpinds && i < interpinds[0]) ? interpinds[i] : -1); |
202 |
DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<< |
DBG(dbg_coorder) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<< |
203 |
" ind1:"<<ind1<<" "<<csind2<<"\n"; |
" ind1:"<<ind1<<" "<<csind2<<"\n"; |
204 |
|
|
205 |
|
|
229 |
} |
} |
230 |
} else { |
} else { |
231 |
for(int j = 0; j<npars; j++) { |
for(int j = 0; j<npars; j++) { |
232 |
DBG(dbg) << "Interpolating " |
DBG(dbg_coorder) << "Interpolating " |
233 |
<<(ind1+j)<<" " <<(ind2+j)<<" = " |
<<(ind1+j)<<" " <<(ind2+j)<<" = " |
234 |
<< points1[ind1+j]<<" "<< points2[ind2+j]<<"\n"; |
<< points1[ind1+j]<<" "<< points2[ind2+j]<<"\n"; |
235 |
params.push_back( |
params.push_back( |
243 |
int parent = inds1[i+1+j]; |
int parent = inds1[i+1+j]; |
244 |
Transform *parentcs = cs[parent]; |
Transform *parentcs = cs[parent]; |
245 |
if(parentcs == 0) { |
if(parentcs == 0) { |
246 |
DBG(dbg) << "Parent "<<j<<" not interp\n"; |
DBG(dbg_coorder) << "Parent "<<j<<" not interp\n"; |
247 |
goto nextInd; // If parent's not interpolating, neither are we. |
goto nextInd; // If parent's not interpolating, neither are we. |
248 |
} |
} |
249 |
prev[j] = parentcs; |
prev[j] = parentcs; |
250 |
} |
} |
251 |
DBG(dbg) << "CS assigned "<<tp<<"\n"; |
DBG(dbg_coorder) << "CS assigned "<<tp<<"\n"; |
252 |
|
|
253 |
/** Finally, creates a new coordsys of demanded type and sets its parents and |
/** Finally, creates a new coordsys of demanded type and sets its parents and |
254 |
* params. If the initialized coordsys (according to its initialized attributes) |
* params. If the initialized coordsys (according to its initialized attributes) |
260 |
} else { |
} else { |
261 |
interpolatePointwise: |
interpolatePointwise: |
262 |
// Now, the hairy case. |
// Now, the hairy case. |
263 |
DBG(dbg) << "It got hairy now: "<<tp<<" "<<t2<<"\n"; |
DBG(dbg_coorder) << "It got hairy now: "<<tp<<" "<<t2<<"\n"; |
264 |
if(!cs1_tmp) { |
if(!cs1_tmp) { |
265 |
cs1_tmp = new Coorder(transformFactory); |
cs1_tmp = new Coorder(transformFactory); |
266 |
cs1_tmp->setPoints(ninds, inds1, points1, |
cs1_tmp->setPoints(ninds, inds1, points1, |
287 |
cs[i] = c; |
cs[i] = c; |
288 |
|
|
289 |
if (!cs[i]->shouldBeDrawn()) { |
if (!cs[i]->shouldBeDrawn()) { |
290 |
DBG(dbg) << "CS should not be drawn... freeing it with delete.\n"; |
DBG(dbg_coorder) << "CS should not be drawn... freeing it with delete.\n"; |
291 |
delete cs[i]; // Must be deleted, because created with "new" in factories. |
delete cs[i]; // Must be deleted, because created with "new" in factories. |
292 |
cs[i] = NULL; |
cs[i] = NULL; |
293 |
} |
} |
295 |
nextInd: |
nextInd: |
296 |
if(tmp_c) delete tmp_c; |
if(tmp_c) delete tmp_c; |
297 |
} |
} |
298 |
DBG(dbg) << "end: "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
DBG(dbg_coorder) << "end: "<<cs1_tmp<<" "<<cs2_tmp<<"\n"; |
299 |
} |
} |
300 |
|
|
301 |
Coorder::iterator Coorder::begin() { |
Coorder::iterator Coorder::begin() { |