diff --git a/include/osg/Transform b/include/osg/Transform index a721cd07b..e58d76d61 100644 --- a/include/osg/Transform +++ b/include/osg/Transform @@ -115,7 +115,7 @@ class SG_EXPORT Transform : public Group } else // absolute { - matrix.makeIdent(); + matrix.makeIdentity(); return true; } } @@ -128,13 +128,11 @@ class SG_EXPORT Transform : public Group } else // absolute { - matrix.makeIdent(); + matrix.makeIdentity(); return true; } } - virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const { return false; } - #else /** Set the transform's matrix.*/ diff --git a/src/Demos/hangglide/trees.cpp b/src/Demos/hangglide/trees.cpp index 020c4599c..ff3918bdd 100644 --- a/src/Demos/hangglide/trees.cpp +++ b/src/Demos/hangglide/trees.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -224,7 +224,7 @@ Node *makeTrees( void ) dstate->setTextureAttributeAndModes(0, tex, StateAttribute::ON ); dstate->setTextureAttribute(0, new TexEnv ); - dstate->setAttributeAndModes( new Transparency, StateAttribute::ON ); + dstate->setAttributeAndModes( new BlendFunc, StateAttribute::ON ); AlphaFunc* alphaFunc = new AlphaFunc; alphaFunc->setFunction(AlphaFunc::GEQUAL,0.05f); diff --git a/src/Demos/osgbillboard/osgbillboard.cpp b/src/Demos/osgbillboard/osgbillboard.cpp index 6acddd142..ce72322cc 100644 --- a/src/Demos/osgbillboard/osgbillboard.cpp +++ b/src/Demos/osgbillboard/osgbillboard.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -92,7 +92,7 @@ osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg: // create a tranform node to position each square in appropriate // place and also to add individual texture set to it, so that // that state is inherited down to its children. - osg::Transform* local_transform = osgNew osg::Transform; + osg::MatrixTransform* local_transform = osgNew osg::MatrixTransform; local_transform->postMult(osg::Matrix::translate(offset)); // create the StateSet to store the texture data @@ -117,7 +117,7 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom { if (image==NULL) return NULL; - osg::Transform* top_transform = osgNew osg::Transform; + osg::MatrixTransform* top_transform = osgNew osg::MatrixTransform; top_transform->postMult(osg::Matrix::translate(offset)); osg::Vec3 local_offset(0.0f,0.0f,0.0f); diff --git a/src/Demos/osgcallback/osgcallback.cpp b/src/Demos/osgcallback/osgcallback.cpp index c706b476d..29ca5006f 100644 --- a/src/Demos/osgcallback/osgcallback.cpp +++ b/src/Demos/osgcallback/osgcallback.cpp @@ -129,7 +129,7 @@ struct BillboardCallback : public osg::Billboard::ComputeBillboardCallback struct DrawableCullCallback : public osg::Drawable::CullCallback { /** do customized cull code.*/ - virtual bool cull(osg::NodeVisitor*, osg::Drawable* drawable, osg::State *state=NULL) const + virtual bool cull(osg::NodeVisitor*, osg::Drawable* drawable, osg::State *state) const { std::cout<<"Drawable cull callback "< +#include #include #include #include @@ -95,7 +95,7 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph) // ClipNode node to be transformed independantly from the subgraph // that it is clipping. - osg::Transform* transform= osgNew osg::Transform; + osg::MatrixTransform* transform= osgNew osg::MatrixTransform; osg::NodeCallback* nc = new osgUtil::TransformCallback(subgraph->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f)); transform->setAppCallback(nc); diff --git a/src/Demos/osgconv/OrientationConverter.cpp b/src/Demos/osgconv/OrientationConverter.cpp index 8fcb6dc93..9f3a486a9 100644 --- a/src/Demos/osgconv/OrientationConverter.cpp +++ b/src/Demos/osgconv/OrientationConverter.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include "OrientationConverter.h" @@ -48,7 +48,7 @@ Node* OrientationConverter::convert( Node *node ) T = Matrix::translate( bs.center() ); osg::Group* root = new osg::Group; - osg::Transform* transform = new osg::Transform; + osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setDataVariance(osg::Object::STATIC); transform->setMatrix( C * R * S * T ); diff --git a/src/Demos/osgcopy/osgcopy.cpp b/src/Demos/osgcopy/osgcopy.cpp index 051c98ece..4af4b5559 100644 --- a/src/Demos/osgcopy/osgcopy.cpp +++ b/src/Demos/osgcopy/osgcopy.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Demos/osgcube/osgcube.cpp b/src/Demos/osgcube/osgcube.cpp index 6a9bb0fd9..7c03d68e2 100644 --- a/src/Demos/osgcube/osgcube.cpp +++ b/src/Demos/osgcube/osgcube.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include @@ -20,7 +20,7 @@ class MyTransformCallback : public osg::NodeCallback{ public: - MyTransformCallback(osg::Transform* node,float angularVelocity) + MyTransformCallback(osg::MatrixTransform* node,float angularVelocity) { _nodeToOperateOn = node; _angular_velocity = angularVelocity; @@ -62,7 +62,7 @@ class MyTransformCallback : public osg::NodeCallback{ protected: - osg::Transform* _nodeToOperateOn; + osg::MatrixTransform* _nodeToOperateOn; float _angular_velocity; int _previousTraversalNumber; @@ -175,7 +175,7 @@ int main( int argc, char **argv ) // parameters that have been matched. viewer.readCommandLine(commandLine); - osg::Transform* myTransform = new osg::Transform(); + osg::MatrixTransform* myTransform = new osg::MatrixTransform(); myTransform->addChild( createGeometryCube() ); // move node in a circle at 90 degrees a sec. diff --git a/src/Demos/osggeometry/osggeometry.cpp b/src/Demos/osggeometry/osggeometry.cpp index cecfce50f..65fa3af86 100644 --- a/src/Demos/osggeometry/osggeometry.cpp +++ b/src/Demos/osggeometry/osggeometry.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -513,7 +513,7 @@ class MyTransformCallback : public osg::NodeCallback virtual void operator() (osg::Node* node, osg::NodeVisitor* nv) { - osg::Transform* transform = dynamic_cast(node); + osg::MatrixTransform* transform = dynamic_cast(node); if (nv && transform && nv->getFrameStamp()) { double time = nv->getFrameStamp()->getReferenceTime(); @@ -623,7 +623,7 @@ osg::Node* createBackground() // create a tranform to move the background back and forward with. - osg::Transform* transform = new osg::Transform(); + osg::MatrixTransform* transform = new osg::MatrixTransform(); transform->setAppCallback(new MyTransformCallback(1.0f)); transform->addChild(geode); diff --git a/src/Demos/osghud/osghud.cpp b/src/Demos/osghud/osghud.cpp index 52939475a..59cc78d1a 100644 --- a/src/Demos/osghud/osghud.cpp +++ b/src/Demos/osghud/osghud.cpp @@ -2,14 +2,14 @@ #include #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include @@ -136,7 +136,7 @@ void set2dScene(osg::Group* rootNode) textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending - osg::Transparency *transp= osgNew osg::Transparency(); + osg::BlendFunc *transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -176,7 +176,7 @@ void set2dScene(osg::Group* rootNode) textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending - transp= osgNew osg::Transparency(); + transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); @@ -332,7 +332,7 @@ int main( int argc, char **argv ) osg::Projection* projection = osgNew osg::Projection; projection->setMatrix(osg::Matrix::ortho2D(0,1024,0,768)); - osg::Transform* modelview_abs = osgNew osg::Transform; + osg::MatrixTransform* modelview_abs = osgNew osg::MatrixTransform; modelview_abs->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); modelview_abs->setMatrix(osg::Matrix::identity()); diff --git a/src/Demos/osgoccluder/osgoccluder.cpp b/src/Demos/osgoccluder/osgoccluder.cpp index 8c031724b..99b04e974 100644 --- a/src/Demos/osgoccluder/osgoccluder.cpp +++ b/src/Demos/osgoccluder/osgoccluder.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/Demos/osgprerender/osgprerender.cpp b/src/Demos/osgprerender/osgprerender.cpp index 168585c17..7d910baad 100644 --- a/src/Demos/osgprerender/osgprerender.cpp +++ b/src/Demos/osgprerender/osgprerender.cpp @@ -1,9 +1,8 @@ #include #include #include -#include +#include #include -#include #include #include #include @@ -445,7 +444,7 @@ int main( int argc, char **argv ) } // create a transform to spin the model. - osg::Transform* loadedModelTransform = new osg::Transform; + osg::MatrixTransform* loadedModelTransform = new osg::MatrixTransform; loadedModelTransform->addChild(loadedModel); osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f)); diff --git a/src/Demos/osgreflect/osgreflect.cpp b/src/Demos/osgreflect/osgreflect.cpp index 0c991b2da..e4cae9e36 100644 --- a/src/Demos/osgreflect/osgreflect.cpp +++ b/src/Demos/osgreflect/osgreflect.cpp @@ -1,9 +1,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -167,7 +167,7 @@ int main( int argc, char **argv ) return 1; } - osg::Transform* loadedModelTransform = new osg::Transform; + osg::MatrixTransform* loadedModelTransform = new osg::MatrixTransform; loadedModelTransform->addChild(loadedModel); // calculate where to place the mirror according to the @@ -318,7 +318,7 @@ int main( int argc, char **argv ) dstate->setAttributeAndModes(stencil,osg::StateAttribute::ON); dstate->setAttributeAndModes(clipplane,osg::StateAttribute::ON); - osg::Transform* dcs = new osg::Transform; + osg::MatrixTransform* dcs = new osg::MatrixTransform; dcs->setStateSet(dstate); dcs->preMult(osg::Matrix::translate(0.0f,0.0f,-z)* osg::Matrix::scale(1.0f,1.0f,-1.0f)* @@ -343,8 +343,8 @@ int main( int argc, char **argv ) stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::ZERO); // set up additive blending. - osg::Transparency* trans = new osg::Transparency; - trans->setFunction(osg::Transparency::ONE,osg::Transparency::ONE); + osg::BlendFunc* trans = new osg::BlendFunc; + trans->setFunction(osg::BlendFunc::ONE,osg::BlendFunc::ONE); osg::StateSet* statesetBin5 = createMirrorTexturedState("Images/tank.rgb"); diff --git a/src/Demos/osgscribe/osgscribe.cpp b/src/Demos/osgscribe/osgscribe.cpp index e3449dad9..1b46f98ee 100644 --- a/src/Demos/osgscribe/osgscribe.cpp +++ b/src/Demos/osgscribe/osgscribe.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include #include diff --git a/src/Demos/osgstereoimage/osgstereoimage.cpp b/src/Demos/osgstereoimage/osgstereoimage.cpp index 8fc933151..41668d9bd 100644 --- a/src/Demos/osgstereoimage/osgstereoimage.cpp +++ b/src/Demos/osgstereoimage/osgstereoimage.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/Demos/osgtext/main.cpp b/src/Demos/osgtext/main.cpp index e2c608807..3fe5589fb 100644 --- a/src/Demos/osgtext/main.cpp +++ b/src/Demos/osgtext/main.cpp @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -105,7 +105,7 @@ void set2dScene(osg::Group* rootNode) geode->addDrawable( text ); // to get antiaA pixmapFonts we have to draw them with blending - osg::Transparency *transp= osgNew osg::Transparency(); + osg::BlendFunc *transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); @@ -138,7 +138,7 @@ void set2dScene(osg::Group* rootNode) geode->addDrawable( text ); // to get antiaA pixmapFonts we have to draw them with blending - transp= osgNew osg::Transparency(); + transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); @@ -267,7 +267,7 @@ void setScene(osg::Group* rootNode) textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); // to get antiaA pixmapFonts we have to draw them with blending - osg::Transparency *transp= osgNew osg::Transparency(); + osg::BlendFunc *transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); @@ -301,7 +301,7 @@ void setScene(osg::Group* rootNode) textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); // to get antiaA pixmapFonts we have to draw them with blending - transp= osgNew osg::Transparency(); + transp= osgNew osg::BlendFunc(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); @@ -540,7 +540,7 @@ int main( int argc, char **argv ) osg::Group* rootNode = osgNew osg::Group; osg::Group* scene2d = osgNew osg::Group; - osg::Transform* textGroup = osgNew osg::Transform; + osg::MatrixTransform* textGroup = osgNew osg::MatrixTransform; // set the name for the hole group rootNode->setName("sceneGroup"); diff --git a/src/Demos/osgtexture/osgtexture.cpp b/src/Demos/osgtexture/osgtexture.cpp index f9df92ca2..bca42f465 100644 --- a/src/Demos/osgtexture/osgtexture.cpp +++ b/src/Demos/osgtexture/osgtexture.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -133,7 +133,7 @@ osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg: // create a tranform node to position each square in appropriate // place and also to add individual texture set to it, so that // that state is inherited down to its children. - osg::Transform* local_transform = new osg::Transform; + osg::MatrixTransform* local_transform = new osg::MatrixTransform; local_transform->postMult(osg::Matrix::translate(offset)); // create the StateSet to store the texture data @@ -158,7 +158,7 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom { if (image==NULL) return NULL; - osg::Transform* top_transform = new osg::Transform; + osg::MatrixTransform* top_transform = new osg::MatrixTransform; top_transform->postMult(osg::Matrix::translate(offset)); osg::Vec3 local_offset(0.0f,0.0f,0.0f); diff --git a/src/Demos/sgv/sgv.cpp b/src/Demos/sgv/sgv.cpp index 3d781a54b..9f6f67769 100644 --- a/src/Demos/sgv/sgv.cpp +++ b/src/Demos/sgv/sgv.cpp @@ -2,10 +2,7 @@ #include #include -#include -#include -#include -#include +#include #include #include diff --git a/src/osg/Makefile b/src/osg/Makefile index 501deb6b9..8a909cb33 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -47,6 +47,7 @@ CXXFILES =\ LineWidth.cpp\ Material.cpp\ Matrix.cpp\ + MatrixTransform.cpp\ MemoryManager.cpp\ Node.cpp\ NodeCallback.cpp\ diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index c50a1a6cd..6c7879240 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include using namespace osg; @@ -306,7 +306,7 @@ void StateSet::setGlobalDefaults() setMode(GL_DEPTH_TEST,StateAttribute::ON); setAttributeAndModes(osgNew AlphaFunc,StateAttribute::OFF); - setAttributeAndModes(osgNew Transparency,StateAttribute::OFF); + setAttributeAndModes(osgNew BlendFunc,StateAttribute::OFF); Material *material = osgNew Material; material->setColorMode(Material::AMBIENT_AND_DIFFUSE); diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp index a793b34c8..12b4e3477 100644 --- a/src/osgParticle/ParticleSystem.cpp +++ b/src/osgParticle/ParticleSystem.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -161,13 +161,13 @@ void osgParticle::ParticleSystem::setDefaultAttributes(const std::string &textur stateset->setTextureAttribute(texture_unit, texenv); } - osg::Transparency *transparency = osgNew osg::Transparency; + osg::BlendFunc *blend = osgNew osg::BlendFunc; if (emissive_particles) { - transparency->setFunction(osg::Transparency::SRC_ALPHA, osg::Transparency::ONE); + blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE); } else { - transparency->setFunction(osg::Transparency::SRC_ALPHA, osg::Transparency::ONE_MINUS_SRC_ALPHA); + blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA); } - stateset->setAttributeAndModes(transparency, osg::StateAttribute::ON); + stateset->setAttributeAndModes(blend, osg::StateAttribute::ON); setStateSet(stateset); } diff --git a/src/osgPlugins/dw/ReaderWriterDW.cpp b/src/osgPlugins/dw/ReaderWriterDW.cpp index 860af5e5e..5fc0dc909 100644 --- a/src/osgPlugins/dw/ReaderWriterDW.cpp +++ b/src/osgPlugins/dw/ReaderWriterDW.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/osgPlugins/flt/flt2osg.cpp b/src/osgPlugins/flt/flt2osg.cpp index 186ed25fa..ffad09044 100644 --- a/src/osgPlugins/flt/flt2osg.cpp +++ b/src/osgPlugins/flt/flt2osg.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -625,7 +625,7 @@ osg::Group* ConvertFromFLT::visitOldLOD(osg::Group& osgParent, OldLodRecord* rec // Converted DOF to use transform - jtracy@ist.ucf.edu osg::Group* ConvertFromFLT::visitDOF(osg::Group& osgParent, DofRecord* rec) { - osg::Transform* transform = new osg::Transform; + osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setName(rec->getData()->szIdent); transform->setDataVariance(osg::Object::DYNAMIC); @@ -966,9 +966,9 @@ void ConvertFromFLT::visitFace(GeoSetBuilder* pBuilder, FaceRecord* rec) if (bBlend) { - osg::Transparency* osgTransparency = new osg::Transparency(); - osgTransparency->setFunction(osg::Transparency::SRC_ALPHA, osg::Transparency::ONE_MINUS_SRC_ALPHA); - osgStateSet->setAttribute(osgTransparency); + osg::BlendFunc* osgBlendFunc = new osg::BlendFunc(); + osgBlendFunc->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA); + osgStateSet->setAttribute(osgBlendFunc); osgStateSet->setMode(GL_BLEND, osg::StateAttribute::ON); osgStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); } @@ -1180,7 +1180,7 @@ int ConvertFromFLT::addVertex(DynGeoSet* dgset, Record* rec) osg::Group* ConvertFromFLT::visitMatrix(osg::Group& osgParent, const osg::Group& /*osgPrimary*/, MatrixRecord* rec) { SMatrix* pSMatrix = (SMatrix*)rec->getData(); - osg::Transform* transform = new osg::Transform; + osg::MatrixTransform* transform = new osg::MatrixTransform; osg::Matrix m; for(int i=0;i<4;++i) diff --git a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp index a5619fac0..9e51cde75 100644 --- a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -324,7 +324,7 @@ osg::Node* ReaderWriter3DS::processNode(StateSetMap drawStateMap,Lib3dsFile *f,L if (pivoted) { // Transform object's pivot point to the world origin - osg::Transform* T=new osg::Transform; + osg::MatrixTransform* T=new osg::MatrixTransform; osgmatrix.set( N[0][0],N[0][1],N[0][2],N[0][3], N[1][0],N[1][1],N[1][2],N[1][3], @@ -336,7 +336,7 @@ osg::Node* ReaderWriter3DS::processNode(StateSetMap drawStateMap,Lib3dsFile *f,L // rotate about "origin" (after the transform this is the world origin) // BUG this matrix also contains the translation to the pivot point - we should plit that out (maybe) - osg::Transform* R=new osg::Transform; + osg::MatrixTransform* R=new osg::MatrixTransform; osgmatrix.set( M[0][0],M[0][1],M[0][2],M[0][3], M[1][0],M[1][1],M[1][2],M[1][3], diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index 038b0b9ed..0815b8c8c 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -157,7 +157,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil // toplevel group or transform osg::Group* osg_top = NULL; if (obj->position[0] != 0.0f || obj->position[2] != 0.0f || obj->position[2] != 0.0f) { - osg::Transform* xform = new osg::Transform; + osg::MatrixTransform* xform = new osg::MatrixTransform; // note obj_x -> osg_x, // obj_y -> osg_z, // obj_z -> osg_y, diff --git a/src/osgPlugins/osg/Makefile b/src/osgPlugins/osg/Makefile index 31e1480fb..713030356 100644 --- a/src/osgPlugins/osg/Makefile +++ b/src/osgPlugins/osg/Makefile @@ -28,6 +28,7 @@ CXXFILES =\ LOD.cpp\ Material.cpp\ Matrix.cpp\ + MatrixTransform.cpp\ Node.cpp\ Object.cpp\ OccluderNode.cpp\ diff --git a/src/osgPlugins/osg/Transform.cpp b/src/osgPlugins/osg/Transform.cpp index 0105a4923..da5530fb7 100644 --- a/src/osgPlugins/osg/Transform.cpp +++ b/src/osgPlugins/osg/Transform.cpp @@ -4,6 +4,8 @@ #include "osgDB/Input" #include "osgDB/Output" +#include "osg/Notify" + using namespace osg; using namespace osgDB; @@ -22,16 +24,6 @@ RegisterDotOsgWrapperProxy g_TransformProxy DotOsgWrapper::READ_AND_WRITE ); -// register old style 'DCS' read and write functions with the osgDB::Registry. -RegisterDotOsgWrapperProxy g_DCSProxy -( - osgNew osg::Transform, - "DCS", - "Object Node Group DCS", - &Transform_readLocalData, - NULL, - DotOsgWrapper::READ_ONLY -); bool Transform_readLocalData(Object& obj, Input& fr) { @@ -61,7 +53,14 @@ bool Transform_readLocalData(Object& obj, Input& fr) if (Matrix* tmpMatrix = static_cast(fr.readObjectOfType(s_matrix))) { + #ifdef USE_DEPRECATED_API transform.setMatrix(*tmpMatrix); + #else + osg::notify(osg::WARN)<<"Warning: loaded Matrix inside a osg::Transform, "<(obj); + #ifdef USE_DEPRECATED_API fw.writeObject(transform.getMatrix()); + #endif fw.indent() << "referenceFrame "; switch (transform.getReferenceFrame()) { diff --git a/src/osgPlugins/pfb/ConvertFromPerformer.cpp b/src/osgPlugins/pfb/ConvertFromPerformer.cpp index a98962430..39b32b0f2 100644 --- a/src/osgPlugins/pfb/ConvertFromPerformer.cpp +++ b/src/osgPlugins/pfb/ConvertFromPerformer.cpp @@ -3,7 +3,7 @@ #include "ConvertFromPerformer.h" #include -#include +#include #include #include #include @@ -291,14 +291,14 @@ osg::Node* ConvertFromPerformer::visitSequence(osg::Group* osgParent,pfSequence* osg::Node* ConvertFromPerformer::visitDCS(osg::Group* osgParent,pfDCS* dcs) { - osg::Transform* osgTransform = dynamic_cast(getOsgObject(dcs)); + osg::MatrixTransform* osgTransform = dynamic_cast(getOsgObject(dcs)); if (osgTransform) { if (osgParent) osgParent->addChild(osgTransform); return osgTransform; } - osgTransform = new osg::Transform; + osgTransform = new osg::MatrixTransform; if (osgParent) osgParent->addChild(osgTransform); registerPfObjectForOsgObject(dcs,osgTransform); @@ -327,15 +327,17 @@ osg::Node* ConvertFromPerformer::visitDCS(osg::Group* osgParent,pfDCS* dcs) osg::Node* ConvertFromPerformer::visitSCS(osg::Group* osgParent,pfSCS* scs) { // note the OSG does not currently have a SCS, so use DCS instead. - osg::Transform* osgTransform = dynamic_cast(getOsgObject(scs)); + osg::MatrixTransform* osgTransform = dynamic_cast(getOsgObject(scs)); if (osgTransform) { if (osgParent) osgParent->addChild(osgTransform); return osgTransform; } - osgTransform = new osg::Transform; + osgTransform = new osg::MatrixTransform; if (osgParent) osgParent->addChild(osgTransform); + + osgTransform->setDataVariance(osg::Object::STATIC); registerPfObjectForOsgObject(scs,osgTransform); diff --git a/src/osgPlugins/txp/TrPageArchive.cpp b/src/osgPlugins/txp/TrPageArchive.cpp index ad1dd649e..f30980dd9 100644 --- a/src/osgPlugins/txp/TrPageArchive.cpp +++ b/src/osgPlugins/txp/TrPageArchive.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/osgPlugins/txp/TrPageParser.cpp b/src/osgPlugins/txp/TrPageParser.cpp index f9a2ad8c0..f823a6a42 100644 --- a/src/osgPlugins/txp/TrPageParser.cpp +++ b/src/osgPlugins/txp/TrPageParser.cpp @@ -29,11 +29,10 @@ #include #include #include -#include +#include #include #include #include -#include #include @@ -531,7 +530,7 @@ void *modelRefRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) Node *osg_Model = (*parse->GetModels())[modelID].get(); // Create the SCS and position the model if (osg_Model) { - Transform *scs = new Transform(); + MatrixTransform *scs = new MatrixTransform(); scs->setMatrix(osg_Mat); scs->addChild(osg_Model); // Add the SCS to the hierarchy diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index a28d7579f..3b2425dc5 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -999,10 +999,12 @@ void Optimizer::RemoveRedundentNodesVisitor::apply(osg::Group& group) void Optimizer::RemoveRedundentNodesVisitor::apply(osg::Transform& transform) { - if (transform.getNumParents()>0) + if (transform.getNumParents()>0 && transform.getDataVariance()==osg::Object::STATIC) { static osg::Matrix identity; - if (transform.getMatrix()==identity && transform.getDataVariance()==osg::Object::STATIC) + osg::Matrix matrix; + transform.getWorldToLocalMatrix(matrix,NULL); + if (matrix==identity) { _redundentNodeList.insert(&transform); } diff --git a/src/osgUtil/TransformCallback.cpp b/src/osgUtil/TransformCallback.cpp index ab51aa0a3..d138ac8a7 100644 --- a/src/osgUtil/TransformCallback.cpp +++ b/src/osgUtil/TransformCallback.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -16,7 +16,7 @@ TransformCallback::TransformCallback(const osg::Vec3& pivot,const osg::Vec3& axi void TransformCallback::operator() (osg::Node* node, osg::NodeVisitor* nv) { - osg::Transform* transform = dynamic_cast(node); + osg::MatrixTransform* transform = dynamic_cast(node); if (nv && transform) {