Added ive reader/writer - from Rune Schmidt Jensen/Michael Gronager
This commit is contained in:
@@ -45,7 +45,8 @@ PLUGIN_DIRS = \
|
||||
tga\
|
||||
tgz\
|
||||
txp\
|
||||
zip
|
||||
zip\
|
||||
ive
|
||||
|
||||
# 3dc\
|
||||
|
||||
|
||||
@@ -1545,6 +1545,24 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin ive"=.\osgPlugins\ive\ive.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgDB
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin osgParticle"=.\osgPlugins\osgParticle\dot_osgParticle.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
||||
389
VisualStudio/osgPlugins/ive/ive.dsp
Executable file
389
VisualStudio/osgPlugins/ive/ive.dsp
Executable file
@@ -0,0 +1,389 @@
|
||||
# Microsoft Developer Studio Project File - Name="osgPlugin ive" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=osgPlugin ive - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ive.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ive.mak" CFG="osgPlugin ive - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "osgPlugin ive - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin ive - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "osgPlugin ive - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../../../lib"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_ive.dll" /libpath:"../../../lib"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin ive - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../../../lib"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_ived.dll" /pdbtype:sept /libpath:"../../../lib"
|
||||
# SUBTRACT LINK32 /pdb:none /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "osgPlugin ive - Win32 Release"
|
||||
# Name "osgPlugin ive - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\AnimationPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\AnimationPathCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Billboard.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\BlendFunc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\CullFace.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DataInputStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DataOutputStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Drawable.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawArrayLengths.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawArrays.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawElementsUShort.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Exception.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Geode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Geometry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Group.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Image.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Light.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LightSource.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LOD.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Material.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\MatrixTransform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Node.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Object.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\PositionAttitudeTransform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\PrimitiveSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Sequence.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\StateSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexEnv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexEnvCombine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexGen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Texture.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Texture2D.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TextureCubeMap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Transform.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\AnimationPath
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\AnimationPathCallback
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Billboard
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\BlendFunc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\CullFace
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DataInputStream
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DataOutputStream
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DataTypeSize
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Drawable
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawArrayLengths
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawArrays
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\DrawElementsUShort
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Exception
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Geode
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Geometry
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Group
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Image
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Light
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LightSource
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\LOD
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Material
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\MatrixTransform
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Node
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Object
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\PositionAttitudeTransform
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\PrimitiveSet
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ReadWrite
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Sequence
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\StateSet
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexEnv
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexEnvCombine
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexGen
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Texture
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Texture2D
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TextureCubeMap
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Transform
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -58,6 +58,9 @@ int main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
osg::Timer timer;
|
||||
osg::Timer_t start_tick = timer.tick();
|
||||
|
||||
// read the scene from the list of file specified commandline args.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
|
||||
@@ -68,11 +71,15 @@ int main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
osg::Timer_t end_tick = timer.tick();
|
||||
|
||||
cout << "Time to load = "<<timer.delta_s(start_tick,end_tick);
|
||||
|
||||
// optimize the scene graph, remove rendundent nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
|
||||
|
||||
76
src/osgPlugins/ive/AnimationPath.cpp
Normal file
76
src/osgPlugins/ive/AnimationPath.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: AnimationPath.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::AnimationPath in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 25.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "AnimationPath.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void AnimationPath::write(DataOutputStream* out){
|
||||
// Write AnimationPath's identification.
|
||||
out->writeInt(IVEANIMATIONPATH);
|
||||
// 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("AnimationPath::write(): Could not cast this osg::AnimationPath to an osg::Object.");
|
||||
// Write AnimationPath's properties.
|
||||
|
||||
// Write loopmode
|
||||
out->writeInt(getLoopMode());
|
||||
// Write control points
|
||||
AnimationPath::TimeControlPointMap tcpm = getTimeControlPointMap();
|
||||
out->writeInt(tcpm.size());
|
||||
for(AnimationPath::TimeControlPointMap::iterator itr=tcpm.begin(); itr!=tcpm.end(); ++itr){
|
||||
out->writeFloat(itr->first);
|
||||
out->writeVec3(itr->second._position);
|
||||
out->writeQuat(itr->second._rotation);
|
||||
out->writeVec3(itr->second._scale);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPath::read(DataInputStream* in){
|
||||
// Peek on AnimationPath's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEANIMATIONPATH){
|
||||
// Read AnimationPath'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("AnimationPath::read(): Could not cast this osg::AnimationPath to an osg::Object.");
|
||||
// Read AnimationPath's properties
|
||||
|
||||
// Read loopmode
|
||||
setLoopMode((osg::AnimationPath::LoopMode)in->readInt());
|
||||
// Read control points
|
||||
int size = in->readInt();
|
||||
for(int i=0;i<size;i++){
|
||||
float time = in->readFloat();
|
||||
osg::Vec3 pos = in->readVec3();
|
||||
osg::Quat rot = in->readQuat();
|
||||
osg::Vec3 scale = in->readVec3();
|
||||
insert(time, osg::AnimationPath::ControlPoint(pos, rot, scale));
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("AnimationPath::read(): Expected AnimationPath identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/AnimationPath.h
Normal file
15
src/osgPlugins/ive/AnimationPath.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ANIMATIONPATH
|
||||
#define IVE_ANIMATIONPATH 1
|
||||
|
||||
#include <osg/AnimationPath>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT AnimationPath : public osg::AnimationPath, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
73
src/osgPlugins/ive/AnimationPathCallback.cpp
Normal file
73
src/osgPlugins/ive/AnimationPathCallback.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: AnimationPathCallback.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::AnimationPathCallback in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 25.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "AnimationPathCallback.h"
|
||||
#include "AnimationPath.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void AnimationPathCallback::write(DataOutputStream* out){
|
||||
// Write AnimationPathCallback's identification.
|
||||
out->writeInt(IVEANIMATIONPATHCALLBACK);
|
||||
// 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("AnimationPathCallback::write(): Could not cast this osg::AnimationPathCallback to an osg::Object.");
|
||||
// Write AnimationPathCallback's properties.
|
||||
|
||||
out->writeDouble(_timeOffset);
|
||||
out->writeDouble(_timeMultiplier);
|
||||
out->writeDouble(_firstTime);
|
||||
out->writeDouble(_animationTime);
|
||||
// Write animationpath if any
|
||||
out->writeInt((int)getAnimationPath());
|
||||
if(getAnimationPath()){
|
||||
((ive::AnimationPath*)(getAnimationPath()))->write(out);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPathCallback::read(DataInputStream* in){
|
||||
// Peek on AnimationPathCallback's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEANIMATIONPATHCALLBACK){
|
||||
// Read AnimationPathCallback'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("AnimationPathCallback::read(): Could not cast this osg::AnimationPathCallback to an osg::Object.");
|
||||
// Read AnimationPathCallback's properties
|
||||
_timeOffset = in->readDouble();
|
||||
_timeMultiplier = in->readDouble();
|
||||
_firstTime = in->readDouble();
|
||||
_animationTime = in->readDouble();
|
||||
// Read animationpath if any
|
||||
if(in->readInt()){
|
||||
osg::AnimationPath* path = new osg::AnimationPath();
|
||||
((ive::AnimationPath*)(path))->read(in);
|
||||
setAnimationPath(path);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("AnimationPathCallback::read(): Expected AnimationPathCallback identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/AnimationPathCallback.h
Normal file
15
src/osgPlugins/ive/AnimationPathCallback.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ANIMATIONPATHCALLBACK
|
||||
#define IVE_ANIMATIONPATHCALLBACK 1
|
||||
|
||||
#include <osg/AnimationPath>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT AnimationPathCallback : public osg::AnimationPathCallback, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
78
src/osgPlugins/ive/Billboard.cpp
Normal file
78
src/osgPlugins/ive/Billboard.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Billboard.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Billboard in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 24.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Billboard.h"
|
||||
#include "Geode.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Billboard::write(DataOutputStream* out){
|
||||
// Write Billboard's identification.
|
||||
out->writeInt(IVEBILLBOARD);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Geode* geode = dynamic_cast<osg::Geode*>(this);
|
||||
if(geode){
|
||||
((ive::Geode*)(geode))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Billboard::write(): Could not cast this osg::Billboard to an osg::Geode.");
|
||||
// Write Billboard's properties.
|
||||
|
||||
// Write mode
|
||||
out->writeInt(getMode());
|
||||
// Write axis
|
||||
out->writeVec3(getAxis());
|
||||
// Write normal
|
||||
out->writeVec3(getNormal());
|
||||
// Write positions
|
||||
int size = _positionList.size();
|
||||
out->writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
out->writeVec3(getPos(i));
|
||||
}
|
||||
}
|
||||
|
||||
void Billboard::read(DataInputStream* in){
|
||||
// Peek on Billboard's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEBILLBOARD){
|
||||
// Read Billboard's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Geode* geode = dynamic_cast<osg::Geode*>(this);
|
||||
if(geode){
|
||||
((ive::Geode*)(geode))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Billboard::read(): Could not cast this osg::Billboard to an osg::Geode.");
|
||||
// Read Billboard's properties
|
||||
|
||||
// Read mode
|
||||
setMode((osg::Billboard::Mode)in->readInt());
|
||||
// Read axis
|
||||
setAxis(in->readVec3());
|
||||
// Read normal
|
||||
setNormal(in->readVec3());
|
||||
// Read positions
|
||||
int size = in->readInt();
|
||||
for(int i=0;i<size;i++){
|
||||
setPos(i,in->readVec3());
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("Billboard::read(): Expected Billboard identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Billboard.h
Normal file
15
src/osgPlugins/ive/Billboard.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_BILLBOARD
|
||||
#define IVE_BILLBOARD 1
|
||||
|
||||
#include <osg/Billboard>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Billboard : public osg::Billboard, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
63
src/osgPlugins/ive/BlendFunc.cpp
Normal file
63
src/osgPlugins/ive/BlendFunc.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: BlendFunc.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::BlendFunc in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void BlendFunc::write(DataOutputStream* out){
|
||||
// Write BlendFunc's identification.
|
||||
out->writeInt(IVEBLENDFUNC);
|
||||
// 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("BlendFunc::write(): Could not cast this osg::BlendFunc to an osg::Object.");
|
||||
// Write BlendFunc's properties.
|
||||
|
||||
// Write source
|
||||
out->writeInt(getSource());
|
||||
// Write destination
|
||||
out->writeInt(getDestination());
|
||||
}
|
||||
|
||||
void BlendFunc::read(DataInputStream* in){
|
||||
// Peek on BlendFunc's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEBLENDFUNC){
|
||||
// Read BlendFunc'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("BlendFunc::read(): Could not cast this osg::BlendFunc to an osg::Object.");
|
||||
// Read BlendFunc's properties
|
||||
|
||||
// Read source
|
||||
setSource((GLenum)in->readInt());
|
||||
// Read destination
|
||||
setDestination((GLenum)in->readInt());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("BlendFunc::read(): Expected BlendFunc identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/BlendFunc.h
Normal file
15
src/osgPlugins/ive/BlendFunc.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_BLENDFUNC
|
||||
#define IVE_BLENDFUNC 1
|
||||
|
||||
#include <osg/BlendFunc>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT BlendFunc : public osg::BlendFunc, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
54
src/osgPlugins/ive/CullFace.cpp
Normal file
54
src/osgPlugins/ive/CullFace.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: CullFace.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::CullFace in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerator
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 27.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "CullFace.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void CullFace::write(DataOutputStream* out){
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVECULLFACE);
|
||||
// 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("CullFace::write(): Could not cast this osg::CullFace to an osg::Object.");
|
||||
// Write CullFace's properties.
|
||||
out->writeInt(getMode());
|
||||
}
|
||||
|
||||
void CullFace::read(DataInputStream* in){
|
||||
// Peek on CullFace's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECULLFACE){
|
||||
// Read CullFace'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("CullFace::read(): Could not cast this osg::CullFace to an osg::Object.");
|
||||
// Read CullFace's properties
|
||||
setMode((osg::CullFace::Mode)in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("CullFace::read(): Expected CullFace identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/CullFace.h
Normal file
15
src/osgPlugins/ive/CullFace.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_CULLFACE
|
||||
#define IVE_CULLFACE 1
|
||||
|
||||
#include <osg/CullFace>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT CullFace : public osg::CullFace, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
326
src/osgPlugins/ive/DataInputStream.cpp
Normal file
326
src/osgPlugins/ive/DataInputStream.cpp
Normal file
@@ -0,0 +1,326 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: DataInputStream.cpp
|
||||
*
|
||||
* DESCRIPTION: Implements methods to read simpel datatypes from an
|
||||
* input stream.
|
||||
*
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 11.03.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "DataInputStream.h"
|
||||
#include "StateSet.h"
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
using namespace ive;
|
||||
using namespace std;
|
||||
|
||||
DataInputStream::DataInputStream(std::istream* istream){
|
||||
_istream = istream;
|
||||
_peeking = false;
|
||||
_peekValue = 0;
|
||||
|
||||
if(!istream){
|
||||
throw Exception("DataInputStream::DataInputStream(): null pointer exception in argument.");
|
||||
}
|
||||
|
||||
_version = readInt();
|
||||
|
||||
// Are we trying to open a binary .ive file which version are newer than this library.
|
||||
if(_version>VERSION){
|
||||
throw Exception("DataInputStream::DataInputStream(): The version found in the file is newer than this library can handle.");
|
||||
}
|
||||
}
|
||||
|
||||
DataInputStream::~DataInputStream(){}
|
||||
|
||||
bool DataInputStream::readBool(){
|
||||
bool b;
|
||||
_istream->read((char*)&b, BOOLSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readBool(): Failed to read boolean value.");
|
||||
return b;
|
||||
}
|
||||
|
||||
char DataInputStream::readChar(){
|
||||
char c;
|
||||
_istream->read(&c, CHARSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readChar(): Failed to read char value.");
|
||||
return c;
|
||||
}
|
||||
|
||||
unsigned short DataInputStream::readUShort(){
|
||||
unsigned short s;
|
||||
_istream->read((char*)&s, SHORTSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUShort(): Failed to read unsigned short value.");
|
||||
return s;
|
||||
}
|
||||
|
||||
int DataInputStream::readInt(){
|
||||
if(_peeking){
|
||||
_peeking = false;
|
||||
return _peekValue;
|
||||
}
|
||||
int i;
|
||||
_istream->read((char*)&i, INTSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readInt(): Failed to read int value.");
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an integer from the stream, but
|
||||
* save it such that the next readInt call will
|
||||
* return the same integer.
|
||||
*/
|
||||
int DataInputStream::peekInt(){
|
||||
if(_peeking){
|
||||
return _peekValue;
|
||||
}
|
||||
_peekValue = readInt();
|
||||
_peeking = true;
|
||||
return _peekValue;
|
||||
}
|
||||
|
||||
float DataInputStream::readFloat(){
|
||||
float f;
|
||||
_istream->read((char*)&f, FLOATSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readFloat(): Failed to read float value.");
|
||||
return f;
|
||||
}
|
||||
|
||||
long DataInputStream::readLong(){
|
||||
long l;
|
||||
_istream->read((char*)&l, LONGSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readLong(): Failed to read long value.");
|
||||
return l;
|
||||
}
|
||||
|
||||
double DataInputStream::readDouble(){
|
||||
double d;
|
||||
_istream->read((char*)&d, DOUBLESIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readDouble(): Failed to read double value.");
|
||||
return d;
|
||||
}
|
||||
|
||||
std::string DataInputStream::readString(){
|
||||
std::string s;
|
||||
int size = readInt();
|
||||
s.resize(size);
|
||||
_istream->read((char*)s.c_str(), size);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readString(): Failed to read string value.");
|
||||
return s;
|
||||
}
|
||||
|
||||
void DataInputStream::readCharArray(char* data, int size){
|
||||
_istream->read(data, size);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readCharArray(): Failed to read char value.");
|
||||
}
|
||||
|
||||
osg::Vec2 DataInputStream::readVec2(){
|
||||
osg::Vec2 v;
|
||||
v.set(readFloat(), readFloat());
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Vec3 DataInputStream::readVec3(){
|
||||
osg::Vec3 v;
|
||||
v.set(readFloat(),readFloat(),readFloat());
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Vec4 DataInputStream::readVec4(){
|
||||
osg::Vec4 v;
|
||||
v.set(readFloat(), readFloat(), readFloat(), readFloat());
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::UByte4 DataInputStream::readUByte4(){
|
||||
osg::UByte4 v;
|
||||
v.set(readChar(), readChar(), readChar(), readChar());
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Quat DataInputStream::readQuat(){
|
||||
osg::Quat q;
|
||||
q.set(readFloat(), readFloat(), readFloat(), readFloat());
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
osg::Image* DataInputStream::readImage(std::string filename){
|
||||
// If image is already read and in list
|
||||
// then just return pointer to this.
|
||||
for(ImageList::iterator mitr=_imageList.begin();
|
||||
mitr!=_imageList.end(); ++mitr){
|
||||
if(mitr->first.compare(filename) == 0){
|
||||
return mitr->second.get();
|
||||
}
|
||||
}
|
||||
// Image is not in list.
|
||||
// Read it from disk,
|
||||
osg::Image* image = osgDB::readImageFile(filename.c_str());
|
||||
// add it to the imageList,
|
||||
_imageList.push_back(ImagePair(filename, image));
|
||||
// and return image pointer.
|
||||
return image;
|
||||
}
|
||||
|
||||
osg::StateSet* DataInputStream::readStateSet(){
|
||||
// Read statesets unique ID.
|
||||
int id = readInt();
|
||||
// See if stateset is already in the list.
|
||||
for(StateSetList::iterator itr=_statesetList.begin();
|
||||
itr!=_statesetList.end(); ++itr){
|
||||
if(itr->first == id){
|
||||
return itr->second.get();
|
||||
}
|
||||
}
|
||||
// StateSet is not in list.
|
||||
// Create a new stateset,
|
||||
osg::StateSet* stateset = new osg::StateSet();
|
||||
// read its properties from stream
|
||||
((ive::StateSet*)(stateset))->read(this);
|
||||
// and add it to the stateset list,
|
||||
_statesetList.push_back(StateSetPair(id, stateset));
|
||||
return stateset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
osg::Geometry::AttributeBinding DataInputStream::readBinding(){
|
||||
char c = readChar();
|
||||
switch((int)c){
|
||||
case 0: return osg::Geometry::BIND_OFF;
|
||||
case 1: return osg::Geometry::BIND_OVERALL;
|
||||
case 2: return osg::Geometry::BIND_PER_PRIMITIVE;
|
||||
case 3: return osg::Geometry::BIND_PER_PRIMITIVE_SET;
|
||||
case 4: return osg::Geometry::BIND_PER_VERTEX;
|
||||
default: throw Exception("Unknown binding type in DataInputStream::readBinding()");
|
||||
}
|
||||
}
|
||||
|
||||
osg::Array* DataInputStream::readArray(){
|
||||
char c = readChar();
|
||||
switch((int)c){
|
||||
case 0: return readIntArray();
|
||||
case 1: return readUByteArray();
|
||||
case 2: return readUShortArray();
|
||||
case 3: return readUIntArray();
|
||||
case 4: return readUByte4Array();
|
||||
case 5: return readFloatArray();
|
||||
case 6: return readVec2Array();
|
||||
case 7: return readVec3Array();
|
||||
case 8: return readVec4Array();
|
||||
default: throw Exception("Unknown array type in DataInputStream::readArray()");
|
||||
}
|
||||
}
|
||||
|
||||
osg::IntArray* DataInputStream::readIntArray(){
|
||||
int size = readInt();
|
||||
osg::IntArray* a = new osg::IntArray();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back(readInt());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::UByteArray* DataInputStream::readUByteArray(){
|
||||
int size = readInt();
|
||||
osg::UByteArray* a = new osg::UByteArray();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back(readChar());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::UShortArray* DataInputStream::readUShortArray(){
|
||||
int size = readInt();
|
||||
osg::UShortArray* a = new osg::UShortArray();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back(readUShort());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::UIntArray* DataInputStream::readUIntArray(){
|
||||
int size = readInt();
|
||||
osg::UIntArray* a = new osg::UIntArray();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back((unsigned int)readInt());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::UByte4Array* DataInputStream::readUByte4Array(){
|
||||
int size = readInt();
|
||||
osg::UByte4Array* a = new osg::UByte4Array();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back(readUByte4());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::FloatArray* DataInputStream::readFloatArray(){
|
||||
int size = readInt();
|
||||
osg::FloatArray* a = new osg::FloatArray();
|
||||
a->reserve(size);
|
||||
for(int i =0; i<size;i++){
|
||||
a->push_back(readFloat());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Vec2Array* DataInputStream::readVec2Array(){
|
||||
int size = readInt();
|
||||
osg::Vec2Array* a = new osg::Vec2Array(size);
|
||||
for(int i = 0; i < size; i++){
|
||||
(*a)[i] = (readVec2());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Vec3Array* DataInputStream::readVec3Array(){
|
||||
int size = readInt();
|
||||
osg::Vec3Array* a = new osg::Vec3Array(size);
|
||||
for(int i = 0; i < size; i++){
|
||||
(*a)[i] = readVec3();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Vec4Array* DataInputStream::readVec4Array(){
|
||||
int size = readInt();
|
||||
osg::Vec4Array* a = new osg::Vec4Array(size);
|
||||
for(int i = 0; i < size; i++){
|
||||
(*a)[i] = (readVec4());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Matrix DataInputStream::readMatrix(){
|
||||
osg::Matrix mat;
|
||||
float* p = mat.ptr();
|
||||
for(int i=0;i<16;i++){
|
||||
p[i] = readFloat();
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
82
src/osgPlugins/ive/DataInputStream.h
Normal file
82
src/osgPlugins/ive/DataInputStream.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef IVE_DATAINPUTSTREAM
|
||||
#define IVE_DATAINPUTSTREAM 1
|
||||
|
||||
|
||||
#include <iostream> // for ifstream
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Quat>
|
||||
#include <osg/Array>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include "DataTypeSize.h"
|
||||
#include "Export.h"
|
||||
#include "Exception.h"
|
||||
|
||||
|
||||
#include <osg/Image>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace ive{
|
||||
|
||||
class IVE_EXPORT DataInputStream{
|
||||
|
||||
public:
|
||||
DataInputStream(std::istream* istream);
|
||||
~DataInputStream();
|
||||
bool readBool();
|
||||
char readChar();
|
||||
unsigned short readUShort();
|
||||
int readInt();
|
||||
int peekInt();
|
||||
float readFloat();
|
||||
long readLong();
|
||||
double readDouble();
|
||||
std::string readString();
|
||||
void readCharArray(char* data, int size);
|
||||
osg::Vec2 readVec2();
|
||||
osg::Vec3 readVec3();
|
||||
osg::Vec4 readVec4();
|
||||
osg::UByte4 readUByte4();
|
||||
osg::Quat readQuat();
|
||||
osg::Matrix readMatrix();
|
||||
osg::Geometry::AttributeBinding readBinding();
|
||||
osg::Image* readImage(std::string s);
|
||||
osg::StateSet* readStateSet();
|
||||
osg::Array* readArray();
|
||||
osg::IntArray* readIntArray();
|
||||
osg::UByteArray* readUByteArray();
|
||||
osg::UShortArray* readUShortArray();
|
||||
osg::UIntArray* readUIntArray();
|
||||
osg::UByte4Array* readUByte4Array();
|
||||
osg::FloatArray* readFloatArray();
|
||||
osg::Vec2Array* readVec2Array();
|
||||
osg::Vec3Array* readVec3Array();
|
||||
osg::Vec4Array* readVec4Array();
|
||||
|
||||
// Container to map image filenames to their respective images.
|
||||
typedef std::pair<std::string, osg::ref_ptr<osg::Image> > ImagePair;
|
||||
typedef std::vector<ImagePair> ImageList;
|
||||
|
||||
// Container to map stateset id to their respective stateset.
|
||||
typedef std::pair<int, osg::ref_ptr<osg::StateSet> > StateSetPair;
|
||||
typedef std::vector<StateSetPair> StateSetList;
|
||||
|
||||
|
||||
private:
|
||||
std::istream* _istream;
|
||||
int _version;
|
||||
bool _peeking;
|
||||
int _peekValue;
|
||||
ImageList _imageList;
|
||||
StateSetList _statesetList;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // IVE_DATAINPUTSTREAM
|
||||
252
src/osgPlugins/ive/DataOutputStream.cpp
Normal file
252
src/osgPlugins/ive/DataOutputStream.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: DataOutputStream.cpp
|
||||
*
|
||||
* DESCRIPTION: Implements methods to write simpel datatypes to an
|
||||
* output stream.
|
||||
*
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 11.03.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "DataOutputStream.h"
|
||||
#include "Exception.h"
|
||||
#include "StateSet.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
DataOutputStream::DataOutputStream(std::ostream * ostream){
|
||||
|
||||
_includeImageData= true;
|
||||
_ostream = ostream;
|
||||
if(!_ostream)
|
||||
throw Exception("DataOutputStream::DataOutputStream(): null pointer exception in argument.");
|
||||
writeInt(VERSION);
|
||||
}
|
||||
|
||||
DataOutputStream::~DataOutputStream(){}
|
||||
|
||||
void DataOutputStream::writeBool(bool b){
|
||||
_ostream->write((char*)&b, BOOLSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeChar(char c){
|
||||
_ostream->write(&c, CHARSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShort(unsigned short s){
|
||||
_ostream->write((char*)&s, SHORTSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeInt(int i){
|
||||
_ostream->write((char*)&i, INTSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloat(float f){
|
||||
_ostream->write((char*)&f, FLOATSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeLong(long l){
|
||||
_ostream->write((char*)&l, LONGSIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeDouble(double d){
|
||||
_ostream->write((char*)&d, DOUBLESIZE);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeString(std::string s){
|
||||
writeInt(s.size());
|
||||
_ostream->write(s.c_str(), s.size());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeCharArray(char* data, int size){
|
||||
_ostream->write(data, size);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2(osg::Vec2 v){
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.x());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec3(osg::Vec3 v){
|
||||
writeFloat(v.z());
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.x());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec4(osg::Vec4 v){
|
||||
writeFloat(v.w());
|
||||
writeFloat(v.z());
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.x());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByte4(osg::UByte4 v){
|
||||
writeChar(v.a());
|
||||
writeChar(v.b());
|
||||
writeChar(v.g());
|
||||
writeChar(v.r());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeQuat(osg::Quat q){
|
||||
writeFloat(q.w());
|
||||
writeFloat(q.z());
|
||||
writeFloat(q.y());
|
||||
writeFloat(q.x());
|
||||
}
|
||||
|
||||
void DataOutputStream::writeStateSet(osg::StateSet* stateset){
|
||||
// If stateset is already in list we do not write it again.
|
||||
// We just writes its unique ID.
|
||||
for(StateSetList::iterator itr=_statesetList.begin();
|
||||
itr!=_statesetList.end(); ++itr){
|
||||
if((*itr) == (int)stateset){
|
||||
writeInt((*itr));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// StateSet is not in list.
|
||||
// We write its unique ID,
|
||||
writeInt((int)stateset);
|
||||
// add it to the stateset list,
|
||||
_statesetList.push_back((int)stateset);
|
||||
// and write it to stream.
|
||||
((ive::StateSet*)(stateset))->write(this);
|
||||
}
|
||||
|
||||
void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
|
||||
switch(b){
|
||||
case osg::Geometry::BIND_OFF: writeChar((char) 0); break;
|
||||
case osg::Geometry::BIND_OVERALL: writeChar((char) 1); break;
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE: writeChar((char) 2); break;
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break;
|
||||
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
|
||||
default: throw Exception("Unknown binding in DataOutputStream::writeBinding()");
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeArray(osg::Array* a){
|
||||
switch(a->getType()){
|
||||
case osg::Array::IntArrayType:
|
||||
writeChar((char)0);
|
||||
writeIntArray(static_cast<osg::IntArray*>(a));
|
||||
break;
|
||||
case osg::Array::UByteArrayType:
|
||||
writeChar((char)1);
|
||||
writeUByteArray(static_cast<osg::UByteArray*>(a));
|
||||
break;
|
||||
case osg::Array::UShortArrayType:
|
||||
writeChar((char)2);
|
||||
writeUShortArray(static_cast<osg::UShortArray*>(a));
|
||||
break;
|
||||
case osg::Array::UIntArrayType:
|
||||
writeChar((char)3);
|
||||
writeUIntArray(static_cast<osg::UIntArray*>(a));
|
||||
break;
|
||||
case osg::Array::UByte4ArrayType:
|
||||
writeChar((char)4);
|
||||
writeUByte4Array(static_cast<osg::UByte4Array*>(a));
|
||||
break;
|
||||
case osg::Array::FloatArrayType:
|
||||
writeChar((char)5);
|
||||
writeFloatArray(static_cast<osg::FloatArray*>(a));
|
||||
break;
|
||||
case osg::Array::Vec2ArrayType:
|
||||
writeChar((char)6);
|
||||
writeVec2Array(static_cast<osg::Vec2Array*>(a));
|
||||
break;
|
||||
case osg::Array::Vec3ArrayType:
|
||||
writeChar((char)7);
|
||||
writeVec3Array(static_cast<osg::Vec3Array*>(a));
|
||||
break;
|
||||
case osg::Array::Vec4ArrayType:
|
||||
writeChar((char)8);
|
||||
writeVec4Array(static_cast<osg::Vec4Array*>(a));
|
||||
break;
|
||||
default: throw Exception("Unknown array type in DataOutputStream::writeArray()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataOutputStream::writeIntArray(osg::IntArray* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt(a->index(i));
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByteArray(osg::UByteArray* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeChar((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShortArray(osg::UShortArray* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeUShort((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUIntArray(osg::UIntArray* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByte4Array(osg::UByte4Array* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeUByte4((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloatArray(osg::FloatArray* a){
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeFloat((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataOutputStream::writeVec2Array(osg::Vec2Array* a){
|
||||
int size = a->size();
|
||||
writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec2((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec3Array(osg::Vec3Array* a){
|
||||
int size = a->size();
|
||||
writeInt(size);
|
||||
for(int i = 0; i < size; i++){
|
||||
writeVec3((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec4Array(osg::Vec4Array* a){
|
||||
int size = a->size();
|
||||
writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec4((*a)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataOutputStream::writeMatrix(osg::Matrix mat){
|
||||
float* p = mat.ptr();
|
||||
for(int i=0;i<16;i++){
|
||||
writeFloat(p[i]);
|
||||
}
|
||||
}
|
||||
74
src/osgPlugins/ive/DataOutputStream.h
Normal file
74
src/osgPlugins/ive/DataOutputStream.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef IVE_DATAOUTPUTSTREAM
|
||||
#define IVE_DATAOUTPUTSTREAM 1
|
||||
|
||||
|
||||
|
||||
#include <iostream> // for ofstream
|
||||
#include <string>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Quat>
|
||||
#include <osg/Array>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include "Export.h"
|
||||
#include "DataTypeSize.h"
|
||||
#include "Exception.h"
|
||||
|
||||
#include <osg/StateSet>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace ive {
|
||||
|
||||
class IVE_EXPORT DataOutputStream{
|
||||
|
||||
public:
|
||||
DataOutputStream(std::ostream* ostream);
|
||||
~DataOutputStream();
|
||||
void writeBool(bool b);
|
||||
void writeChar(char c);
|
||||
void writeUShort(unsigned short s);
|
||||
void writeInt(int i);
|
||||
void writeFloat(float f);
|
||||
void writeLong(long l);
|
||||
void writeDouble(double d);
|
||||
void writeString(std::string s);
|
||||
void writeCharArray(char* data, int size);
|
||||
void writeVec2(osg::Vec2 v);
|
||||
void writeVec3(osg::Vec3 v);
|
||||
void writeVec4(osg::Vec4 v);
|
||||
void writeUByte4(osg::UByte4 v);
|
||||
void writeQuat(osg::Quat q);
|
||||
void writeStateSet(osg::StateSet* stateset);
|
||||
void writeBinding(osg::Geometry::AttributeBinding b);
|
||||
void writeArray(osg::Array* a);
|
||||
void writeIntArray(osg::IntArray* a);
|
||||
void writeUByteArray(osg::UByteArray* a);
|
||||
void writeUShortArray(osg::UShortArray* a);
|
||||
void writeUIntArray(osg::UIntArray* a);
|
||||
void writeUByte4Array(osg::UByte4Array* a);
|
||||
void writeFloatArray(osg::FloatArray* a);
|
||||
void writeVec2Array(osg::Vec2Array* a);
|
||||
void writeVec3Array(osg::Vec3Array* a);
|
||||
void writeVec4Array(osg::Vec4Array* a);
|
||||
void writeMatrix(osg::Matrix mat);
|
||||
|
||||
// Set and get include image data in stream
|
||||
void setIncludeImageData(bool b) {_includeImageData=b;};
|
||||
bool getIncludeImageData() {return _includeImageData;};
|
||||
|
||||
private:
|
||||
std::ostream* _ostream;
|
||||
|
||||
// Container to map stateset uniques to their respective stateset.
|
||||
typedef std::vector<int> StateSetList;
|
||||
StateSetList _statesetList;
|
||||
|
||||
bool _includeImageData;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // IVE_DATAOUTPUTSTREAM
|
||||
16
src/osgPlugins/ive/DataTypeSize.h
Normal file
16
src/osgPlugins/ive/DataTypeSize.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef IVE_DATATYPESIZE
|
||||
#define IVE_DATATYPESIZE 1
|
||||
|
||||
|
||||
#define BOOLSIZE 1
|
||||
#define CHARSIZE 1
|
||||
#define SHORTSIZE 2
|
||||
#define INTSIZE 4
|
||||
#define FLOATSIZE 4
|
||||
#define LONGSIZE 4
|
||||
#define DOUBLESIZE 8
|
||||
|
||||
// NOTE: Update anytime the binary format changes
|
||||
#define VERSION 0x01
|
||||
|
||||
#endif
|
||||
70
src/osgPlugins/ive/DrawArrayLengths.cpp
Normal file
70
src/osgPlugins/ive/DrawArrayLengths.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: DrawArrayLengths.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::DrawArrayLengths in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "DrawArrayLengths.h"
|
||||
#include "PrimitiveSet.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void DrawArrayLengths::write(DataOutputStream* out){
|
||||
// Write DrawArrayLengths's identification.
|
||||
out->writeInt(IVEDRAWARRAYLENGTHS);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawArrayLengths::write(): Could not cast this osg::DrawArrayLengths to an osg::PrimitiveSet.");
|
||||
|
||||
// Write DrawArrayLengths's properties.
|
||||
out->writeInt(getFirst());
|
||||
|
||||
// Write array length and its elements.
|
||||
out->writeInt(size());
|
||||
for(unsigned int i=0; i<size(); i++){
|
||||
out->writeInt(((osg::VectorSizei)(*this))[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DrawArrayLengths::read(DataInputStream* in){
|
||||
// Read DrawArrayLengths's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEDRAWARRAYLENGTHS){
|
||||
// Code to read DrawArrayLengths's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawArrayLengths::read(): Could not cast this osg::DrawArrayLengths to an osg::PrimtiveSet.");
|
||||
|
||||
// Read properties
|
||||
setFirst(in->readInt());
|
||||
|
||||
// Read array length and its elements.
|
||||
int size = in->readInt();
|
||||
for(int i=0; i<size; i++){
|
||||
push_back(in->readInt());
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawArrayLengths::read(): Expected DrawArrayLengths identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/DrawArrayLengths.h
Normal file
15
src/osgPlugins/ive/DrawArrayLengths.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_DRAWARRAYLENGTHS
|
||||
#define IVE_DRAWARRAYLENGTHS 1
|
||||
|
||||
#include <osg/PrimitiveSet>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT DrawArrayLengths : public osg::DrawArrayLengths, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
60
src/osgPlugins/ive/DrawArrays.cpp
Normal file
60
src/osgPlugins/ive/DrawArrays.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: DrawArrays.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::DrawArrays in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 18.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "DrawArrays.h"
|
||||
#include "PrimitiveSet.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void DrawArrays::write(DataOutputStream* out){
|
||||
// Write DrawArrays's identification.
|
||||
out->writeInt(IVEDRAWARRAYS);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawArrays::write(): Could not cast this osg::DrawArrays to an osg::PrimitiveSet.");
|
||||
|
||||
|
||||
// Write DrawArrays's properties.
|
||||
out->writeInt(getFirst());
|
||||
out->writeInt(getCount());
|
||||
}
|
||||
|
||||
void DrawArrays::read(DataInputStream* in){
|
||||
// Read DrawArrays's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEDRAWARRAYS){
|
||||
// Code to read DrawArrays's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawArrays::read(): Could not cast this osg::DrawArrays to an osg::PrimitiveSet.");
|
||||
|
||||
|
||||
// Read DrawArrays properties
|
||||
setFirst(in->readInt());
|
||||
setCount(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawArrays::read(): Expected DrawArrays identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/DrawArrays.h
Normal file
15
src/osgPlugins/ive/DrawArrays.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_DRAWARRAYS
|
||||
#define IVE_DRAWARRAYS 1
|
||||
|
||||
#include <osg/PrimitiveSet>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT DrawArrays : public ReadWrite, public osg::DrawArrays{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
64
src/osgPlugins/ive/DrawElementsUShort.cpp
Normal file
64
src/osgPlugins/ive/DrawElementsUShort.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: DrawElementsUShort.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::DrawElementsUShort in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "DrawElementsUShort.h"
|
||||
#include "PrimitiveSet.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void DrawElementsUShort::write(DataOutputStream* out){
|
||||
// Write DrawElementsUShort's identification.
|
||||
out->writeInt(IVEDRAWELEMENTSUSHORT);
|
||||
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawElementsUShort::write(): Could not cast this osg::DrawElementsUShort to an osg::PrimitiveSet.");
|
||||
// Write DrawElementsUShort's properties.
|
||||
|
||||
// Write array length and its elements.
|
||||
out->writeInt(size());
|
||||
for(unsigned int i=0; i<size(); i++){
|
||||
out->writeUShort(((osg::VectorUShort)(*this))[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawElementsUShort::read(DataInputStream* in){
|
||||
// Read DrawElementsUShort's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEDRAWELEMENTSUSHORT){
|
||||
// Code to read DrawElementsUShort's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);
|
||||
if(prim){
|
||||
((ive::PrimitiveSet*)(prim))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("DrawElementsUShort::read(): Could not cast this osg::DrawElementsUShort to an osg::PrimtiveSet.");
|
||||
|
||||
// Read array length and its elements.
|
||||
int size = in->readInt();
|
||||
for(int i=0; i<size; i++){
|
||||
push_back(in->readUShort());
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawElementsUShort::read(): Expected DrawElementsUShort identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/DrawElementsUShort.h
Normal file
15
src/osgPlugins/ive/DrawElementsUShort.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_DRAWELEMENTSUSHORT
|
||||
#define IVE_DRAWELEMENTSUSHORT 1
|
||||
|
||||
#include <osg/PrimitiveSet>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT DrawElementsUShort : public osg::DrawElementsUShort, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
93
src/osgPlugins/ive/Drawable.cpp
Normal file
93
src/osgPlugins/ive/Drawable.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Drawable.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Drawable in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 18.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Drawable.h"
|
||||
#include "Object.h"
|
||||
#include "StateSet.h"
|
||||
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Drawable::write(DataOutputStream* out){
|
||||
// Write Drawable's identification.
|
||||
out->writeInt(IVEDRAWABLE);
|
||||
// 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("Drawable::write(): Could not cast this osg::Drawable to an osg::Object.");
|
||||
|
||||
// Write Drawable's properties.
|
||||
|
||||
// Write stateset.
|
||||
out->writeInt((int)getStateSet());
|
||||
if(getStateSet())
|
||||
out->writeStateSet(getStateSet());
|
||||
|
||||
// Write shape
|
||||
out->writeInt((int)getShape());
|
||||
if (getShape()){
|
||||
//static_cast<Shape*>(getShape())->write(out);
|
||||
}
|
||||
|
||||
// Write support display list.
|
||||
out->writeBool(getSupportsDisplayList());
|
||||
|
||||
// Write use display list.
|
||||
out->writeBool(getUseDisplayList());
|
||||
|
||||
}
|
||||
|
||||
void Drawable::read(DataInputStream* in){
|
||||
// Read Drawable's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEDRAWABLE){
|
||||
// Code to read Drawable's properties.
|
||||
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("Drawable::read(): Could not cast this osg::Drawable to an osg::Object.");
|
||||
|
||||
// Read in drawable's properties
|
||||
|
||||
// Read stateset if any
|
||||
if(in->readInt()){
|
||||
setStateSet(in->readStateSet());
|
||||
}
|
||||
|
||||
// Read shape if any
|
||||
if(in->readInt()){
|
||||
//osg::Shape* shape = new osg::Shape();
|
||||
//static_cast<Shape*>(shape)->read(in);
|
||||
//setShape(shape);
|
||||
}
|
||||
|
||||
// Read support display list
|
||||
setSupportsDisplayList(in->readBool());
|
||||
|
||||
// Read use display list
|
||||
setUseDisplayList(in->readBool());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("Drawable::read(): Expected Drawable identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Drawable.h
Normal file
15
src/osgPlugins/ive/Drawable.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_DRAWABLE
|
||||
#define IVE_DRAWABLE 1
|
||||
|
||||
#include <osg/Drawable>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Drawable : public ReadWrite, public osg::Drawable{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
23
src/osgPlugins/ive/Exception.cpp
Normal file
23
src/osgPlugins/ive/Exception.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Exception.cpp
|
||||
*
|
||||
* DESCRIPTION: Exception throwed when error occur.
|
||||
*
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 17.03.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#include "Exception.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
Exception::Exception(std::string error){
|
||||
_error = error;
|
||||
}
|
||||
|
||||
Exception::~Exception(){}
|
||||
20
src/osgPlugins/ive/Exception.h
Normal file
20
src/osgPlugins/ive/Exception.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef IVE_EXCEPTION
|
||||
#define IVE_EXCEPTION 1
|
||||
|
||||
#include "Export.h"
|
||||
#include <string>
|
||||
|
||||
namespace ive{
|
||||
|
||||
class IVE_EXPORT Exception{
|
||||
public:
|
||||
Exception(std::string error);
|
||||
~Exception();
|
||||
std::string getError(){return _error;};
|
||||
private:
|
||||
std::string _error;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
41
src/osgPlugins/ive/Export.h
Normal file
41
src/osgPlugins/ive/Export.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef IVE_EXPORT_H
|
||||
#define IVE_EXPORT_H 1
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4251 )
|
||||
#pragma warning( disable : 4267 )
|
||||
#pragma warning( disable : 4275 )
|
||||
#pragma warning( disable : 4290 )
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
|
||||
# ifdef IVE_LIBRARY
|
||||
# define IVE_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define IVE_EXPORT __declspec(dllimport)
|
||||
# endif /* IVE_LIBRARY */
|
||||
#else
|
||||
# define IVE_EXPORT
|
||||
#endif
|
||||
|
||||
// set up define for whether member templates are supported by VisualStudio compilers.
|
||||
#ifdef _MSC_VER
|
||||
# if (_MSC_VER >= 1300)
|
||||
# define __STL_MEMBER_TEMPLATES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define NULL pointer value */
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
47
src/osgPlugins/ive/GNUmakefile
Normal file
47
src/osgPlugins/ive/GNUmakefile
Normal file
@@ -0,0 +1,47 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
AnimationPath.cpp\
|
||||
AnimationPathCallback.cpp\
|
||||
Billboard.cpp\
|
||||
BlendFunc.cpp\
|
||||
CullFace.cpp\
|
||||
DataInputStream.cpp\
|
||||
DataOutputStream.cpp\
|
||||
DrawArrayLengths.cpp\
|
||||
DrawArrays.cpp\
|
||||
DrawElementsUShort.cpp\
|
||||
Drawable.cpp\
|
||||
Exception.cpp\
|
||||
Geode.cpp\
|
||||
Geometry.cpp\
|
||||
Group.cpp\
|
||||
Image.cpp\
|
||||
LOD.cpp\
|
||||
Light.cpp\
|
||||
LightSource.cpp\
|
||||
Material.cpp\
|
||||
MatrixTransform.cpp\
|
||||
Node.cpp\
|
||||
Object.cpp\
|
||||
PositionAttitudeTransform.cpp\
|
||||
PrimitiveSet.cpp\
|
||||
Sequence.cpp\
|
||||
StateSet.cpp\
|
||||
TexEnv.cpp\
|
||||
TexEnvCombine.cpp\
|
||||
TexGen.cpp\
|
||||
Texture.cpp\
|
||||
Texture2D.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
Transform.cpp\
|
||||
ReaderWriterIVE.cpp\
|
||||
|
||||
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = ive
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
86
src/osgPlugins/ive/Geode.cpp
Normal file
86
src/osgPlugins/ive/Geode.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Geode.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Geode in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 18.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Node.h"
|
||||
#include "Geode.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Geometry>
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Geode::write(DataOutputStream* out){
|
||||
// Write Geode's identification.
|
||||
out->writeInt(IVEGEODE);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
((ive::Node*)(node))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Geode::write(): Could not cast this osg::Geode to an osg::Node.");
|
||||
|
||||
|
||||
// Write Geode's properties.
|
||||
|
||||
// Write number of drawables.
|
||||
out->writeInt(getNumDrawables());
|
||||
// Write out every drawable.
|
||||
for(unsigned int i=0;i<getNumDrawables();i++){
|
||||
osg::Drawable* drawable = getDrawable(i);
|
||||
if(dynamic_cast<osg::Geometry*>(drawable))
|
||||
((ive::Geometry*)(drawable))->write(out);
|
||||
else{
|
||||
throw Exception("Unknown drawable in Geode::write()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Geode::read(DataInputStream* in){
|
||||
// Read Geode's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEGEODE){
|
||||
// Code to read Geode's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
((ive::Node*)(node))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Geode::read(): Could not cast this osg::Geode to an osg::Node.");
|
||||
|
||||
|
||||
// Read number of drawables.
|
||||
int size = in->readInt();
|
||||
// Read the drawables.
|
||||
for(int i = 0; i<size; i++){
|
||||
int id = in->peekInt();
|
||||
osg::Drawable* drawable;
|
||||
if(id == IVEGEOMETRY){
|
||||
drawable = new osg::Geometry();
|
||||
((Geometry*)(drawable))->read(in);
|
||||
addDrawable(drawable);
|
||||
}
|
||||
else
|
||||
throw Exception("Unknown drawable identification in Geode::read()");
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Geode::read(): Expected Geode identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Geode.h
Normal file
15
src/osgPlugins/ive/Geode.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_GEODE
|
||||
#define IVE_GEODE 1
|
||||
|
||||
#include <osg/Geode>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Geode : public ReadWrite, public osg::Geode{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
231
src/osgPlugins/ive/Geometry.cpp
Normal file
231
src/osgPlugins/ive/Geometry.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Geometry.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Geometry in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 18.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Geometry.h"
|
||||
#include "Drawable.h"
|
||||
#include "DrawArrays.h"
|
||||
#include "DrawArrayLengths.h"
|
||||
#include "DrawElementsUShort.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Geometry::write(DataOutputStream* out){
|
||||
// Write Geometry's identification.
|
||||
out->writeInt(IVEGEOMETRY);
|
||||
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(this);
|
||||
if(drawable){
|
||||
((ive::Drawable*)(drawable))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Geometry::write(): Could not cast this osg::Geometry to an osg::Drawable.");
|
||||
|
||||
|
||||
// Write Geometry's properties.
|
||||
|
||||
// Write primitiveset list.
|
||||
int size = getNumPrimitiveSets();
|
||||
out->writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
if(dynamic_cast<osg::DrawArrays*>(getPrimitiveSet(i)))
|
||||
((ive::DrawArrays*)(getPrimitiveSet(i)))->write(out);
|
||||
else if(dynamic_cast<osg::DrawArrayLengths*>(getPrimitiveSet(i)))
|
||||
((ive::DrawArrayLengths*)(getPrimitiveSet(i)))->write(out);
|
||||
else if(dynamic_cast<osg::DrawElementsUShort*>(getPrimitiveSet(i)))
|
||||
((ive::DrawElementsUShort*)(getPrimitiveSet(i)))->write(out);
|
||||
else
|
||||
throw Exception("Unknown PrimitivSet in Geometry::write()");
|
||||
}
|
||||
|
||||
// Write vertex array if any
|
||||
out->writeInt((int)getVertexArray());
|
||||
if (getVertexArray()){
|
||||
out->writeVec3Array(getVertexArray());
|
||||
}
|
||||
// Write vertex indices if any
|
||||
out->writeInt((int)getVertexIndices());
|
||||
if (getVertexIndices()){
|
||||
out->writeArray(getVertexIndices());
|
||||
}
|
||||
// Write normal array if any
|
||||
out->writeInt((int)getNormalArray());
|
||||
if (getNormalArray()){
|
||||
out->writeBinding(getNormalBinding());
|
||||
out->writeVec3Array(getNormalArray());
|
||||
}
|
||||
// Write normal indices if any
|
||||
out->writeInt((int)getNormalIndices());
|
||||
if (getNormalIndices()){
|
||||
out->writeArray(getNormalIndices());
|
||||
}
|
||||
// Write color array if any.
|
||||
out->writeInt((int)getColorArray());
|
||||
if (getColorArray()){
|
||||
out->writeBinding(getColorBinding());
|
||||
out->writeArray(getColorArray());
|
||||
}
|
||||
// Write color indices if any
|
||||
out->writeInt((int)getColorIndices());
|
||||
if (getColorIndices()){
|
||||
out->writeArray(getColorIndices());
|
||||
}
|
||||
// Write secondary color array if any
|
||||
out->writeInt((int)getSecondaryColorArray());
|
||||
if (getSecondaryColorArray()){
|
||||
out->writeBinding(getSecondaryColorBinding());
|
||||
out->writeArray(getSecondaryColorArray());
|
||||
}
|
||||
// Write second color indices if any
|
||||
out->writeInt((int)getSecondaryColorIndices());
|
||||
if (getSecondaryColorIndices()){
|
||||
out->writeArray(getSecondaryColorIndices());
|
||||
}
|
||||
// Write fog coord array if any
|
||||
out->writeInt((int)getFogCoordArray());
|
||||
if (getFogCoordArray()){
|
||||
out->writeBinding(getFogCoordBinding());
|
||||
out->writeArray(getFogCoordArray());
|
||||
}
|
||||
// Write fog coord indices if any
|
||||
out->writeInt((int)getFogCoordIndices());
|
||||
if (getFogCoordIndices()){
|
||||
out->writeArray(getFogCoordIndices());
|
||||
}
|
||||
// Write texture coord arrays
|
||||
Geometry::TexCoordArrayList& tcal = getTexCoordArrayList();
|
||||
out->writeInt(tcal.size());
|
||||
for(unsigned int j=0;j<tcal.size();j++){
|
||||
// Write coords if valid
|
||||
out->writeBool(tcal[j].first.valid());
|
||||
if (tcal[j].first.valid()){
|
||||
out->writeArray(tcal[j].first.get());
|
||||
}
|
||||
// Write indices if valid
|
||||
out->writeBool(tcal[j].second.valid());
|
||||
if (tcal[j].second.valid()){
|
||||
out->writeArray(tcal[j].second.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Geometry::read(DataInputStream* in){
|
||||
// Read Geometry's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEGEOMETRY){
|
||||
// Code to read Geometry's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(this);
|
||||
if(drawable){
|
||||
((ive::Drawable*)(drawable))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Geometry::read(): Could not cast this osg::Geometry to an osg::Drawable.");
|
||||
|
||||
|
||||
// Read geoemtry properties
|
||||
|
||||
// Read primitiveset list.
|
||||
int size = in->readInt();
|
||||
int i;
|
||||
for(i=0;i<size;i++){
|
||||
osg::PrimitiveSet* prim;
|
||||
int primID = in->peekInt();
|
||||
if(primID==IVEDRAWARRAYS){
|
||||
prim = new osg::DrawArrays();
|
||||
((ive::DrawArrays*)(prim))->read(in);
|
||||
addPrimitiveSet(prim);
|
||||
}
|
||||
else if(primID==IVEDRAWARRAYLENGTHS){
|
||||
prim = new osg::DrawArrayLengths();
|
||||
((ive::DrawArrayLengths*)(prim))->read(in);
|
||||
addPrimitiveSet(prim);
|
||||
}
|
||||
else if(primID==IVEDRAWELEMENTSUSHORT){
|
||||
prim = new osg::DrawElementsUShort();
|
||||
((ive::DrawElementsUShort*)(prim))->read(in);
|
||||
addPrimitiveSet(prim);
|
||||
}
|
||||
else{
|
||||
throw Exception("Unkown PrimitiveSet in Geometry::read()");
|
||||
}
|
||||
}
|
||||
|
||||
// Read vertex array if any
|
||||
int va=in->readInt();
|
||||
if (va){
|
||||
setVertexArray(in->readVec3Array());
|
||||
}
|
||||
// Read vertex indices if any
|
||||
int vi = in->readInt();
|
||||
if (vi){
|
||||
setVertexIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
// Read normal array if any
|
||||
int na =in->readInt();
|
||||
if(na){
|
||||
setNormalBinding(in->readBinding());
|
||||
setNormalArray(in->readVec3Array());
|
||||
}
|
||||
// Read normal indices if any
|
||||
int ni = in->readInt();
|
||||
if(ni){
|
||||
setNormalIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
// Read color array if any.
|
||||
if(in->readInt()){
|
||||
setColorBinding(in->readBinding());
|
||||
setColorArray(in->readArray());
|
||||
}
|
||||
// Read color indices if any
|
||||
if(in->readInt()){
|
||||
setColorIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
// Read secondary color array if any
|
||||
if(in->readInt()){
|
||||
setSecondaryColorBinding(in->readBinding());
|
||||
setSecondaryColorArray(in->readArray());
|
||||
}
|
||||
// Read second color indices if any
|
||||
if(in->readInt()){
|
||||
setSecondaryColorIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
// Read fog coord array if any
|
||||
if(in->readInt()){
|
||||
setFogCoordBinding(in->readBinding());
|
||||
setFogCoordArray(in->readArray());
|
||||
}
|
||||
// Read fog coord indices if any
|
||||
if(in->readInt()){
|
||||
setFogCoordIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
// Read texture coord arrays
|
||||
size = in->readInt();
|
||||
for(i =0;i<size;i++){
|
||||
// Read coords if valid
|
||||
bool coords_valid = in->readBool();
|
||||
if(coords_valid)
|
||||
setTexCoordArray(i, in->readArray());
|
||||
// Read Indices if valid
|
||||
bool indices_valid = in->readBool();
|
||||
if(indices_valid)
|
||||
setTexCoordIndices(i, static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Geometry::read(): Expected Geometry identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Geometry.h
Normal file
15
src/osgPlugins/ive/Geometry.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_GEOMETRY
|
||||
#define IVE_GEOMETRY 1
|
||||
|
||||
#include <osg/Geometry>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Geometry : public ReadWrite, public osg::Geometry{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
165
src/osgPlugins/ive/Group.cpp
Normal file
165
src/osgPlugins/ive/Group.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Group.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Group in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 17.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Node.h"
|
||||
#include "Group.h"
|
||||
#include "MatrixTransform.h"
|
||||
#include "Geode.h"
|
||||
#include "LightSource.h"
|
||||
#include "Billboard.h"
|
||||
#include "Sequence.h"
|
||||
#include "LOD.h"
|
||||
//#include "ViewPoint.h"
|
||||
#include "PositionAttitudeTransform.h"
|
||||
#include "Transform.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Group::write(DataOutputStream* out){
|
||||
// Write Group's identification.
|
||||
out->writeInt(IVEGROUP);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
static_cast<ive::Node*>(node)->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Group::write(): Could not cast this osg::Group to an osg::Node.");
|
||||
|
||||
// Write Group's properties.
|
||||
|
||||
// Write number of children.
|
||||
out->writeInt(getNumChildren());
|
||||
// Write children.
|
||||
for(unsigned int i=0; i<getNumChildren(); i++){
|
||||
osg::Node* child = getChild(i);
|
||||
if(dynamic_cast<osg::MatrixTransform*>(child)){
|
||||
((ive::MatrixTransform*)(child))->write(out);
|
||||
}
|
||||
// else if(dynamic_cast<osgfIVE::ViewPoint*>(child)){
|
||||
// ((ive::ViewPoint*)(child))->write(out);
|
||||
// }
|
||||
else if(dynamic_cast<osg::PositionAttitudeTransform*>(child)){
|
||||
((ive::PositionAttitudeTransform*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::LightSource*>(child)){
|
||||
((ive::LightSource*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::Sequence*>(child)){
|
||||
((ive::Sequence*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::LOD*>(child)){
|
||||
((ive::LOD*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::Transform*>(child)){
|
||||
((ive::Transform*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::Group*>(child)){
|
||||
((ive::Group*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::Billboard*>(child)){
|
||||
((ive::Billboard*)(child))->write(out);
|
||||
}
|
||||
else if(dynamic_cast<osg::Geode*>(child)){
|
||||
((ive::Geode*)(child))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Unknown child in Group::write()");
|
||||
}
|
||||
}
|
||||
|
||||
void Group::read(DataInputStream* in){
|
||||
// Read Group's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEGROUP){
|
||||
// Read Group's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
((ive::Node*)(node))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Group::read(): Could not cast this osg::Group to an osg::Node.");
|
||||
|
||||
|
||||
// Read groups properties.
|
||||
|
||||
// Read number of children.
|
||||
int size = in->readInt();
|
||||
// Read children.
|
||||
for(int i=0; i<size; i++){
|
||||
int id = in->peekInt();
|
||||
osg::Node* child;
|
||||
if(id == IVEMATRIXTRANSFORM){
|
||||
child = new osg::MatrixTransform();
|
||||
((ive::MatrixTransform*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
// else if(id == IVEVIEWPOINT){
|
||||
// child = new osgfIVE::ViewPoint();
|
||||
// ((ive::ViewPoint*)(child))->read(in);
|
||||
// addChild(child);
|
||||
// }
|
||||
else if(id == IVEPOSITIONATTITUDETRANSFORM){
|
||||
child = new osg::PositionAttitudeTransform();
|
||||
((ive::PositionAttitudeTransform*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVELIGHTSOURCE){
|
||||
child = new osg::LightSource();
|
||||
((ive::LightSource*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVESEQUENCE){
|
||||
child = new osg::Sequence();
|
||||
((ive::Sequence*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVELOD){
|
||||
child = new osg::LOD();
|
||||
((ive::LOD*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVETRANSFORM){
|
||||
child = new osg::Transform();
|
||||
((ive::Transform*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVEGROUP){
|
||||
child = new osg::Group();
|
||||
((ive::Group*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVEBILLBOARD){
|
||||
child = new osg::Billboard();
|
||||
((ive::Billboard*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else if(id == IVEGEODE){
|
||||
child = new osg::Geode();
|
||||
((ive::Geode*)(child))->read(in);
|
||||
addChild(child);
|
||||
}
|
||||
else{
|
||||
throw Exception("Unknown child identification in Group::read()");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Group::read(): Expected Group identification");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Group.h
Normal file
15
src/osgPlugins/ive/Group.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_GROUP
|
||||
#define IVE_GROUP 1
|
||||
|
||||
#include <osg/Group>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Group : public osg::Group, public ReadWrite{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* out);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
121
src/osgPlugins/ive/Image.cpp
Normal file
121
src/osgPlugins/ive/Image.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Image.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Image in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Image.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Image::write(DataOutputStream* out){
|
||||
// Write Image's identification.
|
||||
out->writeInt(IVEIMAGE);
|
||||
// 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("Image::write(): Could not cast this osg::Image to an osg::Object.");
|
||||
// Write Image's properties.
|
||||
|
||||
// Write name
|
||||
out->writeString(getFileName());
|
||||
|
||||
// Write width, height, depth of image.
|
||||
out->writeInt(s());
|
||||
out->writeInt(t());
|
||||
out->writeInt(r());
|
||||
|
||||
// Write formats, type and packing
|
||||
out->writeInt(getInternalTextureFormat());
|
||||
out->writeInt(getPixelFormat());
|
||||
out->writeInt(getDataType());
|
||||
out->writeInt(getPacking());
|
||||
|
||||
// Write modified tag.
|
||||
out->writeInt(getModifiedTag());
|
||||
|
||||
// Write mipmapdata vector
|
||||
int size = _mipmapData.size();
|
||||
out->writeInt(size);
|
||||
for(int i=0;i<size;i++)
|
||||
out->writeInt(_mipmapData[i]);
|
||||
|
||||
// Write image data if any
|
||||
out->writeInt((int)data());
|
||||
if(data()){
|
||||
// Compute the size of image data and write this.
|
||||
unsigned int size = computeRowWidthInBytes(s(),getPixelFormat(),getDataType(),getPacking())*t()*r();
|
||||
out->writeInt(size);
|
||||
// Write the data
|
||||
out->writeCharArray((char*)data(), size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Image::read(DataInputStream* in){
|
||||
// Peek Image's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEIMAGE){
|
||||
// Read Image'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("Image::read(): Could not cast this osg::Image to an osg::Object.");
|
||||
// Read Image's properties.
|
||||
|
||||
// Read name
|
||||
setFileName(in->readString());
|
||||
|
||||
// Read width, height, depth of image.
|
||||
int s=in->readInt();
|
||||
int t=in->readInt();
|
||||
int r=in->readInt();
|
||||
|
||||
// Read formats, type and packing
|
||||
GLint internalTextureFormat = (GLint) in->readInt();
|
||||
GLenum pixelFormat = (GLenum) in->readInt();
|
||||
GLenum dataType = (GLenum) in->readInt();;
|
||||
unsigned int packing = (unsigned int)in->readInt();
|
||||
|
||||
// Read modified tag.
|
||||
setModifiedTag((unsigned int)in->readInt());
|
||||
|
||||
// Read mipmapdata vector
|
||||
int size = in->readInt();
|
||||
_mipmapData.resize(size);
|
||||
for(int i=0;i<size;i++)
|
||||
_mipmapData[i]=(unsigned int)in->readInt();
|
||||
|
||||
// Read image data if any
|
||||
if(in->readInt()){
|
||||
unsigned int dataSize = (unsigned int)in->readInt();
|
||||
//char* data = (char*)malloc (dataSize);
|
||||
char* data = new char[dataSize];
|
||||
if(!data)
|
||||
throw Exception("Image::read(): Unable to allocate memory for image data.");
|
||||
in->readCharArray(data,dataSize);
|
||||
setImage(s, t, r, internalTextureFormat, pixelFormat,
|
||||
dataType, (unsigned char* ) data, osg::Image::USE_NEW_DELETE, packing);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Image::read(): Expected Image identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Image.h
Normal file
15
src/osgPlugins/ive/Image.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_IMAGE
|
||||
#define IVE_IMAGE 1
|
||||
|
||||
#include <osg/Image>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Image : public osg::Image, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
74
src/osgPlugins/ive/LOD.cpp
Normal file
74
src/osgPlugins/ive/LOD.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: LOD.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::LOD in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 24.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "LOD.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void LOD::write(DataOutputStream* out){
|
||||
// Write LOD's identification.
|
||||
out->writeInt(IVELOD);
|
||||
// If the osg 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("LOD::write(): Could not cast this osg::LOD to an osg::Group.");
|
||||
// Write LOD's properties.
|
||||
|
||||
// Write centermode
|
||||
out->writeInt(getCenterMode());
|
||||
out->writeVec3(getCenter());
|
||||
// Write rangelist
|
||||
int size = getNumRanges();
|
||||
out->writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
out->writeFloat(getMinRange(i));
|
||||
out->writeFloat(getMaxRange(i));
|
||||
}
|
||||
}
|
||||
|
||||
void LOD::read(DataInputStream* in){
|
||||
// Peek on LOD's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVELOD){
|
||||
// Read LOD's identification.
|
||||
id = in->readInt();
|
||||
// If the osg 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("LOD::read(): Could not cast this osg::LOD to an osg::Group.");
|
||||
// Read LOD's properties
|
||||
|
||||
// Read centermode
|
||||
setCenterMode((osg::LOD::CenterMode)in->readInt());
|
||||
setCenter(in->readVec3());
|
||||
// Read rangelist
|
||||
int size = in->readInt();;
|
||||
for(int i=0;i<size;i++){
|
||||
float min = in->readFloat();
|
||||
float max = in->readFloat();
|
||||
setRange(i, min, max);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("LOD::read(): Expected LOD identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/LOD.h
Normal file
15
src/osgPlugins/ive/LOD.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_LOD
|
||||
#define IVE_LOD 1
|
||||
|
||||
#include <osg/LOD>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT LOD : public osg::LOD, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
75
src/osgPlugins/ive/Light.cpp
Normal file
75
src/osgPlugins/ive/Light.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Light.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Light in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Light.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Light::write(DataOutputStream* out){
|
||||
// Write Light's identification.
|
||||
out->writeInt(IVELIGHT);
|
||||
// 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("Light::write(): Could not cast this osg::Light to an osg::Object.");
|
||||
// Write Light's properties.
|
||||
out->writeInt(getLightNum());
|
||||
out->writeVec4(getAmbient());
|
||||
out->writeVec4(getDiffuse());
|
||||
out->writeVec4(getSpecular());
|
||||
out->writeVec4(getPosition());
|
||||
out->writeVec3(getDirection());
|
||||
out->writeFloat(getConstantAttenuation());
|
||||
out->writeFloat(getLinearAttenuation ());
|
||||
out->writeFloat(getQuadraticAttenuation());
|
||||
out->writeFloat(getSpotExponent());
|
||||
out->writeFloat(getSpotCutoff());
|
||||
|
||||
}
|
||||
|
||||
void Light::read(DataInputStream* in){
|
||||
// Peek on Light's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVELIGHT){
|
||||
// Read Light'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("Light::read(): Could not cast this osg::Light to an osg::Object.");
|
||||
// Read Light's properties
|
||||
setLightNum(in->readInt());
|
||||
setAmbient(in->readVec4());
|
||||
setDiffuse(in->readVec4());
|
||||
setSpecular(in->readVec4());
|
||||
setPosition(in->readVec4());
|
||||
setDirection(in->readVec3());
|
||||
setConstantAttenuation(in->readFloat());
|
||||
setLinearAttenuation (in->readFloat());
|
||||
setQuadraticAttenuation(in->readFloat());
|
||||
setSpotExponent(in->readFloat());
|
||||
setSpotCutoff(in->readFloat());
|
||||
}
|
||||
else{
|
||||
throw Exception("Light::read(): Expected Light identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Light.h
Normal file
15
src/osgPlugins/ive/Light.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_LIGHT
|
||||
#define IVE_LIGHT 1
|
||||
|
||||
#include <osg/Light>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Light : public osg::Light, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
72
src/osgPlugins/ive/LightSource.cpp
Normal file
72
src/osgPlugins/ive/LightSource.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: LightSource.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::LightSource in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "LightSource.h"
|
||||
#include "Group.h"
|
||||
#include "Light.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void LightSource::write(DataOutputStream* out){
|
||||
// Write LightSource's identification.
|
||||
out->writeInt(IVELIGHTSOURCE);
|
||||
// If the osg 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("LightSource::write(): Could not cast this osg::LightSource to an osg::Group.");
|
||||
// Write LightSource's properties.
|
||||
|
||||
// Write out light
|
||||
out->writeInt((int)getLight());
|
||||
if(getLight()){
|
||||
((ive::Light*)(getLight()))->write(out);
|
||||
}
|
||||
|
||||
// Write reference frame
|
||||
out->writeInt((int)getReferenceFrame());
|
||||
}
|
||||
|
||||
void LightSource::read(DataInputStream* in){
|
||||
// Peek on LightSource's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVELIGHTSOURCE){
|
||||
// Read LightSource's identification.
|
||||
id = in->readInt();
|
||||
// If the osg 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("LightSource::read(): Could not cast this osg::LightSource to an osg::Object.");
|
||||
// Read LightSource's properties
|
||||
|
||||
// Read light
|
||||
if(in->readInt()){
|
||||
osg::Light* light = new osg::Light();
|
||||
((ive::Light*)(light))->read(in);
|
||||
setLight(light);
|
||||
}
|
||||
|
||||
// Read reference frame
|
||||
setReferenceFrame((osg::LightSource::ReferenceFrame) in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("LightSource::read(): Expected LightSource identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/LightSource.h
Normal file
15
src/osgPlugins/ive/LightSource.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_LIGHTSOURCE
|
||||
#define IVE_LIGHTSOURCE 1
|
||||
|
||||
#include <osg/LightSource>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT LightSource : public osg::LightSource, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
98
src/osgPlugins/ive/Material.cpp
Normal file
98
src/osgPlugins/ive/Material.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Material.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Material in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Material.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Material::write(DataOutputStream* out){
|
||||
// Write Material's identification.
|
||||
out->writeInt(IVEMATERIAL);
|
||||
// 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("Material::write(): Could not cast this osg::Material to an osg::Object.");
|
||||
// Write Material's properties.
|
||||
|
||||
// Write color mode
|
||||
out->writeInt(_colorMode);
|
||||
// Write ambient
|
||||
out->writeBool(_ambientFrontAndBack);
|
||||
out->writeVec4(_ambientFront);
|
||||
out->writeVec4(_ambientBack);
|
||||
// Write diffuse
|
||||
out->writeBool(_diffuseFrontAndBack);
|
||||
out->writeVec4(_diffuseFront);
|
||||
out->writeVec4(_diffuseBack);
|
||||
// Write specular
|
||||
out->writeBool(_specularFrontAndBack);
|
||||
out->writeVec4(_specularFront);
|
||||
out->writeVec4(_specularBack);
|
||||
// Write emmision
|
||||
out->writeBool(_emissionFrontAndBack);
|
||||
out->writeVec4(_emissionFront);
|
||||
out->writeVec4(_emissionBack);
|
||||
// Write shininess
|
||||
out->writeBool(_shininessFrontAndBack);
|
||||
out->writeFloat(_shininessFront);
|
||||
out->writeFloat(_shininessBack);
|
||||
|
||||
}
|
||||
|
||||
void Material::read(DataInputStream* in){
|
||||
// Read Material's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEMATERIAL){
|
||||
// Code to read Material's properties.
|
||||
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("Material::read(): Could not cast this osg::Material to an osg::Object.");
|
||||
|
||||
// Read color mode.
|
||||
_colorMode = (osg::Material::ColorMode)in->readInt();
|
||||
// Read ambient
|
||||
_ambientFrontAndBack = in->readBool();
|
||||
_ambientFront = in->readVec4();
|
||||
_ambientBack = in->readVec4();
|
||||
// Read diffuse
|
||||
_diffuseFrontAndBack = in->readBool();
|
||||
_diffuseFront = in->readVec4();
|
||||
_diffuseBack = in->readVec4();
|
||||
// Read specular
|
||||
_specularFrontAndBack = in->readBool();
|
||||
_specularFront = in->readVec4();
|
||||
_specularBack = in->readVec4();
|
||||
// Read emission
|
||||
_emissionFrontAndBack = in->readBool();
|
||||
_emissionFront = in->readVec4();
|
||||
_emissionBack = in->readVec4();
|
||||
// Read shiniess
|
||||
_shininessFrontAndBack = in->readBool();
|
||||
_shininessFront = in->readFloat();
|
||||
_shininessBack = in->readFloat();
|
||||
}
|
||||
else{
|
||||
throw Exception("Material::read(): Expected Material identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Material.h
Normal file
15
src/osgPlugins/ive/Material.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_MATERIAL
|
||||
#define IVE_MATERIAL 1
|
||||
|
||||
#include <osg/Material>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Material : public osg::Material, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
58
src/osgPlugins/ive/MatrixTransform.cpp
Normal file
58
src/osgPlugins/ive/MatrixTransform.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: MatrixTransform.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::MatrixTransform in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 17.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "MatrixTransform.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void MatrixTransform::write(DataOutputStream* out){
|
||||
// Write MatrixTransform's identification.
|
||||
out->writeInt(IVEMATRIXTRANSFORM);
|
||||
|
||||
// If the osg 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("MatrixTransform::write(): Could not cast this osg::MatrixTransform to an osg::Group.");
|
||||
|
||||
|
||||
// Write MatrixTransform's properties.
|
||||
out->writeMatrix(getMatrix());
|
||||
}
|
||||
|
||||
void MatrixTransform::read(DataInputStream* in){
|
||||
// Read MatrixTransform's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEMATRIXTRANSFORM){
|
||||
// Code to read MatrixTransform's properties.
|
||||
id = in->readInt();
|
||||
// If the osg 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("MatrixTransform::read(): Could not cast this osg::MatrixTransform to an osg::Group.");
|
||||
|
||||
// Read matrix
|
||||
setMatrix(in->readMatrix());
|
||||
}
|
||||
else{
|
||||
throw Exception("MatrixTransform::read(): Expected MatrixTransform identification");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/MatrixTransform.h
Normal file
15
src/osgPlugins/ive/MatrixTransform.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_MATRIXTRANSFORM
|
||||
#define IVE_MATRIXTRANSFORM 1
|
||||
|
||||
#include <osg/MatrixTransform>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT MatrixTransform : public osg::MatrixTransform, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
106
src/osgPlugins/ive/Node.cpp
Normal file
106
src/osgPlugins/ive/Node.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Node.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Node in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 10.03.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Node.h"
|
||||
#include "MatrixTransform.h"
|
||||
#include "Group.h"
|
||||
#include "Object.h"
|
||||
#include "StateSet.h"
|
||||
#include "AnimationPathCallback.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
|
||||
void Node::write(DataOutputStream* out){
|
||||
|
||||
// Write node identification.
|
||||
out->writeInt(IVENODE);
|
||||
|
||||
// Write out any inherited classes.
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj){
|
||||
((ive::Object*)(obj))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Node::write(): Could not cast this osg::Node to an osg::Object.");
|
||||
|
||||
|
||||
// Write osg::node properties.
|
||||
|
||||
// Write Name
|
||||
out->writeString(getName());
|
||||
// Write culling active
|
||||
out->writeBool( getCullingActive());
|
||||
// Write Descriptions
|
||||
int nDesc = getDescriptions().size();
|
||||
out->writeInt(nDesc);
|
||||
if(nDesc!=0){
|
||||
std::vector<std::string> desc = getDescriptions();
|
||||
for(int i=0;i<nDesc;i++)
|
||||
out->writeString(desc[i]);
|
||||
}
|
||||
// Write Stateset if any
|
||||
out->writeInt((int) getStateSet());
|
||||
if(getStateSet())
|
||||
out->writeStateSet(getStateSet());
|
||||
|
||||
|
||||
// Write UpdateCallback if any
|
||||
osg::NodeCallback* nc = getUpdateCallback();
|
||||
if(nc && dynamic_cast<osg::AnimationPathCallback*>(nc)){
|
||||
out->writeInt((int)nc);
|
||||
((ive::AnimationPathCallback*)(nc))->write(out);
|
||||
}
|
||||
else
|
||||
out->writeInt(0x0);
|
||||
}
|
||||
|
||||
|
||||
void Node::read(DataInputStream* in){
|
||||
// Peak on the identification id.
|
||||
int id = in->peekInt();
|
||||
|
||||
if(id == IVENODE){
|
||||
id = in->readInt();
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj){
|
||||
((ive::Object*)(obj))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Node::read(): Could not cast this osg::Node to an osg::Object.");
|
||||
// Read name
|
||||
setName(in->readString());
|
||||
// Read Culling active
|
||||
setCullingActive(in->readBool());
|
||||
// Read descriptions
|
||||
int nDesc = in->readInt();
|
||||
if(nDesc!=0){
|
||||
for(int i=0;i<nDesc;i++)
|
||||
addDescription(in->readString());
|
||||
}
|
||||
// Read StateSet if any
|
||||
if(in->readInt()){
|
||||
setStateSet(in->readStateSet());
|
||||
}
|
||||
// Read UpdateCallback if any
|
||||
if(in->readInt()){
|
||||
osg::AnimationPathCallback* nc = new osg::AnimationPathCallback();
|
||||
((ive::AnimationPathCallback*)(nc))->read(in);
|
||||
setUpdateCallback(nc);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Node::read(): Expected Node identification");
|
||||
}
|
||||
}
|
||||
16
src/osgPlugins/ive/Node.h
Normal file
16
src/osgPlugins/ive/Node.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef IVE_NODE
|
||||
#define IVE_NODE 1
|
||||
|
||||
#include <osg/Node>
|
||||
#include "ReadWrite.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Node : public osg::Node, public ReadWrite{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
47
src/osgPlugins/ive/Object.cpp
Normal file
47
src/osgPlugins/ive/Object.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Object.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Object in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 17.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Object::write(DataOutputStream* out){
|
||||
// Write Object's identification.
|
||||
out->writeInt(IVEOBJECT);
|
||||
|
||||
// Write Object's properties.
|
||||
switch(getDataVariance()){
|
||||
case(osg::Object::STATIC): out->writeChar((char)0); break;
|
||||
case(osg::Object::DYNAMIC): out->writeChar((char)1); break;
|
||||
}
|
||||
}
|
||||
|
||||
void Object::read(DataInputStream* in){
|
||||
// Read Object's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEOBJECT){
|
||||
// Code to read Object's properties.
|
||||
id = in->readInt();
|
||||
|
||||
char c = in->readChar();
|
||||
switch((int)c){
|
||||
case 0: setDataVariance(osg::Object::STATIC);break;
|
||||
case 1: setDataVariance(osg::Object::DYNAMIC);break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Object::read(): Expected Object identification");
|
||||
}
|
||||
}
|
||||
18
src/osgPlugins/ive/Object.h
Normal file
18
src/osgPlugins/ive/Object.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef IVE_OBJECT
|
||||
#define IVE_OBJECT 1
|
||||
|
||||
|
||||
#include <osg/Object>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
|
||||
class IVE_EXPORT Object : public ReadWrite, public osg::Object{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* out);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
60
src/osgPlugins/ive/PositionAttitudeTransform.cpp
Normal file
60
src/osgPlugins/ive/PositionAttitudeTransform.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: PositionAttitudeTransform.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::PositionAttitudeTransform in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 25.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "PositionAttitudeTransform.h"
|
||||
#include "Transform.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void PositionAttitudeTransform::write(DataOutputStream* out){
|
||||
// Write PositionAttitudeTransform's identification.
|
||||
out->writeInt(IVEPOSITIONATTITUDETRANSFORM);
|
||||
// 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("PositionAttitudeTransform::write(): Could not cast this osg::PositionAttitudeTransform to an osg::Transform.");
|
||||
// Write PositionAttitudeTransform's properties.
|
||||
|
||||
out->writeVec3(getPosition());
|
||||
out->writeQuat(getAttitude());
|
||||
out->writeVec3(getPivotPoint());
|
||||
}
|
||||
|
||||
void PositionAttitudeTransform::read(DataInputStream* in){
|
||||
// Peek on PositionAttitudeTransform's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEPOSITIONATTITUDETRANSFORM){
|
||||
// Read PositionAttitudeTransform'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("PositionAttitudeTransform::read(): Could not cast this osg::PositionAttitudeTransform to an osg::Transform.");
|
||||
// Read PositionAttitudeTransform's properties
|
||||
setPosition(in->readVec3());
|
||||
setAttitude(in->readQuat());
|
||||
setPivotPoint(in->readVec3());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("PositionAttitudeTransform::read(): Expected PositionAttitudeTransform identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/PositionAttitudeTransform.h
Normal file
15
src/osgPlugins/ive/PositionAttitudeTransform.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_POSITIONATTITUDETRANSFORM
|
||||
#define IVE_POSITIONATTITUDETRANSFORM 1
|
||||
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT PositionAttitudeTransform : public osg::PositionAttitudeTransform, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
58
src/osgPlugins/ive/PrimitiveSet.cpp
Normal file
58
src/osgPlugins/ive/PrimitiveSet.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: PrimitiveSet.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::PrimitiveSet in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 18.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Object.h"
|
||||
#include "PrimitiveSet.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void PrimitiveSet::write(DataOutputStream* out){
|
||||
// Write PrimitiveSet's identification.
|
||||
out->writeInt(IVEPRIMITIVESET);
|
||||
// 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("PrimitiveSet::write(): Could not cast this osg::PrimitiveSet to an osg::Object.");
|
||||
|
||||
|
||||
// Write PrimitiveSet's properties.
|
||||
out->writeInt(getMode());
|
||||
}
|
||||
|
||||
void PrimitiveSet::read(DataInputStream* in){
|
||||
// Read PrimitiveSet's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEPRIMITIVESET){
|
||||
// Code to read PrimitiveSet's properties.
|
||||
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("PrimitiveSet::read(): Could not cast this osg::PrimitiveSet to an osg::Object.");
|
||||
|
||||
|
||||
// Read in primitiveset properties.
|
||||
setMode(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("PrimitiveSet::read(): Expected PrimitiveSet identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/PrimitiveSet.h
Normal file
15
src/osgPlugins/ive/PrimitiveSet.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_PRIMITIVESET
|
||||
#define IVE_PRIMITIVESET 1
|
||||
|
||||
#include <osg/PrimitiveSet>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT PrimitiveSet : public ReadWrite, public osg::PrimitiveSet{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
66
src/osgPlugins/ive/ReadWrite.h
Normal file
66
src/osgPlugins/ive/ReadWrite.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef IVE_READWRITE
|
||||
#define IVE_READWRITE 1
|
||||
|
||||
#include "DataInputStream.h"
|
||||
#include "DataOutputStream.h"
|
||||
|
||||
namespace ive {
|
||||
|
||||
// Objects and Nodes
|
||||
#define IVEOBJECT 0x00000001
|
||||
#define IVENODE 0x00000002
|
||||
#define IVEGROUP 0x00000003
|
||||
#define IVEMATRIXTRANSFORM 0x00000004
|
||||
#define IVESTATESET 0x00000005
|
||||
#define IVEGEODE 0x00000006
|
||||
#define IVEIMAGE 0x00000007
|
||||
#define IVELIGHTSOURCE 0x00000008
|
||||
#define IVELIGHT 0x00000009
|
||||
#define IVEBILLBOARD 0x00000010
|
||||
#define IVELOD 0x00000011
|
||||
#define IVESEQUENCE 0x00000012
|
||||
#define IVETRANSFORM 0x00000013
|
||||
#define IVEPOSITIONATTITUDETRANSFORM 0x00000014
|
||||
#define IVEANIMATIONPATH 0x00000015
|
||||
|
||||
// Node callbacks
|
||||
#define IVENODECALLBACK 0x00000050
|
||||
#define IVEANIMATIONPATHCALLBACK 0x00000051
|
||||
|
||||
// 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
|
||||
|
||||
// Drawables
|
||||
#define IVEDRAWABLE 0x00001000
|
||||
#define IVEGEOMETRY 0x00001001
|
||||
|
||||
// Primitive set
|
||||
#define IVEPRIMITIVESET 0x00010000
|
||||
#define IVEDRAWARRAYS 0x00010001
|
||||
#define IVEDRAWARRAYLENGTHS 0x00010002
|
||||
#define IVEDRAWELEMENTSUSHORT 0x00010003
|
||||
|
||||
// Our own classes
|
||||
#define IVEVIEWPOINT 0x00100001
|
||||
|
||||
class IVE_EXPORT ReadWrite{
|
||||
|
||||
public:
|
||||
virtual void write(DataOutputStream* out) const = 0;
|
||||
virtual void read(DataInputStream* out) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // IVE_READWRITE
|
||||
86
src/osgPlugins/ive/ReaderWriterIVE.cpp
Normal file
86
src/osgPlugins/ive/ReaderWriterIVE.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "MatrixTransform.h"
|
||||
#include "Group.h"
|
||||
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/Registry>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
class IVEReaderWriter : public ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual const char* className() { return "IVE Reader/Writer"; }
|
||||
|
||||
virtual bool acceptsExtension(const std::string& extension)
|
||||
{
|
||||
return equalCaseInsensitive(extension,"ive");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& fileName, const Options*)
|
||||
{
|
||||
std::string ext = getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
try{
|
||||
// Create datainputstream.
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
ive::DataInputStream* in = new ive::DataInputStream(&istream);
|
||||
|
||||
// Which object is written first in the stream.
|
||||
int id = in->peekInt();
|
||||
|
||||
if(id==IVEMATRIXTRANSFORM)
|
||||
{
|
||||
osg::MatrixTransform* rootNode = new osg::MatrixTransform;
|
||||
((ive::MatrixTransform*)(rootNode))->read(in);
|
||||
return rootNode;
|
||||
}
|
||||
else if(id==IVEGROUP)
|
||||
{
|
||||
osg::Group* rootNode = new osg::Group;
|
||||
((ive::Group*)(rootNode))->read(in);
|
||||
return rootNode;
|
||||
}
|
||||
else{
|
||||
cout <<"Unknown class identification in file "<< id << endl;
|
||||
}
|
||||
}
|
||||
catch(ive::Exception e)
|
||||
{
|
||||
std::cout<<"Error reading file: "<< e.getError()<<std::endl;
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual WriteResult writeNode(const Node& node,const std::string& fileName, const osgDB::ReaderWriter::Options*)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ofstream ostream(fileName.c_str(), ios::out | ios::binary);
|
||||
ive::DataOutputStream* out = new ive::DataOutputStream(&ostream);
|
||||
// write ive file.
|
||||
if(dynamic_cast<const osg::MatrixTransform*>(&node))
|
||||
const_cast<ive::MatrixTransform*>(static_cast<const ive::MatrixTransform*>(&node))->write(out);
|
||||
else if(dynamic_cast<const osg::Group*>(&node))
|
||||
const_cast<ive::Group*>(static_cast<const ive::Group*>(&node))->write(out);
|
||||
else
|
||||
std::cout<<"File must start with a MatrixTransform or Group "<<std::endl;
|
||||
ostream.flush();
|
||||
ostream.close();
|
||||
return WriteResult::FILE_SAVED;
|
||||
}
|
||||
catch(ive::Exception e)
|
||||
{
|
||||
std::cout<<"Error parsing OSG file: "<< e.getError() << std::endl;
|
||||
}
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
RegisterReaderWriterProxy<IVEReaderWriter> g_IVEReaderWriterProxy;
|
||||
91
src/osgPlugins/ive/Sequence.cpp
Normal file
91
src/osgPlugins/ive/Sequence.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Sequence.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Sequence in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 24.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Sequence.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Sequence::write(DataOutputStream* out){
|
||||
// Write Sequence's identification.
|
||||
out->writeInt(IVESEQUENCE);
|
||||
// If the osg 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("Sequence::write(): Could not cast this osg::Sequence to an osg::Group.");
|
||||
// Write Sequence's properties.
|
||||
|
||||
// Write frame times.
|
||||
int size = getNumChildren();
|
||||
out->writeInt(size);
|
||||
for(int i=0;i<size;i++){
|
||||
out->writeFloat(getTime(i));
|
||||
}
|
||||
// Write loop mode & interval
|
||||
osg::Sequence::LoopMode mode;
|
||||
int begin, end;
|
||||
getInterval(mode, begin, end);
|
||||
out->writeInt(mode);
|
||||
out->writeInt(begin);
|
||||
out->writeInt(end);
|
||||
// Write duration
|
||||
float speed;
|
||||
int nreps;
|
||||
getDuration(speed, nreps);
|
||||
out->writeFloat(speed);
|
||||
out->writeInt(nreps);
|
||||
// Write sequence mode
|
||||
out->writeInt(getMode());
|
||||
|
||||
}
|
||||
|
||||
void Sequence::read(DataInputStream* in){
|
||||
// Peek on Sequence's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVESEQUENCE){
|
||||
// Read Sequence's identification.
|
||||
id = in->readInt();
|
||||
// If the osg 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("Sequence::read(): Could not cast this osg::Sequence to an osg::Group.");
|
||||
// Read Sequence's properties
|
||||
// Read frame times.
|
||||
int size = in->readInt();
|
||||
for(int i=0;i<size;i++){
|
||||
setTime(i, in->readFloat());
|
||||
}
|
||||
// Read loop mode & interval
|
||||
int mode = in->readInt();
|
||||
int begin = in->readInt();
|
||||
int end = in->readInt();
|
||||
setInterval((osg::Sequence::LoopMode)mode, begin, end);
|
||||
// Read duration
|
||||
float speed = in->readFloat();
|
||||
int nreps = in->readInt();
|
||||
setDuration(speed, nreps);
|
||||
// Read sequence mode
|
||||
setMode((osg::Sequence::SequenceMode)in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Sequence::read(): Expected Sequence identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Sequence.h
Normal file
15
src/osgPlugins/ive/Sequence.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_SEQUENCE
|
||||
#define IVE_SEQUENCE 1
|
||||
|
||||
#include <osg/Sequence>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Sequence : public osg::Sequence, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
266
src/osgPlugins/ive/StateSet.cpp
Normal file
266
src/osgPlugins/ive/StateSet.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: StateSet.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::StateSet in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 17.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "StateSet.h"
|
||||
#include "Object.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
#include "Texture2D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
#include "TexEnvCombine.h"
|
||||
#include "TexGen.h"
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void StateSet::write(DataOutputStream* out){
|
||||
// Write StateSet's identification.
|
||||
out->writeInt(IVESTATESET);
|
||||
// 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("StateSet::write(): Could not cast this osg::StateSet to an osg::Object.");
|
||||
|
||||
// Write render bin bin details.
|
||||
switch(getRenderBinMode()){
|
||||
case osg::StateSet::INHERIT_RENDERBIN_DETAILS: out->writeChar((char)0);break;
|
||||
case osg::StateSet::USE_RENDERBIN_DETAILS: out->writeChar((char)1);break;
|
||||
case osg::StateSet::OVERRIDE_RENDERBIN_DETAILS: out->writeChar((char)2);break;
|
||||
case osg::StateSet::ENCLOSE_RENDERBIN_DETAILS: out->writeChar((char)3);break;
|
||||
default: throw Exception("Unknown RenderBinMode in StateSet::write()");
|
||||
}
|
||||
out->writeInt(getBinNumber());
|
||||
out->writeString(getBinName());
|
||||
|
||||
|
||||
StateSet::ModeList ml = getModeList();
|
||||
StateSet::AttributeList al = getAttributeList();
|
||||
|
||||
// Write stateset modes, this could for instance be GL_NORMALIZE, GL_LIGHT, etc.
|
||||
out->writeInt(ml.size());
|
||||
for(StateSet::ModeList::const_iterator mitr=ml.begin(); mitr!=ml.end(); ++mitr){
|
||||
out->writeInt((unsigned int)mitr->first);
|
||||
out->writeInt((unsigned int)mitr->second);
|
||||
}
|
||||
|
||||
// Write stateset attributes, this could for instance be alphafunctions, materials, etc.
|
||||
out->writeInt(al.size());
|
||||
for(StateSet::AttributeList::iterator aitr=al.begin(); aitr!=al.end(); ++aitr){
|
||||
// This is a BlendFunc.
|
||||
if(dynamic_cast<osg::BlendFunc*>(aitr->second.first.get())){
|
||||
((ive::BlendFunc*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a Material
|
||||
else if(dynamic_cast<osg::Material*>(aitr->second.first.get())){
|
||||
((ive::Material*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a CullFace
|
||||
else if(dynamic_cast<osg::CullFace*>(aitr->second.first.get())){
|
||||
((ive::CullFace*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
else{
|
||||
std::string className = (aitr->second.first.get())->className();
|
||||
throw Exception(std::string("StateSet::write(): Unknown StateAttribute: ").append(className));
|
||||
}
|
||||
}
|
||||
|
||||
StateSet::TextureModeList tml = getTextureModeList();
|
||||
StateSet::TextureAttributeList tal = getTextureAttributeList();
|
||||
|
||||
// Write texture stateset modes, this could for instance be TEXGEN ON, TEXTURECUBEMAP ON, etc.
|
||||
int nUnits = tml.size();
|
||||
out->writeInt(nUnits);
|
||||
int unit;
|
||||
for(unit=0;unit<nUnits;unit++){
|
||||
ml = tml[unit];
|
||||
out->writeInt(ml.size());
|
||||
for(StateSet::ModeList::const_iterator mitr=ml.begin(); mitr!=ml.end(); ++mitr){
|
||||
out->writeInt((unsigned int)mitr->first);
|
||||
out->writeInt((unsigned int)mitr->second);
|
||||
}
|
||||
}
|
||||
|
||||
// Write texture attributes, this could for instance texture2D, texturecubemap
|
||||
nUnits = tal.size();
|
||||
out->writeInt(nUnits);
|
||||
for(unit=0;unit<nUnits;unit++){
|
||||
al = tal[unit];
|
||||
out->writeInt(al.size());
|
||||
for(StateSet::AttributeList::iterator aitr=al.begin(); aitr!=al.end(); ++aitr){
|
||||
// This is a Texture2D
|
||||
if(dynamic_cast<osg::Texture2D*>(aitr->second.first.get())){
|
||||
((ive::Texture2D*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a TextureCubeMap
|
||||
else if(dynamic_cast<osg::TextureCubeMap*>(aitr->second.first.get())){
|
||||
((ive::TextureCubeMap*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a TexEnv
|
||||
else if(dynamic_cast<osg::TexEnv*>(aitr->second.first.get())){
|
||||
((ive::TexEnv*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a TexEnvCombine
|
||||
else if(dynamic_cast<osg::TexEnvCombine*>(aitr->second.first.get())){
|
||||
((ive::TexEnvCombine*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
// This is a TexGen
|
||||
else if(dynamic_cast<osg::TexGen*>(aitr->second.first.get())){
|
||||
((ive::TexGen*)(aitr->second.first.get()))->write(out);
|
||||
out->writeInt(aitr->second.second);
|
||||
}
|
||||
else{
|
||||
std::string className = (aitr->second.first.get())->className();
|
||||
throw Exception(std::string("StateSet::write(): Unknown Texture StateAttribute: ").append(className));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StateSet::read(DataInputStream* in){
|
||||
// Read StateSet's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVESTATESET){
|
||||
// Code to read StateSet's properties.
|
||||
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("StateSet::read(): Could not cast this osg::StateSet to an osg::Object.");
|
||||
|
||||
// Read render bin details.
|
||||
char c = in->readChar();
|
||||
int num = in->readInt();
|
||||
std::string name = in->readString();
|
||||
switch((int)c){
|
||||
case 0:
|
||||
setRenderBinDetails(num, name, osg::StateSet::INHERIT_RENDERBIN_DETAILS);
|
||||
break;
|
||||
case 1:
|
||||
setRenderBinDetails(num, name, osg::StateSet::USE_RENDERBIN_DETAILS);
|
||||
break;
|
||||
case 2:
|
||||
setRenderBinDetails(num, name, osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
|
||||
break;
|
||||
case 3:
|
||||
setRenderBinDetails(num, name, osg::StateSet::ENCLOSE_RENDERBIN_DETAILS);
|
||||
break;
|
||||
default: throw Exception("Unkown RenderBinMode in StateSet::read()");
|
||||
}
|
||||
|
||||
// Read stateset modes.
|
||||
int size = in->readInt();
|
||||
int i;
|
||||
for(i=0;i<size;i++){
|
||||
int mode = in->readInt();
|
||||
int value = in->readInt();
|
||||
setMode((osg::StateAttribute::GLMode)mode, (osg::StateAttribute::GLModeValue)value);
|
||||
}
|
||||
|
||||
// Read state attributes
|
||||
size = in->readInt();
|
||||
for(i=0;i<size;i++){
|
||||
osg::StateAttribute* attribute;
|
||||
int attributeID = in->peekInt();
|
||||
if(attributeID == IVEBLENDFUNC){
|
||||
attribute = new osg::BlendFunc();
|
||||
((ive::BlendFunc*)(attribute))->read(in);
|
||||
setAttribute(attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVEMATERIAL){
|
||||
attribute = new osg::Material();
|
||||
((ive::Material*)(attribute))->read(in);
|
||||
setAttribute(attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVECULLFACE){
|
||||
attribute = new osg::CullFace();
|
||||
((ive::CullFace*)(attribute))->read(in);
|
||||
setAttribute(attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Unkown StateAttribute in StateSet::read()");
|
||||
}
|
||||
}
|
||||
|
||||
// Read texture stateset mode.
|
||||
int nUnits = in->readInt();
|
||||
int unit;
|
||||
for(unit=0;unit<nUnits;unit++){
|
||||
size = in->readInt();
|
||||
for(i=0;i<size;i++){
|
||||
int mode = in->readInt();
|
||||
int value = in->readInt();
|
||||
setTextureMode(unit,(osg::StateAttribute::GLMode)mode, (osg::StateAttribute::GLModeValue)value);
|
||||
}
|
||||
}
|
||||
|
||||
// Read texture attributes.
|
||||
nUnits = in->readInt();
|
||||
for(unit=0;unit<nUnits;unit++){
|
||||
size = in->readInt();
|
||||
for(i=0;i<size;i++){
|
||||
osg::StateAttribute* attribute;
|
||||
int attributeID = in->peekInt();
|
||||
if(attributeID == IVETEXTURE2D){
|
||||
attribute = new osg::Texture2D();
|
||||
((ive::Texture2D*)(attribute))->read(in);
|
||||
setTextureAttribute(unit, attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVETEXTURECUBEMAP){
|
||||
attribute = new osg::TextureCubeMap();
|
||||
((ive::TextureCubeMap*)(attribute))->read(in);
|
||||
setTextureAttribute(unit, attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVETEXENV){
|
||||
attribute = new osg::TexEnv();
|
||||
((ive::TexEnv*)(attribute))->read(in);
|
||||
setTextureAttribute(unit, attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVETEXENVCOMBINE){
|
||||
attribute = new osg::TexEnvCombine();
|
||||
((ive::TexEnvCombine*)(attribute))->read(in);
|
||||
setTextureAttribute(unit, attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else if(attributeID == IVETEXGEN){
|
||||
attribute = new osg::TexGen();
|
||||
((ive::TexGen*)(attribute))->read(in);
|
||||
setTextureAttribute(unit, attribute, (osg::StateAttribute::OverrideValue)in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Unkown Texture StateAttribute in StateSet::read()");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("StateSet::read(): Expected StateSet identification");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/StateSet.h
Normal file
15
src/osgPlugins/ive/StateSet.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_STATESET
|
||||
#define IVE_STATESET 1
|
||||
|
||||
#include <osg/StateSet>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT StateSet : public ReadWrite, public osg::StateSet{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* out);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
62
src/osgPlugins/ive/TexEnv.cpp
Normal file
62
src/osgPlugins/ive/TexEnv.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: TexEnv.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::TexEnv in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "TexEnv.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void TexEnv::write(DataOutputStream* out){
|
||||
// Write TexEnv's identification.
|
||||
out->writeInt(IVETEXENV);
|
||||
// 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("TexEnv::write(): Could not cast this osg::TexEnv to an osg::Object.");
|
||||
// Write TexEnv's properties.
|
||||
|
||||
// Write mode
|
||||
out->writeInt(getMode());
|
||||
// Write color
|
||||
out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void TexEnv::read(DataInputStream* in){
|
||||
// Peek on TexEnv's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXENV){
|
||||
// Read TexEnv'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("TexEnv::read(): Could not cast this osg::TexEnv to an osg::Object.");
|
||||
// Read TexEnv's properties
|
||||
|
||||
// Read mode
|
||||
setMode((osg::TexEnv::Mode)in->readInt());
|
||||
// Read color
|
||||
setColor(in->readVec4());
|
||||
}
|
||||
else{
|
||||
throw Exception("TexEnv::read(): Expected TexEnv identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/TexEnv.h
Normal file
15
src/osgPlugins/ive/TexEnv.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXENV
|
||||
#define IVE_TEXENV 1
|
||||
|
||||
#include <osg/TexEnv>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT TexEnv : public osg::TexEnv, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
98
src/osgPlugins/ive/TexEnvCombine.cpp
Normal file
98
src/osgPlugins/ive/TexEnvCombine.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: TexEnvCombine.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::TexEnvCombine in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "TexEnvCombine.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void TexEnvCombine::write(DataOutputStream* out){
|
||||
// Write TexEnvCombine's identification.
|
||||
out->writeInt(IVETEXENVCOMBINE);
|
||||
// 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("TexEnvCombine::write(): Could not cast this osg::TexEnvCombine to an osg::Object.");
|
||||
// Write TexEnvCombine's properties.
|
||||
|
||||
// Write combine method
|
||||
out->writeInt(getCombine_RGB());
|
||||
out->writeInt(getCombine_Alpha());
|
||||
// Write source params
|
||||
out->writeInt(getSource0_RGB());
|
||||
out->writeInt(getSource1_RGB());
|
||||
out->writeInt(getSource2_RGB());
|
||||
out->writeInt(getSource0_Alpha());
|
||||
out->writeInt(getSource1_Alpha());
|
||||
out->writeInt(getSource2_Alpha());
|
||||
// Write operand params
|
||||
out->writeInt(getOperand0_RGB());
|
||||
out->writeInt(getOperand1_RGB());
|
||||
out->writeInt(getOperand2_RGB());
|
||||
out->writeInt(getOperand0_Alpha());
|
||||
out->writeInt(getOperand1_Alpha());
|
||||
out->writeInt(getOperand2_Alpha());
|
||||
// Write scale and constant color
|
||||
out->writeFloat(getScale_RGB());
|
||||
out->writeFloat(getScale_Alpha());
|
||||
out->writeVec4(getConstantColor());
|
||||
|
||||
}
|
||||
|
||||
void TexEnvCombine::read(DataInputStream* in){
|
||||
// Peek on TexEnvCombine's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXENVCOMBINE){
|
||||
// Read TexEnvCombine'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("TexEnvCombine::read(): Could not cast this osg::TexEnvCombine to an osg::Object.");
|
||||
// Read TexEnvCombine's properties
|
||||
|
||||
// Read combine method
|
||||
setCombine_RGB((GLint)in->readInt());
|
||||
setCombine_Alpha((GLint)in->readInt());
|
||||
// Read combine source
|
||||
setSource0_RGB((GLint)in->readInt());
|
||||
setSource1_RGB((GLint)in->readInt());
|
||||
setSource2_RGB((GLint)in->readInt());
|
||||
setSource0_Alpha((GLint)in->readInt());
|
||||
setSource1_Alpha((GLint)in->readInt());
|
||||
setSource2_Alpha((GLint)in->readInt());
|
||||
// read combine params
|
||||
setOperand0_RGB((GLint)in->readInt());
|
||||
setOperand1_RGB((GLint)in->readInt());
|
||||
setOperand2_RGB((GLint)in->readInt());
|
||||
setOperand0_Alpha((GLint)in->readInt());
|
||||
setOperand1_Alpha((GLint)in->readInt());
|
||||
setOperand2_Alpha((GLint)in->readInt());
|
||||
// Read scale and constant color
|
||||
setScale_RGB(in->readFloat());
|
||||
setScale_Alpha(in->readFloat());
|
||||
setConstantColor(in->readVec4());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("TexEnvCombine::read(): Expected TexEnvCombine identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/TexEnvCombine.h
Normal file
15
src/osgPlugins/ive/TexEnvCombine.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXENVCOMBINE
|
||||
#define IVE_TEXENVCOMBINE 1
|
||||
|
||||
#include <osg/TexEnvCombine>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT TexEnvCombine : public osg::TexEnvCombine, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
59
src/osgPlugins/ive/TexGen.cpp
Normal file
59
src/osgPlugins/ive/TexGen.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: TexGen.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::TexGen in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "TexGen.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void TexGen::write(DataOutputStream* out){
|
||||
// Write TexGen's identification.
|
||||
out->writeInt(IVETEXGEN);
|
||||
// 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("TexGen::write(): Could not cast this osg::TexGen to an osg::Object.");
|
||||
// Write TexGen's properties.
|
||||
|
||||
// Write mode
|
||||
out->writeInt(getMode());
|
||||
|
||||
// Notice no support for planes yet
|
||||
}
|
||||
|
||||
void TexGen::read(DataInputStream* in){
|
||||
// Peek on TexGen's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXGEN){
|
||||
// Read TexGen'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("TexGen::read(): Could not cast this osg::TexGen to an osg::Object.");
|
||||
// Read TexGen's properties
|
||||
setMode((osg::TexGen::Mode)in->readInt());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("TexGen::read(): Expected TexGen identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/TexGen.h
Normal file
15
src/osgPlugins/ive/TexGen.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXGEN
|
||||
#define IVE_TEXGEN 1
|
||||
|
||||
#include <osg/TexGen>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT TexGen : public osg::TexGen, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
79
src/osgPlugins/ive/Texture.cpp
Normal file
79
src/osgPlugins/ive/Texture.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Texture.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Texture in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Texture.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Texture::write(DataOutputStream* out){
|
||||
// Write Texture's identification.
|
||||
out->writeInt(IVETEXTURE);
|
||||
// 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("Texture::write(): Could not cast this osg::Texture to an osg::Object.");
|
||||
// Write Texture's properties.
|
||||
out->writeInt(_wrap_s);
|
||||
out->writeInt(_wrap_t);
|
||||
out->writeInt(_wrap_r);
|
||||
|
||||
out->writeInt(_min_filter);
|
||||
out->writeInt(_mag_filter);
|
||||
out->writeFloat(_maxAnisotropy);
|
||||
|
||||
out->writeVec4(_borderColor);
|
||||
|
||||
out->writeInt(_internalFormatMode);
|
||||
|
||||
// out->writeInt(_internalFormat);
|
||||
}
|
||||
|
||||
void Texture::read(DataInputStream* in){
|
||||
// Read Texture's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXTURE){
|
||||
// Read Texture'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("Texture::read(): Could not cast this osg::Texture to an osg::Object.");
|
||||
|
||||
// Read properties
|
||||
_wrap_s = (osg::Texture::WrapMode)in->readInt();
|
||||
_wrap_t = (osg::Texture::WrapMode)in->readInt();;
|
||||
_wrap_r = (osg::Texture::WrapMode)in->readInt();;
|
||||
|
||||
_min_filter = (osg::Texture::FilterMode)in->readInt();;
|
||||
_mag_filter = (osg::Texture::FilterMode)in->readInt();;
|
||||
_maxAnisotropy = in->readFloat();;
|
||||
|
||||
_borderColor = in->readVec4();;
|
||||
|
||||
_internalFormatMode = (osg::Texture::InternalFormatMode)in->readInt();;
|
||||
// _internalFormat = in->readInt();;
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("Texture::read(): Expected Texture identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Texture.h
Normal file
15
src/osgPlugins/ive/Texture.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXTURE
|
||||
#define IVE_TEXTURE 1
|
||||
|
||||
#include <osg/Texture>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Texture : public osg::Texture, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
97
src/osgPlugins/ive/Texture2D.cpp
Normal file
97
src/osgPlugins/ive/Texture2D.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Texture2D.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Texture2D in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 20.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Texture2D.h"
|
||||
#include "Texture.h"
|
||||
#include "Image.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Texture2D::write(DataOutputStream* out){
|
||||
// Write Texture2D's identification.
|
||||
out->writeInt(IVETEXTURE2D);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
|
||||
if(tex){
|
||||
((ive::Texture*)(tex))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Texture2D::write(): Could not cast this osg::Texture2D to an osg::Texture.");
|
||||
// Write Texture2D's properties.
|
||||
// Write image.
|
||||
|
||||
// Should we include images date in stream
|
||||
bool includeImg = out->getIncludeImageData();
|
||||
out->writeBool(includeImg);
|
||||
|
||||
// Include image data in stream
|
||||
if(includeImg){
|
||||
out->writeInt((int)getImage());
|
||||
if(getImage())
|
||||
((ive::Image*)getImage())->write(out);
|
||||
}
|
||||
// Only include image name in stream
|
||||
else{
|
||||
if (getImage() && !(getImage()->getFileName().empty())){
|
||||
out->writeString(getImage()->getFileName());
|
||||
}
|
||||
else{
|
||||
out->writeString("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Texture2D::read(DataInputStream* in){
|
||||
// Read Texture2D's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXTURE2D){
|
||||
// Code to read Texture2D's properties.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
|
||||
if(tex){
|
||||
((ive::Texture*)(tex))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Texture2D::read(): Could not cast this osg::Texture2D to an osg::Texture.");
|
||||
// Read image.
|
||||
|
||||
// Should we read image data from stream
|
||||
bool includeImg = in->readBool();
|
||||
|
||||
// Read image data from stream
|
||||
if(includeImg){
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)image)->read(in);
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
// Only read image name from stream.
|
||||
else{
|
||||
std::string filename = in->readString();
|
||||
if(filename.compare("")!=0){
|
||||
osg::Image* image = in->readImage(filename);
|
||||
if (image){
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Texture2D::read(): Expected Texture2D identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Texture2D.h
Normal file
15
src/osgPlugins/ive/Texture2D.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXTURE2D
|
||||
#define IVE_TEXTURE2D 1
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Texture2D : public osg::Texture2D, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
129
src/osgPlugins/ive/TextureCubeMap.cpp
Normal file
129
src/osgPlugins/ive/TextureCubeMap.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: TextureCubeMap.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::TextureCubeMap in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "Texture.h"
|
||||
#include "Image.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void TextureCubeMap::write(DataOutputStream* out){
|
||||
// Write TextureCubeMap's identification.
|
||||
out->writeInt(IVETEXTURECUBEMAP);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
|
||||
if(tex){
|
||||
((ive::Texture*)(tex))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("TextureCubeMap::write(): Could not cast this osg::TextureCubeMap to an osg::Texture.");
|
||||
// Write TextureCubeMap's properties.
|
||||
|
||||
// Write texture size
|
||||
int width,height;
|
||||
getTextureSize(width, height);
|
||||
out->writeInt(width);
|
||||
out->writeInt(height);
|
||||
|
||||
// Write number of mipmap levels
|
||||
out->writeInt(getNumMipmapLevels());
|
||||
|
||||
// Write images if any
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::POSITIVE_X));
|
||||
if(getImage(osg::TextureCubeMap::POSITIVE_X))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::POSITIVE_X)))->write(out);
|
||||
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::NEGATIVE_X));
|
||||
if(getImage(osg::TextureCubeMap::NEGATIVE_X))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::NEGATIVE_X)))->write(out);
|
||||
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::POSITIVE_Y));
|
||||
if(getImage(osg::TextureCubeMap::POSITIVE_Y))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::POSITIVE_Y)))->write(out);
|
||||
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::NEGATIVE_Y));
|
||||
if(getImage(osg::TextureCubeMap::NEGATIVE_Y))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::NEGATIVE_Y)))->write(out);
|
||||
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::POSITIVE_Z));
|
||||
if(getImage(osg::TextureCubeMap::POSITIVE_Z))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::POSITIVE_Z)))->write(out);
|
||||
|
||||
out->writeInt((int)getImage(osg::TextureCubeMap::NEGATIVE_Z));
|
||||
if(getImage(osg::TextureCubeMap::NEGATIVE_Z))
|
||||
((ive::Image*)(getImage(osg::TextureCubeMap::NEGATIVE_Z)))->write(out);
|
||||
|
||||
}
|
||||
|
||||
void TextureCubeMap::read(DataInputStream* in){
|
||||
// Peek on TextureCubeMap's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXTURECUBEMAP){
|
||||
// Read TextureCubeMap's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
|
||||
if(tex){
|
||||
((ive::Texture*)(tex))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("TextureCubeMap::read(): Could not cast this osg::TextureCubeMap to an osg::Texture.");
|
||||
// Read TextureCubeMap's properties
|
||||
|
||||
// Read texture size
|
||||
int width = in->readInt();
|
||||
int height = in->readInt();
|
||||
setTextureSize(width, height);
|
||||
|
||||
// Read number of mipmap levels
|
||||
setNumMipmapLevels((unsigned int)in->readInt());
|
||||
|
||||
// Read images if any
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::POSITIVE_X, image);
|
||||
}
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::NEGATIVE_X, image);
|
||||
}
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::POSITIVE_Y, image);
|
||||
}
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::NEGATIVE_Y, image);
|
||||
}
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::POSITIVE_Z, image);
|
||||
}
|
||||
if(in->readInt()){
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)(image))->read(in);
|
||||
setImage(osg::TextureCubeMap::NEGATIVE_Z, image);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("TextureCubeMap::read(): Expected TextureCubeMap identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/TextureCubeMap.h
Normal file
15
src/osgPlugins/ive/TextureCubeMap.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXTURECUBEMAP
|
||||
#define IVE_TEXTURECUBEMAP 1
|
||||
|
||||
#include <osg/TextureCubeMap>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT TextureCubeMap : public osg::TextureCubeMap, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
54
src/osgPlugins/ive/Transform.cpp
Normal file
54
src/osgPlugins/ive/Transform.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Transform.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Transform in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 25.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Transform.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Transform::write(DataOutputStream* out){
|
||||
// Write Transform's identification.
|
||||
out->writeInt(IVETRANSFORM);
|
||||
// If the osg 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("Transform::write(): Could not cast this osg::Transform to an osg::Group.");
|
||||
// Write Transform's properties.
|
||||
out->writeInt(getReferenceFrame());
|
||||
}
|
||||
|
||||
void Transform::read(DataInputStream* in){
|
||||
// Peek on Transform's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETRANSFORM){
|
||||
// Read Transform's identification.
|
||||
id = in->readInt();
|
||||
// If the osg 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("Transform::read(): Could not cast this osg::Transform to an osg::Group.");
|
||||
// Read Transform's properties
|
||||
setReferenceFrame((osg::Transform::ReferenceFrame)in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Transform::read(): Expected Transform identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Transform.h
Normal file
15
src/osgPlugins/ive/Transform.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TRANSFORM
|
||||
#define IVE_TRANSFORM 1
|
||||
|
||||
#include <osg/Transform>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT Transform : public osg::Transform, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
52
src/osgPlugins/ive/ViewPoint.cpp
Normal file
52
src/osgPlugins/ive/ViewPoint.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: ViewPoint.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::ViewPoint in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 24.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "ViewPoint.h"
|
||||
#include "PositionAttitudeTransform.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void ViewPoint::write(DataOutputStream* out){
|
||||
// Write ViewPoint's identification.
|
||||
out->writeInt(IVEVIEWPOINT);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*>(this);
|
||||
if(pat){
|
||||
((ive::PositionAttitudeTransform*)(pat))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("ViewPoint::write(): Could not cast this osg::ViewPoint to an osg::PositionAttitudeTransform.");
|
||||
// Write ViewPoint's properties.
|
||||
}
|
||||
|
||||
void ViewPoint::read(DataInputStream* in){
|
||||
// Peek on ViewPoint's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEVIEWPOINT){
|
||||
// Read ViewPoint's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*>(this);
|
||||
if(pat){
|
||||
((ive::PositionAttitudeTransform*)(pat))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("ViewPoint::read(): Could not cast this osg::ViewPoint to an osg::PositionAttitudeTransform.");
|
||||
// Read ViewPoint's properties
|
||||
}
|
||||
else{
|
||||
throw Exception("ViewPoint::read(): Expected ViewPoint identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/ViewPoint.h
Normal file
15
src/osgPlugins/ive/ViewPoint.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_VIEWPOINT
|
||||
#define IVE_VIEWPOINT 1
|
||||
|
||||
#include <osgfIVE/ViewPoint>
|
||||
#include <ive/ReadWrite.h>
|
||||
|
||||
namespace ive{
|
||||
class IVE_EXPORT ViewPoint : public osgfIVE::ViewPoint, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user