2002-01-24 06:15:39 +08:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
PositionAttitudeTransform::PositionAttitudeTransform()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-09-02 20:31:35 +08:00
|
|
|
bool PositionAttitudeTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-08-13 01:40:36 +08:00
|
|
|
matrix.preMult(osg::Matrix::translate(-_pivotPoint)*
|
|
|
|
osg::Matrix::rotate(_attitude)*
|
|
|
|
osg::Matrix::translate(_position));
|
2002-02-06 05:54:46 +08:00
|
|
|
}
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
else // absolute
|
2002-02-06 05:54:46 +08:00
|
|
|
{
|
2002-08-13 01:40:36 +08:00
|
|
|
matrix = osg::Matrix::translate(-_pivotPoint)*
|
|
|
|
osg::Matrix::rotate(_attitude)*
|
|
|
|
osg::Matrix::translate(_position);
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
return true;
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
|
|
|
|
2002-02-06 05:54:46 +08:00
|
|
|
|
2002-09-02 20:31:35 +08:00
|
|
|
bool PositionAttitudeTransform::computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
2002-02-06 05:54:46 +08:00
|
|
|
{
|
2002-08-13 01:40:36 +08:00
|
|
|
matrix.postMult(osg::Matrix::translate(-_position)*
|
|
|
|
osg::Matrix::rotate(_attitude.inverse())*
|
|
|
|
osg::Matrix::translate(_pivotPoint));
|
2002-02-06 05:54:46 +08:00
|
|
|
}
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
else // absolute
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-08-13 01:40:36 +08:00
|
|
|
matrix = osg::Matrix::translate(-_position)*
|
|
|
|
osg::Matrix::rotate(_attitude.inverse())*
|
|
|
|
osg::Matrix::translate(_pivotPoint);
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC)
and ones that do not vary (STATIC). Removed the equivalent code in
osg::Transform, StateSet and StateAttribute, as these are now encompassed
by the new DataVariance field.
Removed MatrixMode enum from Matrix, and associated fields/parameters from
osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing
any useful functionality, but made the interface more complex (MatrixMode
was an experimental API)
Added ReferenceFrame field to osg::Transform which allows users to specify
transforms that are relative to their parents (the default, and previous behavior)
or absolute reference frame, which can be used for HUD's, camera relative
light sources etc etc. Note, the view frustum culling for absolute Transform
are disabled, and all their parents up to the root are also automatically
have view frustum culling disabled. However, once passed an absolute Transform
node culling will return to its default state of on, so you can still cull
underneath an absolute transform, its only the culling above which is disabled.
2002-04-12 07:20:23 +08:00
|
|
|
return true;
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
2002-08-13 21:22:46 +08:00
|
|
|
|
|
|
|
void PositionAttitudeTransform::AnimationPathCallback::operator()(Node* node, NodeVisitor* nv)
|
|
|
|
{
|
|
|
|
PositionAttitudeTransform* pat = dynamic_cast<PositionAttitudeTransform*>(node);
|
|
|
|
if (pat &&
|
|
|
|
_animationPath.valid() &&
|
|
|
|
nv->getVisitorType()==NodeVisitor::APP_VISITOR &&
|
|
|
|
nv->getFrameStamp())
|
|
|
|
{
|
|
|
|
double time = nv->getFrameStamp()->getReferenceTime();
|
|
|
|
if (_firstTime==0.0) _firstTime = time;
|
2002-08-13 23:31:10 +08:00
|
|
|
AnimationPath::ControlPoint cp;
|
2002-10-08 03:51:11 +08:00
|
|
|
if (_animationPath->getInterpolatedControlPoint(((time-_firstTime)-_timeOffset)*_timeMultiplier,cp))
|
2002-08-13 21:22:46 +08:00
|
|
|
{
|
2002-08-13 23:31:10 +08:00
|
|
|
pat->setPosition(cp._position);
|
|
|
|
pat->setAttitude(cp._rotation);
|
2002-08-13 21:22:46 +08:00
|
|
|
}
|
|
|
|
}
|
2002-10-01 00:50:16 +08:00
|
|
|
// must call any nested node callbacks and continue subgraph traversal.
|
|
|
|
traverse(node,nv);
|
2002-08-13 21:22:46 +08:00
|
|
|
}
|