Added ClipNode::set/getReferenceFrame();

This commit is contained in:
Robert Osfield
2008-12-19 15:29:59 +00:00
parent f4fe462b28
commit 0ea6cdeb96
7 changed files with 100 additions and 6 deletions

View File

@@ -32,6 +32,11 @@ void ClipNode::write(DataOutputStream* out){
throw Exception("ClipNode::write(): Could not cast this osg::ClipNode to an osg::Group.");
// Write ClipNode's properties.
if ( out->getVersion() >= VERSION_0037 )
{
out->writeInt((int)getReferenceFrame());
}
out->writeUInt(getNumClipPlanes());
for (unsigned int i=0;i<getNumClipPlanes();++i)
@@ -56,6 +61,11 @@ void ClipNode::read(DataInputStream* in){
throw Exception("ClipNode::read(): Could not cast this osg::ClipNode to an osg::Object.");
// Read ClipNode's properties
if ( in->getVersion() >= VERSION_0037 )
{
setReferenceFrame((osg::ClipNode::ReferenceFrame) in->readInt());
}
unsigned int numClipPlanes = in->readUInt();
for (unsigned int i=0;i<numClipPlanes;++i)

View File

@@ -45,8 +45,9 @@
#define VERSION_0034 34
#define VERSION_0035 35
#define VERSION_0036 36
#define VERSION_0037 37
#define VERSION VERSION_0036
#define VERSION VERSION_0037
/* The BYTE_SEX tag is used to check the endian
of the IVE file being read in. The IVE format

View File

@@ -27,6 +27,22 @@ bool ClipNode_readLocalData(Object& obj, Input& fr)
ClipNode& clipnode = static_cast<ClipNode&>(obj);
if (fr[0].matchWord("referenceFrame"))
{
if (fr[1].matchWord("ABSOLUTE"))
{
clipnode.setReferenceFrame(ClipNode::ABSOLUTE_RF);
fr += 2;
iteratorAdvanced = true;
}
if (fr[1].matchWord("RELATIVE"))
{
clipnode.setReferenceFrame(ClipNode::RELATIVE_RF);
fr += 2;
iteratorAdvanced = true;
}
}
osg::ref_ptr<StateAttribute> sa=0;
while((sa=fr.readStateAttribute())!=0)
{
@@ -43,6 +59,17 @@ bool ClipNode_writeLocalData(const Object& obj, Output& fw)
{
const ClipNode& clipnode = static_cast<const ClipNode&>(obj);
fw.indent() << "referenceFrame ";
switch (clipnode.getReferenceFrame())
{
case ClipNode::ABSOLUTE_RF:
fw << "ABSOLUTE\n";
break;
case ClipNode::RELATIVE_RF:
default:
fw << "RELATIVE\n";
};
for(unsigned int i=0;i<clipnode.getNumClipPlanes();++i)
{
fw.writeObject(*clipnode.getClipPlane(i));