Added support for CameraView into NodeVistor, and support for CameraNode and CameraView
into the AnimationPathCallback so you can now animate both via animation paths.
This commit is contained in:
@@ -39,6 +39,7 @@ class Switch;
|
||||
class TexGenNode;
|
||||
class Transform;
|
||||
class CameraNode;
|
||||
class CameraView;
|
||||
|
||||
/** Visitor for type safe operations on osg::Nodes.
|
||||
Based on GOF's Visitor pattern. The NodeVisitor
|
||||
@@ -234,7 +235,8 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
|
||||
virtual void apply(LightSource& node) { apply((Group&)node); }
|
||||
|
||||
virtual void apply(Transform& node) { apply((Group&)node); }
|
||||
virtual void apply(CameraNode& node) { apply((Group&)node); }
|
||||
virtual void apply(CameraNode& node) { apply((Transform&)node); }
|
||||
virtual void apply(CameraView& node) { apply((Transform&)node); }
|
||||
virtual void apply(MatrixTransform& node) { apply((Transform&)node); }
|
||||
virtual void apply(PositionAttitudeTransform& node) { apply((Transform&)node); }
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <osg/AnimationPath>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/CameraNode>
|
||||
#include <osg/CameraView>
|
||||
#include <osg/io_utils>
|
||||
|
||||
using namespace osg;
|
||||
@@ -122,6 +124,37 @@ class AnimationPathCallbackVisitor : public NodeVisitor
|
||||
_pivotPoint(pivotPoint),
|
||||
_useInverseMatrix(useInverseMatrix) {}
|
||||
|
||||
virtual void apply(CameraNode& camera)
|
||||
{
|
||||
Matrix matrix;
|
||||
if (_useInverseMatrix)
|
||||
_cp.getInverse(matrix);
|
||||
else
|
||||
_cp.getMatrix(matrix);
|
||||
|
||||
camera.setViewMatrix(osg::Matrix::translate(-_pivotPoint)*matrix);
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(CameraView& cv)
|
||||
{
|
||||
if (_useInverseMatrix)
|
||||
{
|
||||
Matrix matrix;
|
||||
_cp.getInverse(matrix);
|
||||
cv.setPosition(matrix.getTrans());
|
||||
cv.setAttitude(_cp.getRotation().inverse());
|
||||
cv.setFocalLength(1.0f/_cp.getScale().x());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
cv.setPosition(_cp.getPosition());
|
||||
cv.setAttitude(_cp.getRotation());
|
||||
cv.setFocalLength(_cp.getScale().x());
|
||||
}
|
||||
}
|
||||
|
||||
virtual void apply(MatrixTransform& mt)
|
||||
{
|
||||
Matrix matrix;
|
||||
|
||||
Reference in New Issue
Block a user