2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-01-24 06:15:39 +08:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
2004-02-22 19:58:44 +08:00
|
|
|
PositionAttitudeTransform::PositionAttitudeTransform():
|
|
|
|
_scale(1.0f,1.0f,1.0f)
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-09-02 20:31:35 +08:00
|
|
|
bool PositionAttitudeTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2004-10-25 04:04:00 +08:00
|
|
|
if (_referenceFrame==RELATIVE_RF)
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-08-13 01:40:36 +08:00
|
|
|
matrix.preMult(osg::Matrix::translate(-_pivotPoint)*
|
2004-02-22 19:58:44 +08:00
|
|
|
osg::Matrix::scale(_scale)*
|
2002-08-13 01:40:36 +08:00
|
|
|
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)*
|
2004-02-22 19:58:44 +08:00
|
|
|
osg::Matrix::scale(_scale)*
|
2002-08-13 01:40:36 +08:00
|
|
|
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
|
|
|
{
|
2004-10-25 04:04:00 +08:00
|
|
|
if (_referenceFrame==RELATIVE_RF)
|
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())*
|
2004-02-22 19:58:44 +08:00
|
|
|
osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*
|
2002-08-13 01:40:36 +08:00
|
|
|
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())*
|
2004-02-22 19:58:44 +08:00
|
|
|
osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*
|
2002-08-13 01:40:36 +08:00
|
|
|
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
|
|
|
}
|