Ported distribution across to use the new osg::MatrixTransform and osg::BlendFunc

class instead of osg::Transform and osg::Transparancy respectively.
This commit is contained in:
Robert Osfield
2002-07-12 18:12:01 +00:00
parent 8128265e09
commit 6f392cdbfa
32 changed files with 93 additions and 97 deletions

View File

@@ -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.*/

View File

@@ -6,7 +6,7 @@
#include <osg/Geometry>
#include <osg/Texture>
#include <osg/TexEnv>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/AlphaFunc>
#include <osgDB/ReadFile>
@@ -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);

View File

@@ -1,7 +1,7 @@
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osg/Billboard>
@@ -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);

View File

@@ -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 "<<drawable<<std::endl;
return false;

View File

@@ -1,4 +1,4 @@
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/ClipNode>
#include <osg/Billboard>
#include <osg/Geode>
@@ -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);

View File

@@ -1,6 +1,6 @@
#include <stdio.h>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgUtil/Optimizer>
#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 );

View File

@@ -1,4 +1,4 @@
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Billboard>
#include <osg/Geode>
#include <osg/Group>

View File

@@ -2,7 +2,7 @@
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Vec3>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgGA/TrackballManipulator>
@@ -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.

View File

@@ -2,7 +2,7 @@
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Vec3>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osgDB/ReadFile>
@@ -513,7 +513,7 @@ class MyTransformCallback : public osg::NodeCallback
virtual void operator() (osg::Node* node, osg::NodeVisitor* nv)
{
osg::Transform* transform = dynamic_cast<osg::Transform*>(node);
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(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);

View File

@@ -2,14 +2,14 @@
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Projection>
#include <osg/Billboard>
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/Material>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/Depth>
#include <osgDB/Registry>
@@ -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());

View File

@@ -2,7 +2,7 @@
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Billboard>
#include <osg/Geode>
#include <osg/Group>

View File

@@ -1,9 +1,8 @@
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osg/Transparency>
#include <osg/Stencil>
#include <osg/ColorMask>
#include <osg/Depth>
@@ -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));

View File

@@ -1,9 +1,9 @@
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/Stencil>
#include <osg/ColorMask>
#include <osg/Depth>
@@ -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");

View File

@@ -1,5 +1,3 @@
#include <osg/Transform>
#include <osg/Billboard>
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>

View File

@@ -1,6 +1,6 @@
#include <osg/Node>
#include <osg/Notify>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osgGA/TrackballManipulator>

View File

@@ -13,8 +13,8 @@
#include <osg/Node>
#include <osg/StateSet>
#include <osg/Material>
#include <osg/Transparency>
#include <osg/Transform>
#include <osg/BlendFunc>
#include <osg/MatrixTransform>
#include <osg/PolygonMode>
#include <osg/Depth>
#include <osg/Notify>
@@ -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");

View File

@@ -1,7 +1,7 @@
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Texture>
#include <osg/DrawPixels>
@@ -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);

View File

@@ -2,10 +2,7 @@
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Transform>
#include <osg/Billboard>
#include <osg/Geode>
#include <osg/Group>
#include <osg/Node>
#include <osg/Notify>
#include <osgDB/Registry>

View File

@@ -47,6 +47,7 @@ CXXFILES =\
LineWidth.cpp\
Material.cpp\
Matrix.cpp\
MatrixTransform.cpp\
MemoryManager.cpp\
Node.cpp\
NodeCallback.cpp\

View File

@@ -9,7 +9,7 @@
#include <osg/CullFace>
#include <osg/FrontFace>
#include <osg/PolygonMode>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/Depth>
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);

View File

@@ -9,7 +9,7 @@
#include <osg/GL>
#include <osg/StateSet>
#include <osg/Texture>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/TexEnv>
#include <osg/Material>
@@ -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);
}

View File

@@ -17,7 +17,6 @@
#include <osg/LightSource>
#include <osg/Material>
#include <osg/Texture>
#include <osg/Transparency>
#include <osg/TexEnv>
#include <osg/StateSet>
#include <osg/Notify>

View File

@@ -4,7 +4,7 @@
#include <osg/Group>
#include <osg/LOD>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Switch>
#include <osg/Geode>
#include <osg/GeoSet>
@@ -13,7 +13,7 @@
#include <osg/TexEnv>
#include <osg/TexGen>
#include <osg/AlphaFunc>
#include <osg/Transparency>
#include <osg/BlendFunc>
#include <osg/Point>
#include <osg/Material>
#include <osg/PolygonOffset>
@@ -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)

View File

@@ -6,7 +6,7 @@
#include <osg/Material>
#include <osg/TexEnv>
#include <osg/ref_ptr>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
@@ -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],

View File

@@ -21,7 +21,7 @@
#include <osg/Notify>
#include <osg/Node>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osg/Geometry>
@@ -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,

View File

@@ -28,6 +28,7 @@ CXXFILES =\
LOD.cpp\
Material.cpp\
Matrix.cpp\
MatrixTransform.cpp\
Node.cpp\
Object.cpp\
OccluderNode.cpp\

View File

@@ -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<Matrix*>(fr.readObjectOfType(s_matrix)))
{
#ifdef USE_DEPRECATED_API
transform.setMatrix(*tmpMatrix);
#else
osg::notify(osg::WARN)<<"Warning: loaded Matrix inside a osg::Transform, "<<std::endl;
osg::notify(osg::WARN)<<" this indicates that the file is out of date, "<<std::endl;
osg::notify(osg::WARN)<<" the matrix data will be lost, convert the file by replacing "<<std::endl;
osg::notify(osg::WARN)<<" instances with MatrixTransform in the .osg file, and then reload."<<endl;
#endif
osgDelete tmpMatrix;
@@ -89,7 +88,9 @@ bool Transform_writeLocalData(const Object& obj, Output& fw)
{
const Transform& transform = static_cast<const Transform&>(obj);
#ifdef USE_DEPRECATED_API
fw.writeObject(transform.getMatrix());
#endif
fw.indent() << "referenceFrame ";
switch (transform.getReferenceFrame()) {

View File

@@ -3,7 +3,7 @@
#include "ConvertFromPerformer.h"
#include <osg/Group>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/LOD>
#include <osg/Switch>
#include <osg/Geode>
@@ -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<osg::Transform*>(getOsgObject(dcs));
osg::MatrixTransform* osgTransform = dynamic_cast<osg::MatrixTransform*>(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<osg::Transform*>(getOsgObject(scs));
osg::MatrixTransform* osgTransform = dynamic_cast<osg::MatrixTransform*>(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);

View File

@@ -7,7 +7,6 @@
#include <osg/Texture>
#include <osg/Material>
#include <osg/TexEnv>
#include <osg/Transparency>
#include <osg/CullFace>
#include <osg/Light>
#include <osg/StateSet>

View File

@@ -29,11 +29,10 @@
#include <osg/Geode>
#include <osg/Billboard>
#include <osg/Matrix>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osg/Geometry>
#include <osg/CullFace>
#include <osg/Light>
#include <osg/Transparency>
#include <osg/Notify>
@@ -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

View File

@@ -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);
}

View File

@@ -1,4 +1,4 @@
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgUtil/TransformCallback>
@@ -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<osg::Transform*>(node);
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(node);
if (nv && transform)
{