📄 shape.cpp
字号:
#include <osg/Shape>#include <osg/Notify>#include <osg/io_utils>#include <osgDB/Registry>#include <osgDB/Input>#include <osgDB/ParameterOutput>using namespace osg;using namespace osgDB;//////////////////////////////////////////////////////////////////////////////// forward declare functions to use later.bool Sphere_readLocalData(Object& obj, Input& fr);bool Sphere_writeLocalData(const Object& obj, Output& fw);//register the read and write functions with the osgDB::Registry.RegisterDotOsgWrapperProxy g_SphereFuncProxy( new osg::Sphere, "Sphere", "Object Sphere", &Sphere_readLocalData, &Sphere_writeLocalData, DotOsgWrapper::READ_AND_WRITE);bool Sphere_readLocalData(Object& obj, Input& fr){ bool iteratorAdvanced = false; Sphere& sphere = static_cast<Sphere&>(obj); if (fr.matchSequence("Center %f %f %f")) { osg::Vec3 center; fr[1].getFloat(center.x()); fr[2].getFloat(center.y()); fr[3].getFloat(center.z()); sphere.setCenter(center); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("Radius %f")) { float radius; fr[1].getFloat(radius); sphere.setRadius(radius); fr+=2; iteratorAdvanced = true; } return iteratorAdvanced;}bool Sphere_writeLocalData(const Object& obj, Output& fw){ const Sphere& sphere = static_cast<const Sphere&>(obj); fw.indent()<<"Center "<<sphere.getCenter()<<std::endl; fw.indent()<<"Radius "<<sphere.getRadius()<<std::endl; return true;}//////////////////////////////////////////////////////////////////////////////// forward declare functions to use later.bool Box_readLocalData(Object& obj, Input& fr);bool Box_writeLocalData(const Object& obj, Output& fw);//register the read and write functions with the osgDB::Registry.RegisterDotOsgWrapperProxy g_BoxFuncProxy( new osg::Box, "Box", "Object Box", &Box_readLocalData, &Box_writeLocalData, DotOsgWrapper::READ_AND_WRITE);bool Box_readLocalData(Object& obj, Input& fr){ bool iteratorAdvanced = false; Box& box = static_cast<Box&>(obj); if (fr.matchSequence("Center %f %f %f")) { osg::Vec3 center; fr[1].getFloat(center.x()); fr[2].getFloat(center.y()); fr[3].getFloat(center.z()); box.setCenter(center); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("HalfLengths %f %f %f")) { osg::Vec3 lenghts; fr[1].getFloat(lenghts.x()); fr[2].getFloat(lenghts.y()); fr[3].getFloat(lenghts.z()); box.setHalfLengths(lenghts); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("Rotation %f %f %f %f")) { osg::Quat rotation; fr[1].getFloat(rotation.x()); fr[2].getFloat(rotation.y()); fr[3].getFloat(rotation.z()); fr[4].getFloat(rotation.w()); box.setRotation(rotation); fr+=5; iteratorAdvanced = true; } return iteratorAdvanced;}bool Box_writeLocalData(const Object& obj, Output& fw){ const Box& box = static_cast<const Box&>(obj); fw.indent()<<"Center "<<box.getCenter()<<std::endl; fw.indent()<<"HalfLengths "<<box.getHalfLengths()<<std::endl; fw.indent()<<"Rotation "<<box.getRotation()<<std::endl; return true;}//////////////////////////////////////////////////////////////////////////////// forward declare functions to use later.bool Cone_readLocalData(Object& obj, Input& fr);bool Cone_writeLocalData(const Object& obj, Output& fw);//register the read and write functions with the osgDB::Registry.RegisterDotOsgWrapperProxy g_ConeFuncProxy( new osg::Cone, "Cone", "Object Cone", &Cone_readLocalData, &Cone_writeLocalData, DotOsgWrapper::READ_AND_WRITE);bool Cone_readLocalData(Object& obj, Input& fr){ bool iteratorAdvanced = false; Cone& cone = static_cast<Cone&>(obj); if (fr.matchSequence("Center %f %f %f")) { osg::Vec3 center; fr[1].getFloat(center.x()); fr[2].getFloat(center.y()); fr[3].getFloat(center.z()); cone.setCenter(center); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("Radius %f")) { float radius; fr[1].getFloat(radius); cone.setRadius(radius); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Height %f")) { float height; fr[1].getFloat(height); cone.setHeight(height); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Rotation %f %f %f %f")) { osg::Quat rotation; fr[1].getFloat(rotation.x()); fr[2].getFloat(rotation.y()); fr[3].getFloat(rotation.z()); fr[4].getFloat(rotation.w()); cone.setRotation(rotation); fr+=5; iteratorAdvanced = true; } return iteratorAdvanced;}bool Cone_writeLocalData(const Object& obj, Output& fw){ const Cone& cone = static_cast<const Cone&>(obj); fw.indent()<<"Center "<<cone.getCenter()<<std::endl; fw.indent()<<"Radius "<<cone.getRadius()<<std::endl; fw.indent()<<"Height "<<cone.getHeight()<<std::endl; fw.indent()<<"Rotation "<<cone.getRotation()<<std::endl; return true;}//////////////////////////////////////////////////////////////////////////////// forward declare functions to use later.bool Cylinder_readLocalData(Object& obj, Input& fr);bool Cylinder_writeLocalData(const Object& obj, Output& fw);//register the read and write functions with the osgDB::Registry.RegisterDotOsgWrapperProxy g_CylinderFuncProxy( new osg::Cylinder, "Cylinder", "Object Cylinder", &Cylinder_readLocalData, &Cylinder_writeLocalData, DotOsgWrapper::READ_AND_WRITE);bool Cylinder_readLocalData(Object& obj, Input& fr){ bool iteratorAdvanced = false; Cylinder& cylinder = static_cast<Cylinder&>(obj); if (fr.matchSequence("Center %f %f %f")) { osg::Vec3 center; fr[1].getFloat(center.x()); fr[2].getFloat(center.y()); fr[3].getFloat(center.z()); cylinder.setCenter(center); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("Radius %f")) { float radius; fr[1].getFloat(radius); cylinder.setRadius(radius); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Height %f")) { float height; fr[1].getFloat(height); cylinder.setHeight(height); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Rotation %f %f %f %f")) { osg::Quat rotation; fr[1].getFloat(rotation.x()); fr[2].getFloat(rotation.y()); fr[3].getFloat(rotation.z()); fr[4].getFloat(rotation.w()); cylinder.setRotation(rotation); fr+=5; iteratorAdvanced = true; } return iteratorAdvanced;}bool Cylinder_writeLocalData(const Object& obj, Output& fw){ const Cylinder& cylinder = static_cast<const Cylinder&>(obj); fw.indent()<<"Center "<<cylinder.getCenter()<<std::endl; fw.indent()<<"Radius "<<cylinder.getRadius()<<std::endl; fw.indent()<<"Height "<<cylinder.getHeight()<<std::endl; fw.indent()<<"Rotation "<<cylinder.getRotation()<<std::endl; return true;}//////////////////////////////////////////////////////////////////////////////// forward declare functions to use later.bool Capsule_readLocalData(Object& obj, Input& fr);bool Capsule_writeLocalData(const Object& obj, Output& fw);//register the read and write functions with the osgDB::Registry.RegisterDotOsgWrapperProxy g_CapsuleFuncProxy( new osg::Capsule, "Capsule", "Object Capsule", &Capsule_readLocalData, &Capsule_writeLocalData, DotOsgWrapper::READ_AND_WRITE);bool Capsule_readLocalData(Object& obj, Input& fr){ bool iteratorAdvanced = false; Capsule& capsule = static_cast<Capsule&>(obj); if (fr.matchSequence("Center %f %f %f")) { osg::Vec3 center; fr[1].getFloat(center.x()); fr[2].getFloat(center.y()); fr[3].getFloat(center.z()); capsule.setCenter(center); fr+=4; iteratorAdvanced = true; } if (fr.matchSequence("Radius %f")) { float radius; fr[1].getFloat(radius); capsule.setRadius(radius); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Height %f")) { float height; fr[1].getFloat(height); capsule.setHeight(height); fr+=2; iteratorAdvanced = true; } if (fr.matchSequence("Rotation %f %f %f %f")) { osg::Quat rotation; fr[1].getFloat(rotation.x()); fr[2].getFloat(rotation.y()); fr[3].getFloat(rotation.z()); fr[4].getFloat(rotation.w()); capsule.setRotation(rotation);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -