2001-09-20 05:08:56 +08:00
|
|
|
#include "osg/Transform"
|
2002-07-14 18:46:46 +08:00
|
|
|
#include "osg/MatrixTransform"
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
#include "osgDB/Registry"
|
|
|
|
#include "osgDB/Input"
|
|
|
|
#include "osgDB/Output"
|
|
|
|
|
2002-07-13 02:12:01 +08:00
|
|
|
#include "osg/Notify"
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
using namespace osg;
|
|
|
|
using namespace osgDB;
|
|
|
|
|
|
|
|
// forward declare functions to use later.
|
|
|
|
bool Transform_readLocalData(Object& obj, Input& fr);
|
|
|
|
bool Transform_writeLocalData(const Object& obj, Output& fw);
|
|
|
|
|
|
|
|
// register the read and write functions with the osgDB::Registry.
|
|
|
|
RegisterDotOsgWrapperProxy g_TransformProxy
|
|
|
|
(
|
2002-12-16 21:40:58 +08:00
|
|
|
new osg::Transform,
|
2001-09-20 05:08:56 +08:00
|
|
|
"Transform",
|
|
|
|
"Object Node Transform Group",
|
|
|
|
&Transform_readLocalData,
|
|
|
|
&Transform_writeLocalData,
|
|
|
|
DotOsgWrapper::READ_AND_WRITE
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
bool Transform_readLocalData(Object& obj, Input& fr)
|
|
|
|
{
|
|
|
|
bool iteratorAdvanced = false;
|
|
|
|
|
|
|
|
Transform& transform = static_cast<Transform&>(obj);
|
|
|
|
|
2001-12-16 00:56:39 +08:00
|
|
|
if (fr[0].matchWord("Type"))
|
|
|
|
{
|
|
|
|
if (fr[1].matchWord("DYNAMIC"))
|
|
|
|
{
|
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
|
|
|
transform.setDataVariance(osg::Object::DYNAMIC);
|
2001-12-16 00:56:39 +08:00
|
|
|
fr +=2 ;
|
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
|
|
|
iteratorAdvanced = true;
|
2001-12-16 00:56:39 +08:00
|
|
|
}
|
|
|
|
else if (fr[1].matchWord("STATIC"))
|
|
|
|
{
|
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
|
|
|
transform.setDataVariance(osg::Object::STATIC);
|
2001-12-16 00:56:39 +08:00
|
|
|
fr +=2 ;
|
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
|
|
|
iteratorAdvanced = true;
|
2001-12-16 00:56:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-06-12 02:41:57 +08:00
|
|
|
if (fr[0].matchWord("referenceFrame")) {
|
2004-10-23 03:26:45 +08:00
|
|
|
if (fr[1].matchWord("RELATIVE_TO_ABSOLUTE") || fr[1].matchWord("ABSOLUTE") ) {
|
|
|
|
transform.setReferenceFrame(Transform::ABSOLUTE);
|
2002-06-12 02:41:57 +08:00
|
|
|
fr += 2;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
2004-10-23 03:26:45 +08:00
|
|
|
if (fr[1].matchWord("RELATIVE_TO_PARENTS") || fr[1].matchWord("RELATIVE")) {
|
|
|
|
transform.setReferenceFrame(Transform::RELATIVE);
|
2002-06-12 02:41:57 +08:00
|
|
|
fr += 2;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
return iteratorAdvanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Transform_writeLocalData(const Object& obj, Output& fw)
|
|
|
|
{
|
|
|
|
const Transform& transform = static_cast<const Transform&>(obj);
|
|
|
|
|
2002-06-12 02:41:57 +08:00
|
|
|
fw.indent() << "referenceFrame ";
|
|
|
|
switch (transform.getReferenceFrame()) {
|
2004-10-23 03:26:45 +08:00
|
|
|
case Transform::ABSOLUTE:
|
|
|
|
fw << "ABSOLUTE\n";
|
2002-06-12 02:41:57 +08:00
|
|
|
break;
|
2004-10-23 03:26:45 +08:00
|
|
|
case Transform::RELATIVE:
|
2002-06-12 02:41:57 +08:00
|
|
|
default:
|
2004-10-23 03:26:45 +08:00
|
|
|
fw << "RELATIVE\n";
|
2002-06-12 02:41:57 +08:00
|
|
|
};
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
return true;
|
|
|
|
}
|