From Nathan Monteleone, addition of AutoTransform support.

This commit is contained in:
Robert Osfield
2006-02-20 19:13:11 +00:00
parent 9473d80345
commit af6af82e56
7 changed files with 107 additions and 0 deletions

View File

@@ -108,6 +108,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\AnimationPathCallback.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\AutoTransform.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\AzimElevationSector.cpp
# End Source File
# Begin Source File
@@ -456,6 +460,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\AnimationPathCallback.h
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\AutoTransform.h
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\AzimElevationSector.h
# End Source File
# Begin Source File

View File

@@ -0,0 +1,73 @@
/**********************************************************************
*
* FILE: AutoTransform.cpp
*
* DESCRIPTION: Read/Write osg::AutoTransform in binary format to disk.
*
* CREATED BY: Nathan Monteleone, based on PositionAttitudeTransform.cpp
*
* HISTORY: Created 02.3.2006
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "AutoTransform.h"
#include "Transform.h"
using namespace ive;
void AutoTransform::write(DataOutputStream* out){
// Write AutoTransform's identification.
out->writeInt(IVEAUTOTRANSFORM);
// If the osg class is inherited by any other class we should also write this to file.
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
if(trans){
((ive::Transform*)(trans))->write(out);
}
else
throw Exception("AutoTransform::write(): Could not cast this osg::AutoTransform to an osg::Transform.");
// Write AutoTransform's properties.
out->writeVec3(getPosition());
out->writeVec3(getPivotPoint());
out->writeFloat(getAutoUpdateEyeMovementTolerance());
out->writeInt(getAutoRotateMode());
out->writeBool(getAutoScaleToScreen());
out->writeQuat(getRotation());
out->writeVec3(getScale());
}
void AutoTransform::read(DataInputStream* in){
// Peek on AutoTransform's identification.
int id = in->peekInt();
if(id == IVEAUTOTRANSFORM){
// Read AutoTransform's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
if(trans){
((ive::Transform*)(trans))->read(in);
}
else
throw Exception("AutoTransform::read(): Could not cast this osg::AutoTransform to an osg::Transform.");
// Read AutoTransform's properties
setPosition(in->readVec3());
setPivotPoint(in->readVec3());
setAutoUpdateEyeMovementTolerance(in->readFloat());
setAutoRotateMode(osg::AutoTransform::AutoRotateMode(in->readInt()));
setAutoScaleToScreen(in->readBool());
setRotation(in->readQuat());
setScale(in->readVec3());
}
else{
throw Exception("AutoTransform::read(): Expected AutoTransform identification.");
}
}

View File

@@ -0,0 +1,15 @@
#ifndef IVE_AUTOTRANSFORM
#define IVE_AUTOTRANSFORM 1
#include <osg/AutoTransform>
#include "ReadWrite.h"
namespace ive{
class AutoTransform : public osg::AutoTransform, public ReadWrite {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -58,6 +58,7 @@
#include "LOD.h"
#include "PagedLOD.h"
#include "PositionAttitudeTransform.h"
#include "AutoTransform.h"
#include "DOFTransform.h"
#include "Transform.h"
#include "Switch.h"
@@ -1141,6 +1142,10 @@ osg::Node* DataInputStream::readNode()
node = new osg::PositionAttitudeTransform();
((ive::PositionAttitudeTransform*)(node))->read(this);
}
else if(nodeTypeID== IVEAUTOTRANSFORM){
node = new osg::AutoTransform();
((ive::AutoTransform*)(node))->read(this);
}
else if(nodeTypeID== IVEDOFTRANSFORM){
node = new osgSim::DOFTransform();
((ive::DOFTransform*)(node))->read(this);

View File

@@ -61,6 +61,7 @@
#include "LOD.h"
#include "PagedLOD.h"
#include "PositionAttitudeTransform.h"
#include "AutoTransform.h"
#include "DOFTransform.h"
#include "Transform.h"
#include "Switch.h"
@@ -914,6 +915,9 @@ void DataOutputStream::writeNode(const osg::Node* node)
else if(dynamic_cast<const osg::PositionAttitudeTransform*>(node)){
((ive::PositionAttitudeTransform*)(node))->write(this);
}
else if(dynamic_cast<const osg::AutoTransform*>(node)){
((ive::AutoTransform*)(node))->write(this);
}
else if(dynamic_cast<const osgSim::DOFTransform*>(node)){
((ive::DOFTransform*)(node))->write(this);
}

View File

@@ -7,6 +7,7 @@ CXXFILES =\
AnimationPath.cpp\
AzimElevationSector.cpp\
AzimSector.cpp\
AutoTransform.cpp\
Billboard.cpp\
BlendFunc.cpp\
BlinkSequence.cpp\

View File

@@ -36,6 +36,7 @@ namespace ive {
#define IVEPROXYNODE 0x00000027
#define IVECAMERANODE 0x00000028
#define IVECAMERAVIEW 0x00000029
#define IVEAUTOTRANSFORM 0x00000030
// Node callbacks
#define IVENODECALLBACK 0x00000050