Removed osg::Transform::ComputeTransformCallback from osg::Transform.

Updated various dependant files to reimplemt callbacks as Transform subclasses.
This commit is contained in:
Robert Osfield
2003-12-09 14:07:44 +00:00
parent d76cef6f8e
commit 9780a7cbd6
10 changed files with 23 additions and 112 deletions

View File

@@ -46,27 +46,6 @@ class DrawableDrawCallback : public osg::Drawable::DrawCallback
}
};
struct TransformCallback : public osg::Transform::ComputeTransformCallback
{
/** Get the transformation matrix which moves from local coords to world coords.*/
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform* transform, osg::NodeVisitor* nv) const
{
std::cout<<"computeLocalToWorldMatrix - pre transform->computeLocalToWorldMatrix"<<std::endl;
bool result = transform->computeLocalToWorldMatrix(matrix,nv);
std::cout<<"computeLocalToWorldMatrix - post transform->computeLocalToWorldMatrix"<<std::endl;
return result;
}
/** Get the transformation matrix which moves from world coords to local coords.*/
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform* transform, osg::NodeVisitor* nv) const
{
std::cout<<"computeWorldToLocalMatrix - pre transform->computeWorldToLocalMatrix"<<std::endl;
bool result = transform->computeWorldToLocalMatrix(matrix,nv);
std::cout<<"computeWorldToLocalMatrix - post transform->computeWorldToLocalMatrix"<<std::endl;
return result;
}
};
struct DrawableUpdateCallback : public osg::Drawable::UpdateCallback
{
virtual void update(osg::NodeVisitor*, osg::Drawable* drawable)
@@ -121,7 +100,6 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
virtual void apply(osg::Transform& node)
{
node.setComputeTransformCallback(new TransformCallback());
apply((osg::Node&)node);
}
};

View File

@@ -26,10 +26,11 @@ extern osg::Node *makeSky( void );
extern osg::Node *makeBase( void );
extern osg::Node *makeClouds( void );
struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransformCallback
class MoveEarthySkyWithEyePointTransform : public osg::Transform
{
public:
/** Get the transformation matrix which moves from local coords to world coords.*/
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
@@ -41,8 +42,10 @@ struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransfo
}
/** Get the transformation matrix which moves from world coords to local coords.*/
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
std::cout<<"computing transform"<<std::endl;
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
{
@@ -67,7 +70,7 @@ osg::Group* createModel()
clearNode->setRequiresClear(false); // we've got base and sky to do it.
// use a transform to make the sky and base around with the eye point.
osg::Transform* transform = new osg::Transform;
osg::Transform* transform = new MoveEarthySkyWithEyePointTransform;
// transform's value isn't knowm until in the cull traversal so its bounding
// volume is can't be determined, therefore culling will be invalid,
@@ -76,10 +79,6 @@ osg::Group* createModel()
// this node or any other branch above this transform.
transform->setCullingActive(false);
// set the compute transform callback to do all the work of
// determining the transform according to the current eye point.
transform->setComputeTransformCallback(new MoveEarthySkyWithEyePointCallback);
// add the sky and base layer.
transform->addChild(makeSky()); // bin number -2 so drawn first.
transform->addChild(makeBase()); // bin number -1 so draw second.

View File

@@ -196,10 +196,11 @@ public:
};
struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransformCallback
class MoveEarthySkyWithEyePointTransform : public osg::Transform
{
public:
/** Get the transformation matrix which moves from local coords to world coords.*/
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
@@ -211,7 +212,7 @@ struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransfo
}
/** Get the transformation matrix which moves from world coords to local coords.*/
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
@@ -262,9 +263,8 @@ osg::Node* createSkyBox()
geode->addDrawable(drawable);
osg::Transform* transform = new osg::Transform;
osg::Transform* transform = new MoveEarthySkyWithEyePointTransform;
transform->setCullingActive(false);
transform->setComputeTransformCallback(new MoveEarthySkyWithEyePointCallback);
transform->addChild(geode);
osg::ClearNode* clearNode = new osg::ClearNode;