Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/ac/Geode.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgPlugins/ac/Geode.cpp (modified) (55 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ac/Geode.cpp
r12645 r13041 47 47 } 48 48 49 void Geode::OutputLines(const int iCurrentMaterial, const unsigned int surfaceFlags, 49 void Geode::OutputLines(const int iCurrentMaterial, const unsigned int surfaceFlags, 50 50 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, ostream& fout) 51 51 { … … 58 58 } 59 59 } 60 void Geode::OutputLineStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 60 void Geode::OutputLineStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 61 61 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, ostream& fout) 62 62 { … … 68 68 } 69 69 } 70 void Geode::OutputLineLoop(const int iCurrentMaterial, const unsigned int surfaceFlags, 70 void Geode::OutputLineLoop(const int iCurrentMaterial, const unsigned int surfaceFlags, 71 71 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, ostream& fout) 72 72 { … … 78 78 } 79 79 } 80 void Geode::OutputTriangle(const int iCurrentMaterial, const unsigned int surfaceFlags, 80 void Geode::OutputTriangle(const int iCurrentMaterial, const unsigned int surfaceFlags, 81 81 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, ostream& fout) 82 82 { … … 85 85 for(unsigned int vindex=drawArray->getFirst(); vindex<indexEnd; ++vindex,++primCount) 86 86 { 87 87 88 88 if ((primCount%3) == 0) 89 89 { … … 93 93 } 94 94 } 95 void Geode::OutputTriangleStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 95 void Geode::OutputTriangleStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 96 96 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout) 97 97 { … … 100 100 for(unsigned int vindex=drawArray->getFirst(); vindex<indexEnd-2; ++vindex, evenodd++) 101 101 { 102 102 103 103 OutputSurfHead(iCurrentMaterial,surfaceFlags,3, fout); 104 104 if (evenodd%2==0) { … … 112 112 } 113 113 } 114 void Geode::OutputTriangleFan(const int iCurrentMaterial, const unsigned int surfaceFlags, 114 void Geode::OutputTriangleFan(const int iCurrentMaterial, const unsigned int surfaceFlags, 115 115 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout) 116 116 { … … 124 124 } 125 125 } 126 void Geode::OutputQuads(const int iCurrentMaterial, const unsigned int surfaceFlags, 126 void Geode::OutputQuads(const int iCurrentMaterial, const unsigned int surfaceFlags, 127 127 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout) 128 128 { … … 131 131 for(unsigned int vindex=drawArray->getFirst(); vindex<indexEnd; ++vindex,++primCount) 132 132 { 133 133 134 134 if ((primCount%4) == 0) 135 135 { … … 139 139 } 140 140 } 141 void Geode::OutputQuadStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 141 void Geode::OutputQuadStrip(const int iCurrentMaterial, const unsigned int surfaceFlags, 142 142 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout) 143 143 { … … 152 152 } 153 153 } 154 void Geode::OutputPolygon(const int iCurrentMaterial, const unsigned int surfaceFlags, 154 void Geode::OutputPolygon(const int iCurrentMaterial, const unsigned int surfaceFlags, 155 155 const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout) 156 156 { … … 171 171 unsigned int localPrimLength; 172 172 localPrimLength = 2; 173 173 174 174 for(GLsizei primCount = 0; primCount < *primItr; ++primCount) 175 175 { … … 181 181 ++vindex; 182 182 } 183 183 184 184 } 185 185 } … … 193 193 unsigned int localPrimLength; 194 194 localPrimLength = 3; 195 195 196 196 for(GLsizei primCount = 0; primCount < *primItr; ++primCount) 197 197 { … … 203 203 ++vindex; 204 204 } 205 205 206 206 } 207 207 } … … 215 215 unsigned int localPrimLength; 216 216 localPrimLength = 4; 217 217 218 218 for(GLsizei primCount = 0; primCount < *primItr; ++primCount) 219 219 { … … 225 225 vindex+=4; 226 226 } 227 227 228 228 } 229 229 } … … 236 236 unsigned int localPrimLength; 237 237 localPrimLength = *primItr; 238 238 239 239 for(GLsizei primCount = 0; primCount < *primItr; ++primCount) 240 240 { … … 246 246 vindex+=2; 247 247 } 248 248 249 249 } 250 250 } … … 257 257 unsigned int localPrimLength; 258 258 localPrimLength = *primItr; 259 259 260 260 for(GLsizei primCount = 0; primCount < *primItr; ++primCount) 261 261 { … … 267 267 ++vindex; 268 268 } 269 269 270 270 } 271 271 } … … 279 279 int localPrimLength= *primItr; 280 280 bool evenodd=true; 281 281 282 282 for(GLsizei primCount = 0; primCount < localPrimLength - 2; ++primCount) 283 283 { … … 292 292 OutputVertex(vindex + primCount + 2, pVertexIndices, pTexCoords, pTexIndices, fout); 293 293 evenodd=!evenodd; 294 } 294 } 295 295 vindex += localPrimLength; 296 296 } … … 303 303 { 304 304 int localPrimLength = *primItr; 305 305 306 306 for(GLsizei primCount = 0; primCount < localPrimLength - 2; primCount++) 307 307 { … … 321 321 { 322 322 unsigned int primLength =3; 323 323 324 324 unsigned int primCount = 0; 325 325 for(osg::DrawElementsUByte::const_iterator primItr=drawElements->begin(); primItr<drawElements->end(); ++primCount,++primItr) … … 329 329 OutputSurfHead(iCurrentMaterial,surfaceFlags,primLength, fout); 330 330 } 331 331 332 332 unsigned int vindex=*primItr; 333 333 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); … … 342 342 for(osg::DrawElementsUByte::const_iterator primItr=drawElements->begin(); primItr<drawElements->end()-2; ++primItr) 343 343 { 344 344 345 345 unsigned int vindex=*primItr; 346 346 unsigned int vindexp1=*(primItr+1); … … 365 365 unsigned int vindex=*(drawElements->begin()); 366 366 for(osg::DrawElementsUByte::const_iterator primItr=drawElements->begin(); primItr<drawElements->end()-2; ++primItr) 367 { 367 { 368 368 unsigned int vindexp1=*(primItr+1); 369 369 unsigned int vindexp2=*(primItr+2); 370 370 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 371 371 372 372 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 373 373 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 383 383 { 384 384 unsigned int vindex=*primItr; 385 385 386 386 unsigned int vindexp1=*(primItr+1); 387 387 unsigned int vindexp2=*(primItr+3); 388 388 unsigned int vindexp3=*(primItr+2); 389 389 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 390 390 391 391 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 392 392 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 403 403 { 404 404 unsigned int vindex=*primItr; 405 405 406 406 unsigned int vindexp1=*(primItr+1); 407 407 unsigned int vindexp2=*(primItr+2); 408 408 unsigned int vindexp3=*(primItr+3); 409 409 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 410 410 411 411 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 412 412 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 435 435 { 436 436 unsigned int primLength =3; 437 437 438 438 unsigned int primCount = 0; 439 439 for(osg::DrawElementsUShort::const_iterator primItr=drawElements->begin(); primItr<drawElements->end(); ++primCount,++primItr) 440 440 { 441 441 442 442 if ((primCount%primLength) == 0) 443 443 { 444 444 OutputSurfHead(iCurrentMaterial,surfaceFlags,primLength, fout); 445 445 } 446 446 447 447 unsigned int vindex=*primItr; 448 448 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); … … 479 479 unsigned int vindex=*(drawElements->begin()); 480 480 for(osg::DrawElementsUShort::const_iterator primItr=drawElements->begin(); primItr<drawElements->end()-2; ++primItr) 481 { 481 { 482 482 unsigned int vindexp1=*(primItr+1); 483 483 unsigned int vindexp2=*(primItr+2); 484 484 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 485 485 486 486 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 487 487 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 497 497 { 498 498 unsigned int vindex=*primItr; 499 499 500 500 unsigned int vindexp1=*(primItr+1); 501 501 unsigned int vindexp2=*(primItr+3); 502 502 unsigned int vindexp3=*(primItr+2); 503 503 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 504 504 505 505 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 506 506 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 517 517 { 518 518 unsigned int vindex=*primItr; 519 519 520 520 unsigned int vindexp1=*(primItr+1); 521 521 unsigned int vindexp2=*(primItr+2); 522 522 unsigned int vindexp3=*(primItr+3); 523 523 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 524 524 525 525 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 526 526 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 549 549 { 550 550 unsigned int primLength =3; 551 551 552 552 unsigned int primCount = 0; 553 553 for(osg::DrawElementsUInt::const_iterator primItr=drawElements->begin(); primItr<drawElements->end(); ++primCount,++primItr) 554 554 { 555 555 556 556 if ((primCount%primLength) == 0) 557 557 { 558 558 OutputSurfHead(iCurrentMaterial,surfaceFlags,primLength, fout); 559 559 } 560 560 561 561 unsigned int vindex=*primItr; 562 562 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); … … 571 571 for(osg::DrawElementsUInt::const_iterator primItr=drawElements->begin(); primItr<drawElements->end()-2; ++primItr) 572 572 { 573 573 574 574 unsigned int vindex=*primItr; 575 575 unsigned int vindexp1=*(primItr+1); … … 594 594 unsigned int vindex=*(drawElements->begin()); 595 595 for(osg::DrawElementsUInt::const_iterator primItr=drawElements->begin(); primItr<drawElements->end()-2; ++primItr) 596 { 596 { 597 597 unsigned int vindexp1=*(primItr+1); 598 598 unsigned int vindexp2=*(primItr+2); 599 599 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 600 600 601 601 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 602 602 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 612 612 { 613 613 unsigned int vindex=*primItr; 614 614 615 615 unsigned int vindexp1=*(primItr+1); 616 616 unsigned int vindexp2=*(primItr+3); 617 617 unsigned int vindexp3=*(primItr+2); 618 618 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 619 619 620 620 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 621 621 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 632 632 { 633 633 unsigned int vindex=*primItr; 634 634 635 635 unsigned int vindexp1=*(primItr+1); 636 636 unsigned int vindexp2=*(primItr+2); 637 637 unsigned int vindexp3=*(primItr+3); 638 638 OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); 639 639 640 640 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 641 641 OutputVertex(vindexp1, pVertexIndices, pTexCoords, pTexIndices, fout); … … 721 721 // Write out world object 722 722 int ngeometry=0; // not all drawables are geometry, text is not converted to facets. 723 for (i = 0; i < iNumDrawables; i++) 723 for (i = 0; i < iNumDrawables; i++) 724 724 { // so here we count the geometries to be converted to AC3D 725 725 const osg::Drawable* Drawable = getDrawable(i); … … 744 744 { 745 745 int iCurrentMaterial = -1; 746 746 747 747 if (theState) { 748 748 pRAP = theState->getAttributePair(osg::StateAttribute::MATERIAL); … … 753 753 } 754 754 } 755 755 756 756 //const osg::Vec3Array 757 757 const osg::Array *pVertexArray = pGeometry->getVertexArray(); … … 764 764 fout << "OBJECT poly" << std::endl; 765 765 fout << "name \"" << getName() << "\"" << std::endl; 766 766 767 767 // Use zero offset co-ordinate as location IS OPTIONAL 768 768 // fout << "loc " << "0 0 0" << std::endl; … … 781 781 << (*pVertexArray)[0][1] << " " 782 782 << (*pVertexArray)[0][2] << std::endl; */ 783 783 784 784 // Check for a texture 785 785 if (theState) … … 796 796 { 797 797 pTexCoords = (const osg::Vec2*)pGeometry->getTexCoordArray(0)->getDataPointer(); 798 798 799 799 // OK now see if I can calcualate the repeats 800 800 osg::Texture::WrapMode eWrapMode_s = pTexture2D->getWrap(osg::Texture::WRAP_S); 801 801 //osg::Texture::WrapMode eWrapMode_t = pTexture2D->getWrap(osg::Texture::WRAP_T); 802 802 803 803 if (eWrapMode_s == osg::Texture::REPEAT) 804 804 { … … 809 809 float fMax = std::numeric_limits<float>::min(); 810 810 unsigned int iNumTexCoords = pGeometry->getTexCoordArray(0)->getNumElements(); 811 811 812 812 for (j = 0; j < iNumTexCoords; j++) 813 813 { … … 843 843 } 844 844 } 845 845 846 846 fout << "numvert " << iNumVertices << std::endl; 847 847 for (j = 0; j < iNumVertices; j++) … … 857 857 fout << (*verts)[j][0] << " " << (*verts)[j][1] << " " << (*verts)[j][2] << std::endl; 858 858 } 859 } 860 861 859 } 860 861 862 862 // Generate a surface for each primitive 863 863 unsigned int iNumSurfaces = 0; // complex tri-strip etc prims use more triangles … … 893 893 } 894 894 fout << "numsurf " << iNumSurfaces << std::endl; 895 895 896 896 for(pItr = pGeometry->getPrimitiveSetList().begin(); pItr != pGeometry->getPrimitiveSetList().end(); ++pItr) 897 897 { 898 898 const osg::PrimitiveSet* primitiveset = pItr->get(); 899 899 GLenum mode=primitiveset->getMode(); 900 900 901 901 unsigned int surfaceFlags = 0x00; 902 902 903 903 switch(mode) 904 904 { … … 916 916 break; // compute later when =0. 917 917 } 918 918 919 919 // osg::StateAttribute::GLModeValue backface =theState->getMode(osg::StateAttribute::CULLFACE); 920 920 // if (backface==osg::StateAttribute::ON) surfaceFlags |= 0x10; … … 963 963 case(osg::PrimitiveSet::DrawArrayLengthsPrimitiveType): 964 964 { 965 965 966 966 const osg::DrawArrayLengths* drawArrayLengths = static_cast<const osg::DrawArrayLengths*>(primitiveset); 967 967 switch(mode) … … 1019 1019 break; // unknown shape 1020 1020 } 1021 1021 1022 1022 break; 1023 1023 } … … 1051 1051 if (primLength == 0) 1052 1052 primLength = primitiveset->getNumIndices(); 1053 1053 1054 1054 const osg::DrawElementsUShort* drawElements = static_cast<const osg::DrawElementsUShort*>(primitiveset); 1055 1056 unsigned int primCount = 0; 1057 1055 1056 unsigned int primCount = 0; 1057 1058 1058 for(osg::DrawElementsUShort::const_iterator primItr=drawElements->begin(); primItr!=drawElements->end(); ++primCount,++primItr) 1059 1059 { 1060 1060 1061 1061 if ((primCount%primLength) == 0) 1062 1062 { 1063 1063 OutputSurfHead(iCurrentMaterial,surfaceFlags,primLength, fout); 1064 1064 } 1065 1065 1066 1066 unsigned int vindex=*primItr; 1067 1067 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 1068 1068 } */ 1069 1069 1070 1070 break; 1071 1071 } … … 1099 1099 if (primLength == 0) 1100 1100 primLength = primitiveset->getNumIndices(); 1101 1101 1102 1102 const osg::DrawElementsUInt* drawElements = static_cast<const osg::DrawElementsUInt*>(primitiveset); 1103 1103 1104 1104 unsigned int primCount=0; 1105 1105 for(osg::DrawElementsUInt::const_iterator primItr=drawElements->begin(); primItr!=drawElements->end(); ++primCount,++primItr) 1106 1106 { 1107 1107 1108 1108 if ((primCount%primLength)==0) 1109 1109 { 1110 1110 OutputSurfHead(iCurrentMaterial,surfaceFlags,primLength, fout); 1111 1111 } 1112 1112 1113 1113 unsigned int vindex=*primItr; 1114 1114 OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); 1115 1115 } */ 1116 1116 1117 1117 break; 1118 1118 }
