- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/dae/daeWGeometry.cpp
r12416 r13041 2 2 * Copyright 2006 Sony Computer Entertainment Inc. 3 3 * 4 * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this 4 * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this 5 5 * file except in compliance with the License. You may obtain a copy of the License at: 6 6 * http://research.scea.com/scea_shared_source_license.html 7 7 * 8 * Unless required by applicable law or agreed to in writing, software distributed under the License 9 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 10 * implied. See the License for the specific language governing permissions and limitations under the 11 * License. 8 * Unless required by applicable law or agreed to in writing, software distributed under the License 9 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 10 * implied. See the License for the specific language governing permissions and limitations under the 11 * License. 12 12 */ 13 13 … … 157 157 if (name.empty()) 158 158 name = uniquify("skincontroller"); 159 else 159 else 160 160 name = uniquify(name); 161 161 pDomController->setId( name.c_str() ); … … 191 191 { 192 192 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomJointsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON)); 193 193 194 194 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR)); 195 195 std::string url = "#" + jointsNameArrayName; … … 214 214 { 215 215 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinBindPoseSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON)); 216 216 217 217 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR)); 218 218 std::string url = "#" + matricesArrayName; … … 238 238 { 239 239 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinWeightsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON)); 240 240 241 241 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR)); 242 242 std::string url = "#" + weightsArrayName; … … 249 249 250 250 domSkin::domJoints* pDomJoints = daeSafeCast< domSkin::domJoints >(pDomSkin->add( COLLADA_ELEMENT_JOINTS )); 251 251 252 252 domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomJoints->add(COLLADA_ELEMENT_INPUT)); 253 253 pDomInput->setSemantic(COMMON_PROFILE_INPUT_JOINT); … … 325 325 if (name.empty()) 326 326 name = uniquify("morphcontroller"); 327 else 327 else 328 328 name = uniquify(name); 329 329 pDomController->setId( name.c_str() ); … … 442 442 { 443 443 osg::Geometry *g = node.getDrawable( i )->asGeometry(); 444 444 445 445 if ( g != NULL ) 446 446 { … … 466 466 467 467 pushStateSet(g->getStateSet()); 468 468 469 469 domGeometry* pDomGeometry = getOrCreateDomGeometry(g); 470 470 if (pDomGeometry) … … 517 517 p->getValue().append( normals.inds!=NULL?normals.inds->index( ncount ):ncount ); 518 518 } 519 519 520 520 if ( color != NULL ) 521 521 { … … 525 525 p->getValue().append( colors.inds!=NULL?colors.inds->index( ccount ):ccount ); 526 526 } 527 527 528 528 for ( unsigned int ti = 0; ti < texcoords.size(); ti++ ) 529 529 { … … 536 536 537 537 bool daeWriter::processGeometry( osg::Geometry *geom, domGeometry *geo, const std::string &name ) 538 { 538 { 539 539 domMesh *mesh = daeSafeCast< domMesh >( geo->add( COLLADA_ELEMENT_MESH ) ); 540 540 domSource *pos = NULL; … … 550 550 domPolygons *polys = NULL; 551 551 domPolylist *polylist = NULL; 552 552 553 553 ArrayNIndices verts( geom->getVertexArray(), geom->getVertexIndices() ); 554 554 ArrayNIndices normals( geom->getNormalArray(), geom->getNormalIndices() ); … … 715 715 switch( mode ) 716 716 { 717 case GL_POINTS: 718 { 719 OSG_WARN << "Geometry contains points rendering. COLLADA does not" << std::endl; 717 case GL_POINTS: 718 { 719 OSG_WARN << "Geometry contains points rendering. COLLADA does not" << std::endl; 720 720 continue; 721 721 } 722 case GL_LINES: 722 case GL_LINES: 723 723 { 724 724 if ( lines == NULL ) … … 729 729 lines->setMaterial( mat.c_str() ); 730 730 } 731 primLength = 2; 731 primLength = 2; 732 732 valid = true; 733 733 break; 734 734 } 735 case GL_TRIANGLES: 735 case GL_TRIANGLES: 736 736 { 737 737 if ( tris == NULL ) … … 742 742 tris->setMaterial( mat.c_str() ); 743 743 } 744 primLength = 3; 744 primLength = 3; 745 745 valid = true; 746 746 break; 747 747 } 748 case GL_QUADS: 748 case GL_QUADS: 749 749 { 750 750 if ( polys == NULL ) … … 760 760 { 761 761 polylist = createPrimGroup<domPolylist>( COLLADA_ELEMENT_POLYLIST, mesh, norm, color, texcoord ); 762 762 763 763 polylist->add( COLLADA_ELEMENT_VCOUNT ); 764 764 polylist->add( COLLADA_ELEMENT_P ); … … 767 767 } 768 768 } 769 primLength = 4; 769 primLength = 4; 770 770 valid = true; 771 771 break; … … 807 807 break; 808 808 } 809 default: 809 default: 810 810 { 811 811 if ( polys == NULL ) … … 828 828 } 829 829 } 830 primLength = 0; 830 primLength = 0; 831 831 valid = true; 832 832 break; // compute later when =0. … … 840 840 { 841 841 //draw arrays (array of contiguous vertices) 842 842 843 843 //(primitive type+begin+end),(primitive type+begin+end)... 844 844 case osg::PrimitiveSet::DrawArraysPrimitiveType: … … 846 846 //OSG_WARN << "DrawArrays" << std::endl; 847 847 848 if ( primLength == 0 ) 848 if ( primLength == 0 ) 849 849 { 850 850 primLength = ps->getNumIndices(); … … 887 887 break; 888 888 } 889 default: 889 default: 890 890 { 891 891 //TODO : test this case … … 988 988 break; 989 989 } 990 default: 990 default: 991 991 { 992 992 … … 1048 1048 1049 1049 osg::DrawElementsUByte* drawElements = static_cast<osg::DrawElementsUByte*>( ps ); 1050 1050 1051 1051 std::vector<domP *> p; 1052 1052 switch ( mode ) … … 1082 1082 break; 1083 1083 } 1084 default: 1084 default: 1085 1085 { 1086 1086 unsigned int nbPolygons=drawElements->size()/primLength; … … 1147 1147 1148 1148 osg::DrawElementsUShort* drawElements = static_cast<osg::DrawElementsUShort*>( ps ); 1149 1149 1150 1150 std::vector<domP *> p; 1151 1151 switch ( mode ) … … 1181 1181 break; 1182 1182 } 1183 default: 1183 default: 1184 1184 { 1185 1185 unsigned int nbPolygons=drawElements->size()/primLength; … … 1200 1200 } 1201 1201 } 1202 1202 1203 1203 unsigned int primCount = 0; 1204 1204 osg::DrawElementsUShort::iterator primItrBegin = drawElements->begin(); … … 1213 1213 1214 1214 unsigned int vindex = *primItr; 1215 1215 1216 1216 appendGeometryIndices(geom,p[iPoly],vindex, 1217 1217 norm,color, 1218 1218 verts,normals,colors,texcoords, 1219 1219 ncount,ccount); 1220 1220 1221 1221 if ( primCount>0 && ((primCount % primLength) == 0) ) 1222 1222 { … … 1236 1236 if (primItrBegin != drawElements->end()) 1237 1237 #endif 1238 primItrEnd+=nbVerticesPerPoly; 1239 } 1240 1238 primItrEnd+=nbVerticesPerPoly; 1239 } 1240 1241 1241 break; 1242 1242 } … … 1248 1248 1249 1249 osg::DrawElementsUInt* drawElements = static_cast<osg::DrawElementsUInt*>( ps ); 1250 1250 1251 1251 std::vector<domP *> p; 1252 1252 switch ( mode ) … … 1282 1282 break; 1283 1283 } 1284 default: 1284 default: 1285 1285 { 1286 1286 unsigned int nbPolygons=drawElements->size()/primLength; … … 1315 1315 1316 1316 unsigned int vindex = *primItr; 1317 1317 1318 1318 appendGeometryIndices(geom,p[iPoly],vindex, 1319 1319 norm,color, 1320 1320 verts,normals,colors,texcoords, 1321 1321 ncount,ccount); 1322 1322 1323 1323 if ( primCount>0 && ((primCount % primLength) == 0) ) 1324 1324 { … … 1337 1337 if (primItrBegin != drawElements->end()) 1338 1338 #endif 1339 primItrEnd+=nbVerticesPerPoly; 1339 primItrEnd+=nbVerticesPerPoly; 1340 1340 } 1341 1341 break; … … 1346 1346 } 1347 1347 1348 if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) 1348 if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) 1349 1349 { 1350 1350 ncount++; 1351 1351 } 1352 if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) 1352 if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) 1353 1353 { 1354 1354 ccount++; … … 1382 1382 param->setName( "R" ); 1383 1383 param->setType( "float" ); 1384 1384 1385 1385 param = daeSafeCast< domParam >( acc->add( COLLADA_ELEMENT_PARAM ) ); 1386 1386 param->setName( "G" );
