void addVec2ArrayElement(osg::Array& a, const KFbxVector2& v) { if (a.getType() == osg::Array::Vec2dArrayType) { static_cast<osg::Vec2dArray&>(a).push_back(osg::Vec2d(v[0], v[1])); } else { static_cast<osg::Vec2Array&>(a).push_back(osg::Vec2( static_cast<float>(v[0]), static_cast<float>(v[1]))); } }
void addColorArrayElement(osg::Array& a, const KFbxColor& c) { if (a.getType() == osg::Array::Vec4dArrayType) { static_cast<osg::Vec4dArray&>(a).push_back(osg::Vec4d(c.mRed, c.mGreen, c.mBlue, c.mAlpha)); } else { static_cast<osg::Vec4Array&>(a).push_back(osg::Vec4( static_cast<float>(c.mRed), static_cast<float>(c.mGreen), static_cast<float>(c.mBlue), static_cast<float>(c.mAlpha))); } }
bool Array_writeLocalData( const osg::Array& array, osgDB::Output& fw ) { switch(array.getType()) { case( osg::Array::ByteArrayType): { const osg::ByteArray& carray = static_cast<const osg::ByteArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArrayAsInts(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::ShortArrayType): { const osg::ShortArray& carray = static_cast<const osg::ShortArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::IntArrayType): { const osg::IntArray& carray = static_cast<const osg::IntArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::UByteArrayType): { const osg::UByteArray& carray = static_cast<const osg::UByteArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArrayAsInts(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::UShortArrayType): { const osg::UShortArray& carray = static_cast<const osg::UShortArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::UIntArrayType): { const osg::UIntArray& carray = static_cast<const osg::UIntArray&>(array); fw<<array.className()<<" "<<carray.size()<<" "; osgDB::writeArray(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::Vec4ubArrayType): { const osg::Vec4ubArray& carray = static_cast<const osg::Vec4ubArray&>(array); fw<<array.className()<<" "<<carray.size()<<" "; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case( osg::Array::FloatArrayType): { const osg::FloatArray& carray = static_cast<const osg::FloatArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end()); return true; } break; case( osg::Array::Vec2ArrayType): { const osg::Vec2Array& carray = static_cast<const osg::Vec2Array&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case( osg::Array::Vec3ArrayType): { const osg::Vec3Array& carray = static_cast<const osg::Vec3Array&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case( osg::Array::Vec4ArrayType): { const osg::Vec4Array& carray = static_cast<const osg::Vec4Array&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case( osg::Array::DoubleArrayType): { int prec = fw.precision(15); const osg::DoubleArray& carray = static_cast<const osg::DoubleArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end()); fw.precision(prec); return true; } break; case( osg::Array::Vec2dArrayType): { int prec = fw.precision(15); const osg::Vec2dArray& carray = static_cast<const osg::Vec2dArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); fw.precision(prec); return true; } break; case( osg::Array::Vec3dArrayType): { int prec = fw.precision(15); const osg::Vec3dArray& carray = static_cast<const osg::Vec3dArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); fw.precision(prec); return true; } break; case( osg::Array::Vec4dArrayType): { int prec = fw.precision(15); const osg::Vec4dArray& carray = static_cast<const osg::Vec4dArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(),1); fw.precision(prec); return true; } break; case( osg::Array::Vec2sArrayType): { const osg::Vec2sArray& carray = static_cast<const osg::Vec2sArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(), 3); return true; } break; case( osg::Array::Vec3sArrayType): { const osg::Vec3sArray& carray = static_cast<const osg::Vec3sArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(), 2); return true; } break; case( osg::Array::Vec4sArrayType): { const osg::Vec4sArray& carray = static_cast<const osg::Vec4sArray&>(array); fw<<array.className()<<" "<<carray.size()<<std::endl; osgDB::writeArray(fw,carray.begin(),carray.end(), 1); return true; } break; case( osg::Array::Vec2bArrayType): { const osg::Vec2bArray& carray = static_cast<const osg::Vec2bArray&>(array); fw<<array.className()<<" "<<carray.size()<<" "; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case( osg::Array::Vec3bArrayType): { const osg::Vec3bArray& carray = static_cast<const osg::Vec3bArray&>(array); fw<<array.className()<<" "<<carray.size()<<" "; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case(osg::Array::Vec4bArrayType): { const osg::Vec4bArray& carray = static_cast<const osg::Vec4bArray&>(array); fw<<array.className()<<" "<<carray.size()<<" "; osgDB::writeArray(fw,carray.begin(),carray.end(),1); return true; } break; case(osg::Array::ArrayType): default: return false; } }