Futher improvements and fixes to osg::AnimationPath, and the osglight

demo to show it action.
This commit is contained in:
Robert Osfield
2002-08-13 15:31:10 +00:00
parent 7c049360ff
commit f9cc8783b3
10 changed files with 175 additions and 172 deletions

View File

@@ -113,19 +113,6 @@ struct TransformCallback : public osg::Transform::ComputeTransformCallback
}
};
struct BillboardCallback : public osg::Billboard::ComputeBillboardCallback
{
/** Get the transformation matrix which moves from local coords to world coords.*/
virtual const bool computeMatrix(osg::Matrix& modelview, const osg::Billboard* billboard, const osg::Vec3& eye_local, const osg::Vec3& pos_local) const
{
std::cout<<"ComputeBillboardCallback - pre billboard->computeMatrix"<<std::endl;
bool result = billboard->computeMatrix(modelview,eye_local,pos_local);
std::cout<<"ComputeBillboardCallback - post billboard->computeMatrix"<<std::endl;
return result;
}
};
struct DrawableAppCallback : public osg::Drawable::AppCallback
{
virtual void app(osg::NodeVisitor*, osg::Drawable* drawable)
@@ -178,12 +165,6 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
}
}
virtual void apply(osg::Billboard& node)
{
node.setComputeBillboardCallback(new BillboardCallback());
apply((osg::Geode&)node);
}
virtual void apply(osg::Transform& node)
{
node.setComputeTransformCallback(new TransformCallback());

View File

@@ -109,22 +109,22 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
lightS2->setStateSetModes(*rootStateSet,osg::StateAttribute::ON);
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
osg::MatrixTransform* mt = new osg::MatrixTransform();
{
// set up the animation path
osg::AnimationPath* animationPath = new osg::AnimationPath;
animationPath->insert(0.0,osg::AnimationPath::Key(bb.corner(0)));
animationPath->insert(1.0,osg::AnimationPath::Key(bb.corner(1)));
animationPath->insert(2.0,osg::AnimationPath::Key(bb.corner(2)));
animationPath->insert(3.0,osg::AnimationPath::Key(bb.corner(3)));
animationPath->insert(4.0,osg::AnimationPath::Key(bb.corner(4)));
animationPath->insert(5.0,osg::AnimationPath::Key(bb.corner(5)));
animationPath->insert(6.0,osg::AnimationPath::Key(bb.corner(6)));
animationPath->insert(7.0,osg::AnimationPath::Key(bb.corner(7)));
animationPath->insert(8.0,osg::AnimationPath::Key(bb.corner(0)));
animationPath->insert(0.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
animationPath->insert(1.0,osg::AnimationPath::ControlPoint(bb.corner(1)));
animationPath->insert(2.0,osg::AnimationPath::ControlPoint(bb.corner(2)));
animationPath->insert(3.0,osg::AnimationPath::ControlPoint(bb.corner(3)));
animationPath->insert(4.0,osg::AnimationPath::ControlPoint(bb.corner(4)));
animationPath->insert(5.0,osg::AnimationPath::ControlPoint(bb.corner(5)));
animationPath->insert(6.0,osg::AnimationPath::ControlPoint(bb.corner(6)));
animationPath->insert(7.0,osg::AnimationPath::ControlPoint(bb.corner(7)));
animationPath->insert(8.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
animationPath->setLoopMode(osg::AnimationPath::SWING);
// attach it to the transform as an app callback.
pat->setAppCallback(new osg::PositionAttitudeTransform::AnimationPathCallback(animationPath));
mt->setAppCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath));
}
// create marker for point light.
@@ -144,12 +144,12 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
osg::Geode* markerGeode = new osg::Geode;
markerGeode->addDrawable(marker);
pat->addChild(lightS2);
pat->addChild(markerGeode);
mt->addChild(lightS2);
mt->addChild(markerGeode);
lightGroup->addChild(lightS2);
lightGroup->addChild(pat);
lightGroup->addChild(mt);
return lightGroup;
}