From Rune Schmidt Jensen, support for osgSim::VisibilityGroup in the .ive loader
and support for node masks.
This commit is contained in:
@@ -320,6 +320,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\LightPoint.cpp
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LightPointNode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\VisibilityGroup.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
@@ -556,6 +560,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\LightPoint.h
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LightPointNode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\VisibilityGroup.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "LightPointNode.h"
|
||||
#include "MultiSwitch.h"
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
@@ -682,6 +683,10 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osg::OccluderNode();
|
||||
((ive::OccluderNode*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVEVISIBILITYGROUP){
|
||||
node = new osgSim::VisibilityGroup();
|
||||
((ive::VisibilityGroup*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVEGROUP){
|
||||
node = new osg::Group();
|
||||
((ive::Group*)(node))->read(this);
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "LightPointNode.h"
|
||||
#include "MultiSwitch.h"
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
@@ -544,6 +545,9 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osg::Transform*>(node)){
|
||||
((ive::Transform*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgSim::VisibilityGroup*>(node)){
|
||||
((ive::VisibilityGroup*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::Group*>(node)){
|
||||
((ive::Group*)(node))->write(this);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ CXXFILES =\
|
||||
ElevationSector.cpp\
|
||||
LightPoint.cpp\
|
||||
LightPointNode.cpp\
|
||||
VisibilityGroup.cpp\
|
||||
|
||||
LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class LightPoint : public osgSim::LightPoint, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
virtual ~LightPoint() {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ void Node::write(DataOutputStream* out){
|
||||
if(getStateSet())
|
||||
out->writeStateSet(getStateSet());
|
||||
|
||||
|
||||
// Write UpdateCallback if any
|
||||
osg::AnimationPathCallback* nc = dynamic_cast<osg::AnimationPathCallback*>(getUpdateCallback());
|
||||
out->writeBool(nc!=0);
|
||||
@@ -63,6 +62,9 @@ void Node::write(DataOutputStream* out){
|
||||
{
|
||||
((ive::AnimationPathCallback*)(nc))->write(out);
|
||||
}
|
||||
|
||||
// Write NodeMask
|
||||
out->writeUInt(getNodeMask());
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +102,8 @@ void Node::read(DataInputStream* in){
|
||||
((ive::AnimationPathCallback*)(nc))->read(in);
|
||||
setUpdateCallback(nc);
|
||||
}
|
||||
// Read NodeMask
|
||||
setNodeMask(in->readUInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Node::read(): Expected Node identification");
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace ive {
|
||||
#define IVELIGHTPOINTNODE 0x00100007
|
||||
#define IVEMULTISWITCH 0x00100008
|
||||
|
||||
#define IVEVISIBILITYGROUP 0x00100009
|
||||
|
||||
class ReadWrite{
|
||||
|
||||
|
||||
58
src/osgPlugins/ive/VisibilityGroup.cpp
Normal file
58
src/osgPlugins/ive/VisibilityGroup.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: VisibilityGroup.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgSim::VisibilityGroup in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerator.exe
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 27.11.2003
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "VisibilityGroup.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void VisibilityGroup::write(DataOutputStream* out){
|
||||
// Write VisibilityGroup's identification.
|
||||
out->writeInt(IVEVISIBILITYGROUP);
|
||||
// If the osgSim class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("VisibilityGroup::write(): Could not cast this osgSim::VisibilityGroup to an osg::Group.");
|
||||
|
||||
// Write VisibilityGroup's properties.
|
||||
out->writeNode(getVisibilityVolume());
|
||||
out->writeUInt(getVolumeIntersectionMask());
|
||||
out->writeFloat(getSegmentLength());
|
||||
}
|
||||
|
||||
void VisibilityGroup::read(DataInputStream* in){
|
||||
// Peek on VisibilityGroup's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEVISIBILITYGROUP){
|
||||
// Read VisibilityGroup's identification.
|
||||
id = in->readInt();
|
||||
// If the osgSim class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("VisibilityGroup::read(): Could not cast this osgSim::VisibilityGroup to an osg::Group.");
|
||||
// Read VisibilityGroup's properties
|
||||
setVisibilityVolume(in->readNode());
|
||||
setVolumeIntersectionMask(in->readUInt());
|
||||
setSegmentLength(in->readFloat());
|
||||
}
|
||||
else{
|
||||
throw Exception("VisibilityGroup::read(): Expected VisibilityGroup identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/VisibilityGroup.h
Normal file
15
src/osgPlugins/ive/VisibilityGroup.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_VISIBILITYGROUP
|
||||
#define IVE_VISIBILITYGROUP 1
|
||||
|
||||
#include <osgSim/VisibilityGroup>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class VisibilityGroup : public osgSim::VisibilityGroup, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user