From Ali Botorabi, adding of osg::Depth support in .ive format.

This commit is contained in:
Robert Osfield
2005-12-19 14:48:04 +00:00
parent 7b31c2e6ac
commit 523f608ba6
7 changed files with 151 additions and 58 deletions

View File

@@ -176,6 +176,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\DataOutputStream.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\Depth.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\DirectionalSector.cpp
# End Source File
# Begin Source File
@@ -524,6 +528,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\DataTypeSize.h
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\Depth.h
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\DirectionalSector.h
# End Source File
# Begin Source File

View File

@@ -19,6 +19,7 @@
#include "StateSet.h"
#include "AlphaFunc.h"
#include "BlendFunc.h"
#include "Depth.h"
#include "Material.h"
#include "CullFace.h"
#include "ClipPlane.h"
@@ -818,6 +819,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
attribute = new osg::BlendFunc();
((ive::BlendFunc*)(attribute))->read(this);
}
else if(attributeID == IVEDEPTH){
attribute = new osg::Depth();
((ive::Depth*)(attribute))->read(this);
}
else if(attributeID == IVEVIEWPORT){
attribute = new osg::Viewport();
((ive::Viewport*)(attribute))->read(this);

View File

@@ -22,6 +22,7 @@
#include "BlendFunc.h"
#include "Material.h"
#include "CullFace.h"
#include "Depth.h"
#include "ClipPlane.h"
#include "PolygonOffset.h"
#include "PolygonMode.h"
@@ -642,6 +643,9 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
else if(dynamic_cast<const osg::BlendFunc*>(attribute)){
((ive::BlendFunc*)(attribute))->write(this);
}
else if(dynamic_cast<const osg::Depth*>(attribute)){
((ive::Depth*)(attribute))->write(this);
}
else if(dynamic_cast<const osg::Viewport*>(attribute)){
((ive::Viewport*)(attribute))->write(this);
}

View File

@@ -0,0 +1,59 @@
/**********************************************************************
*
* FILE: Depth.cpp
*
* DESCRIPTION: Read/Write osg::Depth in binary format to disk.
*
* CREATED BY: Botorabi AT gmx DOT net
*
* HISTORY: Created 14.12.2005
*
**********************************************************************/
#include "Exception.h"
#include "Depth.h"
#include "Object.h"
using namespace ive;
void Depth::write(DataOutputStream* out){
// Write Depth's identification.
out->writeInt(IVEDEPTH);
// If the osg class is inherited by any other class we should also write this to file.
osg::Object* obj = dynamic_cast<osg::Object*>(this);
if(obj){
((ive::Object*)(obj))->write(out);
}
else
throw Exception("Depth::write(): Could not cast this osg::Depth to an osg::Object.");
// Write Depth's properties.
out->writeInt(getFunction());
out->writeBool(getWriteMask());
out->writeFloat(getZNear());
out->writeFloat(getZFar());
}
void Depth::read(DataInputStream* in){
// Peek on Depth's identification.
int id = in->peekInt();
if(id == IVEDEPTH){
// Read Depth's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Object* obj = dynamic_cast<osg::Object*>(this);
if(obj){
((ive::Object*)(obj))->read(in);
}
else
throw Exception("Depth::read(): Could not cast this osg::Depth to an osg::Object.");
// Read CullFace's properties
setFunction((osg::Depth::Function)in->readInt());
setWriteMask(in->readBool());
setZNear(in->readFloat());
setZFar(in->readFloat());
}
else{
throw Exception("Depth::read(): Expected Depth identification.");
}
}

View File

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

View File

@@ -22,6 +22,7 @@ CXXFILES =\
CullFace.cpp\
DataInputStream.cpp\
DataOutputStream.cpp\
Depth.cpp\
DirectionalSector.cpp\
DOFTransform.cpp\
Drawable.cpp\

View File

@@ -2,7 +2,7 @@
#define IVE_READWRITE 1
#include "DataInputStream.h"
#include "DataOutputStream.h"
#include "DataOutputStream.h"
namespace ive {
@@ -43,77 +43,78 @@ namespace ive {
#define IVECLUSTERCULLINGCALLBACK 0x00000052
// State attributes.
#define IVESTATEATTRIBUTE 0x00000100
#define IVEALPHAFUNC 0x00000101
#define IVEBLENDFUNC 0x00000102
#define IVEMATERIAL 0x00000110
#define IVETEXTURE 0x00000120
#define IVETEXTURE1D 0x00000121
#define IVETEXTURE2D 0x00000122
#define IVETEXTURE3D 0x00000123
#define IVETEXTURECUBEMAP 0x00000124
#define IVETEXENV 0x00000125
#define IVETEXENVCOMBINE 0x00000126
#define IVETEXGEN 0x00000127
#define IVECULLFACE 0x00000128
#define IVEPOLYGONOFFSET 0x00000129
#define IVESHADEMODEL 0x0000012A
#define IVEPOINT 0x0000012B
#define IVETEXMAT 0x0000012C
#define IVELINEWIDTH 0x0000012D
#define IVEFRAGMENTPROGRAM 0x0000012E
#define IVEVERTEXPROGRAM 0x0000012F
#define IVELIGHTMODEL 0x00001121
#define IVECLIPPLANE 0x00001122
#define IVEFRONTFACE 0x00001123
#define IVEPROGRAM 0x00001124
#define IVESHADER 0x00001125
#define IVEUNIFORM 0x00001126
#define IVEVIEWPORT 0x00001127
#define IVESCISSOR 0x00001128
#define IVEPOLYGONMODE 0x00001129
#define IVESTATEATTRIBUTE 0x00000100
#define IVEALPHAFUNC 0x00000101
#define IVEBLENDFUNC 0x00000102
#define IVEMATERIAL 0x00000110
#define IVETEXTURE 0x00000120
#define IVETEXTURE1D 0x00000121
#define IVETEXTURE2D 0x00000122
#define IVETEXTURE3D 0x00000123
#define IVETEXTURECUBEMAP 0x00000124
#define IVETEXENV 0x00000125
#define IVETEXENVCOMBINE 0x00000126
#define IVETEXGEN 0x00000127
#define IVECULLFACE 0x00000128
#define IVEPOLYGONOFFSET 0x00000129
#define IVESHADEMODEL 0x0000012A
#define IVEPOINT 0x0000012B
#define IVETEXMAT 0x0000012C
#define IVELINEWIDTH 0x0000012D
#define IVEFRAGMENTPROGRAM 0x0000012E
#define IVEVERTEXPROGRAM 0x0000012F
#define IVEDEPTH 0x00000130
#define IVELIGHTMODEL 0x00001121
#define IVECLIPPLANE 0x00001122
#define IVEFRONTFACE 0x00001123
#define IVEPROGRAM 0x00001124
#define IVESHADER 0x00001125
#define IVEUNIFORM 0x00001126
#define IVEVIEWPORT 0x00001127
#define IVESCISSOR 0x00001128
#define IVEPOLYGONMODE 0x00001129
// Drawables
#define IVEDRAWABLE 0x00001000
#define IVEGEOMETRY 0x00001001
#define IVESHAPEDRAWABLE 0x00001002
#define IVEDRAWABLE 0x00001000
#define IVEGEOMETRY 0x00001001
#define IVESHAPEDRAWABLE 0x00001002
// Shapes
#define IVESHAPE 0x00002000
#define IVESPHERE 0x00002001
#define IVEBOX 0x00002002
#define IVECONE 0x00002004
#define IVECYLINDER 0x00002005
#define IVECAPSULE 0x00002006
#define IVEHEIGHTFIELD 0x00002007
#define IVESHAPE 0x00002000
#define IVESPHERE 0x00002001
#define IVEBOX 0x00002002
#define IVECONE 0x00002004
#define IVECYLINDER 0x00002005
#define IVECAPSULE 0x00002006
#define IVEHEIGHTFIELD 0x00002007
// Primitive set
#define IVEPRIMITIVESET 0x00010000
#define IVEDRAWARRAYS 0x00010001
#define IVEDRAWARRAYLENGTHS 0x00010002
#define IVEDRAWELEMENTSUSHORT 0x00010003
#define IVEDRAWELEMENTSUINT 0x00010004
#define IVEDRAWELEMENTSUBYTE 0x00010005
#define IVEPRIMITIVESET 0x00010000
#define IVEDRAWARRAYS 0x00010001
#define IVEDRAWARRAYLENGTHS 0x00010002
#define IVEDRAWELEMENTSUSHORT 0x00010003
#define IVEDRAWELEMENTSUINT 0x00010004
#define IVEDRAWELEMENTSUBYTE 0x00010005
// osgSim classes
#define IVEBLINKSEQUENCE 0x00100001
#define IVEAZIMELEVATIONSECTOR 0x00100002
#define IVEELEVATIONSECTOR 0x00100003
#define IVEAZIMSECTOR 0x00100004
#define IVECONESECTOR 0x00100005
#define IVELIGHTPOINT 0x00100006
#define IVELIGHTPOINTNODE 0x00100007
#define IVEMULTISWITCH 0x00100008
#define IVEBLINKSEQUENCE 0x00100001
#define IVEAZIMELEVATIONSECTOR 0x00100002
#define IVEELEVATIONSECTOR 0x00100003
#define IVEAZIMSECTOR 0x00100004
#define IVECONESECTOR 0x00100005
#define IVELIGHTPOINT 0x00100006
#define IVELIGHTPOINTNODE 0x00100007
#define IVEMULTISWITCH 0x00100008
#define IVEVISIBILITYGROUP 0x00100009
#define IVEDIRECTIONALSECTOR 0x0010000A
#define IVEVISIBILITYGROUP 0x00100009
#define IVEDIRECTIONALSECTOR 0x0010000A
// osgFX classes
#define IVEMULTITEXTURECONTROL 0x01000001
#define IVEMULTITEXTURECONTROL 0x01000001
//osgText classes
#define IVETEXT 0x10000001
#define IVETEXT 0x10000001
class ReadWrite{