00001 #include <esg/geometry/Surface.h>
00002 #include <esg/mesh/PolygonalMesh.h>
00003 #include <esg/mesh/SurfaceMesh.h>
00004
00005 using namespace esg;
00006
00007 bool Surface::_check_vertex()
00008 {
00009 if (_primActVert == _primVertices) {
00010
00011 if (_pRepository) {
00012 _Surface * pS;
00013 if (_havePlaneNormal)
00014 pS = new _Surface(_vertices,
00015 _normals,
00016 _uvCoords,
00017 _primVertices,
00018 _primVertIndices,
00019 _primNormIndices,
00020 _primUVIndices,
00021 _auxPlaneNormal,
00022 true);
00023 else
00024 pS = new _Surface(_vertices,
00025 _normals,
00026 _uvCoords,
00027 _primVertices,
00028 _primVertIndices,
00029 _primNormIndices,
00030 _primUVIndices);
00031 _pRepository->append(pS);
00032 _nSurfaces++;
00033 }
00034
00035
00036 _havePlaneNormal = false;
00037
00038
00039 switch (_vertOrder) {
00040 case TRIANGLES:
00041 case QUADS:
00042 _primActVert = 0;
00043 break;
00044 case TRIANGLE_STRIP:
00045 case QUAD_STRIP:
00046 _primVertIndices[0] = _primVertIndices[_primVertices-1];
00047 _primVertIndices[1] = _primVertIndices[_primVertices-2];
00048 _primNormIndices[0] = _primNormIndices[_primVertices-1];
00049 _primNormIndices[1] = _primNormIndices[_primVertices-2];
00050 _primUVIndices[0] = _primUVIndices[_primVertices-1];
00051 _primUVIndices[1] = _primUVIndices[_primVertices-2];
00052 _primActVert = 2;
00053 break;
00054 case TRIANGLE_FAN:
00055 _primVertIndices[1] = _primVertIndices[_primVertices-1];
00056 _primNormIndices[1] = _primNormIndices[_primVertices-1];
00057 _primUVIndices[1] = _primUVIndices[_primVertices-1];
00058 _primActVert = 2;
00059 break;
00060 }
00061 }
00062
00063 return true;
00064 }
00065
00066 Mesh* Surface::_mesh(int) const
00067 {
00068 if (!_created) return NULL;
00069 if (_fastMesh) return new SurfaceMesh((Surface*)this);
00070 if (!_pIterator) return NULL;
00071
00072
00073 PolygonalMesh * pMesh = new PolygonalMesh(_vertices, _nVert);
00074
00075 _pIterator->initChildrenSearch();
00076 _Surface * pSurface = (_Surface*) _pIterator->firstChild();
00077
00078 while (pSurface) {
00079 Vector3* normals;
00080
00081
00082 if (pSurface->haveVertNormals()) {
00083 normals = new Vector3 [pSurface->numVertices()];
00084 for (unsigned i = 0; i < pSurface->numVertices(); i++)
00085 normals[i].set(pSurface->getVertNormal(i));
00086 } else
00087 normals = NULL;
00088
00089
00090 if (pSurface->haveFixedNormal())
00091 pMesh->addFacet(pSurface->_vindices,
00092 normals,
00093 pSurface->numVertices(),
00094 pSurface->getFacetNormal());
00095 else
00096 pMesh->addFacet(pSurface->_vindices,
00097 normals,
00098 pSurface->numVertices());
00099
00100 delete [] normals;
00101
00102 pSurface = (_Surface*) _pIterator->nextChild();
00103 }
00104
00105 return (Mesh*) pMesh;
00106 }
00107
00108 void Surface::_duplicate_attributes(const Geometry& src)
00109 {
00110 if (!((Surface&)src)._created) {
00111 fprintf(stderr,"Surface Error: can't duplicate attributes during creation process\n");
00112 return;
00113 }
00114
00115 _created = true;
00116
00117 _pPreviousHit = new HitPoint();
00118
00119 _vertOrder = ((Surface&)src)._vertOrder;
00120 _fastMesh = ((Surface&)src)._fastMesh;
00121
00122 _nSurfaces = ((Surface&)src)._nSurfaces;
00123
00124 _pAutoVertices = ((Surface&)src)._pAutoVertices;
00125 if (_pAutoVertices) {
00126 _nVert = ((Surface&)src)._nVert;
00127 _vertices = _pAutoVertices->origObject();
00128 _pAutoVertices->registerReferer(this);
00129 } else {
00130 _nVert = 0;
00131 _vertices = NULL;
00132 fprintf(stderr,"Surface Error: No global array of vertices in source object\n");
00133 }
00134
00135 _pAutoNormals = ((Surface&)src)._pAutoNormals;
00136 if (_pAutoNormals) {
00137 _nNorm = ((Surface&)src)._nNorm;
00138 _normals = _pAutoNormals->origObject();
00139 _pAutoNormals->registerReferer(this);
00140 } else {
00141 _nVert = 0;
00142 _vertices = NULL;
00143 fprintf(stderr,"Surface Error: No global array of vertex normals in source object\n");
00144 }
00145
00146 _pAutoUVCoords = ((Surface&)src)._pAutoUVCoords;
00147 if (_pAutoUVCoords) {
00148 _nUVCoords = ((Surface&)src)._nUVCoords;
00149 _uvCoords = _pAutoUVCoords->origObject();
00150 _pAutoUVCoords->registerReferer(this);
00151 } else {
00152 _nUVCoords = 0;
00153 _uvCoords = NULL;
00154 fprintf(stderr,"Surface Error: No global array of vertex UV coordinates in source object\n");
00155 }
00156
00157 _pAutoInter = ((Surface&)src)._pAutoInter;
00158 if (_pAutoInter) {
00159 _pIntersector = _pAutoInter->origObject();
00160 _pAutoInter->registerReferer(this);
00161 } else
00162 _pIntersector = NULL;
00163
00164 if (((Surface&)src)._pRepository) {
00165 _pRepository = (SDS*)((Surface&)src)._pRepository->clone();
00166 IteratorSDS * pIterator = (IteratorSDS*) ((Surface&)src)._pRepository->createIterator();
00167 pIterator->initChildrenSearch();
00168 _Surface * pObj = (_Surface*) pIterator->firstChild();
00169 while (pObj) {
00170 _pRepository->append(pObj->clone());
00171 pObj = (_Surface*) pIterator->nextChild();
00172 }
00173 _pRepository->build();
00174 } else
00175 _pRepository = NULL;
00176
00177 if (_pRepository) {
00178 _pIterator = (IteratorSDS*)_pRepository->createIterator();
00179 } else {
00180 _pIterator = NULL;
00181 }
00182 }
00183
00184 void Surface::_rotateX(float a)
00185 {
00186 if (!_created || !_pIterator) return;
00187
00188 Matrix3 trMat;
00189 trMat.rotX(a);
00190
00191 for (register unsigned i = 0; i < _nVert; i++)
00192 trMat.transform(_vertices[i]);
00193
00194 for (register unsigned i = 0; i < _nNorm; i++)
00195 trMat.transform(_normals[i]);
00196
00197 _pIterator->initChildrenSearch();
00198 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00199 while (pCand) {
00200 pCand->_rotate(trMat);
00201 pCand = (_Surface*) _pIterator->nextChild();
00202 }
00203 }
00204
00205 void Surface::_rotateY(float a)
00206 {
00207 if (!_created || !_pIterator) return;
00208
00209 Matrix3 trMat;
00210 trMat.rotY(a);
00211
00212 for (register unsigned i = 0; i < _nVert; i++)
00213 trMat.transform(_vertices[i]);
00214
00215 for (register unsigned i = 0; i < _nNorm; i++)
00216 trMat.transform(_normals[i]);
00217
00218 _pIterator->initChildrenSearch();
00219 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00220 while (pCand) {
00221 pCand->_rotate(trMat);
00222 pCand = (_Surface*) _pIterator->nextChild();
00223 }
00224 }
00225
00226 void Surface::_rotateZ(float a)
00227 {
00228 if (!_created || !_pIterator) return;
00229
00230 Matrix3 trMat;
00231 trMat.rotZ(a);
00232
00233 for (register unsigned i = 0; i < _nVert; i++)
00234 trMat.transform(_vertices[i]);
00235
00236 for (register unsigned i = 0; i < _nNorm; i++)
00237 trMat.transform(_normals[i]);
00238
00239 _pIterator->initChildrenSearch();
00240 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00241 while (pCand) {
00242 pCand->_rotate(trMat);
00243 pCand = (_Surface*) _pIterator->nextChild();
00244 }
00245 }
00246
00247 void Surface::_rotate(float a, const Vector3& axis)
00248 {
00249 if (!_created || !_pIterator) return;
00250
00251 Matrix4d trMat;
00252 Matrix3d rotMat;
00253 trMat.rotationGL(a, axis);
00254 trMat.get(rotMat);
00255
00256 for (register unsigned i = 0; i < _nVert; i++)
00257 trMat.transform(_vertices[i]);
00258
00259 for (register unsigned i = 0; i < _nNorm; i++)
00260 trMat.transform(_normals[i]);
00261
00262 _pIterator->initChildrenSearch();
00263 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00264 while (pCand) {
00265 pCand->_transform(trMat);
00266 pCand = (_Surface*) _pIterator->nextChild();
00267 }
00268 }
00269
00270 void Surface::_rotate(const Matrix3& rotMat)
00271 {
00272 if (!_created || !_pIterator) return;
00273
00274 for (register unsigned i = 0; i < _nVert; i++)
00275 rotMat.transform(_vertices[i]);
00276
00277 for (register unsigned i = 0; i < _nNorm; i++)
00278 rotMat.transform(_normals[i]);
00279
00280 _pIterator->initChildrenSearch();
00281 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00282 while (pCand) {
00283 pCand->_rotate(rotMat);
00284 pCand = (_Surface*) _pIterator->nextChild();
00285 }
00286 }
00287
00288 void Surface::_translate(float x, float y, float z)
00289 {
00290 if (!_created || !_pIterator) return;
00291
00292 for (register unsigned i = 0; i < _nVert; i++) {
00293 _vertices[i].x += x;
00294 _vertices[i].y += y;
00295 _vertices[i].z += z;
00296 }
00297
00298 _pIterator->initChildrenSearch();
00299 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00300 while (pCand) {
00301 pCand->_translate(x,y,z);
00302 pCand = (_Surface*) _pIterator->nextChild();
00303 }
00304 }
00305
00306 void Surface::_transform(const Matrix4& trMat)
00307 {
00308 if (!_created || !_pIterator) return;
00309
00310 for (register unsigned i = 0; i < _nVert; i++)
00311 trMat.transform(_vertices[i]);
00312
00313 for (register unsigned i = 0; i < _nNorm; i++) {
00314 Matrix3d rotMat;
00315 trMat.get(rotMat);
00316 rotMat.transform(_normals[i]);
00317 }
00318
00319 _pIterator->initChildrenSearch();
00320 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00321 while (pCand) {
00322 pCand->_transform(trMat);
00323 pCand = (_Surface*) _pIterator->nextChild();
00324 }
00325 }
00326
00327 void Surface::_scale(float s)
00328 {
00329 if (!_created || !_pIterator) return;
00330
00331 for (register unsigned i = 0; i < _nVert; i++) _vertices[i].scale(s);
00332
00333 _pIterator->initChildrenSearch();
00334 _Surface * pCand = (_Surface*) _pIterator->firstChild();
00335 while (pCand) {
00336 pCand->_scale(s);
00337 pCand = (_Surface*) _pIterator->nextChild();
00338 }
00339 }
00340
00341
00342
00343 Surface::Surface(const SDS& ss,
00344 AutoArray<Vertex3>* va,
00345 unsigned nv,
00346 AutoArray<Vector3>* na,
00347 unsigned nn,
00348 AutoArray<Vector2>* uva,
00349 unsigned uvn,
00350 enum VertOrder vo,
00351 AutoPtr<Intersector>* it,
00352 bool fm)
00353 {
00354 _pRepository = (SDS*) ss.clone();
00355 _havePlaneNormal = false;
00356 _vertOrder = vo;
00357 _primActVert = 0;
00358 _created = false;
00359 _pPreviousHit = new HitPoint();
00360 _fastMesh = fm;
00361 _nSurfaces = 0;
00362
00363 if (va && nv) {
00364 _nVert = nv;
00365 _pAutoVertices = va;
00366 _vertices = _pAutoVertices->origObject();
00367 if (!_vertices)
00368 fprintf(stderr,"Surface Error: No global array of vertices defined\n");
00369 _pAutoVertices->registerReferer(this);
00370 } else {
00371 _nVert = 0;
00372 _pAutoVertices = NULL;
00373 _vertices = NULL;
00374 fprintf(stderr,"Surface Error: No global array of vertices defined\n");
00375 }
00376
00377 if (na && nn) {
00378 _nNorm = nn;
00379 _pAutoNormals = na;
00380 _normals = _pAutoNormals->origObject();
00381 _pAutoNormals->registerReferer(this);
00382 } else {
00383 _nNorm = 0;
00384 _pAutoNormals = NULL;
00385 _normals = NULL;
00386 }
00387
00388 if (uva && uvn) {
00389 _nUVCoords = uvn;
00390 _pAutoUVCoords = uva;
00391 _uvCoords = _pAutoUVCoords->origObject();
00392 _pAutoUVCoords->registerReferer(this);
00393 } else {
00394 _nUVCoords = 0;
00395 _pAutoUVCoords = NULL;
00396 _uvCoords = NULL;
00397 }
00398
00399 if (it) {
00400 _pIntersector = it->origObject();
00401 _pAutoInter = it;
00402 it->registerReferer(this);
00403 } else {
00404 _pIntersector = NULL;
00405 _pAutoInter = NULL;
00406 }
00407
00408 if (_pRepository) {
00409 _pIterator = (IteratorSDS*)_pRepository->createIterator();
00410 } else {
00411 _pIterator = NULL;
00412 }
00413
00414 switch (vo) {
00415 case TRIANGLES:
00416 case TRIANGLE_STRIP:
00417 case TRIANGLE_FAN:
00418 _primVertices = 3;
00419 break;
00420 case QUADS:
00421 case QUAD_STRIP:
00422 _primVertices = 4;
00423 break;
00424 default:
00425 fprintf(stderr,"Surface Error: Unsupported vertices interpretation\n");
00426 }
00427 }
00428
00429 Surface::~Surface()
00430 {
00431 if (_pRepository) delete _pRepository;
00432 AutoPtr<Intersector>::destroy(_pAutoInter, this);
00433 AutoArray<Vertex3>::destroy(_pAutoVertices, this);
00434 AutoArray<Vector3>::destroy(_pAutoNormals, this);
00435 AutoArray<Vector2>::destroy(_pAutoUVCoords, this);
00436 if (_pPreviousHit) delete _pPreviousHit;
00437 }
00438
00439 void Surface::normal(const Vector3& v)
00440 {
00441 _auxPlaneNormal.set(v);
00442 _havePlaneNormal = true;
00443 }
00444
00445 bool Surface::vertex(unsigned index)
00446 {
00447
00448 if (index >= _nVert || _normals) return false;
00449 _primVertIndices[_primActVert++] = index;
00450 return _check_vertex();
00451 }
00452
00453 bool Surface::vertex(unsigned vindex, unsigned nindex)
00454 {
00455 if (vindex >= _nVert || nindex >= _nNorm || !_normals) return false;
00456 _primVertIndices[_primActVert] = vindex;
00457 _primNormIndices[_primActVert++] = nindex;
00458 return _check_vertex();
00459 }
00460
00461 bool Surface::vertex(unsigned vindex, unsigned nindex, unsigned uvindex)
00462 {
00463 if (vindex >= _nVert || nindex >= _nNorm || uvindex >= _nUVCoords || !_normals || !_uvCoords) return false;
00464 _primVertIndices[_primActVert] = vindex;
00465 _primNormIndices[_primActVert] = nindex;
00466 _primUVIndices[_primActVert++] = uvindex;
00467 return _check_vertex();
00468 }
00469
00470 bool Surface::vertexUV(unsigned vindex, unsigned uvindex)
00471 {
00472 if (vindex >= _nVert || uvindex >= _nUVCoords || !_uvCoords) return false;
00473 _primVertIndices[_primActVert] = vindex;
00474 _primUVIndices[_primActVert++] = uvindex;
00475 return _check_vertex();
00476 }
00477
00478 bool Surface::done(void)
00479 {
00480 _created = true;
00481 return _pRepository->build();
00482 }
00483
00484 const _Surface* Surface::firstPlane(void)
00485 {
00486 if (!_pIterator) return NULL;
00487 _pIterator->initChildrenSearch();
00488 return (_Surface*) _pIterator->firstChild();
00489 }
00490
00491 const _Surface* Surface::nextPlane(void)
00492 {
00493 return ((_pIterator) ? (_Surface*) _pIterator->nextChild() : NULL);
00494 }
00495
00496 unsigned Surface::numEdges(void) const
00497 {
00498 if (!_pRepository) return 0;
00499 IteratorSDS * pIter = (IteratorSDS*) _pRepository->createIterator();
00500 if (!pIter) return 0;
00501 pIter->initChildrenSearch();
00502
00503 unsigned counter = 0;
00504 _Surface * pS = (_Surface*) pIter->firstChild();
00505 while (pS) {
00506 counter += pS->numVertices();
00507 pS = (_Surface*) pIter->nextChild();
00508 }
00509
00510 return counter;
00511 }
00512
00513 void Surface::rayIntersection(PointEnv* pEnv,
00514 int mask,
00515 const Vector3& origin,
00516 const Vector3& direction,
00517 float maxD)
00518 {
00519 if (!pEnv) return;
00520 pEnv->mask = ENV_HAVE_NOTHING;
00521 if (!_created || !_pIterator || !_pIntersector) return;
00522
00523 const void* pPrevLeaf = ((_pPreviousHit->pSDSLeaf &&
00524 _pPreviousHit->point.equals(origin)) ?
00525 _pPreviousHit->pSDSLeaf :
00526 NULL);
00527
00528 _pIntersector->init(mask, maxD);
00529 _pIterator->initRayIntersection(origin,direction,true,maxD,pPrevLeaf);
00530
00531 if (mask & (ENV_WANT_INTERSECTION|ENV_WANT_NORMAL|ENV_WANT_DISTANCE)) {
00532
00533
00534
00535 const void* pNewLeaf = NULL;
00536 float dist;
00537 SceneGraphObject * pCandidate = _pIterator->firstChild();
00538 while (pCandidate) {
00539 if (_pIntersector->processCandidate(pCandidate,origin,direction)) {
00540 pNewLeaf = _pIterator->lastExploitedElement();
00541 dist = _pIntersector->getActDistance();
00542 if (dist < maxD) {
00543 maxD = dist;
00544 _pIterator->initRayIntersection(origin, direction, false,
00545 maxD, pPrevLeaf);
00546 }
00547 }
00548 pCandidate = _pIterator->nextChild();
00549 }
00550
00551 PointEnv * pAuxE = _pIntersector->adoptIntersection();
00552 if (!pAuxE) return;
00553
00554 if (pAuxE->mask & ENV_HAVE_INTERFERENCE)
00555 pEnv->mask |= ENV_HAVE_INTERFERENCE;
00556
00557 if (pAuxE->mask & ENV_HAVE_INTERSECTION) {
00558 if (pNewLeaf) {
00559 _pPreviousHit->point.set(pAuxE->intersection);
00560 _pPreviousHit->pSDSLeaf = pNewLeaf;
00561 }
00562 pEnv->intersection.set(pAuxE->intersection);
00563 pEnv->mask |= ENV_HAVE_INTERSECTION|ENV_HAVE_INTERFERENCE;
00564 }
00565 if (pAuxE->mask & ENV_HAVE_NORMAL) {
00566 pEnv->normal.set(pAuxE->normal);
00567 pEnv->normalOrientation = pAuxE->normalOrientation;
00568 pEnv->mask |= ENV_HAVE_NORMAL;
00569 }
00570 if (pAuxE->mask & ENV_HAVE_DISTANCE) {
00571 pEnv->distance = pAuxE->distance;
00572 pEnv->mask |= ENV_HAVE_DISTANCE;
00573 }
00574 if (pAuxE->mask & ENV_HAVE_N_DOT_D) {
00575 pEnv->nd = pAuxE->nd;
00576 pEnv->mask |= ENV_HAVE_N_DOT_D;
00577 }
00578 if (pAuxE->mask & ENV_HAVE_N_DOT_O) {
00579 pEnv->no = pAuxE->no;
00580 pEnv->mask |= ENV_HAVE_N_DOT_O;
00581 }
00582
00583 delete pAuxE;
00584 } else {
00585
00586
00587
00588 SceneGraphObject * pCandidate = _pIterator->firstChild();
00589 while (pCandidate) {
00590 if (_pIntersector->processCandidate(pCandidate,origin,direction)) {
00591 pEnv->mask |= ENV_HAVE_INTERFERENCE;
00592 return;
00593 }
00594 pCandidate = _pIterator->nextChild();
00595 }
00596 return;
00597 }
00598 }
00599
00600 bool Surface::mapToUV(const Vector3& v, Vector2& uv)
00601 {
00602 fprintf(stderr,"Surface::mapToUV(): Not implemented\n");
00603 return false;
00604 }
00605
00606 void Surface::randomSample(int mask, PointEnv& pe, double* pdf)
00607 {
00608 pe.mask = ENV_HAVE_NOTHING;
00609
00610 if (!_pIterator) return;
00611 _pIterator->initChildrenSearch();
00612 _Surface* pSurface = (_Surface*) _pIterator->firstChild();
00613 for (unsigned i=(unsigned)((double)_nSurfaces*rand()/(RAND_MAX+1.));i;i--)
00614 pSurface = (_Surface*) _pIterator->nextChild();
00615
00616 if (pSurface) pSurface->randomSample(mask, pe, pdf);
00617 }
00618
00619 bool Surface::randomDirection(const Vector3& pov, Vector3& dir, double* pdf)
00620 {
00621 if (!_pIterator) return false;
00622 _pIterator->initChildrenSearch();
00623 _Surface* pSurface = (_Surface*) _pIterator->firstChild();
00624 for (unsigned i=(unsigned)((double)_nSurfaces*rand()/(RAND_MAX+1.));i;i--)
00625 pSurface = (_Surface*) _pIterator->nextChild();
00626
00627 return ((pSurface) ? pSurface->randomDirection(pov, dir, pdf) : false);
00628 }
00629
00630 Interval Surface::extent(const Vector3& direction) const
00631 {
00632 Interval retInt;
00633
00634 if (_created)
00635 for (unsigned i = 0; i < _nVert; i++) {
00636 float d = direction.dot(_vertices[i]);
00637 if (d < retInt.min) retInt.min = d;
00638 if (d > retInt.max) retInt.max = d;
00639 }
00640
00641 return retInt;
00642 }
00643
00644 Geometry* Surface::clone(const Matrix4* pTrMat) const
00645 {
00646 if (_created) {
00647 Surface * pRet = new Surface;
00648 pRet->_duplicate_attributes(*this);
00649 if (pTrMat) pRet->_transform(*pTrMat);
00650 return pRet;
00651 } else
00652 return NULL;
00653 }
00654
00655 Vector3 Surface::centroid() const
00656 {
00657 Vector3 pog(0.0, 0.0, 0.0);
00658 if (_created)
00659 for (register unsigned i = 0; i < _nVert; i++) {
00660 Vertex3 aux(_vertices[i]);
00661 aux.scale(1.0/_nVert);
00662 pog.add(aux);
00663 }
00664 return pog;
00665 }
00666
00667 double Surface::radius(const Vector3& centroid) const
00668 {
00669 register double r = - MAXDOUBLE;
00670 register double d;
00671 Vector3 aux;
00672 if (_created)
00673 for (register unsigned i = 0; i < _nVert; i++) {
00674 aux.set(_vertices[i]);
00675 aux.sub(centroid);
00676 d = aux.length();
00677 if (d > r) r = d;
00678 }
00679 return r;
00680 }
00681
00682 void Surface::dump(const char* intent, const char* tab)
00683 {
00684 printf("%s geometry PolygonalSurface {\n", intent);
00685 printf("%s %s numPolygons %d", intent, tab, _nSurfaces);
00686 printf("%s %s numVertices %d", intent, tab, _nVert);
00687 printf("%s %s numNormals %d", intent, tab, _nNorm);
00688 printf("%s %s numUVCoords %d", intent, tab, _nUVCoords);
00689 printf("%s %s fastMeshGeneration %s", intent, tab, ((_fastMesh) ? "yes" : "no"));
00690 printf("%s %s interpretation ", intent, tab);
00691 switch (_vertOrder) {
00692 case TRIANGLES: printf("TRIANGLES\n"); break;
00693 case TRIANGLE_STRIP: printf("TRIANGLE_STRIP\n"); break;
00694 case TRIANGLE_FAN: printf("TRIANGLE_FAN\n"); break;
00695 case QUADS: printf("QUADS\n"); break;
00696 case QUAD_STRIP: printf("QUAD_STRIP\n"); break;
00697 default: printf("UNKNOWN\n");
00698 }
00699 if (_vertices) {
00700 printf("%s %s vertices [\n", intent, tab);
00701 for (register unsigned i = 0; i < _nVert; i++)
00702 printf("%s %s %s %f %f %f\n", intent, tab, tab, _vertices[i].x, _vertices[i].y, _vertices[i].z);
00703 printf("%s %s ]\n", intent, tab);
00704 }
00705 if (_normals) {
00706 printf("%s %s vertexNorals [\n", intent, tab);
00707 for (register unsigned i = 0; i < _nVert; i++)
00708 printf("%s %s %s %f %f %f\n", intent, tab, tab, _normals[i].x, _normals[i].y, _normals[i].z);
00709 printf("%s %s ]\n", intent, tab);
00710 }
00711 if (_uvCoords) {
00712 printf("%s %s uvCoordinates [\n", intent, tab);
00713 for (register unsigned i = 0; i < _nVert; i++)
00714 printf("%s %s %s %f %f\n", intent, tab, tab, _uvCoords[i].x, _uvCoords[i].y);
00715 printf("%s %s ]\n", intent, tab);
00716 }
00717
00718 char* newIntent = new char [strlen(intent) + strlen(tab) + 2];
00719 newIntent = strcpy(newIntent, intent);
00720 newIntent = strcat(newIntent, " ");
00721 newIntent = strcat(newIntent, tab);
00722 if (_pRepository) _pRepository->dump(newIntent, tab);
00723 delete [] newIntent;
00724
00725 printf("%s }\n", intent);
00726 }
00727
00728
00729
00730
00731
00732
00733
00734