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.
This commit is contained in:
@@ -57,14 +57,12 @@ class TransformVisitor : public NodeVisitor
|
||||
};
|
||||
|
||||
|
||||
MatrixMode _matrixMode;
|
||||
CoordMode _coordMode;
|
||||
Matrix& _matrix;
|
||||
NodeVisitor* _nodeVisitor;
|
||||
|
||||
TransformVisitor(Matrix& matrix,MatrixMode matrixMode,CoordMode coordMode,NodeVisitor* nv):
|
||||
TransformVisitor(Matrix& matrix,CoordMode coordMode,NodeVisitor* nv):
|
||||
NodeVisitor(),
|
||||
_matrixMode(matrixMode),
|
||||
_coordMode(coordMode),
|
||||
_matrix(matrix),
|
||||
_nodeVisitor(nv)
|
||||
@@ -72,51 +70,44 @@ class TransformVisitor : public NodeVisitor
|
||||
|
||||
virtual void apply(Transform& transform)
|
||||
{
|
||||
bool applyTransform =
|
||||
(_matrixMode==transform.getMatrixMode()) ||
|
||||
(_matrixMode==MODELVIEW && (transform.getMatrixMode()==MODEL || transform.getMatrixMode()==VIEW));
|
||||
|
||||
if (applyTransform)
|
||||
if (_coordMode==LOCAL_TO_WORLD)
|
||||
{
|
||||
if (_coordMode==LOCAL_TO_WORLD)
|
||||
{
|
||||
osg::Matrix localToWorldMat;
|
||||
transform.getLocalToWorldMatrix(localToWorldMat,_nodeVisitor);
|
||||
_matrix.preMult(localToWorldMat);
|
||||
}
|
||||
else // worldToLocal
|
||||
{
|
||||
osg::Matrix worldToLocalMat;
|
||||
transform.getWorldToLocalMatrix(worldToLocalMat,_nodeVisitor);
|
||||
_matrix.postMult(worldToLocalMat);
|
||||
}
|
||||
osg::Matrix localToWorldMat;
|
||||
transform.getLocalToWorldMatrix(localToWorldMat,_nodeVisitor);
|
||||
_matrix.preMult(localToWorldMat);
|
||||
}
|
||||
else // worldToLocal
|
||||
{
|
||||
osg::Matrix worldToLocalMat;
|
||||
transform.getWorldToLocalMatrix(worldToLocalMat,_nodeVisitor);
|
||||
_matrix.postMult(worldToLocalMat);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
const bool NodeVisitor::getLocalToWorldMatrix(Matrix& matrix, MatrixMode mode, Node* node)
|
||||
const bool NodeVisitor::getLocalToWorldMatrix(Matrix& matrix, Node* node)
|
||||
{
|
||||
TransformVisitor tv(matrix,mode,TransformVisitor::LOCAL_TO_WORLD,this);
|
||||
TransformVisitor tv(matrix,TransformVisitor::LOCAL_TO_WORLD,this);
|
||||
for(NodePath::iterator itr=_nodePath.begin();
|
||||
itr!=_nodePath.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr==node) return true; // don't account for matrix attached to specofied node
|
||||
if (*itr==node) return true; // don't account for matrix attached to specified node
|
||||
(*itr)->accept(tv);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool NodeVisitor::getWorldToLocalMatrix(Matrix& matrix, MatrixMode mode, Node* node)
|
||||
const bool NodeVisitor::getWorldToLocalMatrix(Matrix& matrix, Node* node)
|
||||
{
|
||||
TransformVisitor tv(matrix,mode,TransformVisitor::WORLD_TO_LOCAL,this);
|
||||
TransformVisitor tv(matrix,TransformVisitor::WORLD_TO_LOCAL,this);
|
||||
for(NodePath::iterator itr=_nodePath.begin();
|
||||
itr!=_nodePath.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr==node) return true; // don't account for matrix attached to specofied node
|
||||
if (*itr==node) return true; // don't account for matrix attached to specified node
|
||||
(*itr)->accept(tv);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user