- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/Inventor/ConvertToInventor.cpp
r12597 r13041 229 229 230 230 osgType *ptr = (osgType*)array->getDataPointer() + startIndex; 231 231 232 232 if (numItemsUntilMinusOne <= 0) 233 233 for (i=0; i<num; i++, ptr++) … … 370 370 } 371 371 } 372 else if (ivApplicateIntType<SoMFInt32, int32_t>(array, (SoMFInt32&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 372 else if (ivApplicateIntType<SoMFInt32, int32_t>(array, (SoMFInt32&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 373 373 else if (ivApplicateIntType<SoMFUInt32,uint32_t>(array, (SoMFUInt32&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 374 else if (ivApplicateIntType<SoMFShort, int16_t>(array, (SoMFShort&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 374 else if (ivApplicateIntType<SoMFShort, int16_t>(array, (SoMFShort&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 375 375 else if (ivApplicateIntType<SoMFUShort,uint16_t>(array, (SoMFUShort&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; 376 376 else if (field.isOfType(SoMFVec2f::getClassTypeId())) … … 474 474 475 475 if (indices || drawElemIndices) { 476 476 477 477 // "deindex" original data 478 478 if (indices && !drawElemIndices) … … 747 747 // Coin: no (until current version Coin 2.5.0b3) 748 748 // TGS Inventor: introduced in TGS Inventor 5.0 (available in SoTexture class) 749 749 750 750 // note: Coin (since 2.0) uses CLAMP_TO_EDGE for rendering if SoTexture2::CLAMP is specified. 751 751 … … 790 790 791 791 if (ss) { 792 792 793 793 // 794 794 // Lighting 795 795 // 796 796 797 797 // enable/disable lighting 798 798 updateMode(ivState->osgLighting, ss->getMode(GL_LIGHTING)); … … 834 834 835 835 // set two-sided lighting and backface culling off 836 sh->vertexOrdering = ivState->osgFrontFace==osg::FrontFace::COUNTER_CLOCKWISE ? 836 sh->vertexOrdering = ivState->osgFrontFace==osg::FrontFace::COUNTER_CLOCKWISE ? 837 837 SoShapeHints::COUNTERCLOCKWISE : SoShapeHints::CLOCKWISE; 838 838 sh->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; … … 850 850 // Inventor does not support this setup and it lits the unculled faces only. 851 851 OSG_WARN << "IvWriter: Culling was set in a way that one-sided lighting will lit the culled sides of faces. " 852 "Using lighting on correct faces." << std::endl; 852 "Using lighting on correct faces." << std::endl; 853 853 854 854 // face culling on … … 880 880 if (!ivState->osgTexture2Enabled || 881 881 ivState->osgTexture==NULL || ivState->osgTexture->getImage(0)==NULL) 882 882 883 883 // empty texture disables texturing 884 884 ivState->ivTexture = new SoTexture2; 885 885 886 886 else { 887 887 888 888 // reuse texture if possible 889 889 ivState->ivTexture = ivTexturesMap[ivState->osgTexture][ivState->osgTexEnv]; … … 899 899 const std::string &textureName = ivState->osgTexture->getImage(0)->getFileName(); 900 900 ivState->ivTexture->filename.setValue(textureName.c_str()); // FIXME: handle inlined texture data in the files 901 901 902 902 // wrap 903 903 ivState->ivTexture->wrapS.setValue(convertTextureWrap( … … 951 951 "back faces. This is not handled properly. Using front material only." << std::endl; 952 952 } 953 953 954 954 // Convert colors 955 955 // OSG represents colors by: Vec3, Vec4,Vec4ub … … 1180 1180 // Post-processing for DrawArrayLengths 1181 1181 if (drawArrayLengths && primSize==0 && drawArrayLengths->size()>=2) { 1182 1182 1183 1183 postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->coordIndex); 1184 1184 1185 1185 if (ivNormals && g->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX) 1186 1186 postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->normalIndex); 1187 1187 1188 1188 if (ivMaterial && g->getColorBinding()==osg::Geometry::BIND_PER_VERTEX) 1189 1189 postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->materialIndex); 1190 1190 1191 1191 if (ivTexCoords && !ivTexCoords->isOfType(SoTextureCoordinateFunction::getClassTypeId())) 1192 1192 postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->textureCoordIndex); … … 1258 1258 startIndex, n); 1259 1259 } 1260 } 1260 } 1261 1261 else 1262 1262 #endif // __COIN__ 1263 1263 nonIndexedTexCoords = ivTexCoords; 1264 1264 } 1265 1265 1266 1266 // create alternate normals 1267 1267 if (ivNormals) { … … 1301 1301 if (shape->isOfType(SoPointSet::getClassTypeId())) 1302 1302 ((SoPointSet*)shape)->numPoints.setValue(elementsCount); else 1303 1303 1304 1304 if (shape->isOfType(SoLineSet::getClassTypeId())) { 1305 1305 switch (pset->getMode()) { … … 1562 1562 texCoords = new SoTextureCoordinate2; 1563 1563 osgArray2ivMField(g->getTexCoordArray(0), ((SoTextureCoordinate2*)texCoords)->point); 1564 } 1564 } 1565 1565 #ifdef __COIN__ 1566 1566 else { … … 1607 1607 case GL_TRIANGLES: 1608 1608 case GL_TRIANGLE_STRIP: 1609 case GL_QUAD_STRIP: if (useIndices) 1609 case GL_QUAD_STRIP: if (useIndices) 1610 1610 if (vrml1Conversion) { 1611 1611 shape = new SoIndexedFaceSet; … … 1665 1665 const osg::DrawArrayLengths *drawArrayLengths = 1666 1666 dynamic_cast<const osg::DrawArrayLengths*>(pset); 1667 1667 1668 1668 int startIndex = drawArrayLengths->getFirst(); 1669 1669 1670 1670 ok = processPrimitiveSet(g, pset, NULL, needSeparateTriangles, 1671 1671 -1, primSize, startIndex, -1, normalIndex, colorIndex, … … 1679 1679 break; 1680 1680 } 1681 1681 1682 1682 case osg::PrimitiveSet::DrawElementsUBytePrimitiveType: 1683 1683 case osg::PrimitiveSet::DrawElementsUShortPrimitiveType: … … 1755 1755 // convert rotation 1756 1756 rotation = osg::Quat(-M_PI_2, osg::Vec3(0.,1.,0.)) * osg::Quat(M_PI_2, osg::Vec3(1.,0.,0.)) * rotation; 1757 1757 1758 1758 if (center.length2()==0. && rotation.zeroRotation() && ivState->ivTexture==NULL) 1759 1759 1760 1760 // optimized handling of single node 1761 1761 root->addChild(ivNode); 1762 1762 1763 1763 else { 1764 1764 SoSeparator *root2 = new SoSeparator; 1765 1765 1766 1766 // handle transformation 1767 1767 if (center.length2()!=0. || !rotation.zeroRotation()) { … … 1774 1774 if (ivState->ivTexture) 1775 1775 root2->addChild(ivState->ivTexture); 1776 1776 1777 1777 // build graph 1778 1778 root2->addChild(ivNode); … … 1780 1780 } 1781 1781 } 1782 1783 virtual void apply(const osg::Sphere &s) { 1782 1783 virtual void apply(const osg::Sphere &s) { 1784 1784 SoSphere *ivSphere = new SoSphere; 1785 1785 ivSphere->radius.setValue(s.getRadius()); … … 1807 1807 processNode(ivCylinder, c.getCenter(), c.getRotation(), ivState->ivHead); 1808 1808 } 1809 1809 1810 1810 void warnNonSupported() { 1811 1811 OSG_WARN << "IvWriter: Not supported ShapeDrawable found. Skipping it." << std::endl; … … 1817 1817 virtual void apply(const osg::HeightField&) { warnNonSupported(); } 1818 1818 virtual void apply(const osg::CompositeShape&) { warnNonSupported(); } 1819 1819 1820 1820 InventorState *ivState; 1821 1821 MyShapeVisitor(InventorState *ivState) { this->ivState = ivState; } … … 1840 1840 processGeometry(g, ivDrawableState); 1841 1841 else 1842 1842 1843 1843 if ((sd = dynamic_cast<osg::ShapeDrawable*>(d)) != NULL) { 1844 1844 processShapeDrawable(sd, ivDrawableState); … … 1898 1898 1899 1899 if (useIvExtensions) { 1900 1900 1901 1901 // Create SoSeparator and convert StateSet 1902 1902 InventorState *ivState = createInventorState(node.getStateSet()); … … 1928 1928 billboard->axisOfRotation.setValue(axis); 1929 1929 #else 1930 1930 1931 1931 billboard->axisOfRotation.setValue(SbVec3f(0.f,0.f,0.f)); 1932 1932 … … 1955 1955 1956 1956 popInventorState(); 1957 1957 1958 1958 } else 1959 1959 apply((osg::Geode&)node); … … 2022 2022 osg::LOD::RangeMode rangeMode = node.getRangeMode(); 2023 2023 if (rangeMode == osg::LOD::DISTANCE_FROM_EYE_POINT) { 2024 2024 2025 2025 // use SoLOD for DISTANCE_FROM_EYE_POINT 2026 2026 SoLOD *lod = new SoLOD; … … 2051 2051 2052 2052 } else { 2053 2053 2054 2054 // undefined mode -> put warning 2055 2055 OSG_WARN << "IvWriter: Undefined LOD::RangeMode value." << std::endl;
