From 5408077c3be0a87e88890303fec8db8578b0a782 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 May 2003 19:51:12 +0000 Subject: [PATCH] Added ive reader/writer - from Rune Schmidt Jensen/Michael Gronager --- Make/makedirdefs | 3 +- VisualStudio/VisualStudio.dsw | 18 + VisualStudio/osgPlugins/ive/ive.dsp | 389 ++++++++++++++++++ examples/osgviewer/osgviewer.cpp | 7 + src/osgPlugins/ive/AnimationPath.cpp | 76 ++++ src/osgPlugins/ive/AnimationPath.h | 15 + src/osgPlugins/ive/AnimationPathCallback.cpp | 73 ++++ src/osgPlugins/ive/AnimationPathCallback.h | 15 + src/osgPlugins/ive/Billboard.cpp | 78 ++++ src/osgPlugins/ive/Billboard.h | 15 + src/osgPlugins/ive/BlendFunc.cpp | 63 +++ src/osgPlugins/ive/BlendFunc.h | 15 + src/osgPlugins/ive/CullFace.cpp | 54 +++ src/osgPlugins/ive/CullFace.h | 15 + src/osgPlugins/ive/DataInputStream.cpp | 326 +++++++++++++++ src/osgPlugins/ive/DataInputStream.h | 82 ++++ src/osgPlugins/ive/DataOutputStream.cpp | 252 ++++++++++++ src/osgPlugins/ive/DataOutputStream.h | 74 ++++ src/osgPlugins/ive/DataTypeSize.h | 16 + src/osgPlugins/ive/DrawArrayLengths.cpp | 70 ++++ src/osgPlugins/ive/DrawArrayLengths.h | 15 + src/osgPlugins/ive/DrawArrays.cpp | 60 +++ src/osgPlugins/ive/DrawArrays.h | 15 + src/osgPlugins/ive/DrawElementsUShort.cpp | 64 +++ src/osgPlugins/ive/DrawElementsUShort.h | 15 + src/osgPlugins/ive/Drawable.cpp | 93 +++++ src/osgPlugins/ive/Drawable.h | 15 + src/osgPlugins/ive/Exception.cpp | 23 ++ src/osgPlugins/ive/Exception.h | 20 + src/osgPlugins/ive/Export.h | 41 ++ src/osgPlugins/ive/GNUmakefile | 47 +++ src/osgPlugins/ive/Geode.cpp | 86 ++++ src/osgPlugins/ive/Geode.h | 15 + src/osgPlugins/ive/Geometry.cpp | 231 +++++++++++ src/osgPlugins/ive/Geometry.h | 15 + src/osgPlugins/ive/Group.cpp | 165 ++++++++ src/osgPlugins/ive/Group.h | 15 + src/osgPlugins/ive/Image.cpp | 121 ++++++ src/osgPlugins/ive/Image.h | 15 + src/osgPlugins/ive/LOD.cpp | 74 ++++ src/osgPlugins/ive/LOD.h | 15 + src/osgPlugins/ive/Light.cpp | 75 ++++ src/osgPlugins/ive/Light.h | 15 + src/osgPlugins/ive/LightSource.cpp | 72 ++++ src/osgPlugins/ive/LightSource.h | 15 + src/osgPlugins/ive/Material.cpp | 98 +++++ src/osgPlugins/ive/Material.h | 15 + src/osgPlugins/ive/MatrixTransform.cpp | 58 +++ src/osgPlugins/ive/MatrixTransform.h | 15 + src/osgPlugins/ive/Node.cpp | 106 +++++ src/osgPlugins/ive/Node.h | 16 + src/osgPlugins/ive/Object.cpp | 47 +++ src/osgPlugins/ive/Object.h | 18 + .../ive/PositionAttitudeTransform.cpp | 60 +++ .../ive/PositionAttitudeTransform.h | 15 + src/osgPlugins/ive/PrimitiveSet.cpp | 58 +++ src/osgPlugins/ive/PrimitiveSet.h | 15 + src/osgPlugins/ive/ReadWrite.h | 66 +++ src/osgPlugins/ive/ReaderWriterIVE.cpp | 86 ++++ src/osgPlugins/ive/Sequence.cpp | 91 ++++ src/osgPlugins/ive/Sequence.h | 15 + src/osgPlugins/ive/StateSet.cpp | 266 ++++++++++++ src/osgPlugins/ive/StateSet.h | 15 + src/osgPlugins/ive/TexEnv.cpp | 62 +++ src/osgPlugins/ive/TexEnv.h | 15 + src/osgPlugins/ive/TexEnvCombine.cpp | 98 +++++ src/osgPlugins/ive/TexEnvCombine.h | 15 + src/osgPlugins/ive/TexGen.cpp | 59 +++ src/osgPlugins/ive/TexGen.h | 15 + src/osgPlugins/ive/Texture.cpp | 79 ++++ src/osgPlugins/ive/Texture.h | 15 + src/osgPlugins/ive/Texture2D.cpp | 97 +++++ src/osgPlugins/ive/Texture2D.h | 15 + src/osgPlugins/ive/TextureCubeMap.cpp | 129 ++++++ src/osgPlugins/ive/TextureCubeMap.h | 15 + src/osgPlugins/ive/Transform.cpp | 54 +++ src/osgPlugins/ive/Transform.h | 15 + src/osgPlugins/ive/ViewPoint.cpp | 52 +++ src/osgPlugins/ive/ViewPoint.h | 15 + 79 files changed, 4802 insertions(+), 1 deletion(-) create mode 100755 VisualStudio/osgPlugins/ive/ive.dsp create mode 100644 src/osgPlugins/ive/AnimationPath.cpp create mode 100644 src/osgPlugins/ive/AnimationPath.h create mode 100644 src/osgPlugins/ive/AnimationPathCallback.cpp create mode 100644 src/osgPlugins/ive/AnimationPathCallback.h create mode 100644 src/osgPlugins/ive/Billboard.cpp create mode 100644 src/osgPlugins/ive/Billboard.h create mode 100644 src/osgPlugins/ive/BlendFunc.cpp create mode 100644 src/osgPlugins/ive/BlendFunc.h create mode 100644 src/osgPlugins/ive/CullFace.cpp create mode 100644 src/osgPlugins/ive/CullFace.h create mode 100644 src/osgPlugins/ive/DataInputStream.cpp create mode 100644 src/osgPlugins/ive/DataInputStream.h create mode 100644 src/osgPlugins/ive/DataOutputStream.cpp create mode 100644 src/osgPlugins/ive/DataOutputStream.h create mode 100644 src/osgPlugins/ive/DataTypeSize.h create mode 100644 src/osgPlugins/ive/DrawArrayLengths.cpp create mode 100644 src/osgPlugins/ive/DrawArrayLengths.h create mode 100644 src/osgPlugins/ive/DrawArrays.cpp create mode 100644 src/osgPlugins/ive/DrawArrays.h create mode 100644 src/osgPlugins/ive/DrawElementsUShort.cpp create mode 100644 src/osgPlugins/ive/DrawElementsUShort.h create mode 100644 src/osgPlugins/ive/Drawable.cpp create mode 100644 src/osgPlugins/ive/Drawable.h create mode 100644 src/osgPlugins/ive/Exception.cpp create mode 100644 src/osgPlugins/ive/Exception.h create mode 100644 src/osgPlugins/ive/Export.h create mode 100644 src/osgPlugins/ive/GNUmakefile create mode 100644 src/osgPlugins/ive/Geode.cpp create mode 100644 src/osgPlugins/ive/Geode.h create mode 100644 src/osgPlugins/ive/Geometry.cpp create mode 100644 src/osgPlugins/ive/Geometry.h create mode 100644 src/osgPlugins/ive/Group.cpp create mode 100644 src/osgPlugins/ive/Group.h create mode 100644 src/osgPlugins/ive/Image.cpp create mode 100644 src/osgPlugins/ive/Image.h create mode 100644 src/osgPlugins/ive/LOD.cpp create mode 100644 src/osgPlugins/ive/LOD.h create mode 100644 src/osgPlugins/ive/Light.cpp create mode 100644 src/osgPlugins/ive/Light.h create mode 100644 src/osgPlugins/ive/LightSource.cpp create mode 100644 src/osgPlugins/ive/LightSource.h create mode 100644 src/osgPlugins/ive/Material.cpp create mode 100644 src/osgPlugins/ive/Material.h create mode 100644 src/osgPlugins/ive/MatrixTransform.cpp create mode 100644 src/osgPlugins/ive/MatrixTransform.h create mode 100644 src/osgPlugins/ive/Node.cpp create mode 100644 src/osgPlugins/ive/Node.h create mode 100644 src/osgPlugins/ive/Object.cpp create mode 100644 src/osgPlugins/ive/Object.h create mode 100644 src/osgPlugins/ive/PositionAttitudeTransform.cpp create mode 100644 src/osgPlugins/ive/PositionAttitudeTransform.h create mode 100644 src/osgPlugins/ive/PrimitiveSet.cpp create mode 100644 src/osgPlugins/ive/PrimitiveSet.h create mode 100644 src/osgPlugins/ive/ReadWrite.h create mode 100644 src/osgPlugins/ive/ReaderWriterIVE.cpp create mode 100644 src/osgPlugins/ive/Sequence.cpp create mode 100644 src/osgPlugins/ive/Sequence.h create mode 100644 src/osgPlugins/ive/StateSet.cpp create mode 100644 src/osgPlugins/ive/StateSet.h create mode 100644 src/osgPlugins/ive/TexEnv.cpp create mode 100644 src/osgPlugins/ive/TexEnv.h create mode 100644 src/osgPlugins/ive/TexEnvCombine.cpp create mode 100644 src/osgPlugins/ive/TexEnvCombine.h create mode 100644 src/osgPlugins/ive/TexGen.cpp create mode 100644 src/osgPlugins/ive/TexGen.h create mode 100644 src/osgPlugins/ive/Texture.cpp create mode 100644 src/osgPlugins/ive/Texture.h create mode 100644 src/osgPlugins/ive/Texture2D.cpp create mode 100644 src/osgPlugins/ive/Texture2D.h create mode 100644 src/osgPlugins/ive/TextureCubeMap.cpp create mode 100644 src/osgPlugins/ive/TextureCubeMap.h create mode 100644 src/osgPlugins/ive/Transform.cpp create mode 100644 src/osgPlugins/ive/Transform.h create mode 100644 src/osgPlugins/ive/ViewPoint.cpp create mode 100644 src/osgPlugins/ive/ViewPoint.h diff --git a/Make/makedirdefs b/Make/makedirdefs index aac681e5a..0fc7f6020 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -45,7 +45,8 @@ PLUGIN_DIRS = \ tga\ tgz\ txp\ - zip + zip\ + ive # 3dc\ diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw index 1cbaac55b..6c0c2e8a4 100644 --- a/VisualStudio/VisualStudio.dsw +++ b/VisualStudio/VisualStudio.dsw @@ -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> diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp new file mode 100755 index 000000000..519fb9321 --- /dev/null +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -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 diff --git a/examples/osgviewer/osgviewer.cpp b/examples/osgviewer/osgviewer.cpp index 92073f9b3..01fedc6bd 100644 --- a/examples/osgviewer/osgviewer.cpp +++ b/examples/osgviewer/osgviewer.cpp @@ -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 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 = "<writeInt(IVEANIMATIONPATH); + // If the osg class is inherited by any other class we should also write this to file. + osg::Object* obj = dynamic_cast(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(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;ireadFloat(); + 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."); + } +} diff --git a/src/osgPlugins/ive/AnimationPath.h b/src/osgPlugins/ive/AnimationPath.h new file mode 100644 index 000000000..fa5dba806 --- /dev/null +++ b/src/osgPlugins/ive/AnimationPath.h @@ -0,0 +1,15 @@ +#ifndef IVE_ANIMATIONPATH +#define IVE_ANIMATIONPATH 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT AnimationPath : public osg::AnimationPath, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/AnimationPathCallback.cpp b/src/osgPlugins/ive/AnimationPathCallback.cpp new file mode 100644 index 000000000..cac929188 --- /dev/null +++ b/src/osgPlugins/ive/AnimationPathCallback.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/AnimationPathCallback.h b/src/osgPlugins/ive/AnimationPathCallback.h new file mode 100644 index 000000000..98961902b --- /dev/null +++ b/src/osgPlugins/ive/AnimationPathCallback.h @@ -0,0 +1,15 @@ +#ifndef IVE_ANIMATIONPATHCALLBACK +#define IVE_ANIMATIONPATHCALLBACK 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT AnimationPathCallback : public osg::AnimationPathCallback, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Billboard.cpp b/src/osgPlugins/ive/Billboard.cpp new file mode 100644 index 000000000..de4ae0e23 --- /dev/null +++ b/src/osgPlugins/ive/Billboard.cpp @@ -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(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;iwriteVec3(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(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;ireadVec3()); + } + + } + else{ + throw Exception("Billboard::read(): Expected Billboard identification."); + } +} diff --git a/src/osgPlugins/ive/Billboard.h b/src/osgPlugins/ive/Billboard.h new file mode 100644 index 000000000..a57720340 --- /dev/null +++ b/src/osgPlugins/ive/Billboard.h @@ -0,0 +1,15 @@ +#ifndef IVE_BILLBOARD +#define IVE_BILLBOARD 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Billboard : public osg::Billboard, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/BlendFunc.cpp b/src/osgPlugins/ive/BlendFunc.cpp new file mode 100644 index 000000000..74c6ee7d3 --- /dev/null +++ b/src/osgPlugins/ive/BlendFunc.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/BlendFunc.h b/src/osgPlugins/ive/BlendFunc.h new file mode 100644 index 000000000..76e964ca8 --- /dev/null +++ b/src/osgPlugins/ive/BlendFunc.h @@ -0,0 +1,15 @@ +#ifndef IVE_BLENDFUNC +#define IVE_BLENDFUNC 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT BlendFunc : public osg::BlendFunc, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/CullFace.cpp b/src/osgPlugins/ive/CullFace.cpp new file mode 100644 index 000000000..66e1f5ff9 --- /dev/null +++ b/src/osgPlugins/ive/CullFace.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/CullFace.h b/src/osgPlugins/ive/CullFace.h new file mode 100644 index 000000000..41d6d134f --- /dev/null +++ b/src/osgPlugins/ive/CullFace.h @@ -0,0 +1,15 @@ +#ifndef IVE_CULLFACE +#define IVE_CULLFACE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT CullFace : public osg::CullFace, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp new file mode 100644 index 000000000..848bedf95 --- /dev/null +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -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 + +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; ipush_back(readInt()); + } + return a; +} + +osg::UByteArray* DataInputStream::readUByteArray(){ + int size = readInt(); + osg::UByteArray* a = new osg::UByteArray(); + a->reserve(size); + for(int i =0; ipush_back(readChar()); + } + return a; +} + +osg::UShortArray* DataInputStream::readUShortArray(){ + int size = readInt(); + osg::UShortArray* a = new osg::UShortArray(); + a->reserve(size); + for(int i =0; ipush_back(readUShort()); + } + return a; +} + +osg::UIntArray* DataInputStream::readUIntArray(){ + int size = readInt(); + osg::UIntArray* a = new osg::UIntArray(); + a->reserve(size); + for(int i =0; ipush_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; ipush_back(readUByte4()); + } + return a; +} + +osg::FloatArray* DataInputStream::readFloatArray(){ + int size = readInt(); + osg::FloatArray* a = new osg::FloatArray(); + a->reserve(size); + for(int i =0; ipush_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; +} diff --git a/src/osgPlugins/ive/DataInputStream.h b/src/osgPlugins/ive/DataInputStream.h new file mode 100644 index 000000000..896deb57e --- /dev/null +++ b/src/osgPlugins/ive/DataInputStream.h @@ -0,0 +1,82 @@ +#ifndef IVE_DATAINPUTSTREAM +#define IVE_DATAINPUTSTREAM 1 + + +#include // for ifstream +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DataTypeSize.h" +#include "Export.h" +#include "Exception.h" + + +#include +#include +#include + +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 > ImagePair; + typedef std::vector ImageList; + + // Container to map stateset id to their respective stateset. + typedef std::pair > StateSetPair; + typedef std::vector StateSetList; + + +private: + std::istream* _istream; + int _version; + bool _peeking; + int _peekValue; + ImageList _imageList; + StateSetList _statesetList; +}; + +} +#endif // IVE_DATAINPUTSTREAM diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp new file mode 100644 index 000000000..69774a2e3 --- /dev/null +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -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(a)); + break; + case osg::Array::UByteArrayType: + writeChar((char)1); + writeUByteArray(static_cast(a)); + break; + case osg::Array::UShortArrayType: + writeChar((char)2); + writeUShortArray(static_cast(a)); + break; + case osg::Array::UIntArrayType: + writeChar((char)3); + writeUIntArray(static_cast(a)); + break; + case osg::Array::UByte4ArrayType: + writeChar((char)4); + writeUByte4Array(static_cast(a)); + break; + case osg::Array::FloatArrayType: + writeChar((char)5); + writeFloatArray(static_cast(a)); + break; + case osg::Array::Vec2ArrayType: + writeChar((char)6); + writeVec2Array(static_cast(a)); + break; + case osg::Array::Vec3ArrayType: + writeChar((char)7); + writeVec3Array(static_cast(a)); + break; + case osg::Array::Vec4ArrayType: + writeChar((char)8); + writeVec4Array(static_cast(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; iindex(i)); + } +} + +void DataOutputStream::writeUByteArray(osg::UByteArray* a){ + int size = a->getNumElements(); + writeInt(size); + for(int i =0; igetNumElements(); + writeInt(size); + for(int i =0; igetNumElements(); + writeInt(size); + for(int i =0; igetNumElements(); + writeInt(size); + for(int i =0; igetNumElements(); + writeInt(size); + for(int i =0; isize(); + writeInt(size); + for(int i=0;isize(); + 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 // for ofstream +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Export.h" +#include "DataTypeSize.h" +#include "Exception.h" + +#include +#include + +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 StateSetList; + StateSetList _statesetList; + + bool _includeImageData; + +}; + +} +#endif // IVE_DATAOUTPUTSTREAM diff --git a/src/osgPlugins/ive/DataTypeSize.h b/src/osgPlugins/ive/DataTypeSize.h new file mode 100644 index 000000000..4abc819cf --- /dev/null +++ b/src/osgPlugins/ive/DataTypeSize.h @@ -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 \ No newline at end of file diff --git a/src/osgPlugins/ive/DrawArrayLengths.cpp b/src/osgPlugins/ive/DrawArrayLengths.cpp new file mode 100644 index 000000000..38df2d2e4 --- /dev/null +++ b/src/osgPlugins/ive/DrawArrayLengths.cpp @@ -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(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; iwriteInt(((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(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; ireadInt()); + } + + } + else{ + throw Exception("DrawArrayLengths::read(): Expected DrawArrayLengths identification."); + } +} diff --git a/src/osgPlugins/ive/DrawArrayLengths.h b/src/osgPlugins/ive/DrawArrayLengths.h new file mode 100644 index 000000000..225f3a6db --- /dev/null +++ b/src/osgPlugins/ive/DrawArrayLengths.h @@ -0,0 +1,15 @@ +#ifndef IVE_DRAWARRAYLENGTHS +#define IVE_DRAWARRAYLENGTHS 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT DrawArrayLengths : public osg::DrawArrayLengths, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/DrawArrays.cpp b/src/osgPlugins/ive/DrawArrays.cpp new file mode 100644 index 000000000..3e97f55f8 --- /dev/null +++ b/src/osgPlugins/ive/DrawArrays.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/DrawArrays.h b/src/osgPlugins/ive/DrawArrays.h new file mode 100644 index 000000000..a94873620 --- /dev/null +++ b/src/osgPlugins/ive/DrawArrays.h @@ -0,0 +1,15 @@ +#ifndef IVE_DRAWARRAYS +#define IVE_DRAWARRAYS 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT DrawArrays : public ReadWrite, public osg::DrawArrays{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/DrawElementsUShort.cpp b/src/osgPlugins/ive/DrawElementsUShort.cpp new file mode 100644 index 000000000..2e502da2b --- /dev/null +++ b/src/osgPlugins/ive/DrawElementsUShort.cpp @@ -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(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; iwriteUShort(((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(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; ireadUShort()); + } + } + else{ + throw Exception("DrawElementsUShort::read(): Expected DrawElementsUShort identification."); + } +} diff --git a/src/osgPlugins/ive/DrawElementsUShort.h b/src/osgPlugins/ive/DrawElementsUShort.h new file mode 100644 index 000000000..325b912ef --- /dev/null +++ b/src/osgPlugins/ive/DrawElementsUShort.h @@ -0,0 +1,15 @@ +#ifndef IVE_DRAWELEMENTSUSHORT +#define IVE_DRAWELEMENTSUSHORT 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT DrawElementsUShort : public osg::DrawElementsUShort, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Drawable.cpp b/src/osgPlugins/ive/Drawable.cpp new file mode 100644 index 000000000..f59c80549 --- /dev/null +++ b/src/osgPlugins/ive/Drawable.cpp @@ -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(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(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(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)->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."); + } +} diff --git a/src/osgPlugins/ive/Drawable.h b/src/osgPlugins/ive/Drawable.h new file mode 100644 index 000000000..beedd31d7 --- /dev/null +++ b/src/osgPlugins/ive/Drawable.h @@ -0,0 +1,15 @@ +#ifndef IVE_DRAWABLE +#define IVE_DRAWABLE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Drawable : public ReadWrite, public osg::Drawable{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Exception.cpp b/src/osgPlugins/ive/Exception.cpp new file mode 100644 index 000000000..644dbc753 --- /dev/null +++ b/src/osgPlugins/ive/Exception.cpp @@ -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(){} diff --git a/src/osgPlugins/ive/Exception.h b/src/osgPlugins/ive/Exception.h new file mode 100644 index 000000000..5dc6ece81 --- /dev/null +++ b/src/osgPlugins/ive/Exception.h @@ -0,0 +1,20 @@ +#ifndef IVE_EXCEPTION +#define IVE_EXCEPTION 1 + +#include "Export.h" +#include + +namespace ive{ + +class IVE_EXPORT Exception{ +public: + Exception(std::string error); + ~Exception(); + std::string getError(){return _error;}; +private: + std::string _error; +}; + +} + +#endif \ No newline at end of file diff --git a/src/osgPlugins/ive/Export.h b/src/osgPlugins/ive/Export.h new file mode 100644 index 000000000..e0289cbfd --- /dev/null +++ b/src/osgPlugins/ive/Export.h @@ -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 diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile new file mode 100644 index 000000000..9ea5f1ec6 --- /dev/null +++ b/src/osgPlugins/ive/GNUmakefile @@ -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 diff --git a/src/osgPlugins/ive/Geode.cpp b/src/osgPlugins/ive/Geode.cpp new file mode 100644 index 000000000..ceab97f5f --- /dev/null +++ b/src/osgPlugins/ive/Geode.cpp @@ -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 +#include + +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(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(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(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; ipeekInt(); + 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."); + } +} diff --git a/src/osgPlugins/ive/Geode.h b/src/osgPlugins/ive/Geode.h new file mode 100644 index 000000000..51a5d7d24 --- /dev/null +++ b/src/osgPlugins/ive/Geode.h @@ -0,0 +1,15 @@ +#ifndef IVE_GEODE +#define IVE_GEODE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Geode : public ReadWrite, public osg::Geode{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Geometry.cpp b/src/osgPlugins/ive/Geometry.cpp new file mode 100644 index 000000000..6f8cc2669 --- /dev/null +++ b/src/osgPlugins/ive/Geometry.cpp @@ -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(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(getPrimitiveSet(i))) + ((ive::DrawArrays*)(getPrimitiveSet(i)))->write(out); + else if(dynamic_cast(getPrimitiveSet(i))) + ((ive::DrawArrayLengths*)(getPrimitiveSet(i)))->write(out); + else if(dynamic_cast(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;jwriteBool(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(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;ipeekInt(); + 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(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(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(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(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(in->readArray())); + } + // Read texture coord arrays + size = in->readInt(); + for(i =0;ireadBool(); + if(coords_valid) + setTexCoordArray(i, in->readArray()); + // Read Indices if valid + bool indices_valid = in->readBool(); + if(indices_valid) + setTexCoordIndices(i, static_cast(in->readArray())); + } + } + else{ + throw Exception("Geometry::read(): Expected Geometry identification."); + } +} diff --git a/src/osgPlugins/ive/Geometry.h b/src/osgPlugins/ive/Geometry.h new file mode 100644 index 000000000..d2fc670aa --- /dev/null +++ b/src/osgPlugins/ive/Geometry.h @@ -0,0 +1,15 @@ +#ifndef IVE_GEOMETRY +#define IVE_GEOMETRY 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Geometry : public ReadWrite, public osg::Geometry{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Group.cpp b/src/osgPlugins/ive/Group.cpp new file mode 100644 index 000000000..22bacb1be --- /dev/null +++ b/src/osgPlugins/ive/Group.cpp @@ -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(this); + if(node){ + static_cast(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(child)){ + ((ive::MatrixTransform*)(child))->write(out); + } +// else if(dynamic_cast(child)){ +// ((ive::ViewPoint*)(child))->write(out); +// } + else if(dynamic_cast(child)){ + ((ive::PositionAttitudeTransform*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::LightSource*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::Sequence*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::LOD*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::Transform*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::Group*)(child))->write(out); + } + else if(dynamic_cast(child)){ + ((ive::Billboard*)(child))->write(out); + } + else if(dynamic_cast(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(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; ipeekInt(); + 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"); + } +} diff --git a/src/osgPlugins/ive/Group.h b/src/osgPlugins/ive/Group.h new file mode 100644 index 000000000..fd77a4087 --- /dev/null +++ b/src/osgPlugins/ive/Group.h @@ -0,0 +1,15 @@ +#ifndef IVE_GROUP +#define IVE_GROUP 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Group : public osg::Group, public ReadWrite{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* out); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Image.cpp b/src/osgPlugins/ive/Image.cpp new file mode 100644 index 000000000..1713d3f64 --- /dev/null +++ b/src/osgPlugins/ive/Image.cpp @@ -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(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;iwriteInt(_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(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;ireadInt(); + + // 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."); + } +} diff --git a/src/osgPlugins/ive/Image.h b/src/osgPlugins/ive/Image.h new file mode 100644 index 000000000..e8309407b --- /dev/null +++ b/src/osgPlugins/ive/Image.h @@ -0,0 +1,15 @@ +#ifndef IVE_IMAGE +#define IVE_IMAGE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Image : public osg::Image, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/LOD.cpp b/src/osgPlugins/ive/LOD.cpp new file mode 100644 index 000000000..92e7fe6bd --- /dev/null +++ b/src/osgPlugins/ive/LOD.cpp @@ -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(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;iwriteFloat(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(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;ireadFloat(); + float max = in->readFloat(); + setRange(i, min, max); + } + } + else{ + throw Exception("LOD::read(): Expected LOD identification."); + } +} diff --git a/src/osgPlugins/ive/LOD.h b/src/osgPlugins/ive/LOD.h new file mode 100644 index 000000000..3569665a1 --- /dev/null +++ b/src/osgPlugins/ive/LOD.h @@ -0,0 +1,15 @@ +#ifndef IVE_LOD +#define IVE_LOD 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT LOD : public osg::LOD, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Light.cpp b/src/osgPlugins/ive/Light.cpp new file mode 100644 index 000000000..e91dbe2ec --- /dev/null +++ b/src/osgPlugins/ive/Light.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/Light.h b/src/osgPlugins/ive/Light.h new file mode 100644 index 000000000..660a4c222 --- /dev/null +++ b/src/osgPlugins/ive/Light.h @@ -0,0 +1,15 @@ +#ifndef IVE_LIGHT +#define IVE_LIGHT 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Light : public osg::Light, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/LightSource.cpp b/src/osgPlugins/ive/LightSource.cpp new file mode 100644 index 000000000..9841a0c1e --- /dev/null +++ b/src/osgPlugins/ive/LightSource.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/LightSource.h b/src/osgPlugins/ive/LightSource.h new file mode 100644 index 000000000..105bc4b3c --- /dev/null +++ b/src/osgPlugins/ive/LightSource.h @@ -0,0 +1,15 @@ +#ifndef IVE_LIGHTSOURCE +#define IVE_LIGHTSOURCE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT LightSource : public osg::LightSource, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Material.cpp b/src/osgPlugins/ive/Material.cpp new file mode 100644 index 000000000..b1b4f3e5e --- /dev/null +++ b/src/osgPlugins/ive/Material.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/Material.h b/src/osgPlugins/ive/Material.h new file mode 100644 index 000000000..f802af80a --- /dev/null +++ b/src/osgPlugins/ive/Material.h @@ -0,0 +1,15 @@ +#ifndef IVE_MATERIAL +#define IVE_MATERIAL 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Material : public osg::Material, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/MatrixTransform.cpp b/src/osgPlugins/ive/MatrixTransform.cpp new file mode 100644 index 000000000..d98f607ef --- /dev/null +++ b/src/osgPlugins/ive/MatrixTransform.cpp @@ -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(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(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"); + } +} diff --git a/src/osgPlugins/ive/MatrixTransform.h b/src/osgPlugins/ive/MatrixTransform.h new file mode 100644 index 000000000..380396a2c --- /dev/null +++ b/src/osgPlugins/ive/MatrixTransform.h @@ -0,0 +1,15 @@ +#ifndef IVE_MATRIXTRANSFORM +#define IVE_MATRIXTRANSFORM 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT MatrixTransform : public osg::MatrixTransform, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Node.cpp b/src/osgPlugins/ive/Node.cpp new file mode 100644 index 000000000..25c4c45e9 --- /dev/null +++ b/src/osgPlugins/ive/Node.cpp @@ -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(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 desc = getDescriptions(); + for(int i=0;iwriteString(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(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(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;ireadString()); + } + // 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"); + } +} \ No newline at end of file diff --git a/src/osgPlugins/ive/Node.h b/src/osgPlugins/ive/Node.h new file mode 100644 index 000000000..5c4a10a4c --- /dev/null +++ b/src/osgPlugins/ive/Node.h @@ -0,0 +1,16 @@ +#ifndef IVE_NODE +#define IVE_NODE 1 + +#include +#include "ReadWrite.h" +#include + +namespace ive{ +class IVE_EXPORT Node : public osg::Node, public ReadWrite{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Object.cpp b/src/osgPlugins/ive/Object.cpp new file mode 100644 index 000000000..2c840ea7e --- /dev/null +++ b/src/osgPlugins/ive/Object.cpp @@ -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"); + } +} diff --git a/src/osgPlugins/ive/Object.h b/src/osgPlugins/ive/Object.h new file mode 100644 index 000000000..8bb633c14 --- /dev/null +++ b/src/osgPlugins/ive/Object.h @@ -0,0 +1,18 @@ +#ifndef IVE_OBJECT +#define IVE_OBJECT 1 + + +#include +#include "ReadWrite.h" + +namespace ive{ + +class IVE_EXPORT Object : public ReadWrite, public osg::Object{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* out); +}; + +} + +#endif \ No newline at end of file diff --git a/src/osgPlugins/ive/PositionAttitudeTransform.cpp b/src/osgPlugins/ive/PositionAttitudeTransform.cpp new file mode 100644 index 000000000..a28a3ab71 --- /dev/null +++ b/src/osgPlugins/ive/PositionAttitudeTransform.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/PositionAttitudeTransform.h b/src/osgPlugins/ive/PositionAttitudeTransform.h new file mode 100644 index 000000000..332d9abd5 --- /dev/null +++ b/src/osgPlugins/ive/PositionAttitudeTransform.h @@ -0,0 +1,15 @@ +#ifndef IVE_POSITIONATTITUDETRANSFORM +#define IVE_POSITIONATTITUDETRANSFORM 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT PositionAttitudeTransform : public osg::PositionAttitudeTransform, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/PrimitiveSet.cpp b/src/osgPlugins/ive/PrimitiveSet.cpp new file mode 100644 index 000000000..c560c8abb --- /dev/null +++ b/src/osgPlugins/ive/PrimitiveSet.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/PrimitiveSet.h b/src/osgPlugins/ive/PrimitiveSet.h new file mode 100644 index 000000000..6e4d13bd3 --- /dev/null +++ b/src/osgPlugins/ive/PrimitiveSet.h @@ -0,0 +1,15 @@ +#ifndef IVE_PRIMITIVESET +#define IVE_PRIMITIVESET 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT PrimitiveSet : public ReadWrite, public osg::PrimitiveSet{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h new file mode 100644 index 000000000..1b2668bcc --- /dev/null +++ b/src/osgPlugins/ive/ReadWrite.h @@ -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 diff --git a/src/osgPlugins/ive/ReaderWriterIVE.cpp b/src/osgPlugins/ive/ReaderWriterIVE.cpp new file mode 100644 index 000000000..e338c9f44 --- /dev/null +++ b/src/osgPlugins/ive/ReaderWriterIVE.cpp @@ -0,0 +1,86 @@ +#include "MatrixTransform.h" +#include "Group.h" + +#include +#include + +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()<(&node)) + const_cast(static_cast(&node))->write(out); + else if(dynamic_cast(&node)) + const_cast(static_cast(&node))->write(out); + else + std::cout<<"File must start with a MatrixTransform or Group "< g_IVEReaderWriterProxy; diff --git a/src/osgPlugins/ive/Sequence.cpp b/src/osgPlugins/ive/Sequence.cpp new file mode 100644 index 000000000..4de3c4d73 --- /dev/null +++ b/src/osgPlugins/ive/Sequence.cpp @@ -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(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;iwriteFloat(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(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;ireadFloat()); + } + // 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."); + } +} diff --git a/src/osgPlugins/ive/Sequence.h b/src/osgPlugins/ive/Sequence.h new file mode 100644 index 000000000..4c989f5bd --- /dev/null +++ b/src/osgPlugins/ive/Sequence.h @@ -0,0 +1,15 @@ +#ifndef IVE_SEQUENCE +#define IVE_SEQUENCE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Sequence : public osg::Sequence, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/StateSet.cpp b/src/osgPlugins/ive/StateSet.cpp new file mode 100644 index 000000000..47aae1d50 --- /dev/null +++ b/src/osgPlugins/ive/StateSet.cpp @@ -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 + +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(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(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(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(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;unitwriteInt(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;unitwriteInt(al.size()); + for(StateSet::AttributeList::iterator aitr=al.begin(); aitr!=al.end(); ++aitr){ + // This is a Texture2D + if(dynamic_cast(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(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(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(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(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(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;ireadInt(); + int value = in->readInt(); + setMode((osg::StateAttribute::GLMode)mode, (osg::StateAttribute::GLModeValue)value); + } + + // Read state attributes + size = in->readInt(); + for(i=0;ipeekInt(); + 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;unitreadInt(); + for(i=0;ireadInt(); + int value = in->readInt(); + setTextureMode(unit,(osg::StateAttribute::GLMode)mode, (osg::StateAttribute::GLModeValue)value); + } + } + + // Read texture attributes. + nUnits = in->readInt(); + for(unit=0;unitreadInt(); + for(i=0;ipeekInt(); + 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"); + } +} diff --git a/src/osgPlugins/ive/StateSet.h b/src/osgPlugins/ive/StateSet.h new file mode 100644 index 000000000..e241f65ee --- /dev/null +++ b/src/osgPlugins/ive/StateSet.h @@ -0,0 +1,15 @@ +#ifndef IVE_STATESET +#define IVE_STATESET 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT StateSet : public ReadWrite, public osg::StateSet{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* out); +}; +} + +#endif diff --git a/src/osgPlugins/ive/TexEnv.cpp b/src/osgPlugins/ive/TexEnv.cpp new file mode 100644 index 000000000..b9966b0f1 --- /dev/null +++ b/src/osgPlugins/ive/TexEnv.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/TexEnv.h b/src/osgPlugins/ive/TexEnv.h new file mode 100644 index 000000000..d6a550a32 --- /dev/null +++ b/src/osgPlugins/ive/TexEnv.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXENV +#define IVE_TEXENV 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT TexEnv : public osg::TexEnv, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/TexEnvCombine.cpp b/src/osgPlugins/ive/TexEnvCombine.cpp new file mode 100644 index 000000000..f314bfcb2 --- /dev/null +++ b/src/osgPlugins/ive/TexEnvCombine.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/TexEnvCombine.h b/src/osgPlugins/ive/TexEnvCombine.h new file mode 100644 index 000000000..ddbe25134 --- /dev/null +++ b/src/osgPlugins/ive/TexEnvCombine.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXENVCOMBINE +#define IVE_TEXENVCOMBINE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT TexEnvCombine : public osg::TexEnvCombine, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/TexGen.cpp b/src/osgPlugins/ive/TexGen.cpp new file mode 100644 index 000000000..e00f7cb3f --- /dev/null +++ b/src/osgPlugins/ive/TexGen.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/TexGen.h b/src/osgPlugins/ive/TexGen.h new file mode 100644 index 000000000..843c3487c --- /dev/null +++ b/src/osgPlugins/ive/TexGen.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXGEN +#define IVE_TEXGEN 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT TexGen : public osg::TexGen, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Texture.cpp b/src/osgPlugins/ive/Texture.cpp new file mode 100644 index 000000000..c1b96912e --- /dev/null +++ b/src/osgPlugins/ive/Texture.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/Texture.h b/src/osgPlugins/ive/Texture.h new file mode 100644 index 000000000..1d4d707ab --- /dev/null +++ b/src/osgPlugins/ive/Texture.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXTURE +#define IVE_TEXTURE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Texture : public osg::Texture, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Texture2D.cpp b/src/osgPlugins/ive/Texture2D.cpp new file mode 100644 index 000000000..b451f38c0 --- /dev/null +++ b/src/osgPlugins/ive/Texture2D.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/Texture2D.h b/src/osgPlugins/ive/Texture2D.h new file mode 100644 index 000000000..07847e4d6 --- /dev/null +++ b/src/osgPlugins/ive/Texture2D.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXTURE2D +#define IVE_TEXTURE2D 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Texture2D : public osg::Texture2D, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/TextureCubeMap.cpp b/src/osgPlugins/ive/TextureCubeMap.cpp new file mode 100644 index 000000000..f397e679e --- /dev/null +++ b/src/osgPlugins/ive/TextureCubeMap.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/TextureCubeMap.h b/src/osgPlugins/ive/TextureCubeMap.h new file mode 100644 index 000000000..55b8bfb1c --- /dev/null +++ b/src/osgPlugins/ive/TextureCubeMap.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXTURECUBEMAP +#define IVE_TEXTURECUBEMAP 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT TextureCubeMap : public osg::TextureCubeMap, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/Transform.cpp b/src/osgPlugins/ive/Transform.cpp new file mode 100644 index 000000000..5f25801dd --- /dev/null +++ b/src/osgPlugins/ive/Transform.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/Transform.h b/src/osgPlugins/ive/Transform.h new file mode 100644 index 000000000..a0be671a8 --- /dev/null +++ b/src/osgPlugins/ive/Transform.h @@ -0,0 +1,15 @@ +#ifndef IVE_TRANSFORM +#define IVE_TRANSFORM 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class IVE_EXPORT Transform : public osg::Transform, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/ViewPoint.cpp b/src/osgPlugins/ive/ViewPoint.cpp new file mode 100644 index 000000000..62c077184 --- /dev/null +++ b/src/osgPlugins/ive/ViewPoint.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/ViewPoint.h b/src/osgPlugins/ive/ViewPoint.h new file mode 100644 index 000000000..67bbd4734 --- /dev/null +++ b/src/osgPlugins/ive/ViewPoint.h @@ -0,0 +1,15 @@ +#ifndef IVE_VIEWPOINT +#define IVE_VIEWPOINT 1 + +#include +#include + +namespace ive{ +class IVE_EXPORT ViewPoint : public osgfIVE::ViewPoint, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif