Checked in Macro Jez's additions to osgText to support .osg IO make it
a fully functioning NodeKit. Also reimplement notify() to try an prevent a crash which has been caused by to objects in notify.cpp being initiliazed twice, the second time the auto_ptr holding the dev/null ofstream was being initilized to 0.
This commit is contained in:
@@ -31,6 +31,7 @@ CXXFILES =\
|
||||
Point.cpp\
|
||||
PolygonMode.cpp\
|
||||
PolygonOffset.cpp\
|
||||
Projection.cpp\
|
||||
ReaderWriterOSG.cpp\
|
||||
ShadeModel.cpp\
|
||||
StateSet.cpp\
|
||||
|
||||
49
src/osgPlugins/osg/Projection.cpp
Normal file
49
src/osgPlugins/osg/Projection.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <osg/Projection>
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool Projection_readLocalData(Object& obj, Input& fr);
|
||||
bool Projection_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_ProjectionProxy
|
||||
(
|
||||
osgNew osg::Projection,
|
||||
"Projection",
|
||||
"Object Node Group Projection",
|
||||
&Projection_readLocalData,
|
||||
&Projection_writeLocalData
|
||||
);
|
||||
|
||||
bool Projection_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
Projection &myobj = static_cast<Projection &>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
static Matrix s_matrix;
|
||||
|
||||
if (Matrix* tmpMatrix = static_cast<Matrix*>(fr.readObjectOfType(s_matrix)))
|
||||
{
|
||||
myobj.setMatrix(*tmpMatrix);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
bool Projection_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const Projection& myobj = static_cast<const Projection&>(obj);
|
||||
|
||||
fw.writeObject(myobj.getMatrix());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -39,7 +39,6 @@ bool Transform_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
Transform& transform = static_cast<Transform&>(obj);
|
||||
|
||||
|
||||
if (fr[0].matchWord("Type"))
|
||||
{
|
||||
if (fr[1].matchWord("DYNAMIC"))
|
||||
@@ -69,6 +68,19 @@ bool Transform_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("referenceFrame")) {
|
||||
if (fr[1].matchWord("RELATIVE_TO_ABSOLUTE")) {
|
||||
transform.setReferenceFrame(Transform::RELATIVE_TO_ABSOLUTE);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
if (fr[1].matchWord("RELATIVE_TO_PARENTS")) {
|
||||
transform.setReferenceFrame(Transform::RELATIVE_TO_PARENTS);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -79,5 +91,15 @@ bool Transform_writeLocalData(const Object& obj, Output& fw)
|
||||
|
||||
fw.writeObject(transform.getMatrix());
|
||||
|
||||
fw.indent() << "referenceFrame ";
|
||||
switch (transform.getReferenceFrame()) {
|
||||
case Transform::RELATIVE_TO_ABSOLUTE:
|
||||
fw << "RELATIVE_TO_ABSOLUTE\n";
|
||||
break;
|
||||
case Transform::RELATIVE_TO_PARENTS:
|
||||
default:
|
||||
fw << "RELATIVE_TO_PARENTS\n";
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user