Removed the flt plugin from OpenSceneGraph/trunk, this project can now be found in the deprecated directory.
This commit is contained in:
@@ -66,7 +66,6 @@ PLUGIN_DIRS = \
|
||||
dw \
|
||||
dxf \
|
||||
shp \
|
||||
flt \
|
||||
hdr \
|
||||
ive \
|
||||
3ds \
|
||||
|
||||
@@ -2949,30 +2949,6 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin flt"=.\osgPlugins\flt\flt.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
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgUtil
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgSim
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin dae"=.\osgPlugins\dae\dae.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
||||
@@ -1,556 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="osgPlugin flt" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=osgPlugin flt - 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 "flt.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 "flt.mak" CFG="osgPlugin flt - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "osgPlugin flt - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin flt - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin flt - Win32 Release Static" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "osgPlugin flt - Win32 Debug Static" (based on "Win32 (x86) Static 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 flt - 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 "../../../bin/$(PlatformName)"
|
||||
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# 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" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FLT_LIBRARY" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x414 /d "NDEBUG"
|
||||
# ADD RSC /l 0x417 /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 /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 OpenThreadsWin32.lib /nologo /dll /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgdb_flt.dll" /implib:"../../../lib/$(PlatformName)/osgdb_flt.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin flt - 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 "../../../bin/$(PlatformName)"
|
||||
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# 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 /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FLT_LIBRARY" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x414 /d "_DEBUG"
|
||||
# ADD RSC /l 0x417 /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 OpenThreadsWin32d.lib /nologo /dll /debug /machine:I386 /out:"$(OutDir)/osgdb_fltd.dll" /pdbtype:sept /implib:"../../../lib/$(PlatformName)/osgdb_fltd.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /pdb:none /incremental:no
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin flt - Win32 Release Static"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "../../../lib"
|
||||
# PROP BASE Intermediate_Dir "Release_Static"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../../../lib/$(PlatformName)"
|
||||
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /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
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_flt_s.lib"
|
||||
# SUBTRACT LIB32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin flt - Win32 Debug Static"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "../../../lib"
|
||||
# PROP BASE Intermediate_Dir "Debug_Static"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../../../lib/$(PlatformName)"
|
||||
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_MBCS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /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
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_fltd_s.lib"
|
||||
# SUBTRACT LIB32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "osgPlugin flt - Win32 Release"
|
||||
# Name "osgPlugin flt - Win32 Debug"
|
||||
# Name "osgPlugin flt - Win32 Release Static"
|
||||
# Name "osgPlugin flt - Win32 Debug Static"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\BoundingVolumeRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\BSPRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ColorPaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\CommentRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ControlRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\DofRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ExtensionRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ExternalRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FaceRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FindExternalModelVisitor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\flt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\flt2osg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FltFile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\GeoSetBuilder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\GroupRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\HeaderRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Input.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\InstanceRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointPaletteRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointSystemRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourcePaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourceRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LocalVertexPoolRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LodRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LongIDRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MaterialPaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MeshPrimitiveRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MeshRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MultiTextureRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ObjectRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\OldMaterialPaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\OldVertexRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Pool.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ReaderWriterATTR.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ReaderWriterFLT.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Record.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\RecordVisitor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Registry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\RoadRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\SwitchRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TextureMappingPaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TexturePaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TransformationRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\UnknownRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\UVListRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\VertexPoolRecords.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\AttrData.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\BoundingVolumeRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\BSPRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ColorPaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\CommentRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ControlRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\DofRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ExtensionRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ExternalRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FaceRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FindExternalModelVisitor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\flt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\flt2osg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FltFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\FltRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\GeoSetBuilder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\GroupRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\HeaderRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Input.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\InstanceRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointPaletteRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointSystemRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourcePaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourceRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LocalVertexPoolRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LodRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LongIDRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MaterialPaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MeshPrimitiveRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MeshRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\MultiTextureRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ObjectRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\OldMaterialPaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\OldVertexRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\opcodes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Pool.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\ReaderWriterFLT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Record.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\RecordVisitor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\Registry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\RoadRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\SwitchRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TextureMappingPaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TexturePaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\TransformationRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\UnknownRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\UVListRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\VertexPoolRecords.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\license.txt
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -87,7 +87,6 @@ IF (BUILD_OSG_3D_PLUGINS)
|
||||
ADD_SUBDIRECTORY(x)
|
||||
ADD_SUBDIRECTORY(dw)
|
||||
ADD_SUBDIRECTORY(dxf)
|
||||
#ADD_SUBDIRECTORY(flt)
|
||||
ADD_SUBDIRECTORY(OpenFlight)
|
||||
ADD_SUBDIRECTORY(geo)
|
||||
ADD_SUBDIRECTORY(obj)
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
#ifndef __ATTR_DATA_H
|
||||
#define __ATTR_DATA_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Referenced>
|
||||
|
||||
// Detail Texture as defined in Creator v2.5.1 got lot's of parameters that I don't know
|
||||
// how they work, so I have implemented only the things I need, and if someone needs
|
||||
// something else it's posible to use other parameters using the new flt::AttrData class
|
||||
// Now the implemented parameters are:
|
||||
// - txDetail_m, txDetail_n : Control how new texcoord will be generated.
|
||||
// - modulateDetail : If set to true, be use scale_rgb and scale_alpha values from
|
||||
// osg::TexEnvCombine to make a lighted image.
|
||||
//
|
||||
// I implement detail texture as a new TexEnvCombine attribute in texture unit 1
|
||||
// that is added to the stateset of the geometry.
|
||||
//
|
||||
// flt::AttrData class is used to store Texture Attribute Data as defined in Creator
|
||||
// so we can pass this info to others loader object an use it where needed.
|
||||
//
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
namespace flt {
|
||||
|
||||
typedef signed int int32;
|
||||
|
||||
class AttrData : public osg::Object {
|
||||
public:
|
||||
osg::ref_ptr<osg::StateSet> stateset;
|
||||
|
||||
int32 useDetail; // TRUE if using next 5 integers for detail texture
|
||||
int32 txDetail_j; // J argument for TX_DETAIL
|
||||
int32 txDetail_k; // K argument for TX_DETAIL
|
||||
int32 txDetail_m; // M argument for TX_DETAIL
|
||||
int32 txDetail_n; // N argument for TX_DETAIL
|
||||
int32 txDetail_s; // Scramble argument for TX_DETAIL
|
||||
bool modulateDetail; // True if Magnification filter type is MODULATE_DETAIL
|
||||
|
||||
AttrData() :
|
||||
stateset(0),
|
||||
useDetail(0),
|
||||
txDetail_j(0),
|
||||
txDetail_k(0),
|
||||
txDetail_m(0),
|
||||
txDetail_n(0),
|
||||
txDetail_s(0),
|
||||
modulateDetail(false) {}
|
||||
|
||||
|
||||
AttrData(const AttrData& attr,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||
osg::Object(attr,copyop),
|
||||
stateset(attr.stateset),
|
||||
useDetail(attr.useDetail),
|
||||
txDetail_j(attr.txDetail_j),
|
||||
txDetail_k(attr.txDetail_k),
|
||||
txDetail_m(attr.txDetail_m),
|
||||
txDetail_n(attr.txDetail_n),
|
||||
txDetail_s(attr.txDetail_s),
|
||||
modulateDetail(attr.modulateDetail) {}
|
||||
|
||||
virtual osg::Object* cloneType() const { return new AttrData(); }
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AttrData(*this,copyop); }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "AttrData"; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __ATTR_DATA_H
|
||||
@@ -1,39 +0,0 @@
|
||||
// BSPRecord.cpp
|
||||
//
|
||||
// Author: Michael M. Morrison
|
||||
//
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "BSPRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BSPRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BSPRecord> g_BSPProxy;
|
||||
|
||||
BSPRecord::BSPRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BSPRecord::~BSPRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BSPRecord::endian()
|
||||
{
|
||||
SBSP *pSBSP = (SBSP*)getData();
|
||||
|
||||
ENDIAN( pSBSP->planeA );
|
||||
ENDIAN( pSBSP->planeB );
|
||||
ENDIAN( pSBSP->planeC );
|
||||
ENDIAN( pSBSP->planeD );
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// BSPRecord.h
|
||||
//
|
||||
// Author: Michael M. Morrison
|
||||
//
|
||||
|
||||
#ifndef __FLT_BSP_RECORD_H
|
||||
#define __FLT_BSP_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SBSP
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
uint32 reserved; // Reserved
|
||||
float64 planeA; // Plane Equation A
|
||||
float64 planeB; // Plane Equation B
|
||||
float64 planeC; // Plane Equation C
|
||||
float64 planeD; // Plane Equation D
|
||||
};
|
||||
|
||||
class BSPRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
BSPRecord();
|
||||
|
||||
virtual Record* clone() const { return new BSPRecord(); }
|
||||
virtual const char* className() const { return "BSPRecord"; }
|
||||
virtual int classOpcode() const { return BSP_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SBSP); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SBSP* getData() const { return (SBSP*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~BSPRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
// BoundingVolumeRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "BoundingVolumeRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingBoxRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BoundingBoxRecord> g_BoundingBoxProxy;
|
||||
|
||||
BoundingBoxRecord::BoundingBoxRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BoundingBoxRecord::~BoundingBoxRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoundingBoxRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingSphereRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BoundingSphereRecord> g_BoundingSphereProxy;
|
||||
|
||||
BoundingSphereRecord::BoundingSphereRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BoundingSphereRecord::~BoundingSphereRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoundingSphereRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingCylinderRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BoundingCylinderRecord> g_BoundingCylinderProxy;
|
||||
|
||||
BoundingCylinderRecord::BoundingCylinderRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BoundingCylinderRecord::~BoundingCylinderRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoundingCylinderRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingVolumeCenterRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BoundingVolumeCenterRecord> g_BoundingVolumeCenterProxy;
|
||||
|
||||
BoundingVolumeCenterRecord::BoundingVolumeCenterRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BoundingVolumeCenterRecord::~BoundingVolumeCenterRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoundingVolumeCenterRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingVolumeOrientationRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<BoundingVolumeOrientationRecord> g_BoundingVolumeOrientationProxy;
|
||||
|
||||
BoundingVolumeOrientationRecord::BoundingVolumeOrientationRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
BoundingVolumeOrientationRecord::~BoundingVolumeOrientationRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoundingVolumeOrientationRecord::endian()
|
||||
{
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
// BoundingVolumeRecords.h
|
||||
|
||||
#ifndef __FLT_BOUNDING_VOLUME_RECORDS_H
|
||||
#define __FLT_BOUNDING_VOLUME_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingBoxRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct BoundingBoxTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
#if 0
|
||||
Int 4 Reserved
|
||||
Double 8 x coordinate of lowest corner
|
||||
Double 8 y coordinate of lowest corner
|
||||
Double 8 z coordinate of lowest corner
|
||||
Double 8 x coordinate of highest corner
|
||||
Double 8 y coordinate of highest corner
|
||||
Double 8 z coordinate of highest corner
|
||||
#endif
|
||||
} SBoundingBox;
|
||||
|
||||
|
||||
|
||||
class BoundingBoxRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
BoundingBoxRecord();
|
||||
|
||||
virtual Record* clone() const { return new BoundingBoxRecord(); }
|
||||
virtual const char* className() const { return "BoundingBoxRecord"; }
|
||||
virtual int classOpcode() const { return BOUNDING_BOX_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~BoundingBoxRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingSphereRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct BoundingSphereTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
#if 0
|
||||
Unsigned Int 2 Length of the record
|
||||
Int 4 Reserved
|
||||
Double 8 Radius of the sphere
|
||||
#endif
|
||||
} SBoundingSphere;
|
||||
|
||||
|
||||
|
||||
class BoundingSphereRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
BoundingSphereRecord();
|
||||
|
||||
virtual Record* clone() const { return new BoundingSphereRecord(); }
|
||||
virtual const char* className() const { return "BoundingSphereRecord"; }
|
||||
virtual int classOpcode() const { return BOUNDING_SPHERE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~BoundingSphereRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingCylinderRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct BoundingCylinderTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
#if 0
|
||||
Int 4 Reserved
|
||||
Double 8 Radius of the cylinder base
|
||||
Double 8 Height of the cylinder
|
||||
#endif
|
||||
} SBoundingCylinder;
|
||||
|
||||
|
||||
|
||||
class BoundingCylinderRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
BoundingCylinderRecord();
|
||||
|
||||
virtual Record* clone() const { return new BoundingCylinderRecord(); }
|
||||
virtual const char* className() const { return "BoundingCylinderRecord"; }
|
||||
virtual int classOpcode() const { return BOUNDING_CYLINDER_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~BoundingCylinderRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingVolumeCenterRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct BoundingVolumeCenterTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
#if 0
|
||||
Int 4 Reserved
|
||||
Double 8 x coordinate of center
|
||||
Double 8 y coordinate of center
|
||||
Double 8 z coordinate of center
|
||||
#endif
|
||||
} SBoundingVolumeCenter;
|
||||
|
||||
|
||||
|
||||
class BoundingVolumeCenterRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
BoundingVolumeCenterRecord();
|
||||
|
||||
virtual Record* clone() const { return new BoundingVolumeCenterRecord(); }
|
||||
virtual const char* className() const { return "BoundingVolumeCenterRecord"; }
|
||||
virtual int classOpcode() const { return BOUNDING_VOLUME_CENTER_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~BoundingVolumeCenterRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BoundingVolumeOrientationRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct BoundingVolumeOrientationTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
#if 0
|
||||
Int 2 Bounding Volume Orientation Opcode 109
|
||||
Unsigned Int 2 Length of the record
|
||||
Int 4 Reserved
|
||||
Double 8 Yaw angle
|
||||
Double 8 Pitch angle
|
||||
Double 8 Roll angle
|
||||
#endif
|
||||
} SBoundingVolumeOrientation;
|
||||
|
||||
|
||||
|
||||
class BoundingVolumeOrientationRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
BoundingVolumeOrientationRecord();
|
||||
|
||||
virtual Record* clone() const { return new BoundingVolumeOrientationRecord(); }
|
||||
virtual const char* className() const { return "BoundingVolumeOrientationRecord"; }
|
||||
virtual int classOpcode() const { return BOUNDING_VOLUME_ORIENTATION_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~BoundingVolumeOrientationRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
// ColorPaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Input.h"
|
||||
#include "Registry.h"
|
||||
#include "ColorPaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MaterialPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<ColorPaletteRecord> g_ColorPaletteRecordProxy;
|
||||
|
||||
ColorPaletteRecord::ColorPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
ColorPaletteRecord::~ColorPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void ColorPaletteRecord::endian()
|
||||
{
|
||||
int flightVersion = getFlightVersion();
|
||||
|
||||
if (flightVersion > 13)
|
||||
{
|
||||
// TODO: May cause crash on win32
|
||||
// It's only color names so we ignore
|
||||
#if 0
|
||||
SColorPalette* pSColor = (SColorPalette*)getData();
|
||||
size_t nOffset = sizeof(SColorPalette);
|
||||
|
||||
if ((nOffset < getSize())
|
||||
&& (flightVersion >= 1500))
|
||||
{
|
||||
int n = 0;
|
||||
ENDIAN( pSColor->nNames );
|
||||
|
||||
while ((n++ < pSColor->nNames) && (nOffset < getSize()))
|
||||
{
|
||||
SColorName* pName = (SColorName*)((char*)pSColor)+nOffset;
|
||||
ENDIAN( pName->swSize );
|
||||
ENDIAN( pName->nIndex );
|
||||
nOffset += pName->swSize;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else // version 11, 12 & 13
|
||||
{
|
||||
SOldColorPalette* pSColor = (SOldColorPalette*)getData();
|
||||
size_t i;
|
||||
for (i=0; i < sizeof(pSColor->Colors)/sizeof(pSColor->Colors[0]); i++)
|
||||
{
|
||||
ENDIAN( pSColor->Colors[i]._red );
|
||||
ENDIAN( pSColor->Colors[i]._green );
|
||||
ENDIAN( pSColor->Colors[i]._blue );
|
||||
}
|
||||
|
||||
for (i=0; i < sizeof(pSColor->FixedColors)/sizeof(pSColor->FixedColors[0]); i++)
|
||||
{
|
||||
ENDIAN( pSColor->FixedColors[i]._red );
|
||||
ENDIAN( pSColor->FixedColors[i]._green );
|
||||
ENDIAN( pSColor->FixedColors[i]._blue );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// ColorPaletteRecord.h
|
||||
|
||||
#ifndef __FLT_COLOR_PALETTE_RECORD_H
|
||||
#define __FLT_COLOR_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ColorPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SColorName
|
||||
{
|
||||
uint16 swSize; // Length of color name entry
|
||||
int16 Reserved1;
|
||||
int16 nIndex; // Color entry index
|
||||
int16 Reserved2;
|
||||
char szName[1]; // Color name string (variable length, up to 80 bytes)
|
||||
};
|
||||
|
||||
|
||||
struct SColorPalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szReserved[128]; // Reserved
|
||||
color32 Colors[1024]; // Color 0 - 1023
|
||||
int32 nNames;
|
||||
// Followed by SColorName. SColorName is of valiable length!
|
||||
};
|
||||
|
||||
|
||||
struct SOldColorPalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
color48 Colors[32]; // Color 0 - 31
|
||||
color48 FixedColors[56]; // Fixed Intensity Color 0 - 55 (4096-> )
|
||||
};
|
||||
|
||||
|
||||
class ColorPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
ColorPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new ColorPaletteRecord(); }
|
||||
virtual const char* className() const { return "ColorPaletteRecord"; }
|
||||
virtual int classOpcode() const { return COLOR_PALETTE_OP; }
|
||||
// virtual size_t sizeofData() const { return sizeof(SColorPalette); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SColorPalette* getData() const { return (SColorPalette*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~ColorPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_COLOR_PALETTE_RECORD_H
|
||||
@@ -1,31 +0,0 @@
|
||||
// CommentRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "CommentRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CommentRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<CommentRecord> g_CommentRecordProxy;
|
||||
|
||||
CommentRecord::CommentRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
CommentRecord::~CommentRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void CommentRecord::endian()
|
||||
{
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// CommentRecord.h
|
||||
|
||||
#ifndef __FLT_COMMENT_RECORD_H
|
||||
#define __FLT_COMMENT_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CommentRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SComment
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szComment[1]; // (Length - 4) ASCII ID of node
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CommentRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
CommentRecord();
|
||||
|
||||
virtual Record* clone() const { return new CommentRecord(); }
|
||||
virtual const char* className() const { return "CommentRecord"; }
|
||||
virtual int classOpcode() const { return COMMENT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~CommentRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// ControlRecord.cpp
|
||||
|
||||
#include "Registry.h"
|
||||
#include "ControlRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
RegisterRecordProxy<PushLevelRecord> g_PushLevelProxy;
|
||||
RegisterRecordProxy<PopLevelRecord> g_PopLevelProxy;
|
||||
|
||||
RegisterRecordProxy<PushSubfaceRecord> g_PushSubfaceProxy;
|
||||
RegisterRecordProxy<PopSubfaceRecord> g_PopSubfaceProxy;
|
||||
|
||||
RegisterRecordProxy<PushExtensionRecord> g_PushExtensionProxy;
|
||||
RegisterRecordProxy<PopExtensionRecord> g_PopExtensionProxy;
|
||||
@@ -1,125 +0,0 @@
|
||||
// ControlRecord.h
|
||||
|
||||
#ifndef __FLT_CONTROL_RECORD_H
|
||||
#define __FLT_CONTROL_RECORD_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PushLevelRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class PushLevelRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PushLevelRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PushLevelRecord(); }
|
||||
virtual const char* className() const { return "PushLevelRecord"; }
|
||||
virtual int classOpcode() const { return PUSH_LEVEL_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PushLevelRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PopLevelRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PopLevelRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PopLevelRecord(); }
|
||||
virtual const char* className() const { return "PopLevelRecord"; }
|
||||
virtual int classOpcode() const { return POP_LEVEL_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PopLevelRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PushSubfaceRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PushSubfaceRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PushSubfaceRecord(); }
|
||||
virtual const char* className() const { return "PushSubfaceRecord"; }
|
||||
virtual int classOpcode() const { return PUSH_SUBFACE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PushSubfaceRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PopSubfaceRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PopSubfaceRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PopSubfaceRecord(); }
|
||||
virtual const char* className() const { return "PopSubfaceRecord"; }
|
||||
virtual int classOpcode() const { return POP_SUBFACE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PopSubfaceRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PushExtensionRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PushExtensionRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PushExtensionRecord(); }
|
||||
virtual const char* className() const { return "PushExtensionRecord"; }
|
||||
virtual int classOpcode() const { return PUSH_EXTENSION_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PushExtensionRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PopExtensionRecord : public ControlRecord
|
||||
{
|
||||
public:
|
||||
PopExtensionRecord() {}
|
||||
|
||||
virtual Record* clone() const { return new PopExtensionRecord(); }
|
||||
virtual const char* className() const { return "PopExtensionRecord"; }
|
||||
virtual int classOpcode() const { return POP_EXTENSION_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~PopExtensionRecord() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_CONTROL_RECORD_H
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// DofRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "DofRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DofRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<DofRecord> g_DofProxy;
|
||||
|
||||
DofRecord::DofRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
DofRecord::~DofRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DofRecord::endian()
|
||||
{
|
||||
SDegreeOfFreedom *pSDof = (SDegreeOfFreedom*)getData();
|
||||
|
||||
ENDIAN( pSDof->diReserved );
|
||||
pSDof->OriginLocalDOF.endian();
|
||||
pSDof->PointOnXaxis.endian();
|
||||
pSDof->PointInXYplane.endian();
|
||||
pSDof->dfZ.endian();
|
||||
pSDof->dfY.endian();
|
||||
pSDof->dfX.endian();
|
||||
pSDof->dfPitch.endian();
|
||||
pSDof->dfRoll.endian();
|
||||
pSDof->dfYaw.endian();
|
||||
pSDof->dfZscale.endian();
|
||||
pSDof->dfYscale.endian();
|
||||
pSDof->dfXscale.endian();
|
||||
ENDIAN( pSDof->dwFlags );
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// DofRecord.h
|
||||
|
||||
|
||||
|
||||
#ifndef __FLT_DOF_RECORD_H
|
||||
#define __FLT_DOF_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SRange
|
||||
{
|
||||
float64 _dfMin; // Minimum value with respect to the local coord system
|
||||
float64 _dfMax; // Maximum value with respect to the local coordsystem
|
||||
float64 _dfCurrent; // Current value with respect to the local coord system
|
||||
float64 _dfIncrement; // Increment
|
||||
|
||||
inline float64 minRange() { return _dfMin; }
|
||||
inline float64 maxRange() { return _dfMax; }
|
||||
inline float64 current() { return _dfCurrent; }
|
||||
inline float64 increment() { return _dfIncrement; }
|
||||
void endian() {
|
||||
ENDIAN( _dfMin );
|
||||
ENDIAN( _dfMax );
|
||||
ENDIAN( _dfCurrent );
|
||||
ENDIAN( _dfIncrement );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef struct DegreeOfFreedomTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 diReserved; // Reserved
|
||||
float64x3 OriginLocalDOF; // Origin (x,y,z) of the DOF's local coordinate system
|
||||
float64x3 PointOnXaxis; // Point (x,y,z) on the x-axis of the DOF's local coord system
|
||||
float64x3 PointInXYplane; // Point (x,y,z) in xy plane of the DOF's local coord system
|
||||
SRange dfZ; // Legal z values with respect to the local coord system
|
||||
SRange dfY; // Legal y values with respect to the local coord system
|
||||
SRange dfX; // Legal x values with respect to the local coord system
|
||||
SRange dfPitch; // Legal pitch values (rotation about the x-axis)
|
||||
SRange dfRoll; // Legal roll values( rotation about the y-axis)
|
||||
SRange dfYaw; // Legal yaw values (rotation about the z-axis)
|
||||
SRange dfZscale; // Legal z scale values (about local origin)
|
||||
SRange dfYscale; // Legal y scale values about local origin)
|
||||
SRange dfXscale; // Legal x scale values (about local origin)
|
||||
uint32 dwFlags; // Flags, bits from left to right (see OF doc)
|
||||
} SDegreeOfFreedom;
|
||||
|
||||
|
||||
|
||||
class DofRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
DofRecord();
|
||||
|
||||
virtual Record* clone() const { return new DofRecord(); }
|
||||
virtual const char* className() const { return "DofRecord"; }
|
||||
virtual int classOpcode() const { return DOF_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SDegreeOfFreedom); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SDegreeOfFreedom* getData() const { return (SDegreeOfFreedom*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
protected:
|
||||
virtual ~DofRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// ExtensionRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "ExtensionRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtensionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<ExtensionRecord> g_ExtensionProxy;
|
||||
|
||||
ExtensionRecord::ExtensionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
ExtensionRecord::~ExtensionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ExtensionRecord::endian()
|
||||
{
|
||||
SExtension *pExtension = (SExtension*)getData();
|
||||
|
||||
// VALID_RECORD(SHeader, pRecHdr)
|
||||
ENDIAN( pExtension->code );
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// ExtensionRecord.h
|
||||
|
||||
#ifndef __FLT_EXTENSION_RECORD_H
|
||||
#define __FLT_EXTENSION_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
namespace flt {
|
||||
class Input;
|
||||
};
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtensionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct ExtensionTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
char site[8]; // Site ID - Unique site name
|
||||
char reserved; // Reserved
|
||||
char revision; // Revision - site specific
|
||||
uint16 code; // Record code - site specific
|
||||
// char n/a; // Extended data - site specific
|
||||
}SExtension;
|
||||
|
||||
|
||||
class ExtensionRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
ExtensionRecord();
|
||||
|
||||
virtual Record* clone() const { return new ExtensionRecord(); }
|
||||
virtual const char* className() const { return "ExtensionRecord"; }
|
||||
virtual int classOpcode() const { return EXTENSION_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SExtension); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
virtual ~ExtensionRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,102 +0,0 @@
|
||||
// ExternalRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "FltFile.h"
|
||||
#include "ExternalRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExternalRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<ExternalRecord> g_ExternalProxy;
|
||||
|
||||
ExternalRecord::ExternalRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
ExternalRecord::~ExternalRecord()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filename of the external record. External references are
|
||||
* specified as either:
|
||||
* filename - include the entire file
|
||||
* filename<modelname> - include only the specified model from the file
|
||||
*
|
||||
* Therefore, the filename is either the entire string or the portion of the
|
||||
* string prior to the first '<' character.
|
||||
**/
|
||||
const std::string ExternalRecord::getFilename( void )
|
||||
{
|
||||
std::string wholeFilename(getData()->szPath);
|
||||
std::string filename;
|
||||
|
||||
size_t pos = wholeFilename.find_first_of( "<" );
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
filename = wholeFilename.substr( 0, pos );
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = wholeFilename;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the modelname of the external record. External references are
|
||||
* specified as either:
|
||||
* filename - include the entire file
|
||||
* filename<modelname> - include only the specified model from the file
|
||||
*
|
||||
* Therefore, the modelname is the portion of the string between '<' and '>'
|
||||
* characters when those characters are present. Otherwise there is no
|
||||
* modelname.
|
||||
**/
|
||||
std::string ExternalRecord::getModelName( void )
|
||||
{
|
||||
std::string wholeFilename(getData()->szPath);
|
||||
std::string modelName;
|
||||
|
||||
size_t pos = wholeFilename.find_first_of( "<" );
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
size_t pos2 = wholeFilename.find_first_of( ">" );
|
||||
|
||||
// Starting after the first '<', return the characters prior to the
|
||||
// first '>'.
|
||||
modelName = wholeFilename.substr( pos+1, pos2-pos-1 );
|
||||
}
|
||||
|
||||
return modelName;
|
||||
}
|
||||
|
||||
|
||||
void ExternalRecord::setExternal(FltFile* pExternal)
|
||||
{
|
||||
_fltfile = pExternal;
|
||||
}
|
||||
|
||||
|
||||
void ExternalRecord::endian()
|
||||
{
|
||||
SExternalReference *pSExternal = (SExternalReference*)getData();
|
||||
|
||||
if (getFlightVersion() > 13)
|
||||
{
|
||||
ENDIAN( pSExternal->dwFlags );
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
// ExternalRecord.h
|
||||
|
||||
#ifndef __FLT_EXTERNAL_RECORD_H
|
||||
#define __FLT_EXTERNAL_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SExternalReference
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szPath[200]; // 199 char ASCII Path; 0 terminates
|
||||
// version 11, 12 & 13 stops here!
|
||||
uint8 swReserved[4]; // Reserved
|
||||
uint32 dwFlags; // Flags (bits from left to right)
|
||||
// 0 = Color Palette Override
|
||||
// 1 = Material Palette Override
|
||||
// 2 = Texture Palette Override
|
||||
// 3 = Line Palette Override
|
||||
// 4 = Sound Palette Override
|
||||
// 5 = Light source Palette Override
|
||||
// 6 = Light point Palette Override
|
||||
// 7-31 Spare
|
||||
// int16 iReserved; // Reserved
|
||||
};
|
||||
|
||||
|
||||
class ExternalRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
ExternalRecord();
|
||||
|
||||
virtual Record* clone() const { return new ExternalRecord(); }
|
||||
virtual const char* className() const { return "ExternalRecord"; }
|
||||
virtual int classOpcode() const { return EXTERNAL_REFERENCE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SExternalReference* getData() const { return (SExternalReference*)_pData; }
|
||||
|
||||
void setExternal(FltFile* pExternal);
|
||||
|
||||
FltFile* getExternal() { return _fltfile.get(); }
|
||||
|
||||
const std::string getFilename( void );
|
||||
std::string getModelName() ;
|
||||
|
||||
enum Flag
|
||||
{
|
||||
COLOR_PALETTE_OVERRIDE = BIT31,
|
||||
MATERIAL_PALETTE_OVERRIDE = BIT30,
|
||||
TEXTURE_PALETTE_OVERRIDE = BIT29,
|
||||
LINESTYLE_PALETTE_OVERRIDE = BIT28,
|
||||
SOUND_PALETTE_OVERRIDE = BIT27,
|
||||
LIGHTSOURCE_PALETTE_OVERRIDE = BIT26,
|
||||
LIGHT_POINT_PALETTE_OVERRIDE = BIT25
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual ~ExternalRecord();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
virtual void endian();
|
||||
|
||||
osg::ref_ptr<FltFile> _fltfile;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
// FaceRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "FaceRecord.h"
|
||||
#include "Input.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FaceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<FaceRecord> g_FaceProxy;
|
||||
|
||||
FaceRecord::FaceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
FaceRecord::~FaceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int FaceRecord::numberOfVertices()
|
||||
{
|
||||
for (int n=0; n < getNumChildren(); n++)
|
||||
{
|
||||
Record* child = getChild(n);
|
||||
if (!child) continue;
|
||||
|
||||
if (child->isOfType(VERTEX_LIST_OP))
|
||||
{
|
||||
return ((VertexListRecord*)child)->numberOfVertices();
|
||||
}
|
||||
else if (child->isOfType(MORPH_VERTEX_LIST_OP))
|
||||
{
|
||||
return ((MorphVertexListRecord*)child)->numberOfVertices();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FaceRecord::getVertexPoolOffset(int index)
|
||||
{
|
||||
for (int n=0; n < getNumChildren(); n++)
|
||||
{
|
||||
Record* child = getChild(n);
|
||||
if (!child) continue;
|
||||
|
||||
if (child->isOfType(VERTEX_LIST_OP))
|
||||
{
|
||||
return ((VertexListRecord*)child)->getVertexPoolOffset(index);
|
||||
}
|
||||
else if (child->isOfType(MORPH_VERTEX_LIST_OP))
|
||||
{
|
||||
return ((MorphVertexListRecord*)child)->getVertexPoolOffset(index);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FaceRecord::endian()
|
||||
{
|
||||
SFace *pSFace = (SFace*)getData();
|
||||
|
||||
ENDIAN( pSFace->diIRColor );
|
||||
ENDIAN( pSFace->iObjectRelPriority );
|
||||
ENDIAN( pSFace->wPrimaryNameIndex );
|
||||
ENDIAN( pSFace->wSecondaryNameIndex );
|
||||
ENDIAN( pSFace->iDetailTexturePattern );
|
||||
ENDIAN( pSFace->iTexturePattern );
|
||||
ENDIAN( pSFace->iMaterial );
|
||||
ENDIAN( pSFace->iSurfaceMaterial );
|
||||
ENDIAN( pSFace->iFeature );
|
||||
ENDIAN( pSFace->diIRMaterial );
|
||||
ENDIAN( pSFace->wTransparency );
|
||||
|
||||
// Face record extended after version 13
|
||||
if (getFltFile()->getFlightVersion() > 13)
|
||||
{
|
||||
ENDIAN( pSFace->dwFlags );
|
||||
// ENDIAN( pSFace->PrimaryPackedColor );
|
||||
// ENDIAN( pSFace->SecondaryPackedColor );
|
||||
ENDIAN( pSFace->iTextureMapIndex );
|
||||
ENDIAN( pSFace->dwPrimaryColorIndex );
|
||||
ENDIAN( pSFace->dwAlternateColorIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
bool FaceRecord::readLocalData(Input& fr)
|
||||
{
|
||||
if (!PrimNodeRecord::readLocalData(fr))
|
||||
return false;
|
||||
|
||||
//
|
||||
// Check for subfaces
|
||||
//
|
||||
|
||||
Record* pRec;
|
||||
|
||||
if (!(pRec=fr.readCreateRecord(_pFltFile))) return false;
|
||||
|
||||
if (pRec->getOpcode() != PUSH_SUBFACE_OP)
|
||||
return fr.rewindLast();
|
||||
|
||||
while ((pRec=fr.readCreateRecord(_pFltFile)))
|
||||
{
|
||||
if (pRec->getOpcode()==POP_SUBFACE_OP) return true;
|
||||
|
||||
if (pRec->isPrimaryNode())
|
||||
{
|
||||
addChild(pRec);
|
||||
|
||||
if (!((PrimNodeRecord*)pRec)->readLocalData(fr))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return (pRec != NULL);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexListRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<VertexListRecord> g_VertexListProxy;
|
||||
|
||||
VertexListRecord::VertexListRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
VertexListRecord::~VertexListRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int VertexListRecord::numberOfVertices()
|
||||
{
|
||||
return getBodyLength()/4;
|
||||
}
|
||||
|
||||
|
||||
int VertexListRecord::getVertexPoolOffset(int index)
|
||||
{
|
||||
SSingleVertexList *pSVertexList = (SSingleVertexList*)getData();
|
||||
|
||||
if ((index >= 0) && (index < numberOfVertices()))
|
||||
return pSVertexList->diSOffset[index];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void VertexListRecord::endian()
|
||||
{
|
||||
SSingleVertexList *pSVertexList = (SSingleVertexList*)getData();
|
||||
int nNumberOfVertices = numberOfVertices();
|
||||
|
||||
for(int i=0; i < nNumberOfVertices; i++)
|
||||
{
|
||||
ENDIAN( pSVertexList->diSOffset[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MorphVertexListRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MorphVertexListRecord> g_MorphVertexListRecordProxy;
|
||||
|
||||
MorphVertexListRecord::MorphVertexListRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MorphVertexListRecord::~MorphVertexListRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int MorphVertexListRecord::numberOfVertices()
|
||||
{
|
||||
return getBodyLength()/8;
|
||||
}
|
||||
|
||||
|
||||
int MorphVertexListRecord::getVertexPoolOffset(int index)
|
||||
{
|
||||
MorphVertexListTag *pSMorphVertexList = (MorphVertexListTag*)getData();
|
||||
|
||||
if ((index >= 0) && (index < numberOfVertices()))
|
||||
{
|
||||
return pSMorphVertexList->list[index].dwOffset0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MorphVertexListRecord::endian()
|
||||
{
|
||||
SMorphVertexList *pSMorpVertexList = (SMorphVertexList*)getData();
|
||||
int nNumberOfVertices = numberOfVertices();
|
||||
|
||||
for(int i=0; i < nNumberOfVertices; i++)
|
||||
{
|
||||
ENDIAN( pSMorpVertexList->list[i].dwOffset0 );
|
||||
ENDIAN( pSMorpVertexList->list[i].dwOffset100 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VectorRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<VectorRecord> g_VectorProxy;
|
||||
|
||||
VectorRecord::VectorRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
VectorRecord::~VectorRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void VectorRecord::endian()
|
||||
{
|
||||
SVector *pSVector = (SVector*)getData();
|
||||
|
||||
pSVector->Vec.endian();
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
// FaceRecord.h
|
||||
|
||||
#ifndef __FLT_FACE_RECORD_H
|
||||
#define __FLT_FACE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FaceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SFace
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 diIRColor; // IR Color Code
|
||||
int16 iObjectRelPriority; // Polygon relative priority
|
||||
uint8 swDrawFlag; // How to draw the polygon
|
||||
// = 0 Draw solid backfaced
|
||||
// = 1 Draw solid no backface
|
||||
// = 2 Draw closed wireframe (swapped in documentation)
|
||||
// = 3 Draw wireframe and not closed (swapped in documentation)
|
||||
// = 4 Surround with wireframe in alternate color
|
||||
// = 8 Omni-directional light
|
||||
// = 9 Unidirectional light
|
||||
// = 10 Bidirectional light
|
||||
uint8 swTexWhite; // if TRUE, draw textured polygon white (see note 1 below)
|
||||
uint16 wPrimaryNameIndex; // Color name index
|
||||
uint16 wSecondaryNameIndex; // Alternate color name index
|
||||
uint8 swNotUsed; // Not used
|
||||
uint8 swTemplateTrans; // Set template transparency
|
||||
// = 0 None
|
||||
// = 1 Fixed
|
||||
// = 2 Axis type rotate
|
||||
// = 4 Point rotate
|
||||
int16 iDetailTexturePattern; // Detail texture pattern no. -1 if none
|
||||
int16 iTexturePattern; // Texture pattern no. -1 if none
|
||||
int16 iMaterial; // Material code [0-63]. -1 if none
|
||||
int16 iSurfaceMaterial; // Surface material code (for DFAD)
|
||||
int16 iFeature; // Feature ID (for DFAD)
|
||||
int32 diIRMaterial; // IR Material codes
|
||||
uint16 wTransparency; // Transparency
|
||||
// = 0 opaque
|
||||
// = 65535 for totally clear
|
||||
// version 11, 12 & 13 ends here!
|
||||
|
||||
uint8 swInfluenceLODGen; // LOD Generation Control
|
||||
uint8 swLinestyle; // Linestyle Index
|
||||
uint32 dwFlags; // Flags (bits from left to right)
|
||||
// 0 = Terrain
|
||||
// 1 = No Color
|
||||
// 2 = No Alt Color
|
||||
// 3 = Packed color
|
||||
// 4 = Terrain culture cutout (footprint)
|
||||
// 5 = Hidden (not drawn)
|
||||
// 6 = Hidden (not drawn)
|
||||
// 7-31 Spare
|
||||
uint8 swLightMode; // Lightmode
|
||||
// = 0 use face color, not illuminated
|
||||
// = 1 use vertex color, not illuminated
|
||||
// = 2 use face color and vertex normal
|
||||
// = 3 use vertex color and vertex normal
|
||||
|
||||
uint8 Reserved1[7]; // Reserved
|
||||
color32 PrimaryPackedColor; // Packed Color Primary (A, B, G, R)
|
||||
color32 SecondaryPackedColor; // Packed Color Secondary (A, B, G, R)
|
||||
int16 iTextureMapIndex; // Texture mapping index
|
||||
int16 iReserved2;
|
||||
uint32 dwPrimaryColorIndex;
|
||||
uint32 dwAlternateColorIndex;
|
||||
uint16 Reserved3[2];
|
||||
};
|
||||
|
||||
|
||||
class FaceRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum DrawFlag {
|
||||
SOLID_BACKFACED = 0,
|
||||
SOLID_NO_BACKFACE = 1,
|
||||
WIREFRAME_CLOSED = 2,
|
||||
WIREFRAME_NOT_CLOSED = 3,
|
||||
SURROUND_ALTERNATE_COLOR = 4,
|
||||
OMNIDIRECTIONAL_LIGHT = 8,
|
||||
UNIDIRECTIONAL_LIGHT = 9,
|
||||
BIDIRECTIONAL_LIGHT = 10
|
||||
};
|
||||
|
||||
enum LightMode {
|
||||
FACE_COLOR = 0,
|
||||
VERTEX_COLOR = 1,
|
||||
FACE_COLOR_LIGHTING = 2,
|
||||
VERTEX_COLOR_LIGHTING = 3
|
||||
};
|
||||
|
||||
enum FlagBit {
|
||||
TERRAIN_BIT = 0x80000000,
|
||||
NO_COLOR_BIT = 0x40000000,
|
||||
NO_ALT_COLOR_BIT = 0x20000000,
|
||||
PACKED_COLOR_BIT = 0x10000000,
|
||||
FOOTPRINT_BIT = 0x08000000,
|
||||
HIDDEN_BIT = 0x04000000
|
||||
};
|
||||
|
||||
FaceRecord();
|
||||
|
||||
virtual Record* clone() const { return new FaceRecord(); }
|
||||
virtual const char* className() const { return "FaceRecord"; }
|
||||
virtual int classOpcode() const { return FACE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SFace); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SFace* getData() const { return (SFace*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
int numberOfVertices();
|
||||
int getVertexPoolOffset(int index);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~FaceRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexListRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct SingleVertexListTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diSOffset[1]; // Byte offset to this vertex record in vertex table,
|
||||
// the actual vertex of the face
|
||||
} SSingleVertexList;
|
||||
|
||||
|
||||
|
||||
class VertexListRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
VertexListRecord();
|
||||
|
||||
virtual Record* clone() const { return new VertexListRecord(); }
|
||||
virtual const char* className() const { return "VertexListRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_LIST_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SSingleVertexList); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SSingleVertexList* getData() const { return (SSingleVertexList*)_pData; }
|
||||
|
||||
int numberOfVertices();
|
||||
int getVertexPoolOffset(int index);
|
||||
|
||||
protected:
|
||||
virtual ~VertexListRecord();
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MorphVertexListRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct MorphVertexListTag
|
||||
{
|
||||
struct VertexPair
|
||||
{
|
||||
uint32 dwOffset0; // Byte offset into vertex palette of the 0% vertex
|
||||
uint32 dwOffset100; // Byte offset into vertex palette of the 100% vertex
|
||||
};
|
||||
|
||||
SRecHeader RecHeader;
|
||||
VertexPair list[1];
|
||||
} SMorphVertexList;
|
||||
|
||||
|
||||
|
||||
class MorphVertexListRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
MorphVertexListRecord();
|
||||
|
||||
virtual Record* clone() const { return new MorphVertexListRecord(); }
|
||||
virtual const char* className() const { return "MorphVertexListRecord"; }
|
||||
virtual int classOpcode() const { return MORPH_VERTEX_LIST_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SMorphVertexList); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SMorphVertexList* getData() const { return (SMorphVertexList*)_pData; }
|
||||
|
||||
int numberOfVertices();
|
||||
int getVertexPoolOffset(int index);
|
||||
|
||||
protected:
|
||||
virtual ~MorphVertexListRecord();
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VectorRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// A vector record is an ancillary record of the (pre V15.4) face node.
|
||||
// Its only use is to provide the direction vector for old-style
|
||||
// unidirectional and bidirectional light point faces.
|
||||
|
||||
typedef struct VectorTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
float32x3 Vec;
|
||||
} SVector;
|
||||
|
||||
|
||||
|
||||
class VectorRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
VectorRecord();
|
||||
|
||||
virtual Record* clone() const { return new VectorRecord(); }
|
||||
virtual const char* className() const { return "VectorRecord"; }
|
||||
virtual int classOpcode() const { return VECTOR_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SVector); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SVector* getData() const { return (SVector*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~VectorRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
// FindExternalModelVisitor.cpp
|
||||
|
||||
#include "FindExternalModelVisitor.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void FindExternalModelVisitor::apply( osg::Node &node )
|
||||
{
|
||||
if ( node.getName() == _modelName )
|
||||
_model = &node; // Store the node. No need to process children.
|
||||
else
|
||||
traverse( node );
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// FindExternalModelVisitor.h
|
||||
|
||||
#ifndef __FIND_EXTERNAL_MODEL_VISITOR_H_
|
||||
#define __FIND_EXTERNAL_MODEL_VISITOR_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
|
||||
namespace flt {
|
||||
|
||||
/**
|
||||
* A visitor to find a named node.
|
||||
*/
|
||||
class FindExternalModelVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
FindExternalModelVisitor( ) : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN ) {}
|
||||
|
||||
virtual void apply( osg::Node &node );
|
||||
|
||||
void setModelName( std::string modelName ) { _modelName = modelName; }
|
||||
|
||||
osg::Node *getModel() { return _model.get(); }
|
||||
|
||||
private:
|
||||
|
||||
std::string _modelName;
|
||||
osg::ref_ptr<osg::Node> _model;
|
||||
|
||||
};
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FIND_EXTERNAL_MODEL_VISITOR_H_
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
#include "FltFile.h"
|
||||
#include "Registry.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
#include "ExternalRecord.h"
|
||||
#include "flt2osg.h" // ConvertFromFLT
|
||||
#include "Input.h"
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/FileNameUtils>
|
||||
|
||||
#include <osgSim/GeographicLocation>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
FltFile::FltFile(
|
||||
ColorPool* pColorPool,
|
||||
TexturePool* pTexturePool,
|
||||
MaterialPool* pMaterialPool,
|
||||
LtPtAppearancePool* pLtPtAppearancePool,
|
||||
LtPtAnimationPool* pLtPtAnimationPool,
|
||||
osgDB::ReaderWriter::Options* options):
|
||||
_useTextureAlphaForTransparancyBinning(true),
|
||||
_doUnitsConversion(true),
|
||||
_defaultDOFAnimationState(false),
|
||||
_desiredUnits(ConvertToMeters)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if (pColorPool)
|
||||
{
|
||||
// use external color palette, ignore internal
|
||||
_useInternalColorPalette = false;
|
||||
setColorPool( pColorPool );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use internal color palette
|
||||
_useInternalColorPalette = true;
|
||||
setColorPool( new ColorPool );
|
||||
}
|
||||
|
||||
if (pTexturePool)
|
||||
{
|
||||
// use external texture palette, ignore internal
|
||||
_useInternalTexturePalette = false;
|
||||
setTexturePool( pTexturePool );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use internal texture palette
|
||||
_useInternalTexturePalette = true;
|
||||
setTexturePool( new TexturePool );
|
||||
}
|
||||
|
||||
if (pMaterialPool)
|
||||
{
|
||||
// use external material palette, ignore internal
|
||||
_useInternalMaterialPalette = false;
|
||||
setMaterialPool( pMaterialPool );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use internal material palette
|
||||
_useInternalMaterialPalette = true;
|
||||
setMaterialPool( new MaterialPool );
|
||||
}
|
||||
|
||||
if (pLtPtAppearancePool && pLtPtAnimationPool) // Can only be non-NULL if parent is 15.8.
|
||||
{
|
||||
// use external light point appearance and animation palettes, ignore internal
|
||||
_useInternalLtPtPalettes = false;
|
||||
setLtPtAppearancePool( pLtPtAppearancePool );
|
||||
setLtPtAnimationPool( pLtPtAnimationPool );
|
||||
}
|
||||
else
|
||||
{
|
||||
// If they aren't both set, then they must both be NULL.
|
||||
assert( (pLtPtAppearancePool==NULL) && (pLtPtAppearancePool==NULL) );
|
||||
// use internal light point palettes
|
||||
_useInternalLtPtPalettes = true;
|
||||
setLtPtAppearancePool( new LtPtAppearancePool );
|
||||
setLtPtAnimationPool( new LtPtAnimationPool );
|
||||
}
|
||||
|
||||
// no support for external light palettes
|
||||
setLightPool( new LightPool );
|
||||
|
||||
// instances are always internally defined
|
||||
setInstancePool( new InstancePool );
|
||||
|
||||
_options = options;
|
||||
}
|
||||
|
||||
|
||||
osg::Object* FltFile::readObject(const std::string& fileName)
|
||||
{
|
||||
return readNode(fileName);
|
||||
}
|
||||
|
||||
|
||||
osg::Node* FltFile::readNode(const std::string& fileName)
|
||||
{
|
||||
_directory = osgDB::getFilePath(fileName);
|
||||
|
||||
if (readModel(fileName))
|
||||
{
|
||||
// Convert record tree to osg scene graph
|
||||
osg::Node* model = convert();
|
||||
|
||||
if (model)
|
||||
{
|
||||
// Store model origin in returned Node userData.
|
||||
osg::ref_ptr<osgSim::GeographicLocation> loc = new osgSim::GeographicLocation;
|
||||
double lat, lon;
|
||||
getOrigin( lat, lon );
|
||||
loc->set( lat, lon );
|
||||
model->setUserData( loc.get() );
|
||||
|
||||
osg::notify(osg::INFO)<<"FltFile::readNode("<<fileName<<") lat="<<lat<<" lon="<<lon<<std::endl;
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
osg::Group* FltFile::convert()
|
||||
{
|
||||
ConvertFromFLT visit;
|
||||
visit.setUseTextureAlphaForTransparancyBinning(getUseTextureAlphaForTransparancyBinning());
|
||||
visit.setDoUnitsConversion(getDoUnitsConversion());
|
||||
return visit.convert(getHeaderRecord());
|
||||
}
|
||||
|
||||
|
||||
// Read flight model (include externals)
|
||||
bool FltFile::readModel(const std::string& fileName)
|
||||
{
|
||||
if (readFile(fileName))
|
||||
{
|
||||
readExternals();
|
||||
return getHeaderRecord() ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool FltFile::readFile(const std::string& fileName)
|
||||
{
|
||||
|
||||
// havn't found file, look in OSGFILEPATH
|
||||
std::string foundFileName = osgDB::findDataFile(fileName, _options.get());
|
||||
if (foundFileName.empty()) return false;
|
||||
|
||||
FileInput fin;
|
||||
if (!fin.open(foundFileName)) return false;
|
||||
|
||||
Record* pRec = fin.readCreateRecord(this);
|
||||
if (pRec == NULL)
|
||||
{
|
||||
osg::notify(osg::WARN) << "File not found " << fileName << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_headerRecord = (HeaderRecord*)pRec;
|
||||
if (pRec->isPrimaryNode()) // Header
|
||||
pRec->readLocalData(fin);// Read rest of file
|
||||
|
||||
fin.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_FLT 1
|
||||
|
||||
// This class was originally scoped within FltFile::readExternals() function.
|
||||
// Irix 7.3 compilers hork on this.
|
||||
|
||||
class ReadExternal : public RecordVisitor
|
||||
{
|
||||
public:
|
||||
ReadExternal(FltFile* fltFile)
|
||||
{
|
||||
_pFltFile = fltFile;
|
||||
setTraverseMode(RecordVisitor::TRAVERSE_ALL_CHILDREN);
|
||||
}
|
||||
|
||||
virtual void apply(ExternalRecord& rec)
|
||||
{
|
||||
SExternalReference* pSExternal = (SExternalReference*)rec.getData();
|
||||
|
||||
if (pSExternal)
|
||||
{
|
||||
FltFile* pExternalFltFile = NULL;
|
||||
ColorPool* pColorPool = NULL;
|
||||
TexturePool* pTexturePool = NULL;
|
||||
MaterialPool* pMaterialPool = NULL;
|
||||
LtPtAppearancePool* pLtPtAppearancePool = NULL;
|
||||
LtPtAnimationPool* pLtPtAnimationPool = NULL;
|
||||
std::string filename( rec.getFilename() );
|
||||
|
||||
osg::notify(osg::INFO) << "External=" << filename << std::endl;
|
||||
|
||||
if (rec.getFlightVersion() > 13)
|
||||
{
|
||||
if (!(pSExternal->dwFlags & ExternalRecord::COLOR_PALETTE_OVERRIDE))
|
||||
pColorPool = _pFltFile->getColorPool();
|
||||
|
||||
if (!(pSExternal->dwFlags & ExternalRecord::TEXTURE_PALETTE_OVERRIDE))
|
||||
pTexturePool = _pFltFile->getTexturePool();
|
||||
|
||||
if (!(pSExternal->dwFlags & ExternalRecord::MATERIAL_PALETTE_OVERRIDE))
|
||||
pMaterialPool = _pFltFile->getMaterialPool();
|
||||
|
||||
if (rec.getFlightVersion() >= 1580)
|
||||
{
|
||||
if (!(pSExternal->dwFlags & ExternalRecord::LIGHT_POINT_PALETTE_OVERRIDE))
|
||||
{
|
||||
pLtPtAppearancePool = _pFltFile->getLtPtAppearancePool();
|
||||
pLtPtAnimationPool = _pFltFile->getLtPtAnimationPool();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if REGISTER_FLT
|
||||
bool registerFLT = true;
|
||||
#else
|
||||
bool registerFLT = false;
|
||||
#endif
|
||||
|
||||
pExternalFltFile = registerFLT ? Registry::instance()->getFltFile(filename) : NULL;
|
||||
if (pExternalFltFile == NULL)
|
||||
{
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> options =
|
||||
_pFltFile->getOptions() ? _pFltFile->getOptions() :
|
||||
new osgDB::ReaderWriter::Options;
|
||||
|
||||
//Path for Nested external references
|
||||
osgDB::FilePathList& fpl = options->getDatabasePathList();
|
||||
const std::string& filePath = osgDB::getFilePath(filename);
|
||||
std::string pushAndPopPath;
|
||||
//If absolute path
|
||||
if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) ||
|
||||
(filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) )
|
||||
{
|
||||
pushAndPopPath = filePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
pushAndPopPath = (fpl.empty() | fpl.back().empty() ? "." : fpl.back()) + "/" + filePath;
|
||||
}
|
||||
|
||||
/*char optionsString[256];
|
||||
sprintf(optionsString,"FLT_VER %d",rec.getFlightVersion());
|
||||
options->setOptionString(optionsString);*/
|
||||
|
||||
//osg::notify(osg::NOTICE)<<"Create local path"<<pushAndPopPath<<std::endl;
|
||||
|
||||
fpl.push_back(pushAndPopPath);
|
||||
|
||||
|
||||
pExternalFltFile = new FltFile( pColorPool, pTexturePool, pMaterialPool,
|
||||
pLtPtAppearancePool, pLtPtAnimationPool, options.get() );
|
||||
|
||||
if (registerFLT)
|
||||
{
|
||||
Registry::instance()->addFltFile(filename, pExternalFltFile);
|
||||
}
|
||||
|
||||
pExternalFltFile->readModel(filename);
|
||||
|
||||
fpl.pop_back();
|
||||
}
|
||||
|
||||
rec.setExternal(pExternalFltFile);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
FltFile* _pFltFile;
|
||||
};
|
||||
|
||||
void FltFile::readExternals()
|
||||
{
|
||||
ReadExternal visitor(this);
|
||||
_headerRecord->accept(visitor);
|
||||
}
|
||||
|
||||
|
||||
int FltFile::getFlightVersion() const
|
||||
{
|
||||
if (_headerRecord.get())
|
||||
{
|
||||
SHeader* pSHeader = (SHeader*)_headerRecord.get()->getData();
|
||||
if (pSHeader)
|
||||
return pSHeader->diFormatRevLev;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FltFile::getOrigin( double& latitude, double& longitude ) const
|
||||
{
|
||||
if (_headerRecord.get())
|
||||
{
|
||||
SHeader* pSHeader = (SHeader*)_headerRecord.get()->getData();
|
||||
if (pSHeader)
|
||||
{
|
||||
latitude = pSHeader->Origin.x();
|
||||
longitude = pSHeader->Origin.y();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string FltFile::getDesiredUnitsString() const
|
||||
{
|
||||
switch (_desiredUnits)
|
||||
{
|
||||
case ConvertToMeters:
|
||||
return "ConvertToMeters";
|
||||
break;
|
||||
case ConvertToKilometers:
|
||||
return "ConvertToKilometers";
|
||||
break;
|
||||
case ConvertToFeet:
|
||||
return "ConvertToFeet";
|
||||
break;
|
||||
case ConvertToInches:
|
||||
return "ConvertToInches";
|
||||
break;
|
||||
case ConvertToNauticalMiles:
|
||||
return "ConvertToNauticalMiles";
|
||||
break;
|
||||
default:
|
||||
return "Invalid";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// FltFile.h
|
||||
|
||||
#ifndef __FLT_FILE_H
|
||||
#define __FLT_FILE_H
|
||||
|
||||
#include <osg/Group>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "Pool.h"
|
||||
#include "HeaderRecord.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
class Record;
|
||||
|
||||
|
||||
class FltFile : public osg::Referenced
|
||||
{
|
||||
|
||||
public:
|
||||
FltFile(
|
||||
ColorPool* pColorPool = NULL,
|
||||
TexturePool* pTexturePool = NULL,
|
||||
MaterialPool* pMaterialPool = NULL,
|
||||
LtPtAppearancePool* pLtPtAppearancePool = NULL,
|
||||
LtPtAnimationPool* pLtPtAnimationPool = NULL,
|
||||
osgDB::ReaderWriter::Options* options = NULL);
|
||||
|
||||
virtual osg::Object* readObject(const std::string& fileName);
|
||||
virtual osg::Node* readNode(const std::string& fileName);
|
||||
osg::Group* convert();
|
||||
bool readModel(const std::string& fileName);
|
||||
|
||||
ColorPool* getColorPool() { return _colorPool.get(); }
|
||||
TexturePool* getTexturePool() { return _texturePool.get(); }
|
||||
LightPool* getLightPool() { return _lightPool.get(); }
|
||||
MaterialPool* getMaterialPool() { return _materialPool.get(); }
|
||||
InstancePool* getInstancePool() { return _instancePool.get(); }
|
||||
LtPtAppearancePool* getLtPtAppearancePool() { return _ltPtAppearancePool.get(); }
|
||||
LtPtAnimationPool* getLtPtAnimationPool() { return _ltPtAnimationPool.get(); }
|
||||
|
||||
void setColorPool(ColorPool* colorPool) { _colorPool = colorPool; }
|
||||
void setTexturePool(TexturePool* texturePool) { _texturePool = texturePool; }
|
||||
void setLightPool(LightPool* lightPool){ _lightPool = lightPool; }
|
||||
void setMaterialPool(MaterialPool* materialPool){ _materialPool = materialPool; }
|
||||
void setInstancePool(InstancePool* instancePool){ _instancePool = instancePool; }
|
||||
void setLtPtAppearancePool(LtPtAppearancePool* ltPtAppearancePool){ _ltPtAppearancePool = ltPtAppearancePool; }
|
||||
void setLtPtAnimationPool(LtPtAnimationPool* ltPtAnimationPool){ _ltPtAnimationPool = ltPtAnimationPool; }
|
||||
|
||||
inline bool useInternalColorPalette() const { return _useInternalColorPalette; }
|
||||
inline bool useInternalTexturePalette() const { return _useInternalTexturePalette; }
|
||||
inline bool useInternalMaterialPalette() const { return _useInternalMaterialPalette; }
|
||||
inline bool useInternalLtPtPalettes() const { return _useInternalLtPtPalettes; }
|
||||
|
||||
void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTransparancyBinning=flag; }
|
||||
bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTransparancyBinning; }
|
||||
void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; }
|
||||
bool getDoUnitsConversion() const { return _doUnitsConversion; }
|
||||
|
||||
typedef enum {
|
||||
ConvertToMeters,
|
||||
ConvertToKilometers,
|
||||
ConvertToFeet,
|
||||
ConvertToInches,
|
||||
ConvertToNauticalMiles
|
||||
} ConvertUnits;
|
||||
void setDesiredUnits( FltFile::ConvertUnits units ) { _desiredUnits=units; }
|
||||
FltFile::ConvertUnits getDesiredUnits() const { return _desiredUnits; }
|
||||
std::string getDesiredUnitsString() const;
|
||||
|
||||
void setDefaultDOFAnimationState(bool defaultDOFAnimationState) { _defaultDOFAnimationState = defaultDOFAnimationState; }
|
||||
bool getDefaultDOFAnimationState() const { return _defaultDOFAnimationState; }
|
||||
|
||||
int getFlightVersion() const;
|
||||
inline HeaderRecord* getHeaderRecord() { return _headerRecord.get(); }
|
||||
void getOrigin( double& latitude, double& longitude ) const;
|
||||
|
||||
void setOptions(osgDB::ReaderWriter::Options* options) { _options = options; }
|
||||
osgDB::ReaderWriter::Options* getOptions() { return _options.get(); }
|
||||
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~FltFile() {}
|
||||
|
||||
bool readFile(const std::string& fileName);
|
||||
void readExternals();
|
||||
|
||||
private:
|
||||
|
||||
osg::ref_ptr<HeaderRecord> _headerRecord;
|
||||
|
||||
bool _useInternalColorPalette;
|
||||
bool _useInternalTexturePalette;
|
||||
bool _useInternalMaterialPalette;
|
||||
bool _useInternalLtPtPalettes;
|
||||
bool _useTextureAlphaForTransparancyBinning;
|
||||
bool _doUnitsConversion;
|
||||
bool _defaultDOFAnimationState; //< Default DOF Animation state
|
||||
ConvertUnits _desiredUnits;
|
||||
|
||||
std::string _directory;
|
||||
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> _options;
|
||||
|
||||
osg::ref_ptr<ColorPool> _colorPool;
|
||||
osg::ref_ptr<TexturePool> _texturePool;
|
||||
osg::ref_ptr<LightPool> _lightPool;
|
||||
osg::ref_ptr<MaterialPool> _materialPool;
|
||||
osg::ref_ptr<InstancePool> _instancePool;
|
||||
osg::ref_ptr<LtPtAppearancePool> _ltPtAppearancePool;
|
||||
osg::ref_ptr<LtPtAnimationPool> _ltPtAnimationPool;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,95 +0,0 @@
|
||||
// FltRecords.h
|
||||
|
||||
|
||||
#ifndef __FLT_RECORDS_H
|
||||
#define __FLT_RECORDS_H
|
||||
|
||||
#include "flt.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct MorphingVertexListTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diAOffset; // Byte offset to the actual vertex record in the vertex table.
|
||||
int32 diMOffset; // Byte offset to the morph vertex record in the vertex table.
|
||||
} SMorphingVertexList; // see OF doc
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct ReplicateTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int16 iNumber; // Number of replications
|
||||
int16 iSpare; // Spare for fullword alignment
|
||||
} SReplicate;
|
||||
|
||||
/*
|
||||
typedef struct ReferenceTag // OBSOLETE
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int16 iSpare; // Spare
|
||||
int16 iNumber; // Instance definition number
|
||||
} SReference;
|
||||
|
||||
|
||||
typedef struct DefinitionTag // OBSOLETE
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int16 iSpare; // Spare
|
||||
int16 iNumber; // Instance definition number
|
||||
} SDefinition;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
typedef struct ColorTableTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szReserved[128];// Reserved
|
||||
color32 Colors[1024]; // Array of brightest RGB of color 0 - 1024
|
||||
} SColorTable;
|
||||
|
||||
// this record is sometimes immediately followed by a: int32 numberOfColorNames
|
||||
// and then the specified number of ColorNames as described in the structure below
|
||||
// to check if such a list exist: compare RecHeaderBuff.wLength with sizeof(SColorTable)
|
||||
|
||||
typedef struct ColorNameListTag
|
||||
{
|
||||
uint16 wEntryLength;
|
||||
int16 iReserved_1;
|
||||
int16 iEntryIndex;
|
||||
int16 iReserved_2;
|
||||
char *szName; // calc length of string from wEntryLength
|
||||
} SColorNameList;
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef struct ComponentTag
|
||||
{
|
||||
float32 sfRed; // red component of material
|
||||
float32 sfGreen; // green component of material
|
||||
float32 sfBlue; // blue component of material
|
||||
} SComponent;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_RECORDS_H
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
BoundingVolumeRecords.cpp\
|
||||
LongIDRecord.cpp\
|
||||
ColorPaletteRecord.cpp\
|
||||
MaterialPaletteRecord.cpp\
|
||||
CommentRecord.cpp\
|
||||
ObjectRecord.cpp\
|
||||
ControlRecord.cpp\
|
||||
OldVertexRecords.cpp\
|
||||
OldMaterialPaletteRecord.cpp\
|
||||
DofRecord.cpp\
|
||||
ExtensionRecord.cpp\
|
||||
ExternalRecord.cpp\
|
||||
Record.cpp\
|
||||
FaceRecord.cpp\
|
||||
LocalVertexPoolRecord.cpp\
|
||||
MeshPrimitiveRecord.cpp\
|
||||
MeshRecord.cpp\
|
||||
RecordVisitor.cpp\
|
||||
RoadRecords.cpp\
|
||||
GeoSetBuilder.cpp\
|
||||
Registry.cpp\
|
||||
FltFile.cpp\
|
||||
GroupRecord.cpp\
|
||||
SwitchRecord.cpp\
|
||||
HeaderRecord.cpp\
|
||||
TexturePaletteRecord.cpp\
|
||||
Input.cpp\
|
||||
TransformationRecords.cpp\
|
||||
InstanceRecords.cpp\
|
||||
UnknownRecord.cpp\
|
||||
LightPointRecord.cpp\
|
||||
VertexPoolRecords.cpp\
|
||||
LightPointPaletteRecords.cpp\
|
||||
LightPointSystemRecord.cpp\
|
||||
LightSourcePaletteRecord.cpp\
|
||||
flt.cpp\
|
||||
LightSourceRecord.cpp\
|
||||
flt2osg.cpp\
|
||||
LodRecord.cpp\
|
||||
Pool.cpp\
|
||||
TextureMappingPaletteRecord.cpp\
|
||||
ReaderWriterFLT.cpp\
|
||||
ReaderWriterATTR.cpp\
|
||||
MultiTextureRecord.cpp\
|
||||
UVListRecord.cpp\
|
||||
BSPRecord.cpp\
|
||||
FindExternalModelVisitor.cpp\
|
||||
# PointLight.cpp\
|
||||
|
||||
|
||||
|
||||
INC += -I$(THISDIR)
|
||||
|
||||
LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = flt
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
@@ -1,395 +0,0 @@
|
||||
// GeoSetBuilder.cpp
|
||||
|
||||
// Modify DynGeoSet::addToGeometry to generate texture coordinates for texture unit 1
|
||||
// that is used to detail texture
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "flt.h"
|
||||
#include "FltFile.h"
|
||||
#include "Pool.h"
|
||||
#include "opcodes.h"
|
||||
#include "GeoSetBuilder.h"
|
||||
|
||||
#include <osg/Object>
|
||||
#include <osg/LOD>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/Geode>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Material>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/Point>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DynGeoSet
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define APPEND_DynGeoSet_List(list) \
|
||||
if (source->list.size() > 0) \
|
||||
list.insert(list.end(), \
|
||||
source->list.begin(), source->list.end());
|
||||
|
||||
|
||||
void DynGeoSet::append(DynGeoSet* source)
|
||||
{
|
||||
APPEND_DynGeoSet_List(_primLenList)
|
||||
APPEND_DynGeoSet_List(_coordList)
|
||||
if (_normal_binding==osg::Geometry::BIND_PER_VERTEX || _normal_binding==osg::Geometry::BIND_PER_PRIMITIVE) APPEND_DynGeoSet_List(_normalList)
|
||||
if (_color_binding==osg::Geometry::BIND_PER_VERTEX || _color_binding==osg::Geometry::BIND_PER_PRIMITIVE) APPEND_DynGeoSet_List(_colorList)
|
||||
|
||||
for (unsigned int i = 0; i < source->_tcoordLists.size(); i++)
|
||||
{
|
||||
if ((getTextureBinding(i)==osg::Geometry::BIND_PER_VERTEX) ||
|
||||
(getTextureBinding(i)==osg::Geometry::BIND_PER_PRIMITIVE))
|
||||
{
|
||||
if (source->_tcoordLists.size() > 0)
|
||||
{
|
||||
if (_tcoordLists.size() <= i)
|
||||
_tcoordLists.resize(i+1);
|
||||
|
||||
_tcoordLists[i].insert(_tcoordLists[i].end(),
|
||||
source->_tcoordLists[i].begin(),
|
||||
source->_tcoordLists[i].end());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define VERIFY_DynGeoSet_Binding(binding,list) \
|
||||
switch (binding) \
|
||||
{ \
|
||||
case osg::Geometry::BIND_PER_VERTEX: \
|
||||
if (list.size() < _coordList.size()) { \
|
||||
binding = osg::Geometry::BIND_OFF; \
|
||||
list.clear(); } \
|
||||
break; \
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE: \
|
||||
if (list.size() < _primLenList.size()) { \
|
||||
binding = osg::Geometry::BIND_OFF; \
|
||||
list.clear(); } \
|
||||
break; \
|
||||
case osg::Geometry::BIND_OVERALL: \
|
||||
if (list.size() < 1) { \
|
||||
binding = osg::Geometry::BIND_OFF; \
|
||||
list.clear(); } \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
}
|
||||
|
||||
const osg::PrimitiveSet::Mode NO_PRIMITIVE_TYPE = (osg::PrimitiveSet::Mode)0xffff;
|
||||
|
||||
DynGeoSet::DynGeoSet()
|
||||
{
|
||||
_primtype = NO_PRIMITIVE_TYPE;
|
||||
_normal_binding = osg::Geometry::BIND_OFF;
|
||||
_color_binding = osg::Geometry::BIND_OFF;
|
||||
|
||||
_detailTextureEnabled = false;
|
||||
|
||||
_geom = new osg::Geometry;
|
||||
}
|
||||
|
||||
void DynGeoSet::setBinding()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
VERIFY_DynGeoSet_Binding(_normal_binding, _normalList)
|
||||
VERIFY_DynGeoSet_Binding(_color_binding, _colorList)
|
||||
|
||||
for (i = 0; i < _tcoordLists.size(); i++)
|
||||
VERIFY_DynGeoSet_Binding(_texture_bindings[i], _tcoordLists[i])
|
||||
|
||||
// Set bindings
|
||||
setNormalBinding(_normal_binding);
|
||||
setColorBinding(_color_binding);
|
||||
|
||||
for (i = 0; i < _tcoordLists.size(); i++)
|
||||
setTextureBinding(i, _texture_bindings[i]);
|
||||
|
||||
osg::StateSet* stateset = getStateSet();
|
||||
if (stateset)
|
||||
{
|
||||
if (_normal_binding == osg::Geometry::BIND_OFF)
|
||||
stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DynGeoSet::addToGeometry(osg::Geometry* geom)
|
||||
{
|
||||
int indexBase = 0;
|
||||
|
||||
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
|
||||
if (vertices)
|
||||
{
|
||||
indexBase = vertices->size();
|
||||
vertices->insert(vertices->end(),_coordList.begin(),_coordList.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
vertices = new osg::Vec3Array(_coordList.begin(),_coordList.end());
|
||||
geom->setVertexArray(vertices);
|
||||
}
|
||||
|
||||
if (!_normalList.empty())
|
||||
{
|
||||
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
|
||||
if (normals)
|
||||
{
|
||||
if (_normal_binding==osg::Geometry::BIND_PER_VERTEX || _normal_binding==osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
normals->insert(normals->end(),_normalList.begin(),_normalList.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
normals = new osg::Vec3Array(_normalList.begin(),_normalList.end());
|
||||
geom->setNormalArray(normals);
|
||||
|
||||
switch(_normal_binding)
|
||||
{
|
||||
case(osg::Geometry::BIND_OVERALL):geom->setNormalBinding(osg::Geometry::BIND_OVERALL);break;
|
||||
case(osg::Geometry::BIND_PER_VERTEX):geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);break;
|
||||
case(osg::Geometry::BIND_PER_PRIMITIVE):geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);break;
|
||||
default:geom->setNormalBinding(osg::Geometry::BIND_OFF); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < _tcoordLists.size(); i++)
|
||||
{
|
||||
if (!_tcoordLists[i].empty())
|
||||
{
|
||||
// Grab the current layer's texture coordinate array from the
|
||||
// geometry
|
||||
osg::Vec2Array* texcoords =
|
||||
dynamic_cast<osg::Vec2Array*>(geom->getTexCoordArray(i));
|
||||
|
||||
// See if we need to create the texture coordinate array or add to
|
||||
// it
|
||||
if (texcoords)
|
||||
{
|
||||
// Append the new texture coordinates to the end of the existing
|
||||
// list
|
||||
texcoords->insert(texcoords->end(),_tcoordLists[i].begin(),
|
||||
_tcoordLists[i].end());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new texture coordinate array
|
||||
texcoords = new osg::Vec2Array(_tcoordLists[i].begin(),
|
||||
_tcoordLists[i].end());
|
||||
geom->setTexCoordArray(i,texcoords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this geometry uses a detail texture, we apply the detail texture
|
||||
// scalars to the texture coordinates on layer 0 to get the detail texture
|
||||
// coordinates, which we put on layer 1. Note that this assumes that
|
||||
// layer 1 is not in use for multitexturing. This means that
|
||||
// multitexturing and detail texturing are not supported at the same time.
|
||||
if ((_detailTextureEnabled) && (!_tcoordLists.empty()) &&
|
||||
(!_tcoordLists[0].empty()))
|
||||
{
|
||||
// Create a new texture coordinate array for the detail texture
|
||||
// coordinates
|
||||
osg::Vec2Array *texcoords2 = new osg::Vec2Array(_tcoordLists[0].begin(),
|
||||
_tcoordLists[0].end());
|
||||
|
||||
// Scale the texture coordinates from layer 0
|
||||
for(unsigned int index=0;index<texcoords2->size();index++)
|
||||
{
|
||||
(*texcoords2)[index][0] *= _detailTexCoord_m;
|
||||
(*texcoords2)[index][1] *= _detailTexCoord_n;
|
||||
}
|
||||
|
||||
// Set the new texcoord array on layer 1 (this wipes out any existing
|
||||
// texture coordinates there)
|
||||
geom->setTexCoordArray(1,texcoords2);
|
||||
}
|
||||
|
||||
if (!_colorList.empty())
|
||||
{
|
||||
osg::Vec4Array* colors = dynamic_cast<osg::Vec4Array*>(geom->getColorArray());
|
||||
if (colors)
|
||||
{
|
||||
if (_color_binding==osg::Geometry::BIND_PER_VERTEX || _color_binding==osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
colors->insert(colors->end(),_colorList.begin(),_colorList.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = new osg::Vec4Array(_colorList.begin(),_colorList.end());
|
||||
geom->setColorArray(colors);
|
||||
|
||||
switch(_color_binding)
|
||||
{
|
||||
case(osg::Geometry::BIND_OVERALL):geom->setColorBinding(osg::Geometry::BIND_OVERALL);break;
|
||||
case(osg::Geometry::BIND_PER_VERTEX):geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);break;
|
||||
case(osg::Geometry::BIND_PER_PRIMITIVE):geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);break;
|
||||
default:geom->setColorBinding(osg::Geometry::BIND_OFF); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_primtype!=osg::PrimitiveSet::POLYGON)
|
||||
{
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(_primtype,indexBase,_coordList.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
for(PrimLenList::iterator itr=_primLenList.begin();
|
||||
itr!=_primLenList.end();
|
||||
++itr)
|
||||
{
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(_primtype,indexBase,*itr));
|
||||
indexBase += *itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GeoSetBuilder
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// OpenFlight don't save data in GeoSets. This class tries to find
|
||||
// existing GeoSets with matching state before creating a new GeoSet.
|
||||
|
||||
|
||||
GeoSetBuilder::GeoSetBuilder(osg::Geode* geode)
|
||||
{
|
||||
_geode = geode;
|
||||
initPrimData();
|
||||
}
|
||||
|
||||
|
||||
void GeoSetBuilder::initPrimData()
|
||||
{
|
||||
_dynGeoSet = new DynGeoSet;
|
||||
_dynGeoSet->setStateSet(new osg::StateSet);
|
||||
}
|
||||
|
||||
struct SortDynGeoSet
|
||||
{
|
||||
bool operator () (const osg::ref_ptr<DynGeoSet>& lhs,const osg::ref_ptr<DynGeoSet>& rhs)
|
||||
{
|
||||
return *lhs<*rhs;
|
||||
}
|
||||
};
|
||||
|
||||
osg::Geode* GeoSetBuilder::createOsgGeoSets(osg::Geode* geode)
|
||||
{
|
||||
if( geode == NULL) geode = _geode.get();
|
||||
if( geode == NULL) return geode;
|
||||
|
||||
for(DynGeoSetList::iterator itr = _dynGeoSetList.begin();
|
||||
itr!=_dynGeoSetList.end();
|
||||
++itr)
|
||||
{
|
||||
DynGeoSet* dgset = itr->get();
|
||||
osg::Geometry* geom = dgset->getGeometry();
|
||||
geode->addDrawable(geom);
|
||||
dgset->addToGeometry(geom);
|
||||
|
||||
osg::StateSet* stateset = dgset->getStateSet();
|
||||
assert( stateset == geom->getStateSet() );
|
||||
}
|
||||
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(geode, osgUtil::Optimizer::SHARE_DUPLICATE_STATE |
|
||||
osgUtil::Optimizer::MERGE_GEOMETRY |
|
||||
osgUtil::Optimizer::CHECK_GEOMETRY |
|
||||
osgUtil::Optimizer::TESSELLATE_GEOMETRY);
|
||||
return geode;
|
||||
}
|
||||
|
||||
|
||||
bool GeoSetBuilder::addPrimitive(bool dontMerge)
|
||||
{
|
||||
DynGeoSet* dgset = getDynGeoSet(); // This is the new geoset we want to add
|
||||
|
||||
if (dgset->getPrimType()==NO_PRIMITIVE_TYPE)
|
||||
{
|
||||
dgset->setPrimType(findPrimType(dgset->coordListSize()));
|
||||
}
|
||||
|
||||
// Still no primitive type?
|
||||
if (dgset->getPrimType()==NO_PRIMITIVE_TYPE)
|
||||
return false;
|
||||
|
||||
dgset->setBinding();
|
||||
|
||||
dontMerge = true;
|
||||
|
||||
if( dontMerge == true)
|
||||
{
|
||||
_dynGeoSetList.push_back(dgset);
|
||||
}
|
||||
else
|
||||
{
|
||||
DynGeoSet* match = findMatchingGeoSet();
|
||||
if (match)
|
||||
match->append(dgset);
|
||||
else
|
||||
_dynGeoSetList.push_back(dgset);
|
||||
}
|
||||
|
||||
initPrimData(); // initialize _dynGeoSet
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DynGeoSet* GeoSetBuilder::findMatchingGeoSet()
|
||||
{
|
||||
DynGeoSet* new_dgset = getDynGeoSet();
|
||||
for(DynGeoSetList::iterator itr=_dynGeoSetList.begin();
|
||||
itr!=_dynGeoSetList.end();
|
||||
++itr)
|
||||
{
|
||||
DynGeoSet* dgset = itr->get();
|
||||
if (*new_dgset == *dgset)
|
||||
return dgset;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
osg::PrimitiveSet::Mode GeoSetBuilder::findPrimType(const int nVertices)
|
||||
{
|
||||
switch (nVertices)
|
||||
{
|
||||
case 1: return osg::PrimitiveSet::POINTS;
|
||||
case 2: return osg::PrimitiveSet::LINES;
|
||||
case 3: return osg::PrimitiveSet::TRIANGLES;
|
||||
case 4: return osg::PrimitiveSet::QUADS;
|
||||
}
|
||||
|
||||
if (nVertices>=5) return osg::PrimitiveSet::POLYGON;
|
||||
|
||||
return NO_PRIMITIVE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
#ifndef __FLT_GEOSETBUILDER_H
|
||||
#define __FLT_GEOSETBUILDER_H
|
||||
|
||||
// Added DynGeoSet::setDetailTextureAttrData that is used to store texture
|
||||
// Attributes
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
// ---
|
||||
// Added support for multiple layers of texture coordinates. Changed the
|
||||
// detail texture support to only store the M & N scalar values instead of
|
||||
// the whole AttrData structure.
|
||||
// Jason Daly, Sept 25, 2004
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Material>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
class Record;
|
||||
class TmpGeoSet;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DynGeoSet
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#if 1
|
||||
# define COMPARE_DynGeoSet_Parameter(parameter) \
|
||||
if (parameter<rhs.parameter) return -1; \
|
||||
if (rhs.parameter<parameter) return 1;
|
||||
#else
|
||||
# define COMPARE_DynGeoSet_Parameter(parameter) \
|
||||
if (parameter != rhs.parameter) return -1;
|
||||
#endif
|
||||
|
||||
/** DynGeoSet - Dynamic GeoSet.
|
||||
*/
|
||||
class DynGeoSet : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
DynGeoSet();
|
||||
|
||||
int compare(const DynGeoSet& rhs) const
|
||||
{
|
||||
COMPARE_DynGeoSet_Parameter(_color_binding)
|
||||
COMPARE_DynGeoSet_Parameter(_normal_binding)
|
||||
|
||||
for (unsigned int i = 0; i < _texture_bindings.size(); i++)
|
||||
{
|
||||
if (getTextureBinding(i)<rhs.getTextureBinding(i))
|
||||
return -1;
|
||||
if (getTextureBinding(i)>rhs.getTextureBinding(i))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (_color_binding == osg::Geometry::BIND_OVERALL)
|
||||
{
|
||||
if ((_colorList.size() >= 1) && (rhs._colorList.size() >= 1))
|
||||
{
|
||||
if (_colorList[0]<rhs._colorList[0]) return -1;
|
||||
if (rhs._colorList[0]<_colorList[0]) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int result=getStateSet()->compare(*rhs.getStateSet(), true);
|
||||
if (result!=0) return result;
|
||||
|
||||
COMPARE_DynGeoSet_Parameter(_primtype);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int compatible(const DynGeoSet& rhs) const
|
||||
{
|
||||
|
||||
COMPARE_DynGeoSet_Parameter(_color_binding)
|
||||
|
||||
for (unsigned int i = 0; i < _texture_bindings.size(); i++)
|
||||
{
|
||||
if (getTextureBinding(i)<rhs.getTextureBinding(i))
|
||||
return -1;
|
||||
if (getTextureBinding(i)>rhs.getTextureBinding(i))
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result=getStateSet()->compare(*rhs.getStateSet(), true);
|
||||
if (result!=0) return result;
|
||||
|
||||
COMPARE_DynGeoSet_Parameter(_normal_binding)
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
if (_color_binding == osg::Geometry::BIND_OVERALL)
|
||||
{
|
||||
if ((_colorList.size() >= 1) && (rhs._colorList.size() >= 1))
|
||||
{
|
||||
if (_colorList[0]<rhs._colorList[0]) return -1;
|
||||
if (rhs._colorList[0]<_colorList[0]) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool operator < (const DynGeoSet& rhs) const { return compare(rhs)<0; }
|
||||
bool operator == (const DynGeoSet& rhs) const { return compare(rhs)==0; }
|
||||
bool operator != (const DynGeoSet& rhs) const { return compare(rhs)!=0; }
|
||||
|
||||
void setStateSet(osg::StateSet* stateset) {
|
||||
_stateset = stateset;
|
||||
_geom->setStateSet( stateset );
|
||||
}
|
||||
osg::StateSet* getStateSet() { return _stateset.get(); }
|
||||
const osg::StateSet* getStateSet() const { return _stateset.get(); }
|
||||
|
||||
void setColorBinding(osg::Geometry::AttributeBinding bind) { _color_binding = bind; }
|
||||
void setNormalBinding(osg::Geometry::AttributeBinding bind) { _normal_binding = bind; }
|
||||
void setTextureBinding(osg::Geometry::AttributeBinding bind)
|
||||
{
|
||||
setTextureBinding(0, bind);
|
||||
}
|
||||
void setTextureBinding(unsigned int index,
|
||||
osg::Geometry::AttributeBinding bind)
|
||||
{
|
||||
if (_texture_bindings.size() <= index)
|
||||
_texture_bindings.resize(index+1);
|
||||
|
||||
_texture_bindings[index] = bind;
|
||||
}
|
||||
|
||||
osg::Geometry::AttributeBinding getColorBinding() const { return _color_binding; }
|
||||
osg::Geometry::AttributeBinding getNormalBinding() const { return _normal_binding; }
|
||||
osg::Geometry::AttributeBinding getTextureBinding() const { return getTextureBinding(0); }
|
||||
osg::Geometry::AttributeBinding getTextureBinding(unsigned int index) const
|
||||
{
|
||||
if (_texture_bindings.size() > index)
|
||||
return _texture_bindings[index];
|
||||
else
|
||||
return osg::Geometry::BIND_OFF;
|
||||
}
|
||||
|
||||
void setPrimType(osg::PrimitiveSet::Mode type) { _primtype=type; }
|
||||
osg::PrimitiveSet::Mode getPrimType() const { return _primtype; }
|
||||
|
||||
inline void addPrimLen(int len) { _primLenList.push_back(len); }
|
||||
inline void addCoord(const osg::Vec3& coord) { _coordList.push_back(coord); }
|
||||
inline void addNormal(const osg::Vec3& normal) { _normalList.push_back(normal); }
|
||||
inline void addColor(const osg::Vec4& color) { _colorList.push_back(color); }
|
||||
inline void addTCoord(const osg::Vec2& tcoord) { addTCoord(0, tcoord); }
|
||||
inline void addTCoord(unsigned int index, const osg::Vec2& tcoord)
|
||||
{
|
||||
if (_tcoordLists.size() <= index)
|
||||
_tcoordLists.resize(index+1);
|
||||
|
||||
_tcoordLists[index].push_back(tcoord);
|
||||
}
|
||||
|
||||
typedef std::vector<osg::Vec3> CoordList;
|
||||
typedef std::vector<osg::Vec3> NormalList;
|
||||
typedef std::vector<osg::Vec4> ColorList;
|
||||
typedef std::vector<osg::Vec2> TcoordList;
|
||||
typedef std::vector<TcoordList> TcoordLists;
|
||||
typedef std::vector<osg::Geometry::AttributeBinding> TextureBindings;
|
||||
|
||||
const CoordList& getCoordList() { return _coordList; }
|
||||
const NormalList& getNormalList() { return _normalList; }
|
||||
const ColorList& getColorList() { return _colorList; }
|
||||
const TcoordList& getTcoordList() { return getTcoordList(0); }
|
||||
const TcoordList& getTcoordList(unsigned int index)
|
||||
{
|
||||
if (_tcoordLists.size() <= index)
|
||||
_tcoordLists.resize(index+1);
|
||||
|
||||
return _tcoordLists[index];
|
||||
}
|
||||
|
||||
void append(DynGeoSet* source);
|
||||
void setBinding();
|
||||
|
||||
void addToGeometry(osg::Geometry* geom);
|
||||
|
||||
inline int primLenListSize() const { return _primLenList.size(); }
|
||||
inline int coordListSize() const { return _coordList.size(); }
|
||||
inline int normalListSize() const { return _normalList.size(); }
|
||||
inline int colorListSize() const { return _colorList.size(); }
|
||||
inline int tcoordListSize() const { return tcoordListSize(0); }
|
||||
inline int tcoordListSize(unsigned int index) const
|
||||
{
|
||||
if (_tcoordLists.size() <= index)
|
||||
return _tcoordLists[index].size() ;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void enableDetailTexture() { _detailTextureEnabled=true; }
|
||||
inline void disableDetailTexture() { _detailTextureEnabled=false; }
|
||||
inline void setDetailTexCoords(int32 m, int32 n)
|
||||
{
|
||||
// If somebody knows what the other TX_DETAIL parameters do,
|
||||
// please add them. I looked through the OF specs as well as
|
||||
// the SGIS_detail_texture extension, and I didn't find any
|
||||
// clear explanation. The only reason this is here at all is
|
||||
// because of Julian Ortiz' previous work.
|
||||
_detailTexCoord_m = m;
|
||||
_detailTexCoord_n = n;
|
||||
}
|
||||
|
||||
osg::Geometry* getGeometry() {
|
||||
CERR << "_geom.get(): " << _geom.get()
|
||||
<< "; referenceCount: " << _geom.get()->referenceCount()<<"\n";
|
||||
return _geom.get();
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
typedef std::vector<int> PrimLenList;
|
||||
|
||||
osg::ref_ptr<osg::Geometry> _geom;
|
||||
|
||||
osg::ref_ptr<osg::StateSet> _stateset;
|
||||
|
||||
|
||||
osg::PrimitiveSet::Mode _primtype;
|
||||
PrimLenList _primLenList;
|
||||
|
||||
CoordList _coordList;
|
||||
|
||||
osg::Geometry::AttributeBinding _normal_binding;
|
||||
NormalList _normalList;
|
||||
|
||||
osg::Geometry::AttributeBinding _color_binding;
|
||||
ColorList _colorList;
|
||||
|
||||
TextureBindings _texture_bindings;
|
||||
TcoordLists _tcoordLists;
|
||||
|
||||
int32 _detailTexCoord_m;
|
||||
int32 _detailTexCoord_n;
|
||||
bool _detailTextureEnabled;
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GeoSetBuilder
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** GeoSetBuilder - Contains a list of TmpGeoSets to be converted to osg::Geode.
|
||||
*
|
||||
*/
|
||||
|
||||
class GeoSetBuilder
|
||||
{
|
||||
public:
|
||||
GeoSetBuilder(osg::Geode* geode = NULL);
|
||||
virtual ~GeoSetBuilder() {}
|
||||
|
||||
bool addPrimitive( bool dontMerge = false);
|
||||
osg::Geode* createOsgGeoSets(osg::Geode* geode = NULL);
|
||||
|
||||
inline DynGeoSet* getDynGeoSet() { return _dynGeoSet.get(); }
|
||||
inline const DynGeoSet* getDynGeoSet() const { return _dynGeoSet.get(); }
|
||||
inline bool empty() { return _dynGeoSetList.empty(); } ;
|
||||
|
||||
protected:
|
||||
|
||||
void initPrimData();
|
||||
DynGeoSet* findMatchingGeoSet();
|
||||
osg::PrimitiveSet::Mode findPrimType(const int nVertices);
|
||||
|
||||
private:
|
||||
|
||||
osg::ref_ptr<osg::Geode> _geode;
|
||||
osg::ref_ptr<DynGeoSet> _dynGeoSet;
|
||||
|
||||
typedef std::vector<osg::ref_ptr<DynGeoSet> > DynGeoSetList;
|
||||
DynGeoSetList _dynGeoSetList;
|
||||
};
|
||||
|
||||
|
||||
}; // end of namespace flt
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// GroupRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "GroupRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GroupRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<GroupRecord> g_fltGroupProxy;
|
||||
|
||||
GroupRecord::GroupRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
GroupRecord::~GroupRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GroupRecord::endian()
|
||||
{
|
||||
SGroup *pSGroup = (SGroup*)getData();
|
||||
|
||||
ENDIAN( pSGroup->iGroupRelPriority );
|
||||
ENDIAN( pSGroup->dwFlags );
|
||||
ENDIAN( pSGroup->iSpecialId_1 );
|
||||
ENDIAN( pSGroup->iSpecialId_2 );
|
||||
ENDIAN( pSGroup->iSignificance );
|
||||
|
||||
if (getFltFile()->getFlightVersion() >= 1580 )
|
||||
{
|
||||
ENDIAN( pSGroup->iLoopCount );
|
||||
ENDIAN( pSGroup->fLoopDuration );
|
||||
ENDIAN( pSGroup->fLastFrameDuration );
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
// GroupRecord.h
|
||||
|
||||
#ifndef __FLT_GROUP_RECORD_H
|
||||
#define __FLT_GROUP_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SGroup
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int16 iGroupRelPriority; // Group relative priority
|
||||
int16 iSpare; // Spare for fullword alignment
|
||||
uint32 dwFlags; // Flags (bits, from left to right)
|
||||
// 0 = Reserved
|
||||
// 1 = Forward animation
|
||||
// 2 = Cycling animation
|
||||
// 3 = Bounding box follows
|
||||
// 4 = Freeze bounding box
|
||||
// 5 = Default parent
|
||||
// 6 - Backward animation
|
||||
// 7-31 Spare
|
||||
int16 iSpecialId_1; // Special effects ID 1 - defined by real time
|
||||
int16 iSpecialId_2; // Special effects ID 2 - defined by real time
|
||||
int16 iSignificance; // Significance Flags
|
||||
uint8 swLayer; // Layer Number
|
||||
uint8 swReserved[5]; // Reserved
|
||||
int32 iLoopCount; // Animation loop count
|
||||
float32 fLoopDuration; // Animation loop duration
|
||||
float32 fLastFrameDuration; // Duration of last frame in animation
|
||||
};
|
||||
|
||||
|
||||
class GroupRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum FlagBit {
|
||||
FORWARD_ANIM = 0x40000000,
|
||||
SWING_ANIM = 0x20000000,
|
||||
BOUND_BOX_FOLLOW = 0x10000000,
|
||||
FREEZE_BOUND_BOX = 0x08000000,
|
||||
DEFAULT_PARENT = 0x04000000,
|
||||
BACKWARD_ANIM = 0x02000000
|
||||
};
|
||||
|
||||
GroupRecord();
|
||||
|
||||
virtual Record* clone() const { return new GroupRecord(); }
|
||||
virtual const char* className() const { return "GroupRecord"; }
|
||||
virtual int classOpcode() const { return GROUP_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SGroup); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SGroup* getData() const { return (SGroup*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
int childLODs();
|
||||
|
||||
protected:
|
||||
virtual ~GroupRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
// HeaderRecord.cpp
|
||||
|
||||
#include "osg/Group"
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "HeaderRecord.h"
|
||||
#include "Input.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
/*
|
||||
From MultiGen-Paradigm User Forum:
|
||||
http://www.multigen-paradigm.com/ubb/Forum8/HTML/000035.html
|
||||
|
||||
Q:
|
||||
Hi,
|
||||
I am using the MultiGen API to read .flt files. Today I received a
|
||||
.flt file with Packed color for polygons. Going through the MGAPI
|
||||
documentation I didn't find anything about Packed colors in polygons
|
||||
except fltPolyFlagRgbMode, which is set to "1" in that file.
|
||||
Could you please answer the following questions:
|
||||
1) Name of the parameter used for Packed
|
||||
primary color in the fltPolygon structure;
|
||||
2) The function to read the values.
|
||||
Regards, Zoia.
|
||||
|
||||
|
||||
A:
|
||||
The short answer is:
|
||||
There is no fltPolygon attribute that defines the packed color.
|
||||
You need to use mgGetPolyColorRGB and mgGetPolyAltColorRGB to
|
||||
get the primary and alternate rgb values for a polygon.
|
||||
|
||||
The long answer, including a bit of explanation is:
|
||||
|
||||
OpenFlight databases can define color values in RGB space (packed
|
||||
color as you called it) or color index space. The fltHdrRgbMode
|
||||
field of the fltHeader record specifies which color space is used
|
||||
by the database.
|
||||
|
||||
If the database is in color index mode, you can get the RGB
|
||||
colors applied to a polygon by first getting the fltPolyPrimeColor
|
||||
and fltPolyPrimeIntensity attributes of the polygon and then
|
||||
converting those values to RGB by calling mgRGB2Index.
|
||||
|
||||
Note: The attributes fltPolyAltColor and fltPolyAltIntensity can
|
||||
be used to get the alternate color index and intensity.
|
||||
|
||||
If the database is in RGB mode, you can get the RGB colors applied
|
||||
to a polygon by calling the function mgGetPolyColorRGB. But if you
|
||||
take a closer look at this function you will discover that it
|
||||
returns the RGB colors for a polygon regardless of whether the
|
||||
database is in color index or RGB mode.
|
||||
If the database is in color index mode, mgGetPolyColorRGB acquires
|
||||
the color index applied to the polygon and looks up the
|
||||
corresponding RGB values for you.
|
||||
|
||||
So, if you are only after the RGB color values applied to a
|
||||
polygon, the function mgGetPolyColorRGB is always your best bet.
|
||||
Note: mgGetPolyAltColorRGB is the equivalent function to use to
|
||||
get the alternate RGB color values applied to a polygon.
|
||||
|
||||
Hope this helps.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// HeaderRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<HeaderRecord> g_HeaderProxy;
|
||||
|
||||
HeaderRecord::HeaderRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
HeaderRecord::~HeaderRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void HeaderRecord::endian()
|
||||
{
|
||||
// OpenFlight spec dictates values that arepacked and not do not necessarily
|
||||
// adhere to alignment rules. Copy values out of the OpenFlight packed header
|
||||
// and into the SHeader struct and let the compiler worry about alignment
|
||||
// issues within the struct.
|
||||
|
||||
SHeader *pHeader = (SHeader*) malloc( sizeof(SHeader) );
|
||||
char* src = (char*)getData();
|
||||
|
||||
// Numeric constant data sizes taken from OpenFlight spec
|
||||
memcpy( &(pHeader->RecHeader), src, 4 ); src += 4;
|
||||
memcpy( &(pHeader->szIdent), src, 8 ); src += 8;
|
||||
|
||||
// Be sure to swap revision level here, since we reference it to determine
|
||||
// which other fields to memcpy.
|
||||
memcpy( &(pHeader->diFormatRevLev), src, 4 ); src += 4;
|
||||
ENDIAN( pHeader->diFormatRevLev );
|
||||
|
||||
memcpy( &(pHeader->diDatabaseRevLev), src, 4 ); src += 4;
|
||||
memcpy( &(pHeader->szDaTimLastRev), src, 32 ); src += 32;
|
||||
memcpy( &(pHeader->iNextGroup), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextLOD), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextObject), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextPolygon), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iMultDivUnit), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->swVertexCoordUnit), src, 1 ); src += 1;
|
||||
memcpy( &(pHeader->swTexWhite), src, 1 ); src += 1;
|
||||
memcpy( &(pHeader->dwFlags), src, 4 ); src += 4;
|
||||
src += 4*6; // Reserved
|
||||
memcpy( &(pHeader->diProjection), src, 4 ); src += 4;
|
||||
src += 4*7; // Reserved
|
||||
memcpy( &(pHeader->iNextDegOfFreedom), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iVertexStorage), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->diDatabaseSource), src, 4 ); src += 4;
|
||||
memcpy( &(pHeader->dfSWDatabaseCoordX), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfSWDatabaseCoordY), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfDatabaseOffsetX), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfDatabaseOffsetY), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->iNextSound), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextPath), src, 2 ); src += 2;
|
||||
src += 4*2; // Reserved
|
||||
memcpy( &(pHeader->iNextClippingRegion), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextText), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextBSP), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextSwitch), src, 2 ); src += 2;
|
||||
src += 4; // reserved
|
||||
memcpy( &(pHeader->SWCorner), src, 8*2 ); src += 8*2;
|
||||
memcpy( &(pHeader->NECorner), src, 8*2 ); src += 8*2;
|
||||
memcpy( &(pHeader->Origin), src, 8*2 ); src += 8*2;
|
||||
memcpy( &(pHeader->dfLambertUpperLat), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfLambertLowerLat), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->iNextLightSource), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextLightPoint), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextRoad), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextCat), src, 2 ); src += 2;
|
||||
src += 2*4; // Reserved;
|
||||
memcpy( &(pHeader->diEllipsoid), src, 4 ); src += 4;
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1570 )
|
||||
{
|
||||
memcpy( &(pHeader->iNextAdaptiveNodeID), src, 2 ); src += 2;
|
||||
memcpy( &(pHeader->iNextCurveNodeID), src, 2 ); src += 2;
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
memcpy( &(pHeader->iUTMZone), src, 2 ); src += 2;
|
||||
src += 6; // Reserved
|
||||
}
|
||||
else
|
||||
// Must be v15.7
|
||||
src += 2; // Reserved
|
||||
|
||||
memcpy( &(pHeader->dfDatabaseDeltaZ), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfRadius), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->iNextMeshNodeID), src, 2 ); src += 2;
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
memcpy( &(pHeader->iNextLightPointSysID), src, 2 ); src += 2;
|
||||
src += 4; // Reserved
|
||||
memcpy( &(pHeader->dfEarthMajorAxis), src, 8 ); src += 8;
|
||||
memcpy( &(pHeader->dfEarthMinorAxis), src, 8 ); src += 8;
|
||||
}
|
||||
else
|
||||
// Must be v15.7
|
||||
src += 2; // Reserved
|
||||
}
|
||||
|
||||
// Now that we've copied the data into SHeader, we're done with the original packed
|
||||
// data as read out of the OpenFlight file. Free it, and replace it with the
|
||||
// SHeader struct, so that subsequent typecasts of _pData work as expected.
|
||||
free( _pData );
|
||||
_pData = (SRecHeader*)pHeader;
|
||||
|
||||
|
||||
// Proceed with byteswapping
|
||||
ENDIAN( pHeader->diDatabaseRevLev );
|
||||
ENDIAN( pHeader->iNextGroup );
|
||||
ENDIAN( pHeader->iNextLOD );
|
||||
ENDIAN( pHeader->iNextObject );
|
||||
ENDIAN( pHeader->iNextPolygon );
|
||||
ENDIAN( pHeader->iMultDivUnit );
|
||||
ENDIAN( pHeader->dwFlags );
|
||||
ENDIAN( pHeader->diProjection );
|
||||
ENDIAN( pHeader->iNextDegOfFreedom );
|
||||
ENDIAN( pHeader->iVertexStorage );
|
||||
ENDIAN( pHeader->diDatabaseSource );
|
||||
ENDIAN( pHeader->dfSWDatabaseCoordX );
|
||||
ENDIAN( pHeader->dfSWDatabaseCoordY );
|
||||
ENDIAN( pHeader->dfDatabaseOffsetX );
|
||||
ENDIAN( pHeader->dfDatabaseOffsetY );
|
||||
ENDIAN( pHeader->iNextSound );
|
||||
ENDIAN( pHeader->iNextPath );
|
||||
ENDIAN( pHeader->iNextClippingRegion );
|
||||
ENDIAN( pHeader->iNextText );
|
||||
ENDIAN( pHeader->iNextBSP );
|
||||
ENDIAN( pHeader->iNextSwitch );
|
||||
pHeader->SWCorner.endian();
|
||||
pHeader->NECorner.endian();
|
||||
pHeader->Origin.endian();
|
||||
ENDIAN( pHeader->dfLambertUpperLat );
|
||||
ENDIAN( pHeader->dfLambertLowerLat );
|
||||
ENDIAN( pHeader->iNextLightSource );
|
||||
|
||||
// New with 15.7
|
||||
// Note: Don't use "getFltFile()->getFlightVersion()", it's not set yet.
|
||||
if ( pHeader->diFormatRevLev >= 1570 )
|
||||
{
|
||||
ENDIAN( pHeader->iNextAdaptiveNodeID );
|
||||
ENDIAN( pHeader->iNextCurveNodeID );
|
||||
ENDIAN( pHeader->dfDatabaseDeltaZ );
|
||||
ENDIAN( pHeader->dfRadius );
|
||||
ENDIAN( pHeader->iNextMeshNodeID );
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
ENDIAN( pHeader->iUTMZone );
|
||||
ENDIAN( pHeader->iNextLightPointSysID );
|
||||
ENDIAN( pHeader->dfEarthMajorAxis );
|
||||
ENDIAN( pHeader->dfEarthMinorAxis );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void HeaderRecord::decode()
|
||||
{
|
||||
// nothing done here, so commenting out, RO, March 2002.
|
||||
// SHeader *pHeader = (SHeader*)getData();
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
bool HeaderRecord::readLocalData(Input& fr)
|
||||
{
|
||||
return PrimNodeRecord::readLocalData(fr);
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
// HeaderRecord.h
|
||||
|
||||
#ifndef __FLT_HEADER_RECORD_H
|
||||
#define __FLT_HEADER_RECORD_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SHeader
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // ID field (Not curr used)
|
||||
int32 diFormatRevLev; // Format revision level
|
||||
int32 diDatabaseRevLev; // Edit rev. level
|
||||
char szDaTimLastRev[32]; // Date and time last rev.
|
||||
int16 iNextGroup; // Next group ID number
|
||||
int16 iNextLOD; // Next LOD ID number
|
||||
int16 iNextObject; // Next object ID number
|
||||
int16 iNextPolygon; // Next polygon ID number
|
||||
int16 iMultDivUnit; // Unit multiplier/divisor, always = 1
|
||||
uint8 swVertexCoordUnit; // Vertex coordinate units
|
||||
// 0 = Meters
|
||||
// 1 = Kilometers
|
||||
// 4 = Feet
|
||||
// 5 = Inches
|
||||
// 8 = Nautical miles
|
||||
uint8 swTexWhite; // if TRUE set texwhite on new polygons
|
||||
uint32 dwFlags; // Flags (bits, from left to right)
|
||||
// 0 = Save vertex normals
|
||||
// 1 = Packed Color mode
|
||||
// 2 = CAD View mode
|
||||
// 3-31 = Spare
|
||||
int32 diNotUsed_1[6]; // Not Used
|
||||
int32 diProjection; // Projection Type
|
||||
// 0 = Flat Earth
|
||||
// 1 = Trapezoidal
|
||||
// 2 = Round Earth
|
||||
// 3 = Lambert
|
||||
// 4 = UTM
|
||||
// 5 = Geodetic
|
||||
// 6 = Geocentric
|
||||
int32 diNotUsed_2[7]; // Not Used
|
||||
int16 iNextDegOfFreedom; // Next degree of freedom ID number
|
||||
int16 iVertexStorage; // Vertex Storage Type
|
||||
// 1 = Double Precision Float
|
||||
int32 diDatabaseSource; // Database Source
|
||||
// 100 = OpenFlight
|
||||
// 200 = DIG I/DIG II
|
||||
// 300 = Evans and Sutherland CT5A/CT6
|
||||
// 400 = PSP DIG
|
||||
// 600 = General Electric CIV/CV / PT2000
|
||||
// 700 = Evans and Sutherland GDF
|
||||
float64 dfSWDatabaseCoordX; // Southwest Database Coordinate (x,y)
|
||||
float64 dfSWDatabaseCoordY;
|
||||
float64 dfDatabaseOffsetX; // Delta (x,y) to Place Database
|
||||
float64 dfDatabaseOffsetY;
|
||||
int16 iNextSound; // Next Sound Bead Id
|
||||
int16 iNextPath; // Next Path Bead ID
|
||||
int16 iNextClippingRegion;// Next Clipping Region Bead ID
|
||||
int16 iNextText; // Next Text Bead ID
|
||||
int16 iNextBSP; // Next BSP ID
|
||||
int16 iNextSwitch; // Next Switch Bead ID
|
||||
float64x2 SWCorner; // South West Corner Lat/Lon (NB: dec. degrees)
|
||||
float64x2 NECorner; // North East Corner Lat/Lon (NB: dec. degrees)
|
||||
float64x2 Origin; // Origin Lat/Lon (NB: dec. degrees, not radians)
|
||||
float64 dfLambertUpperLat; // Lambert Upper Latitude
|
||||
float64 dfLambertLowerLat; // Lambert Lower Latitude
|
||||
int16 iNextLightSource; // Next Light Source ID Number
|
||||
int16 iNextLightPoint; // Next Light Point ID number
|
||||
int16 iNextRoad; // Next road bead ID number
|
||||
int16 iNextCat; // Next CAT bead ID number
|
||||
int32 diEllipsoid; // Earth ellipsoid model
|
||||
// 0 - WGS 1984
|
||||
// 1 - WGS 1972
|
||||
// 2 - Bessel
|
||||
// 3 - Clarke 1866
|
||||
// 4 - NAD 1927
|
||||
|
||||
// New with 15.7.0 ...
|
||||
int16 iNextAdaptiveNodeID; // Next Adaptive node ID number
|
||||
int16 iNextCurveNodeID; // Next Curve node ID number
|
||||
float64 dfDatabaseDeltaZ; // Delta z to place database (used in
|
||||
// conjunction with existing Delta x and
|
||||
// Delta y values)
|
||||
float64 dfRadius; // Radius (distance from database origin to
|
||||
// farthest corner)
|
||||
uint16 iNextMeshNodeID; // Next Mesh node ID number
|
||||
|
||||
// New with 15.8
|
||||
int16 iUTMZone; // UTM zone 1-60, negative indicates southern hemisphere
|
||||
uint16 iNextLightPointSysID; // Light point system ID
|
||||
float64 dfEarthMajorAxis; // Custom ellipsoid Earth major axis
|
||||
float64 dfEarthMinorAxis; // Custom ellipsoid Earth minor axis
|
||||
};
|
||||
|
||||
|
||||
class HeaderRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
HeaderRecord();
|
||||
|
||||
virtual Record* clone() const { return new HeaderRecord(); }
|
||||
virtual const char* className() const { return "HeaderRecord"; }
|
||||
virtual int classOpcode() const { return HEADER_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SHeader); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
SHeader* getData() const { return (SHeader*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
enum CoordUnit
|
||||
{
|
||||
METERS = 0,
|
||||
KILOMETERS = 1,
|
||||
FEET = 4,
|
||||
INCHES = 5,
|
||||
NAUTICAL_MILES = 8
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~HeaderRecord();
|
||||
|
||||
virtual void endian();
|
||||
virtual void decode();
|
||||
|
||||
virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,255 +0,0 @@
|
||||
// Input.cpp
|
||||
|
||||
#include <string>
|
||||
// #include <malloc.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <osg/Notify>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include "Input.h"
|
||||
#include "Record.h"
|
||||
#include "Registry.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
FileInput::FileInput()
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
|
||||
FileInput::~FileInput()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void FileInput::_init()
|
||||
{
|
||||
_lRecOffset = 0L;
|
||||
_file = NULL;
|
||||
_eof = true;
|
||||
}
|
||||
|
||||
|
||||
size_t FileInput::_read(void *buffer, size_t size)
|
||||
{
|
||||
if (_eof) return 0;
|
||||
|
||||
size_t nItemsRead = ::fread(buffer, size, 1, _file);
|
||||
if (nItemsRead != 1)
|
||||
_eof = true;
|
||||
|
||||
return nItemsRead;
|
||||
}
|
||||
|
||||
|
||||
bool FileInput::eof()
|
||||
{
|
||||
return _eof;
|
||||
}
|
||||
|
||||
|
||||
bool FileInput::open(const std::string& fileName)
|
||||
{
|
||||
_file=::fopen( fileName.c_str(), "rb");
|
||||
if (_file == NULL) return false;
|
||||
_eof = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileInput::close()
|
||||
{
|
||||
if (_file) ::fclose(_file);
|
||||
_init();
|
||||
}
|
||||
|
||||
|
||||
bool FileInput::rewindLast()
|
||||
{
|
||||
if (_file == NULL) return false;
|
||||
return (fseek(_file, _lRecOffset, SEEK_SET) == 0);
|
||||
}
|
||||
|
||||
|
||||
long FileInput::offset()
|
||||
{
|
||||
return _lRecOffset;
|
||||
}
|
||||
|
||||
|
||||
// read opcode and size
|
||||
|
||||
bool FileInput::_readHeader(SRecHeader* pHdr)
|
||||
{
|
||||
int nItemsRead;
|
||||
|
||||
// Save file position for rewind operation
|
||||
_lRecOffset = ::ftell( _file );
|
||||
|
||||
// Read record header (4 bytes)
|
||||
nItemsRead = _read(pHdr, sizeof(SRecHeader));
|
||||
if (nItemsRead != 1)
|
||||
return false;
|
||||
|
||||
if (isLittleEndianMachine())
|
||||
pHdr->endian();
|
||||
|
||||
if ((unsigned)pHdr->length() < sizeof(SRecHeader))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FileInput::_readBody(SRecHeader* pData)
|
||||
{
|
||||
// Read record body
|
||||
int nBodySize = pData->length() - sizeof(SRecHeader);
|
||||
if (nBodySize > 0)
|
||||
{
|
||||
int nItemsRead = _read(pData+1, nBodySize);
|
||||
if (nItemsRead != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FileInput::_readContinuedBody(char* pData, int nBytes)
|
||||
{
|
||||
// Read record body
|
||||
if (nBytes > 0)
|
||||
{
|
||||
int nItemsRead = _read(pData, nBytes);
|
||||
if (nItemsRead != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SRecHeader* FileInput::readRecord()
|
||||
{
|
||||
SRecHeader hdr;
|
||||
SRecHeader* pData;
|
||||
|
||||
if (!_readHeader(&hdr))
|
||||
return NULL;
|
||||
|
||||
// Allocate buffer for record (including header)
|
||||
// This buffer is extended later in Record::cloneRecord()
|
||||
// if defined struct is bigger than read.
|
||||
pData = (SRecHeader*)::malloc(hdr.length());
|
||||
if (pData == NULL)
|
||||
return NULL;
|
||||
|
||||
*pData = hdr;
|
||||
|
||||
// Some records contains only the header
|
||||
if (hdr.length() == sizeof(SRecHeader))
|
||||
return pData;
|
||||
|
||||
if (!_readBody(pData))
|
||||
return NULL;
|
||||
|
||||
|
||||
// Add support for OpenFlight 15.7 (1570) continuation records
|
||||
//
|
||||
|
||||
// Record and FaceRecord both want to rewindLast, so save and restore
|
||||
// the current file offset.
|
||||
const long lRecOffsetSave = _lRecOffset;
|
||||
|
||||
int nTotalLen = hdr.length();
|
||||
// From spec, in practice only these three records can be continued:
|
||||
bool bContinuationPossible = (
|
||||
(hdr.opcode()==COLOR_NAME_PALETTE_OP) ||
|
||||
(hdr.opcode()==EXTENSION_OP) ||
|
||||
(hdr.opcode()==LOCAL_VERTEX_POOL_OP) );
|
||||
|
||||
while (bContinuationPossible)
|
||||
{
|
||||
SRecHeader hdr2;
|
||||
if (_readHeader( &hdr2 ))
|
||||
{
|
||||
if (hdr2.opcode() == CONTINUATION_OP)
|
||||
{
|
||||
int nNewChunkLen = hdr2.length() - 4;
|
||||
size_t nNewLen = nTotalLen + nNewChunkLen;
|
||||
pData = (SRecHeader*)::realloc( (void*)pData, nNewLen );
|
||||
if (pData == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!_readContinuedBody( ((char*)pData) + nTotalLen, nNewChunkLen ))
|
||||
return NULL;
|
||||
nTotalLen = (int)nNewLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a continuation record. Rewind, then exit loop.
|
||||
rewindLast();
|
||||
bContinuationPossible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
// Probably EOF
|
||||
bContinuationPossible = false;
|
||||
}
|
||||
|
||||
_lRecOffset = lRecOffsetSave;
|
||||
|
||||
//
|
||||
// END support for continuation records
|
||||
|
||||
|
||||
return pData;
|
||||
}
|
||||
|
||||
|
||||
Record* Input::readCreateRecord(FltFile* pFltFile)
|
||||
{
|
||||
SRecHeader* pData = readRecord();
|
||||
|
||||
if (pData == NULL) return NULL;
|
||||
|
||||
// find matching record prototype class
|
||||
Record* pProto = Registry::instance()->getPrototype(pData->opcode());
|
||||
if (pProto == NULL)
|
||||
pProto = Registry::instance()->getPrototype(0);
|
||||
|
||||
if (pProto == NULL)
|
||||
{
|
||||
// Should not be possible to end up here!
|
||||
osg::notify(osg::INFO) << "UnknownRecord not in registry!" << std::endl;
|
||||
::free(pData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// clone protoype
|
||||
Record* pRec = pProto->cloneRecord(pData);
|
||||
if (pRec == NULL)
|
||||
{
|
||||
osg::notify(osg::INFO) << "Can't clone record!" << std::endl;
|
||||
::free(pData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pRec->_pFltFile = pFltFile;
|
||||
|
||||
#if 0
|
||||
osg::notify(osg::ALWAYS) << "class = " << pRec->className();
|
||||
osg::notify(osg::ALWAYS) << " op = " << pRec->getOpcode();
|
||||
osg::notify(osg::ALWAYS) << " name = " << pRec->getName();
|
||||
osg::notify(osg::ALWAYS) << " offset = " << offset() << std::endl;
|
||||
#endif
|
||||
|
||||
// Perform any post-read initializations.
|
||||
pRec->postReadInit();
|
||||
|
||||
return pRec;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
#ifndef __FLT_INPUT_H
|
||||
#define __FLT_INPUT_H
|
||||
|
||||
#include "Record.h"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
namespace osg {
|
||||
class Object;
|
||||
class Image;
|
||||
class Node;
|
||||
};
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
class Record;
|
||||
class FltFile;
|
||||
|
||||
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
|
||||
Input() {}
|
||||
|
||||
virtual SRecHeader* readRecord() = 0;
|
||||
virtual bool eof() = 0;
|
||||
virtual bool rewindLast() = 0;
|
||||
virtual long offset() = 0;
|
||||
|
||||
Record* readCreateRecord(FltFile* pFltFile);
|
||||
|
||||
protected:
|
||||
|
||||
/** disallow creation of Objects on the stack.*/
|
||||
virtual ~Input() {}
|
||||
|
||||
private:
|
||||
|
||||
virtual bool _readHeader(SRecHeader* pHdr) = 0;
|
||||
virtual bool _readBody(SRecHeader* pData) = 0;
|
||||
virtual bool _readContinuedBody(char* pData, int nBytes) = 0;
|
||||
};
|
||||
|
||||
|
||||
/** Class for managing the reading of binary .flt files.*/
|
||||
class FileInput : public Input
|
||||
{
|
||||
public:
|
||||
|
||||
FileInput();
|
||||
virtual ~FileInput();
|
||||
|
||||
bool open(const std::string& fileName);
|
||||
void close();
|
||||
virtual bool eof();
|
||||
virtual bool rewindLast();
|
||||
virtual long offset();
|
||||
|
||||
virtual SRecHeader* readRecord();
|
||||
|
||||
private:
|
||||
virtual bool _readHeader(SRecHeader* pHdr);
|
||||
virtual bool _readBody(SRecHeader* pData);
|
||||
virtual bool _readContinuedBody(char* pData, int nBytes);
|
||||
void _init();
|
||||
size_t _read(void *buffer, size_t size);
|
||||
|
||||
FILE* _file;
|
||||
bool _eof;
|
||||
long _lRecOffset;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MemInput : public Input
|
||||
{
|
||||
public:
|
||||
|
||||
MemInput();
|
||||
virtual ~MemInput();
|
||||
|
||||
bool open(SRecHeader* pHdr);
|
||||
void close();
|
||||
virtual bool eof();
|
||||
virtual bool rewindLast();
|
||||
virtual long offset();
|
||||
|
||||
virtual SRecHeader* readRecord();
|
||||
|
||||
private:
|
||||
virtual bool _readHeader(SRecHeader* pHdr);
|
||||
virtual bool _readBody(SRecHeader* pData);
|
||||
virtual bool _readContinuedBody(char* pData, int nBytes);
|
||||
void _init();
|
||||
size_t _read(void *buffer, size_t size);
|
||||
|
||||
bool _eof;
|
||||
long _lRecOffset;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_INPUT_H
|
||||
@@ -1,60 +0,0 @@
|
||||
// InstanceRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "InstanceRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InstanceDefinitionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<InstanceDefinitionRecord> g_InstanceDefinitionProxy;
|
||||
|
||||
InstanceDefinitionRecord::InstanceDefinitionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
InstanceDefinitionRecord::~InstanceDefinitionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void InstanceDefinitionRecord::endian()
|
||||
{
|
||||
SInstanceDefinition *pSInstDef = (SInstanceDefinition*)getData();
|
||||
|
||||
ENDIAN( pSInstDef->iInstDefNumber );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InstanceReferenceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<InstanceReferenceRecord> g_InstanceReferenceProxy;
|
||||
|
||||
InstanceReferenceRecord::InstanceReferenceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
InstanceReferenceRecord::~InstanceReferenceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void InstanceReferenceRecord::endian()
|
||||
{
|
||||
SInstanceReference *pSInstRef = (SInstanceReference*)getData();
|
||||
|
||||
ENDIAN( pSInstRef->iInstDefNumber );
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
// InstanceRecords.h
|
||||
|
||||
|
||||
#ifndef __FLT_INSTANCE_RECORDS_H
|
||||
#define __FLT_INSTANCE_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InstanceDefinitionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct InstanceDefinitionTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int16 iSpare;
|
||||
int16 iInstDefNumber;
|
||||
}SInstanceDefinition;
|
||||
|
||||
|
||||
class InstanceDefinitionRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
InstanceDefinitionRecord();
|
||||
|
||||
virtual Record* clone() const { return new InstanceDefinitionRecord(); }
|
||||
virtual const char* className() const { return "InstanceDefinitionRecord"; }
|
||||
virtual int classOpcode() const { return INSTANCE_DEFINITION_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SInstanceDefinition* getData() const { return (SInstanceDefinition*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~InstanceDefinitionRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InstanceReferenceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct InstanceReferenceTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int16 iSpare;
|
||||
int16 iInstDefNumber;
|
||||
}SInstanceReference;
|
||||
|
||||
|
||||
|
||||
class InstanceReferenceRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
InstanceReferenceRecord();
|
||||
|
||||
virtual Record* clone() const { return new InstanceReferenceRecord(); }
|
||||
virtual const char* className() const { return "InstanceReferenceRecord"; }
|
||||
virtual int classOpcode() const { return INSTANCE_REFERENCE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SInstanceReference* getData() const { return (SInstanceReference*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~InstanceReferenceRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightPointPaletteRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightPointAppearancePaletteRecords
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LtPtAppearancePaletteRecord> g_LtPtAppearancePaletteProxy;
|
||||
|
||||
LtPtAppearancePaletteRecord::LtPtAppearancePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LtPtAppearancePaletteRecord::~LtPtAppearancePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LtPtAppearancePaletteRecord::endian()
|
||||
{
|
||||
SLightPointAppearancePalette* ltPtApp = (SLightPointAppearancePalette*)getData();
|
||||
|
||||
ENDIAN( ltPtApp->index );
|
||||
ENDIAN( ltPtApp->surfMatCode );
|
||||
ENDIAN( ltPtApp->featureID );
|
||||
ENDIAN( ltPtApp->backColor );
|
||||
ENDIAN( ltPtApp->displayMode );
|
||||
ENDIAN( ltPtApp->intensity );
|
||||
ENDIAN( ltPtApp->backIntensity );
|
||||
ENDIAN( ltPtApp->minDefocus );
|
||||
ENDIAN( ltPtApp->maxDefocus );
|
||||
ENDIAN( ltPtApp->fadeMode );
|
||||
ENDIAN( ltPtApp->fogPunch );
|
||||
ENDIAN( ltPtApp->dirMode );
|
||||
ENDIAN( ltPtApp->rangeMode );
|
||||
ENDIAN( ltPtApp->minPixelSize );
|
||||
ENDIAN( ltPtApp->maxPixelSize );
|
||||
ENDIAN( ltPtApp->actualSize );
|
||||
ENDIAN( ltPtApp->transFalloffPixelSize );
|
||||
ENDIAN( ltPtApp->transFalloffExp );
|
||||
ENDIAN( ltPtApp->transFalloffScalar );
|
||||
ENDIAN( ltPtApp->transFalloffClamp );
|
||||
ENDIAN( ltPtApp->fogScalar );
|
||||
ENDIAN( ltPtApp->fogIntensity );
|
||||
ENDIAN( ltPtApp->sizeDiffThreshold );
|
||||
ENDIAN( ltPtApp->directionality );
|
||||
ENDIAN( ltPtApp->horizLobeAngle );
|
||||
ENDIAN( ltPtApp->vertLobeAngle );
|
||||
ENDIAN( ltPtApp->lobeRollAngle );
|
||||
ENDIAN( ltPtApp->dirFalloffExp );
|
||||
ENDIAN( ltPtApp->dirAmbientIntensity );
|
||||
ENDIAN( ltPtApp->significance );
|
||||
ENDIAN( ltPtApp->flags );
|
||||
ENDIAN( ltPtApp->visRange );
|
||||
ENDIAN( ltPtApp->fadeRangeRatio );
|
||||
ENDIAN( ltPtApp->fadeInDurationSecs );
|
||||
ENDIAN( ltPtApp->adeOutDurationSecs );
|
||||
ENDIAN( ltPtApp->lodRangeRatio );
|
||||
ENDIAN( ltPtApp->lodScale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightPointAnimationPaletteRecords
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LtPtAnimationPaletteRecord> g_LtPtAnimationPaletteProxy;
|
||||
|
||||
LtPtAnimationPaletteRecord::LtPtAnimationPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LtPtAnimationPaletteRecord::~LtPtAnimationPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LtPtAnimationPaletteRecord::endian()
|
||||
{
|
||||
SLightPointAnimationPalette* ltPtAnim = (SLightPointAnimationPalette*)getData();
|
||||
|
||||
ENDIAN( ltPtAnim->index );
|
||||
ENDIAN( ltPtAnim->period );
|
||||
ENDIAN( ltPtAnim->phaseDelay );
|
||||
ENDIAN( ltPtAnim->enabledPeriod );
|
||||
ENDIAN( ltPtAnim->axis[0] );
|
||||
ENDIAN( ltPtAnim->axis[1] );
|
||||
ENDIAN( ltPtAnim->axis[2] );
|
||||
ENDIAN( ltPtAnim->flags );
|
||||
ENDIAN( ltPtAnim->animType );
|
||||
ENDIAN( ltPtAnim->morseTiming );
|
||||
ENDIAN( ltPtAnim->wordRate );
|
||||
ENDIAN( ltPtAnim->charRate );
|
||||
ENDIAN( ltPtAnim->numSequences );
|
||||
|
||||
for (int idx=0; idx < ltPtAnim->numSequences; idx++)
|
||||
{
|
||||
SLightPointAnimationSequence* seq = sequence( idx );
|
||||
assert( seq );
|
||||
ENDIAN( seq->seqState );
|
||||
ENDIAN( seq->duration );
|
||||
ENDIAN( seq->seqColor );
|
||||
}
|
||||
}
|
||||
|
||||
SLightPointAnimationSequence*
|
||||
LtPtAnimationPaletteRecord::sequence( int idx )
|
||||
{
|
||||
SLightPointAnimationPalette* ltPtAnim = (SLightPointAnimationPalette*)getData();
|
||||
if (idx >= ltPtAnim->numSequences)
|
||||
return NULL;
|
||||
|
||||
SLightPointAnimationSequence* seq = (SLightPointAnimationSequence*)
|
||||
( (char*)getData() + sizeof( SLightPointAnimationPalette ) );
|
||||
seq += idx;
|
||||
|
||||
return seq;
|
||||
}
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
|
||||
#ifndef __FLT_LIGHT_POINT_PALETTE_RECORDS_H
|
||||
#define __FLT_LIGHT_POINT_PALETTE_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SLightPointAppearancePalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 reserved_0;
|
||||
char name[256];
|
||||
int32 index;
|
||||
int16 surfMatCode;
|
||||
int16 featureID;
|
||||
uint32 backColor; // Back facing color for bidirectional light points
|
||||
int32 displayMode; // Display Mode: 0 -- Raster
|
||||
// 1 -- Calligraphic
|
||||
// 2 -- Either
|
||||
float32 intensity;
|
||||
float32 backIntensity;
|
||||
float32 minDefocus; // Min and max defocus values, 0.0 to 1.0,
|
||||
float32 maxDefocus; // for use with calligraphic lights
|
||||
int32 fadeMode; // Fading mode: 0 -- Enable perspective fading calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 fogPunch; // Fog punch mode: 0 -- Enable fog punch-through calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 dirMode; // Directional mode: 0 -- Enable directional calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 rangeMode; // Range Mode: 0 -- Use depth (Z) buffer calculations
|
||||
// 1 -- Use slant range calculations
|
||||
float32 minPixelSize;
|
||||
float32 maxPixelSize;
|
||||
float32 actualSize; // Actual light size in DB units
|
||||
float32 transFalloffPixelSize;
|
||||
float32 transFalloffExp;
|
||||
float32 transFalloffScalar;
|
||||
float32 transFalloffClamp;
|
||||
float32 fogScalar;
|
||||
float32 fogIntensity;
|
||||
float32 sizeDiffThreshold;
|
||||
int32 directionality; // Directionality: 0 -- Omnidirectional
|
||||
// 1 -- Unidirectional
|
||||
// 2 -- Bidirectional
|
||||
float32 horizLobeAngle;
|
||||
float32 vertLobeAngle;
|
||||
float32 lobeRollAngle;
|
||||
float32 dirFalloffExp;
|
||||
float32 dirAmbientIntensity;
|
||||
float32 significance;
|
||||
int32 flags; // Flag bits: 0 -- Reserved
|
||||
// 1 -- Don't use back color
|
||||
// 2 -- Reserved
|
||||
// ... several others ...
|
||||
// 18-31 -- Spare
|
||||
float32 visRange;
|
||||
float32 fadeRangeRatio;
|
||||
float32 fadeInDurationSecs;
|
||||
float32 adeOutDurationSecs;
|
||||
float32 lodRangeRatio;
|
||||
float32 lodScale;
|
||||
};
|
||||
|
||||
class LtPtAppearancePaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LtPtAppearancePaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new LtPtAppearancePaletteRecord(); }
|
||||
virtual const char* className() const { return "LtPtAppearancePaletteRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_PT_APPEARANCE_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SLightPointAppearancePalette); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LtPtAppearancePaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct SLightPointAnimationPalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 reserved_0;
|
||||
char name[256];
|
||||
int32 index;
|
||||
float32 period; // in seconds
|
||||
float32 phaseDelay; // inb seconds, from start of period
|
||||
float32 enabledPeriod; // time on, in seconds
|
||||
float32 axis[3]; // for rotating animations
|
||||
uint32 flags; // flags bits: 0 -- flashing
|
||||
// 1 -- rotating
|
||||
// 3 -- rotate counter clockwise
|
||||
// 4-31 -- reserved
|
||||
int32 animType; // animation type: 0 -- flashing sequence
|
||||
// 1 -- rotating
|
||||
// 2 -- strobe
|
||||
// 3 -- Morse code
|
||||
int32 morseTiming; // Morse timing: 0 -- standard timing
|
||||
// 1 -- Farnsworth timing
|
||||
int32 wordRate; // for Farnsworth timing
|
||||
int32 charRate; // for Farnsworth timing
|
||||
char morseString[1024];
|
||||
int32 numSequences; // for flashing sequences
|
||||
};
|
||||
// Repeated numSequenses times:
|
||||
struct SLightPointAnimationSequence
|
||||
{
|
||||
uint32 seqState; // sequence state: 0 -- On
|
||||
// 1 -- Off
|
||||
// 2 -- Color Change
|
||||
float32 duration; // duration of sequence in seconds
|
||||
uint32 seqColor; // color, if state is On or Color Change
|
||||
};
|
||||
|
||||
class LtPtAnimationPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LtPtAnimationPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new LtPtAnimationPaletteRecord(); }
|
||||
virtual const char* className() const { return "LtPtAnimationPaletteRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_PT_ANIMATION_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SLightPointAnimationPalette); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
SLightPointAnimationSequence* sequence( int idx );
|
||||
|
||||
enum FlagsBits {
|
||||
FLASHING = 0x80000000,
|
||||
ROTATING = 0x40000000,
|
||||
ROT_COUNTER_CLOCKWISE = 0x20000000
|
||||
};
|
||||
enum AnimationType {
|
||||
SEQ_TYPE = 0,
|
||||
ROT_TYPE = 1,
|
||||
STROBE_TYPE = 2,
|
||||
MORSE_TYPE = 3
|
||||
};
|
||||
enum SequenceState {
|
||||
SEQ_ON = 0,
|
||||
SEQ_OFF = 1,
|
||||
SEQ_COLOR = 2
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual ~LtPtAnimationPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,117 +0,0 @@
|
||||
// LightPointRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightPointRecord.h"
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightPointRecord> g_LightPointProxy;
|
||||
|
||||
LightPointRecord::LightPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightPointRecord::~LightPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
SLightPoint* LightPointRecord::getData() const
|
||||
{
|
||||
if (LightPointRecord::getFlightVersion()>1551)
|
||||
{
|
||||
return (SLightPoint*)_pData;
|
||||
}
|
||||
else
|
||||
{
|
||||
// disable ligth point for older versions since they don't have
|
||||
// the same format as SLightPoint, this needs fixing but this will have
|
||||
// to wait till after OSG 1.0.
|
||||
// Robert Osfield, 18th November 2005.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LightPointRecord::endian()
|
||||
{
|
||||
SLightPoint *pSLightPoint = (SLightPoint*)getData();
|
||||
if (pSLightPoint)
|
||||
{
|
||||
ENDIAN( pSLightPoint->iMaterial );
|
||||
ENDIAN( pSLightPoint->iFeature );
|
||||
ENDIAN( pSLightPoint->diMode );
|
||||
ENDIAN( pSLightPoint->sfIntensityFront );
|
||||
ENDIAN( pSLightPoint->sfIntensityBack );
|
||||
ENDIAN( pSLightPoint->sfMinDefocus );
|
||||
ENDIAN( pSLightPoint->sfMaxDefocus );
|
||||
ENDIAN( pSLightPoint->diFadeMode );
|
||||
ENDIAN( pSLightPoint->diFogPunchMode );
|
||||
ENDIAN( pSLightPoint->diDirectionalMode );
|
||||
ENDIAN( pSLightPoint->diRangeMode );
|
||||
ENDIAN( pSLightPoint->sfMinPixelSize );
|
||||
ENDIAN( pSLightPoint->sfMaxPixelSize );
|
||||
ENDIAN( pSLightPoint->afActualPixelSize );
|
||||
ENDIAN( pSLightPoint->sfTranspFalloff );
|
||||
ENDIAN( pSLightPoint->sfTranspFalloffExponent );
|
||||
ENDIAN( pSLightPoint->sfTranspFalloffScalar );
|
||||
ENDIAN( pSLightPoint->sfTranspFalloffClamp );
|
||||
ENDIAN( pSLightPoint->sfFog );
|
||||
ENDIAN( pSLightPoint->sfReserved );
|
||||
ENDIAN( pSLightPoint->sfSize );
|
||||
ENDIAN( pSLightPoint->diDirection );
|
||||
ENDIAN( pSLightPoint->sfLobeHoriz );
|
||||
ENDIAN( pSLightPoint->sfLobeVert );
|
||||
ENDIAN( pSLightPoint->sfLobeRoll );
|
||||
ENDIAN( pSLightPoint->sfFalloff );
|
||||
ENDIAN( pSLightPoint->sfAmbientIntensity );
|
||||
ENDIAN( pSLightPoint->sfAnimPeriod );
|
||||
ENDIAN( pSLightPoint->sfAnimPhaseDelay );
|
||||
ENDIAN( pSLightPoint->sfAnimPeriodEnable );
|
||||
ENDIAN( pSLightPoint->sfSignificance );
|
||||
ENDIAN( pSLightPoint->sfDrawOrder );
|
||||
ENDIAN( pSLightPoint->sfFlags );
|
||||
ENDIAN( pSLightPoint->dwBackColor );
|
||||
pSLightPoint->animRot.endian();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Indexed LightPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightPointIndexRecord> g_LightPointIndexdProxy;
|
||||
|
||||
LightPointIndexRecord::LightPointIndexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightPointIndexRecord::~LightPointIndexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LightPointIndexRecord::endian()
|
||||
{
|
||||
SLightPointIndex *pSLightPointIndex = (SLightPointIndex*)getData();
|
||||
|
||||
ENDIAN( pSLightPointIndex->iAppearanceIndex );
|
||||
ENDIAN( pSLightPointIndex->iAnimationIndex );
|
||||
ENDIAN( pSLightPointIndex->iDrawOrder );
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
// LightPointRecord.h
|
||||
|
||||
#ifndef __FLT_LIGHT_POINT_RECORD_H
|
||||
#define __FLT_LIGHT_POINT_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SLightPoint
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int16 iMaterial; // Surface material code (for DFAD)
|
||||
int16 iFeature; // Feature ID (for DFAD)
|
||||
int32 dwBackColor; // Back color for all bidirectional points
|
||||
int32 diMode; // Display mode
|
||||
// 0 = RASTER
|
||||
// 1 = CALLIGRAPHIC
|
||||
// 2 = EITHER
|
||||
float32 sfIntensityFront; // Intensity - scalar for front colors
|
||||
float32 sfIntensityBack; // - scalar for back color
|
||||
float32 sfMinDefocus; // Minimum defocus - limit (0.0 - 1.0) for calligraphic points
|
||||
float32 sfMaxDefocus; // Maximum defocus - limit (0.0 - 1.0) for calligraphic points
|
||||
int32 diFadeMode; // Fading mode
|
||||
// 0 = enable perspective fading calculations
|
||||
// 1 = disable calculations
|
||||
int32 diFogPunchMode; // Fog Punch mode
|
||||
// 0 = enable fog punch through calculations
|
||||
// 1 = disable calculations
|
||||
int32 diDirectionalMode; // Directional mode
|
||||
// 0 = enable directional calculations
|
||||
// 1 = disable calculations
|
||||
int32 diRangeMode; // Range mode
|
||||
// 0 = use depth (Z) buffer calculation
|
||||
// 1 = use slant range calculation
|
||||
float32 sfMinPixelSize; // Minimum pixel size
|
||||
// Minimum diameter of points in pixels
|
||||
float32 sfMaxPixelSize; // Maximum pixel size
|
||||
// Maximum diameter of points in pixels
|
||||
float32 afActualPixelSize; // Actual size
|
||||
// Actual diameter of points in database coordinates
|
||||
float32 sfTranspFalloff; // Transparent falloff pixel size
|
||||
// Diameter in pixels when points become transparent
|
||||
float32 sfTranspFalloffExponent; // Transparent falloff exponent
|
||||
// >= 0 - falloff multiplier exponent (1.0 = linear falloff)
|
||||
float32 sfTranspFalloffScalar; // Transparent falloff scalar
|
||||
// > 0 - falloff multiplier scale factor
|
||||
float32 sfTranspFalloffClamp; // Transparent falloff clamp
|
||||
// Minimum permissible falloff multiplier result
|
||||
float32 sfFog; // Fog scalar
|
||||
// >= 0 - adjusts range of points for punch threw effect.
|
||||
float32 sfReserved;
|
||||
float32 sfSize; // Size difference threshold
|
||||
// Point size transition hint to renderer
|
||||
int32 diDirection; // Directional type
|
||||
// 0 = OMNIDIRECTIONAL
|
||||
// 1 = UNIDIRECTIONAL
|
||||
// 2 = BIDIRECTIONAL
|
||||
float32 sfLobeHoriz; // Horizontal lobe angle [degrees]
|
||||
float32 sfLobeVert; // Vertical lobe angle [degrees]
|
||||
float32 sfLobeRoll; // Rotation of lobe about local Y axis [degrees]
|
||||
float32 sfFalloff; // Directional falloff exponent
|
||||
// >= 0 - falloff multiplier exponent
|
||||
// (1.0 = linear falloff)
|
||||
float32 sfAmbientIntensity; // Directional ambient intensity
|
||||
float32 sfAnimPeriod; // Animation period [seconds]
|
||||
float32 sfAnimPhaseDelay; // Animation phase delay [seconds]
|
||||
float32 sfAnimPeriodEnable; // Animation enabled period [seconds]
|
||||
float32 sfSignificance; // Drop out priority for RASCAL lights (0.0 - 1.0)
|
||||
int32 sfDrawOrder; // Calligraphic draw order
|
||||
uint32 sfFlags; // Flags (bits, from left to right)
|
||||
// 0 = reserved
|
||||
// 1 = No back color
|
||||
// TRUE = don<6F>t use back color for
|
||||
// bidirectional points
|
||||
// FALSE = use back color for
|
||||
// bidirectional points
|
||||
// 2 = reserved
|
||||
// 3 = Calligraphic proximity occulting (Debunching)
|
||||
// 4 = Reflective, non-emissive point
|
||||
// 5-7 = Randomize intensity
|
||||
// 0 = never
|
||||
// 1 = low
|
||||
// 2 = medium
|
||||
// 3 = high
|
||||
// 8 = Perspective mode
|
||||
// 9 = Flashing
|
||||
// 10 = Rotating
|
||||
// 11 = Rotate Counter Clockwise
|
||||
// Direction of rotation about local Z axis
|
||||
// 12 = reserved
|
||||
// 13-14 = Quality
|
||||
// 0 = Low
|
||||
// 1 = Medium
|
||||
// 2 = High
|
||||
// 3 = Undefined
|
||||
// 15 = Visible during day
|
||||
// 16 = Visible during dusk
|
||||
// 17 = Visible during night
|
||||
// 18-31 = Spare
|
||||
float32x3 animRot; // Axis of rotation for rotating animation
|
||||
};
|
||||
|
||||
class LightPointRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
LightPointRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightPointRecord(); }
|
||||
virtual const char* className() const { return "LightPointRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_POINT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SLightPoint* getData() const;
|
||||
|
||||
protected:
|
||||
virtual ~LightPointRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct SLightPointIndex
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 iAppearanceIndex; // Index into lt pt appearance palette
|
||||
int32 iAnimationIndex; // Index into lt pt animation palette
|
||||
int32 iDrawOrder; // Calligraphic draw order
|
||||
int32 iReserved_0; // Reserved
|
||||
};
|
||||
|
||||
class LightPointIndexRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
LightPointIndexRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightPointIndexRecord(); }
|
||||
virtual const char* className() const { return "LightPointIndexRecord"; }
|
||||
virtual int classOpcode() const { return INDEXED_LIGHT_PT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SLightPointIndex* getData() const { return (SLightPointIndex*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~LightPointIndexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightPointSystemRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightPointSystemRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightPointSystemRecord> g_LightPointSystemProxy;
|
||||
|
||||
LightPointSystemRecord::LightPointSystemRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightPointSystemRecord::~LightPointSystemRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LightPointSystemRecord::endian()
|
||||
{
|
||||
SLightPointSystem* ltPtSys = (SLightPointSystem*)getData();
|
||||
|
||||
ENDIAN( ltPtSys->intensity );
|
||||
ENDIAN( ltPtSys->animationState );
|
||||
ENDIAN( ltPtSys->flags );
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
|
||||
#ifndef __FLT_LIGHT_POINT_SYSTEM_RECORD_H
|
||||
#define __FLT_LIGHT_POINT_SYSTEM_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SLightPointSystem
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char ident[8];
|
||||
float32 intensity; // Child light point node intensity
|
||||
int32 animationState; // Animation state: 0 -- On
|
||||
// 1 -- Off
|
||||
// 3 -- Random
|
||||
int32 flags; // Flag bits: 0 -- Enable
|
||||
// 1-31 -- Spare
|
||||
};
|
||||
|
||||
|
||||
class LightPointSystemRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LightPointSystemRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightPointSystemRecord(); }
|
||||
virtual const char* className() const { return "LightPointSystemRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_PT_SYSTEM_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
virtual SLightPointSystem* getData() const { return (SLightPointSystem*)_pData; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightPointSystemRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
// LightSourcePaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightSourcePaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightSourcePaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightSourcePaletteRecord> g_LightSourcePaletteProxy;
|
||||
|
||||
LightSourcePaletteRecord::LightSourcePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightSourcePaletteRecord::~LightSourcePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LightSourcePaletteRecord::endian()
|
||||
{
|
||||
SLightSourcePalette *pSLightSourcePalette = (SLightSourcePalette*)getData();
|
||||
|
||||
ENDIAN( pSLightSourcePalette->diReserved_1 );
|
||||
ENDIAN( pSLightSourcePalette->diIndex );
|
||||
ENDIAN( pSLightSourcePalette->diReserved_2 );
|
||||
ENDIAN( pSLightSourcePalette->sfAmbientRGBA[0] );
|
||||
ENDIAN( pSLightSourcePalette->sfAmbientRGBA[1] );
|
||||
ENDIAN( pSLightSourcePalette->sfAmbientRGBA[2] );
|
||||
ENDIAN( pSLightSourcePalette->sfAmbientRGBA[3] );
|
||||
ENDIAN( pSLightSourcePalette->sfDiffuseRGBA[0] );
|
||||
ENDIAN( pSLightSourcePalette->sfDiffuseRGBA[1] );
|
||||
ENDIAN( pSLightSourcePalette->sfDiffuseRGBA[2] );
|
||||
ENDIAN( pSLightSourcePalette->sfDiffuseRGBA[3] );
|
||||
ENDIAN( pSLightSourcePalette->sfSpecularRGBA[0] );
|
||||
ENDIAN( pSLightSourcePalette->sfSpecularRGBA[1] );
|
||||
ENDIAN( pSLightSourcePalette->sfSpecularRGBA[2] );
|
||||
ENDIAN( pSLightSourcePalette->sfSpecularRGBA[3] );
|
||||
ENDIAN( pSLightSourcePalette->sfDropoff );
|
||||
ENDIAN( pSLightSourcePalette->sfCutoff );
|
||||
ENDIAN( pSLightSourcePalette->sfYaw );
|
||||
ENDIAN( pSLightSourcePalette->sfPitch );
|
||||
ENDIAN( pSLightSourcePalette->sfConstantAttuenation );
|
||||
ENDIAN( pSLightSourcePalette->sfLinearAttuenation );
|
||||
ENDIAN( pSLightSourcePalette->sfQuadraticAttuenation );
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// LightSourcePaletteRecord.h
|
||||
|
||||
#ifndef __FLT_LIGHT_SOURCE_PALETTE_RECORD_H
|
||||
#define __FLT_LIGHT_SOURCE_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
typedef struct LightSourcePaletteTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diIndex; // Palette index
|
||||
int32 diReserved_1[2];
|
||||
char szName[20]; // Light source name
|
||||
int32 diReserved_2;
|
||||
float32 sfAmbientRGBA[4]; // Alpha comp. currently unused
|
||||
float32 sfDiffuseRGBA[4]; // Alpha comp. currently unused
|
||||
float32 sfSpecularRGBA[4]; // Alpha comp. currently unused
|
||||
int32 diLightType; // 0 = INFINITE
|
||||
// 1 = LOCAL
|
||||
// 2 = SPOT
|
||||
int32 diReserved_3[10];
|
||||
float32 sfDropoff; // Spot exponential dropoff term
|
||||
float32 sfCutoff; // Spot cutoff angle (radians)
|
||||
float32 sfYaw;
|
||||
float32 sfPitch;
|
||||
float32 sfConstantAttuenation;
|
||||
float32 sfLinearAttuenation;
|
||||
float32 sfQuadraticAttuenation;
|
||||
int32 diModelingLight; // TRUE/FALSE
|
||||
int32 diSpare[19];
|
||||
} SLightSourcePalette;
|
||||
|
||||
|
||||
|
||||
class LightSourcePaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LightSourcePaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightSourcePaletteRecord(); }
|
||||
virtual const char* className() const { return "LightSourcePaletteRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_SOURCE_PALETTE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightSourcePaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// LightSourceRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightSourceRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightSourceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightSourceRecord> g_LightSourceRecordProxy;
|
||||
|
||||
LightSourceRecord::LightSourceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightSourceRecord::~LightSourceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LightSourceRecord::endian()
|
||||
{
|
||||
SLightSource *pSLightSource = (SLightSource*)getData();
|
||||
|
||||
ENDIAN( pSLightSource->diReserved_1 );
|
||||
ENDIAN( pSLightSource->diIndex );
|
||||
ENDIAN( pSLightSource->diReserved_2 );
|
||||
ENDIAN( pSLightSource->dwFlags );
|
||||
ENDIAN( pSLightSource->diReserved_3 );
|
||||
pSLightSource->Coord.endian();
|
||||
ENDIAN( pSLightSource->sfYaw );
|
||||
ENDIAN( pSLightSource->sfPitch );
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// LightSourceRecord.h
|
||||
|
||||
#ifndef __FLT_LIGHT_SOURCE_RECORD_H
|
||||
#define __FLT_LIGHT_SOURCE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightSourceRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct LightSourceTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 diReserved_1;
|
||||
int32 diIndex; //index into lightpalette
|
||||
int32 diReserved_2;
|
||||
uint32 dwFlags; //bits from left to right
|
||||
//0=enabled
|
||||
//1=global
|
||||
//2=reserve
|
||||
//3=export
|
||||
//4=reserved
|
||||
//5-31 spare
|
||||
int32 diReserved_3;
|
||||
float64x3 Coord; // x,y,z coordinate
|
||||
float32 sfYaw;
|
||||
float32 sfPitch;
|
||||
} SLightSource;
|
||||
|
||||
|
||||
class LightSourceRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LightSourceRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightSourceRecord(); }
|
||||
virtual const char* className() const { return "LightSourceRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_SOURCE_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightSourceRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,542 +0,0 @@
|
||||
// LocalVertexPoolRecords.cpp
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786) // Truncated debug names.
|
||||
#endif
|
||||
|
||||
#include "LocalVertexPoolRecord.h"
|
||||
#include "Registry.h"
|
||||
#include <assert.h>
|
||||
|
||||
// The sizes (in bytes) of the various attribute sections of the vertex data.
|
||||
#define SIZE_POSITION 24 // 3 * float64 = 3 * 8
|
||||
#define SIZE_COLOR 4 // 1 uint32
|
||||
#define SIZE_NORMAL 12 // 3 * float32 = 3 * 4
|
||||
#define SIZE_BASE_UV 8 // 2 * float32 = 2 * 4
|
||||
#define SIZE_UV_1 SIZE_BASE_UV
|
||||
#define SIZE_UV_2 SIZE_BASE_UV
|
||||
#define SIZE_UV_3 SIZE_BASE_UV
|
||||
#define SIZE_UV_4 SIZE_BASE_UV
|
||||
#define SIZE_UV_5 SIZE_BASE_UV
|
||||
#define SIZE_UV_6 SIZE_BASE_UV
|
||||
#define SIZE_UV_7 SIZE_BASE_UV
|
||||
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LocalVertexPoolRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LocalVertexPoolRecord> g_LocalVertexPoolProxy;
|
||||
LocalVertexPoolRecord *_current = NULL;
|
||||
|
||||
LocalVertexPoolRecord::LocalVertexPoolRecord()
|
||||
: AncillaryRecord(),
|
||||
_vertexSizeBytesCache(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LocalVertexPoolRecord::~LocalVertexPoolRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the address of the beginning of the vertices.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char *LocalVertexPoolRecord::_getStartOfVertices() const
|
||||
{
|
||||
SLocalVertexPool *pool = (SLocalVertexPool *) this->getData();
|
||||
char *vertex = (char *) (&(pool[1]));
|
||||
return vertex;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the address of the beginning of the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char *LocalVertexPoolRecord::_getStartOfAttribute ( const uint32 &whichVertex, const uint32 &offset ) const
|
||||
{
|
||||
assert ( whichVertex < this->getNumVertices() );
|
||||
|
||||
// Get pointer to start of vertex data.
|
||||
char *startOfVertices = (char *) this->_getStartOfVertices();
|
||||
|
||||
// The number of vertices.
|
||||
//uint32 numVertices = this->getNumVertices();
|
||||
|
||||
// NOTE This function formerly computed sizeOfVertex by taking the record length and dividing
|
||||
// by the number of vertices. This is wrong in 15.7 and beyond, as the record could
|
||||
// exceed 65535 bytes and be continued, in which case the "original" record length
|
||||
// field does not contain the actual length of the data.
|
||||
|
||||
// The size of each individual vertex depends on its attributes, and is cached.
|
||||
size_t sizeOfVertex = this->_getVertexSizeBytes();
|
||||
|
||||
// Set the start of the desired vertex's data.
|
||||
char *startOfAttribute = &startOfVertices[whichVertex * sizeOfVertex];
|
||||
|
||||
// Now adjust for the offset within this vertex.
|
||||
startOfAttribute += offset;
|
||||
|
||||
// Return the pointer.
|
||||
return startOfAttribute;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LocalVertexPoolRecord::getColorIndex ( const uint32 &whichVertex, uint32 &colorIndex ) const
|
||||
{
|
||||
ARGUMENT_CHECK_FOR_GET_FUNCTION ( whichVertex, COLOR_INDEX );
|
||||
|
||||
// Offset to the start of the color.
|
||||
uint32 *color = (uint32 *) this->_getStartOfAttribute ( whichVertex, _offset.color );
|
||||
if ( NULL == color )
|
||||
return false;
|
||||
|
||||
// Set the color index and return.
|
||||
colorIndex = *color;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LocalVertexPoolRecord::getColorRGBA ( const uint32 &whichVertex, float32 &r, float32 &g, float32 &b, float32 &a ) const
|
||||
{
|
||||
ARGUMENT_CHECK_FOR_GET_FUNCTION ( whichVertex, RGB_COLOR );
|
||||
|
||||
// Offset to the start of the color.
|
||||
uint32 *color = (uint32 *) this->_getStartOfAttribute ( whichVertex, _offset.color );
|
||||
if ( NULL == color )
|
||||
return false;
|
||||
|
||||
// Since we already byte-swapped, we have to check the endian of this
|
||||
// machine so that we know how to grab the channels.
|
||||
uint32 red, green, blue, alpha;
|
||||
|
||||
// If this machine is little-endian...
|
||||
if ( flt::isLittleEndianMachine() )
|
||||
{
|
||||
red = ( ( (*color) & 0xFF000000 ) >> 0 );
|
||||
green = ( ( (*color) & 0x00FF0000 ) >> 8 );
|
||||
blue = ( ( (*color) & 0x0000FF00 ) >> 16 );
|
||||
alpha = ( ( (*color) & 0x000000FF ) >> 24 );
|
||||
}
|
||||
|
||||
// Otherwise, big-endian...
|
||||
else
|
||||
{
|
||||
red = ( ( (*color) & 0x000000FF ) >> 0 );
|
||||
green = ( ( (*color) & 0x0000FF00 ) >> 8 );
|
||||
blue = ( ( (*color) & 0x00FF0000 ) >> 16 );
|
||||
alpha = ( ( (*color) & 0xFF000000 ) >> 24 );
|
||||
}
|
||||
|
||||
// Normalize.
|
||||
float32 scale = 1.0f / 255.0f;
|
||||
r = scale * red;
|
||||
g = scale * green;
|
||||
b = scale * blue;
|
||||
a = scale * alpha;
|
||||
|
||||
// It worked.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LocalVertexPoolRecord::getNormal ( const uint32 &whichVertex, float32 &nx, float32 &ny, float32 &nz ) const
|
||||
{
|
||||
ARGUMENT_CHECK_FOR_GET_FUNCTION ( whichVertex, NORMAL );
|
||||
|
||||
// Offset to the start of the normals.
|
||||
float32 *vec = (float32 *) this->_getStartOfAttribute ( whichVertex, _offset.normal );
|
||||
if ( NULL == vec )
|
||||
return false;
|
||||
|
||||
// Set the normal vector and return.
|
||||
nx = vec[0];
|
||||
ny = vec[1];
|
||||
nz = vec[2];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LocalVertexPoolRecord::getPosition ( const uint32 &whichVertex, float64 &px, float64 &py, float64 &pz ) const
|
||||
{
|
||||
ARGUMENT_CHECK_FOR_GET_FUNCTION ( whichVertex, POSITION );
|
||||
|
||||
// Offset to the start of the normals.
|
||||
float64 *point = (float64 *) this->_getStartOfAttribute ( whichVertex, _offset.position );
|
||||
if ( NULL == point )
|
||||
return false;
|
||||
|
||||
// Set the normal vector and return.
|
||||
px = point[0];
|
||||
py = point[1];
|
||||
pz = point[2];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the specified vertex attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LocalVertexPoolRecord::getUV ( const uint32 &whichVertex, const AttributeMask &whichUV, float32 &u, float32 &v ) const
|
||||
{
|
||||
ARGUMENT_CHECK_FOR_GET_FUNCTION ( whichVertex, (uint32) whichUV );
|
||||
|
||||
// Offset to the start of the normals.
|
||||
float32 *uv = (float32 *) this->_getStartOfAttribute ( whichVertex, this->_getOffset ( whichUV ) );
|
||||
if ( NULL == uv )
|
||||
return false;
|
||||
|
||||
// Set the normal vector and return.
|
||||
u = uv[0];
|
||||
v = uv[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Getthe offset that corresponds to the given attribute.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32 LocalVertexPoolRecord::_getOffset ( const AttributeMask &attribute ) const
|
||||
{
|
||||
switch ( attribute )
|
||||
{
|
||||
case POSITION: return _offset.position;
|
||||
case COLOR_INDEX: return _offset.color;
|
||||
case RGB_COLOR: return _offset.color;
|
||||
case NORMAL: return _offset.normal;
|
||||
case BASE_UV: return _offset.baseUV;
|
||||
case UV_1: return _offset.uv1;
|
||||
case UV_2: return _offset.uv2;
|
||||
case UV_3: return _offset.uv3;
|
||||
case UV_4: return _offset.uv4;
|
||||
case UV_5: return _offset.uv5;
|
||||
case UV_6: return _offset.uv6;
|
||||
case UV_7: return _offset.uv7;
|
||||
default:
|
||||
assert ( 0 );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Convert the data from big-endian to little-endian.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LocalVertexPoolRecord::endian()
|
||||
{
|
||||
// Should only be in here for little-endian machines.
|
||||
assert ( flt::isLittleEndianMachine() );
|
||||
|
||||
// Get a pointer to the vertex pool structure. Note: The members of
|
||||
// SLocalVertexPool have already been endian-corrected in
|
||||
// _initAttributeOffsets().
|
||||
SLocalVertexPool *pool = (SLocalVertexPool *) this->getData();
|
||||
|
||||
// Get pointer to start of vertex data.
|
||||
char *vertex = this->_getStartOfVertices();
|
||||
|
||||
// Loop through the vertices and byte-swap the data.
|
||||
for ( uint32 i = 0; i < pool->numVerts; ++i )
|
||||
{
|
||||
if ( this->hasAttribute ( POSITION ) )
|
||||
{
|
||||
// Get the size of the coordinates.
|
||||
size_t size = sizeof ( float64 );
|
||||
|
||||
// Get the values.
|
||||
float64 *x = (float64 *) vertex;
|
||||
float64 *y = &(x[1]);
|
||||
float64 *z = &(y[1]);
|
||||
|
||||
// Swap the data.
|
||||
flt::swapBytes ( size, x );
|
||||
flt::swapBytes ( size, y );
|
||||
flt::swapBytes ( size, z );
|
||||
|
||||
// Move pointer to the end of this chunk of data.
|
||||
vertex = (char *) ( &(z[1]) );
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( COLOR_INDEX ) ||
|
||||
this->hasAttribute ( RGB_COLOR ) )
|
||||
{
|
||||
// Get the size of the coordinates.
|
||||
size_t size = sizeof ( uint32 );
|
||||
|
||||
// Get the value.
|
||||
uint32 *color = (uint32 *) vertex;
|
||||
|
||||
// Swap the data.
|
||||
flt::swapBytes ( size, color );
|
||||
|
||||
// Move pointer to the end of this chunk of data.
|
||||
vertex = (char *) ( &(color[1]) );
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( NORMAL ) )
|
||||
{
|
||||
// Get the size of the elements.
|
||||
size_t size = sizeof ( float32 );
|
||||
|
||||
// Get the values.
|
||||
float32 *x = (float32 *) vertex;
|
||||
float32 *y = &(x[1]);
|
||||
float32 *z = &(y[1]);
|
||||
|
||||
// Swap the data.
|
||||
flt::swapBytes ( size, x );
|
||||
flt::swapBytes ( size, y );
|
||||
flt::swapBytes ( size, z );
|
||||
|
||||
// Move pointer to the end of this chunk of data.
|
||||
vertex = (char *) ( &(z[1]) );
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( BASE_UV ) ||
|
||||
this->hasAttribute ( UV_1 ) ||
|
||||
this->hasAttribute ( UV_2 ) ||
|
||||
this->hasAttribute ( UV_3 ) ||
|
||||
this->hasAttribute ( UV_4 ) ||
|
||||
this->hasAttribute ( UV_5 ) ||
|
||||
this->hasAttribute ( UV_6 ) ||
|
||||
this->hasAttribute ( UV_7 ) )
|
||||
{
|
||||
// Get the size of the elements.
|
||||
size_t size = sizeof ( float32 );
|
||||
|
||||
// Get the values.
|
||||
float32 *u = (float32 *) vertex;
|
||||
float32 *v = &(u[1]);
|
||||
|
||||
// Swap the data.
|
||||
flt::swapBytes ( size, u );
|
||||
flt::swapBytes ( size, v );
|
||||
|
||||
// Move pointer to the end of this chunk of data.
|
||||
vertex = (char *) ( &(v[1]) );
|
||||
}
|
||||
}
|
||||
|
||||
// Should be true. It means that we walked the pointer "vertex" to the
|
||||
// end of the record, but not past it.
|
||||
// If equal, vertex pool record was not continued.
|
||||
// If 16bit record length is less than length of vertex pool, then the original vertex
|
||||
// pool record was continued with one or more CONTINUATION_OP records.
|
||||
assert ( pool->RecHeader._wLength <= ( ( (unsigned long) vertex ) - ( (unsigned long) pool ) ) );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The offsets to the start of each attribute depends on the what attributes
|
||||
// are in the vertices. Here we initialize those integer data members.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LocalVertexPoolRecord::_initAttributeOffsets()
|
||||
{
|
||||
// When we get to here we just got done reading the data (i.e., it is still
|
||||
// big-endian). Correct the endian of the members of SLocalVertexPool
|
||||
// because we need the SLocalVertexPool::attributeMask to determine the
|
||||
// offsets (but do not endian-correct the vertex data that follows). The
|
||||
// rest of the data (the vertices) will be endian-corrected in endian().
|
||||
|
||||
// If we are on a little-endian machine...
|
||||
if ( flt::isLittleEndianMachine() )
|
||||
{
|
||||
// Fix these data members.
|
||||
SLocalVertexPool *pool = (SLocalVertexPool *) this->getData();
|
||||
ENDIAN ( pool->numVerts );
|
||||
ENDIAN ( pool->attributeMask );
|
||||
}
|
||||
|
||||
// Initialize.
|
||||
uint32 current = 0;
|
||||
|
||||
// The order is important because the data will be in this order. We drop
|
||||
// down through here and set the offsets. Each time we update the current
|
||||
// position so that we can set the next one.
|
||||
|
||||
if ( this->hasAttribute ( POSITION ) )
|
||||
{
|
||||
_offset.position = current;
|
||||
current += SIZE_POSITION;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( COLOR_INDEX ) || this->hasAttribute ( RGB_COLOR ) )
|
||||
{
|
||||
// According to 15.7 manual, we should not have both flags.
|
||||
assert ( false == ( this->hasAttribute ( COLOR_INDEX ) && this->hasAttribute ( RGB_COLOR ) ) );
|
||||
|
||||
_offset.color = current;
|
||||
current += SIZE_COLOR;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( NORMAL ) )
|
||||
{
|
||||
_offset.normal = current;
|
||||
current += SIZE_NORMAL;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( BASE_UV ) )
|
||||
{
|
||||
_offset.baseUV = current;
|
||||
current += SIZE_BASE_UV;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_1 ) )
|
||||
{
|
||||
_offset.uv1 = current;
|
||||
current += SIZE_UV_1;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_2 ) )
|
||||
{
|
||||
_offset.uv2 = current;
|
||||
current += SIZE_UV_2;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_3 ) )
|
||||
{
|
||||
_offset.uv3 = current;
|
||||
current += SIZE_UV_3;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_4 ) )
|
||||
{
|
||||
_offset.uv4 = current;
|
||||
current += SIZE_UV_4;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_5 ) )
|
||||
{
|
||||
_offset.uv5 = current;
|
||||
current += SIZE_UV_5;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_6 ) )
|
||||
{
|
||||
_offset.uv6 = current;
|
||||
current += SIZE_UV_6;
|
||||
}
|
||||
|
||||
if ( this->hasAttribute ( UV_7 ) )
|
||||
{
|
||||
_offset.uv7 = current;
|
||||
current += SIZE_UV_7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute the size of each vertex based on its attributes. Cache the
|
||||
// result for later reference.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int LocalVertexPoolRecord::_getVertexSizeBytes() const
|
||||
{
|
||||
if (_vertexSizeBytesCache == 0)
|
||||
{
|
||||
if ( hasAttribute ( POSITION ) )
|
||||
_vertexSizeBytesCache += SIZE_POSITION;
|
||||
|
||||
if ( hasAttribute ( COLOR_INDEX ) || hasAttribute ( RGB_COLOR ) )
|
||||
_vertexSizeBytesCache += SIZE_COLOR;
|
||||
|
||||
if ( hasAttribute ( NORMAL ) )
|
||||
_vertexSizeBytesCache += SIZE_NORMAL;
|
||||
|
||||
if ( hasAttribute ( BASE_UV ) )
|
||||
_vertexSizeBytesCache += SIZE_BASE_UV;
|
||||
|
||||
if ( hasAttribute ( UV_1 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_1;
|
||||
|
||||
if ( hasAttribute ( UV_2 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_2;
|
||||
|
||||
if ( hasAttribute ( UV_3 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_3;
|
||||
|
||||
if ( hasAttribute ( UV_4 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_4;
|
||||
|
||||
if ( hasAttribute ( UV_5 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_5;
|
||||
|
||||
if ( hasAttribute ( UV_6 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_6;
|
||||
|
||||
if ( hasAttribute ( UV_7 ) )
|
||||
_vertexSizeBytesCache += SIZE_UV_7;
|
||||
}
|
||||
|
||||
return _vertexSizeBytesCache;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is called after the record is read.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LocalVertexPoolRecord::postReadInit()
|
||||
{
|
||||
// Initialize the attribute offsets.
|
||||
this->_initAttributeOffsets();
|
||||
|
||||
// Call the base class's function.
|
||||
AncillaryRecord::postReadInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
// LocalVertexPoolRecord.h
|
||||
|
||||
#ifndef __FLT_LOCAL_VERTEX_POOL_RECORDS_H
|
||||
#define __FLT_LOCAL_VERTEX_POOL_RECORDS_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LocalVertexPoolRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SLocalVertexPool // Local vertex info, new with 15.7
|
||||
{
|
||||
SRecHeader RecHeader; // Header (opcode and size)
|
||||
uint32 numVerts; // Number of vertices contained in this record
|
||||
uint32 attributeMask; // 32 bit mask indicating what kind of vertex information is contained in this vertex list. Bits are ordered from left to right (bit 1 is leftmost).
|
||||
};
|
||||
|
||||
|
||||
class LocalVertexPoolRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum AttributeMask
|
||||
{
|
||||
POSITION = 0x80000000, // Has Position - indicates that each vertex in the list includes x, y, and z coordinates (three double-precision floating point values)
|
||||
COLOR_INDEX = 0x40000000, // Has Color Index- indicates that each vertex in the list includes a color value that is a color table index (one integer value)
|
||||
RGB_COLOR = 0x20000000, // Has RGB Color - indicates that each vertex in the list includes a color value that is a packed RGB color value (one integer value) NOTE: Bits 2 and 3 are mutually exclusive - a vertex can have either a color index or an RGB color value or neither, but cannot have both a color index and an RGB value.
|
||||
// In 15.8, has RGBA color
|
||||
NORMAL = 0x10000000, // Has Normal - indicates that each vertex in the list includes a normal (three single-precision floating point values)
|
||||
BASE_UV = 0x08000000, // Has Base UV - indicates that each vertex in the list includes uv texture coordinates for the base texture (two single-precision floating point values)
|
||||
UV_1 = 0x04000000, // Has UV 1 - indicates that each vertex in the list includes uv texture coordinates for layer 1 (two single-precision floating point values)
|
||||
UV_2 = 0x02000000, // Has UV 2 - indicates that each vertex in the list includes uv texture coordinates for layer 2 (two single-precision floating point values)
|
||||
UV_3 = 0x01000000, // Has UV 3 - indicates that each vertex in the list includes uv texture coordinates for layer 3 (two single-precision floating point values)
|
||||
UV_4 = 0x00800000, // Has UV 4 - indicates that each vertex in the list includes uv texture coordinates for layer 4 (two single-precision floating point values)
|
||||
UV_5 = 0x00400000, // Has UV 5 - indicates that each vertex in the list includes uv texture coordinates for layer 5 (two single-precision floating point values)
|
||||
UV_6 = 0x00200000, // Has UV 6 - indicates that each vertex in the list includes uv texture coordinates for layer 6 (two single-precision floating point values)
|
||||
UV_7 = 0x00100000 // Has UV 7 - indicates that each vertex in the list includes uv texture coordinates for layer 7 (two single-precision floating point values)
|
||||
};
|
||||
|
||||
LocalVertexPoolRecord();
|
||||
|
||||
virtual void accept ( RecordVisitor &rv ) { rv.apply ( *this ); }
|
||||
|
||||
virtual const char * className() const { return "LocalVertexPoolRecord"; }
|
||||
virtual int classOpcode() const { return LOCAL_VERTEX_POOL_OP; }
|
||||
virtual Record * clone() const { return new LocalVertexPoolRecord(); }
|
||||
|
||||
virtual SLocalVertexPool* getData() const { return (SLocalVertexPool *) _pData; }
|
||||
uint32 getNumVertices() const { return this->getData()->numVerts; }
|
||||
// Vertex attributes.
|
||||
bool getColorIndex ( const uint32 &whichVertex, uint32 &colorIndex ) const;
|
||||
bool getColorRGBA ( const uint32 &whichVertex, float32 &r, float32 &g, float32 &b, float32 &a ) const;
|
||||
bool getNormal ( const uint32 &whichVertex, float32 &nx, float32 &ny, float32 &nz ) const;
|
||||
bool getPosition ( const uint32 &whichVertex, float64 &px, float64 &py, float64 &pz ) const;
|
||||
bool getUV ( const uint32 &whichVertex, const AttributeMask &whichUV, float32 &u, float32 &v ) const;
|
||||
|
||||
bool hasAttribute ( const uint32 &bits ) const { return flt::hasBits ( this->getData()->attributeMask, bits ); }
|
||||
|
||||
bool isInRange ( const uint32 &i ) const { return i < this->getNumVertices(); }
|
||||
|
||||
virtual void postReadInit();
|
||||
|
||||
virtual size_t sizeofData() const { return sizeof ( SLocalVertexPool ); }
|
||||
|
||||
protected:
|
||||
|
||||
class Offset
|
||||
{
|
||||
public:
|
||||
uint32 position, color, normal, baseUV, uv1, uv2, uv3, uv4, uv5, uv6, uv7;
|
||||
Offset() : position ( 0 ), color ( 0 ), normal ( 0 ), baseUV ( 0 ), uv1 ( 0 ), uv2 ( 0 ), uv3 ( 0 ), uv4 ( 0 ), uv5 ( 0 ), uv6 ( 0 ), uv7 ( 0 ){}
|
||||
} _offset;
|
||||
|
||||
virtual ~LocalVertexPoolRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
uint32 _getOffset ( const AttributeMask &attribute ) const;
|
||||
char * _getStartOfVertices() const;
|
||||
char * _getStartOfAttribute ( const uint32 &whichVertex, const uint32 &attributeOffset ) const;
|
||||
|
||||
void _initAttributeOffsets();
|
||||
|
||||
int _getVertexSizeBytes() const;
|
||||
mutable int _vertexSizeBytesCache;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Used in cpp file. Put it here because (if memory serves) gcc doesn't like
|
||||
// macros in cpp files, only headers. If this is wrong then move to cpp file.
|
||||
//
|
||||
// Note: Asking for an attribute the vertex does not have will just return
|
||||
// false. However, asking for a vertex that is out of range should assert
|
||||
// and then return false. This was an arbitrary decision.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ARGUMENT_CHECK_FOR_GET_FUNCTION(which,attribute) \
|
||||
if ( false == this->hasAttribute ( attribute ) ) \
|
||||
return false; \
|
||||
if ( false == this->isInRange ( which ) ) \
|
||||
{ \
|
||||
assert ( 0 ); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#endif // __FLT_LOCAL_VERTEX_POOL_RECORDS_H
|
||||
@@ -1,78 +0,0 @@
|
||||
// LodRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LodRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LodRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LodRecord> g_LodProxy;
|
||||
|
||||
LodRecord::LodRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LodRecord::~LodRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LodRecord::endian()
|
||||
{
|
||||
SLevelOfDetail *pSLod = (SLevelOfDetail*)getData();
|
||||
|
||||
ENDIAN( pSLod->dfSwitchInDist );
|
||||
ENDIAN( pSLod->dfSwitchOutDist );
|
||||
ENDIAN( pSLod->iSpecialId_1 );
|
||||
ENDIAN( pSLod->iSpecialId_2 );
|
||||
ENDIAN( pSLod->diFlags );
|
||||
pSLod->Center.endian();
|
||||
ENDIAN( pSLod->dfTransitionRange );
|
||||
|
||||
if (getFltFile()->getFlightVersion() >= 1580 )
|
||||
{
|
||||
ENDIAN( pSLod->dfSignificantSize );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldLodRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<OldLodRecord> g_OldLodProxy;
|
||||
|
||||
OldLodRecord::OldLodRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
OldLodRecord::~OldLodRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OldLodRecord::endian()
|
||||
{
|
||||
SOldLOD *pSLod = (SOldLOD*)getData();
|
||||
|
||||
ENDIAN( pSLod->dwSwitchInDist );
|
||||
ENDIAN( pSLod->dwSwitchOutDist );
|
||||
ENDIAN( pSLod->iSpecialId_1 );
|
||||
ENDIAN( pSLod->iSpecialId_2 );
|
||||
ENDIAN( pSLod->diFlags );
|
||||
ENDIAN( pSLod->Center[0] );
|
||||
ENDIAN( pSLod->Center[1] );
|
||||
ENDIAN( pSLod->Center[2] );
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// LodRecord.h
|
||||
|
||||
#ifndef __FLT_LOD_RECORD_H
|
||||
#define __FLT_LOD_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LodRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SLevelOfDetail
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 iSpare; // Spare
|
||||
float64 dfSwitchInDist; // Switch in distance
|
||||
float64 dfSwitchOutDist;// Switch out distance
|
||||
int16 iSpecialId_1; // Special effects ID 1 - defined by real time
|
||||
int16 iSpecialId_2; // Special effects ID 2 - defined by real time
|
||||
int32 diFlags; // Flags (bits, from left to right)
|
||||
// 0 = Use previous slant range
|
||||
// 1 = SPT flag: 0 if replacement LOD, 1 for additive LOD
|
||||
// 2 = Freeze center (don't recalculate)
|
||||
// 3-31 Spare
|
||||
float64x3 Center; // Center coordinate (x,y,z) of LOD block
|
||||
float64 dfTransitionRange; // Transition Range for Morphing
|
||||
float64 dfSignificantSize; // Multigen-Paradigm-internal for 15.8
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LodRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
LodRecord();
|
||||
|
||||
virtual Record* clone() const { return new LodRecord(); }
|
||||
virtual const char* className() const { return "LodRecord"; }
|
||||
virtual int classOpcode() const { return LOD_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SLevelOfDetail); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SLevelOfDetail* getData() const { return (SLevelOfDetail*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
protected:
|
||||
virtual ~LodRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldLodRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SOldLOD
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
uint32 dwSwitchInDist; // Switch in distance
|
||||
uint32 dwSwitchOutDist; // Switch out distance
|
||||
int16 iSpecialId_1; // Special effects ID 1 - defined by real time
|
||||
int16 iSpecialId_2; // Special effects ID 2 - defined by real time
|
||||
int32 diFlags; // Flags (bits, from left to right)
|
||||
// 0 = Use previous slant range
|
||||
// 1 = SPT flag: 0 if replacement LOD, 1 for additive LOD
|
||||
// 2 = Freeze center (don't recalculate)
|
||||
// 3-31 Spare
|
||||
int32 Center[3]; // Center coordinate (x,y,z) of LOD block
|
||||
// int32 spare[14];
|
||||
};
|
||||
|
||||
|
||||
|
||||
class OldLodRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
OldLodRecord();
|
||||
|
||||
virtual Record* clone() const { return new OldLodRecord(); }
|
||||
virtual const char* className() const { return "OldLodRecord"; }
|
||||
virtual int classOpcode() const { return OLD_LOD_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldLOD); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SOldLOD* getData() const { return (SOldLOD*)_pData; }
|
||||
// virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
protected:
|
||||
virtual ~OldLodRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// LongIDRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LongIDRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
RegisterRecordProxy<LongIDRecord> g_LongIDProxy;
|
||||
|
||||
LongIDRecord::LongIDRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LongIDRecord::~LongIDRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LongIDRecord::endian()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// LongIDRecord.h
|
||||
|
||||
#ifndef __FLT_LONG_ID_RECORD_H
|
||||
#define __FLT_LONG_ID_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SLongID
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[1]; // (Length - 4) ASCII ID of node
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LongIDRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LongIDRecord();
|
||||
|
||||
virtual Record* clone() const { return new LongIDRecord(); }
|
||||
virtual const char* className() const { return "LongIDRecord"; }
|
||||
virtual int classOpcode() const { return LONG_ID_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LongIDRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// MaterialPaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "MaterialPaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MaterialPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MaterialPaletteRecord> g_MaterialPaletteProxy;
|
||||
|
||||
MaterialPaletteRecord::MaterialPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MaterialPaletteRecord::~MaterialPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void MaterialPaletteRecord::endian()
|
||||
{
|
||||
SMaterial *pSMaterial = (SMaterial*)getData();
|
||||
|
||||
ENDIAN( pSMaterial->diIndex );
|
||||
ENDIAN( pSMaterial->diFlags );
|
||||
pSMaterial->Ambient.endian();
|
||||
pSMaterial->Diffuse.endian();
|
||||
pSMaterial->Specular.endian();
|
||||
pSMaterial->Emissive.endian();
|
||||
ENDIAN( pSMaterial->sfShininess );
|
||||
ENDIAN( pSMaterial->sfAlpha );
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// MaterialPaletteRecord.h
|
||||
|
||||
#ifndef __FLT_MATERIAL_PALETTE_RECORD_H
|
||||
#define __FLT_MATERIAL_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SMaterial
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diIndex;
|
||||
char szName[12];
|
||||
uint32 diFlags; // bit 0 Materials used
|
||||
// bit 1-31 Spare
|
||||
float32x3 Ambient; // Ambient component of material
|
||||
float32x3 Diffuse; // Diffuse component of material
|
||||
float32x3 Specular; // Specular component of material
|
||||
float32x3 Emissive; // Emissive component of material
|
||||
float32 sfShininess; // Shininess. [0.0-128.0]
|
||||
float32 sfAlpha; // Alpha. [0.0-1.0], where 1.0 is opaque
|
||||
int32 diSpare;
|
||||
};
|
||||
|
||||
|
||||
class MaterialPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
MaterialPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new MaterialPaletteRecord(); }
|
||||
virtual const char* className() const { return "MaterialPaletteRecord"; }
|
||||
virtual int classOpcode() const { return MATERIAL_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SMaterial); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~MaterialPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
// virtual void decode();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
// MeshPrimitiveRecords.cpp
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4786) // Truncated debug names.
|
||||
#endif
|
||||
|
||||
#include "MeshPrimitiveRecord.h"
|
||||
#include "Registry.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MeshPrimitiveRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MeshPrimitiveRecord> g_MeshPrimitiveProxy;
|
||||
|
||||
MeshPrimitiveRecord::MeshPrimitiveRecord() : PrimNodeRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MeshPrimitiveRecord::~MeshPrimitiveRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return the address of the beginning of the vertex indices.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char *MeshPrimitiveRecord::_getStartOfVertexIndices() const
|
||||
{
|
||||
SMeshPrimitive *mesh = this->getData();
|
||||
char *index = (char *) (&(mesh[1]));
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Get the index into the local vertex pool for the given i'th vertex of
|
||||
// this mesh primitive.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool MeshPrimitiveRecord::getVertexIndex ( const uint32 &whichVertex, uint32 &index ) const
|
||||
{
|
||||
assert ( whichVertex < this->getNumVertices() );
|
||||
|
||||
// Get pointer to start of vertex indices.
|
||||
char *start = (char *) this->_getStartOfVertexIndices();
|
||||
|
||||
// Need a pointer to the mesh structure.
|
||||
SMeshPrimitive *mesh = this->getData();
|
||||
|
||||
// Move the pointer to the beginning of the requested vertex index. We are
|
||||
// treating the array of indices as an array of chars (8 bits) so we have to
|
||||
// multiply times the correct elements size (mesh->indexSize) to get the
|
||||
// correct index.
|
||||
uint32 adjust = whichVertex * ((uint32) mesh->indexSize);
|
||||
start = &start[adjust];
|
||||
|
||||
// The index "adjust" that we just calculated should not walk off the end.
|
||||
assert ( adjust <= mesh->indexSize * mesh->numVerts );
|
||||
|
||||
// Interpret the address "start" correctly...
|
||||
switch ( mesh->indexSize )
|
||||
{
|
||||
case sizeof ( uint32 ): index = *((uint32 *) start); break; // No cast required.
|
||||
case sizeof ( uint16 ): index = (uint32) (*((uint16 *) start)); break;
|
||||
case sizeof ( uint8 ): index = (uint32) (*((uint8 *) start)); break;
|
||||
default:
|
||||
|
||||
assert ( 0 ); // Invalid index size (according to 15.7.0 specs).
|
||||
return false;
|
||||
}
|
||||
|
||||
// It worked.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Convert the data from big-endian to little-endian.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MeshPrimitiveRecord::endian()
|
||||
{
|
||||
// Should only be in here for little-endian machines.
|
||||
assert ( flt::isLittleEndianMachine() );
|
||||
|
||||
SMeshPrimitive *mesh = this->getData();
|
||||
ENDIAN ( mesh->primitiveType );
|
||||
ENDIAN ( mesh->indexSize );
|
||||
ENDIAN ( mesh->numVerts );
|
||||
|
||||
// Get pointer to start of vertex indices.
|
||||
char *index = this->_getStartOfVertexIndices();
|
||||
|
||||
// Determine the size of the elements in the array of vertex indices.
|
||||
switch ( mesh->indexSize )
|
||||
{
|
||||
case sizeof ( uint32 ): // 32 bits.
|
||||
|
||||
// Perform byte-swap on all the elements in the array.
|
||||
flt::swapBytesArray ( sizeof ( uint32 ), mesh->numVerts, (uint32 *) index );
|
||||
break;
|
||||
|
||||
case sizeof ( uint16 ): // 16 bits.
|
||||
|
||||
// Perform byte-swap on all the elements in the array.
|
||||
flt::swapBytesArray ( sizeof ( uint16 ), mesh->numVerts, (uint16 *) index );
|
||||
break;
|
||||
|
||||
case sizeof ( uint8 ): // 8 bits.
|
||||
|
||||
// We don't have to swap bytes because there is only one byte.
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
assert ( 0 ); // Invalid index size (according to 15.7.0 specs).
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Sanity check. The address immediately following the last element,
|
||||
// minus the start of this record, should be the size of this record.
|
||||
char *offEndC = &(index[mesh->numVerts * mesh->indexSize]);
|
||||
uint32 offEndI = (uint32) offEndC;
|
||||
uint32 indexI = (uint32) mesh;
|
||||
uint32 diff32 = ( offEndI ) - ( indexI );
|
||||
uint16 diff16 = (uint16) ( diff32 );
|
||||
assert ( mesh->RecHeader._wLength == diff16 );
|
||||
#endif
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// MeshPrimitiveRecord.h
|
||||
|
||||
#ifndef __FLT_MESH_PRIMITIVE_RECORDS_H
|
||||
#define __FLT_MESH_PRIMITIVE_RECORDS_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MeshPrimitiveRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SMeshPrimitive
|
||||
{
|
||||
SRecHeader RecHeader; // Header (opcode and size)
|
||||
uint16 primitiveType; // Primitive Type - can be one of the following values:
|
||||
// 1 - Triangle Strip
|
||||
// 2 - Triangle Fan
|
||||
// 3 - Quadrilateral Strip
|
||||
// 4 - Indexed Polygon
|
||||
// Note: This field specifies how the vertices of the primitive are interpreted.
|
||||
uint16 indexSize; // Specifies the length (in bytes) of each of the vertex indices that follow - will be 1, 2, or 4
|
||||
uint32 numVerts; // Number of vertices contained in this primitive
|
||||
};
|
||||
|
||||
|
||||
class MeshPrimitiveRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum PrimitiveType
|
||||
{
|
||||
TRIANGLE_STRIP = 1,
|
||||
TRIANGLE_FAN = 2,
|
||||
QUADRILATERAL_STRIP = 3,
|
||||
INDEXED_POLYGON = 4
|
||||
};
|
||||
|
||||
MeshPrimitiveRecord();
|
||||
|
||||
virtual void accept ( RecordVisitor &rv ) { rv.apply ( *this ); }
|
||||
|
||||
virtual const char * className() const { return "MeshPrimitiveRecord"; }
|
||||
virtual int classOpcode() const { return MESH_PRIMITIVE_OP; }
|
||||
virtual Record * clone() const { return new MeshPrimitiveRecord(); }
|
||||
|
||||
virtual SMeshPrimitive* getData() const { return (SMeshPrimitive *) _pData; }
|
||||
uint32 getNumVertices() const { return this->getData()->numVerts; }
|
||||
bool getVertexIndex ( const uint32 &whichVertex, uint32 &index ) const;
|
||||
|
||||
virtual size_t sizeofData() const { return sizeof ( SMeshPrimitive ); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~MeshPrimitiveRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
char * _getStartOfVertexIndices() const;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif // __FLT_MESH_PRIMITIVE_RECORDS_H
|
||||
@@ -1,58 +0,0 @@
|
||||
// MeshRecord.cpp
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4786) // Truncated debug names.
|
||||
#endif
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "MeshRecord.h"
|
||||
#include "Input.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MeshRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MeshRecord> g_MeshProxy;
|
||||
|
||||
MeshRecord::MeshRecord() : FaceRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MeshRecord::~MeshRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void MeshRecord::endian()
|
||||
{
|
||||
// Should only be in here for little-endian machines.
|
||||
assert ( flt::isLittleEndianMachine() );
|
||||
|
||||
// Call the base class's function.
|
||||
// Note 1: We can do this because all the data members are the same.
|
||||
// Note 2: FaceRecord::endian() checks for file version. This is
|
||||
// unnecessary for a MeshRecord because it is new with 15.7. Therefore it
|
||||
// could be optimized here, but doing this shouldn't slow us down too much.
|
||||
FaceRecord::endian();
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
bool MeshRecord::readLocalData ( Input &fr )
|
||||
{
|
||||
// Bypass FaceRecord's readLocalData() because it doesn't look for the
|
||||
// correct kind of records. Instead, we call PrimNodeRecord's readLocalData()
|
||||
// which looks for Ancillary Record's (we should at least find a
|
||||
// LocalVertexPoolRecord), and then reads from a PushLevelRecord to a
|
||||
// PopLevelRecord. Inside the push-pop pair we should have at least one
|
||||
// MeshPrimitiveRecord.
|
||||
return PrimNodeRecord::readLocalData ( fr );
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// MeshRecord.h
|
||||
|
||||
#ifndef __FLT_MESH_RECORD_H
|
||||
#define __FLT_MESH_RECORD_H
|
||||
|
||||
|
||||
#include "FaceRecord.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MeshRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Note: the enums for FaceRecord are the same for MeshRecord, so we inherit
|
||||
// and overload where necessary. I was sort of on the fence with this decision,
|
||||
// because a MeshRecord isn't really a more specific case of a FaceRecord s
|
||||
// (which single inheritance typically implies). However, there is too much in
|
||||
// FaceRecord that is identical to not take advantage of. This can be changed
|
||||
// later if the two records diverge, or if it proved to be a bad idea.
|
||||
|
||||
class MeshRecord : public FaceRecord
|
||||
{
|
||||
public:
|
||||
|
||||
MeshRecord();
|
||||
|
||||
virtual void accept ( RecordVisitor &rv ) { rv.apply ( *this ); }
|
||||
|
||||
virtual const char * className() const { return "MeshRecord"; }
|
||||
virtual int classOpcode() const { return MESH_OP; }
|
||||
virtual Record * clone() const { return new MeshRecord(); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~MeshRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
virtual bool readLocalData ( Input &fr );
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif // __FLT_MESH_RECORD_H
|
||||
@@ -1,35 +0,0 @@
|
||||
// MultiTextureRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "MultiTextureRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MultiTextureRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MultiTextureRecord> g_MultiTextureProxy;
|
||||
|
||||
MultiTextureRecord::MultiTextureRecord()
|
||||
{
|
||||
CERR << "MultiTextureRecord created\n";
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MultiTextureRecord::~MultiTextureRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void MultiTextureRecord::endian()
|
||||
{
|
||||
SMultiTexture *pSMultiTexture = (SMultiTexture*)getData();
|
||||
|
||||
ENDIAN( pSMultiTexture->layers );
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// MultiTextureRecord.h
|
||||
|
||||
#ifndef __FLT_MULTI_TEXTURE_RECORD_H
|
||||
#define __FLT_MULTI TEXTURE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct STextureLayer {
|
||||
uint16 texture;
|
||||
uint16 effect;
|
||||
uint16 mapping;
|
||||
uint16 data;
|
||||
void endian() {
|
||||
ENDIAN( texture );
|
||||
ENDIAN( effect );
|
||||
ENDIAN( mapping );
|
||||
ENDIAN( data );
|
||||
};
|
||||
};
|
||||
|
||||
struct SMultiTexture
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint32 layers;
|
||||
|
||||
STextureLayer data[1];
|
||||
};
|
||||
|
||||
class MultiTextureRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
MultiTextureRecord();
|
||||
|
||||
virtual Record* clone() const { return new MultiTextureRecord(); }
|
||||
virtual const char* className() const { return "MultiTextureRecord"; }
|
||||
virtual int classOpcode() const { return MULTI_TEXTURE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SMultiTexture); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~MultiTextureRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// ObjectRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "ObjectRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ObjectRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<ObjectRecord> g_fltObjectProxy;
|
||||
|
||||
ObjectRecord::ObjectRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
ObjectRecord::~ObjectRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ObjectRecord::endian()
|
||||
{
|
||||
SObject *pSObject = (SObject*)getData();
|
||||
|
||||
ENDIAN( pSObject->dwFlags );
|
||||
ENDIAN( pSObject->iObjectRelPriority );
|
||||
ENDIAN( pSObject->wTransparency );
|
||||
ENDIAN( pSObject->iSpecialId_1 );
|
||||
ENDIAN( pSObject->iSpecialId_2 );
|
||||
ENDIAN( pSObject->iSignificance );
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// ObjectRecord.h
|
||||
|
||||
#ifndef __FLT_OBJECT_RECORD_H
|
||||
#define __FLT_OBJECT_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SObject
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
uint32 dwFlags; // Flags (bits from to right)
|
||||
// 0 = Don't display in daylight
|
||||
// 1 = Don't display at dusk
|
||||
// 2 = Don't display at night
|
||||
// 3 = Don't illuminate
|
||||
// 4 = Flat shaded
|
||||
// 5 = Group's shadow object
|
||||
// 6-31 Spare
|
||||
int16 iObjectRelPriority; // Object relative priority
|
||||
uint16 wTransparency; // Transparency factor
|
||||
// = 0 opaque
|
||||
// = 65535 for totally clear
|
||||
int16 iSpecialId_1; // Special effects ID 1 - defined by real time
|
||||
int16 iSpecialId_2; // Special effects ID 2 - defined by real time
|
||||
int16 iSignificance; // Significance
|
||||
int16 iSpare; // Spare
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ObjectRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
ObjectRecord();
|
||||
|
||||
virtual Record* clone() const { return new ObjectRecord(); }
|
||||
virtual const char* className() const { return "ObjectRecord"; }
|
||||
virtual int classOpcode() const { return OBJECT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SObject* getData() const { return (SObject*)_pData; }
|
||||
virtual const std::string getName( void ) const { return std::string(getData()->szIdent); }
|
||||
|
||||
protected:
|
||||
virtual ~ObjectRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
// OldMaterialPaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "OldMaterialPaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldMaterialPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<OldMaterialPaletteRecord> g_OldMaterialPaletteProxy;
|
||||
|
||||
OldMaterialPaletteRecord::OldMaterialPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
OldMaterialPaletteRecord::~OldMaterialPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void OldMaterialPaletteRecord::endian()
|
||||
{
|
||||
SOldMaterial *pSMaterial = (SOldMaterial*)getData();
|
||||
|
||||
for (int i=0; i < 64; i++)
|
||||
{
|
||||
pSMaterial->mat[i].Ambient.endian();
|
||||
pSMaterial->mat[i].Diffuse.endian();
|
||||
pSMaterial->mat[i].Specular.endian();
|
||||
pSMaterial->mat[i].Emissive.endian();
|
||||
ENDIAN( pSMaterial->mat[i].sfShininess );
|
||||
ENDIAN( pSMaterial->mat[i].sfAlpha );
|
||||
ENDIAN( pSMaterial->mat[i].diFlags );
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// OldMaterialPaletteRecord.h
|
||||
|
||||
#ifndef __FLT_OLD_MATERIAL_PALETTE_RECORD_H
|
||||
#define __FLT_OLD_MATERIAL_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SOldMaterial
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
struct
|
||||
{
|
||||
float32x3 Ambient; // Ambient component of material
|
||||
float32x3 Diffuse; // Diffuse component of material
|
||||
float32x3 Specular; // Specular component of material
|
||||
float32x3 Emissive; // Emissive component of material
|
||||
float32 sfShininess; // Shininess. [0.0-128.0]
|
||||
float32 sfAlpha; // Alpha. [0.0-1.0], where 1.0 is opaque
|
||||
uint32 diFlags; // bit 0 Materials used
|
||||
// bit 1-31 Spare
|
||||
uint32 spares[31]; // Spares for material
|
||||
} mat[64];
|
||||
};
|
||||
|
||||
|
||||
class OldMaterialPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
OldMaterialPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new OldMaterialPaletteRecord(); }
|
||||
virtual const char* className() const { return "OldMaterialPaletteRecord"; }
|
||||
virtual int classOpcode() const { return OLD_MATERIAL_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldMaterial); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~OldMaterialPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
// virtual void decode();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,157 +0,0 @@
|
||||
// OldVertexRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "OldVertexRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<OldVertexRecord> g_OldVertexProxy;
|
||||
|
||||
OldVertexRecord::OldVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
OldVertexRecord::~OldVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void OldVertexRecord::endian()
|
||||
{
|
||||
SOldVertex *pVertex = (SOldVertex*)getData();
|
||||
|
||||
ENDIAN( pVertex->v[0] );
|
||||
ENDIAN( pVertex->v[1] );
|
||||
ENDIAN( pVertex->v[2] );
|
||||
if (getSize() >= sizeofData())
|
||||
pVertex->t.endian();
|
||||
}
|
||||
|
||||
// virtual
|
||||
bool OldVertexRecord::readLocalData(Input&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
ostream& operator << (ostream& output, const OldVertexRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexColorRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<OldVertexColorRecord> g_OldVertexColorProxy;
|
||||
|
||||
OldVertexColorRecord::OldVertexColorRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
OldVertexColorRecord::~OldVertexColorRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void OldVertexColorRecord::endian()
|
||||
{
|
||||
SOldVertexColor *pVertex = (SOldVertexColor*)getData();
|
||||
|
||||
ENDIAN( pVertex->v[0] );
|
||||
ENDIAN( pVertex->v[1] );
|
||||
ENDIAN( pVertex->v[2] );
|
||||
ENDIAN( pVertex->color_index );
|
||||
if (getSize() >= sizeofData())
|
||||
pVertex->t.endian();
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
bool OldVertexColorRecord::readLocalData(Input&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ostream& operator << (ostream& output, const OldVertexColorRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexColorNormalRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<OldVertexColorNormalRecord> g_OldVertexColorNormalProxy;
|
||||
|
||||
OldVertexColorNormalRecord::OldVertexColorNormalRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
OldVertexColorNormalRecord::~OldVertexColorNormalRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void OldVertexColorNormalRecord::endian()
|
||||
{
|
||||
SOldVertexColorNormal *pVertex = (SOldVertexColorNormal*)getData();
|
||||
|
||||
ENDIAN( pVertex->v[0] );
|
||||
ENDIAN( pVertex->v[1] );
|
||||
ENDIAN( pVertex->v[2] );
|
||||
ENDIAN( pVertex->color_index );
|
||||
ENDIAN( pVertex->n[0] );
|
||||
ENDIAN( pVertex->n[1] );
|
||||
ENDIAN( pVertex->n[2] );
|
||||
if (getSize() >= sizeofData())
|
||||
pVertex->t.endian();
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
bool OldVertexColorNormalRecord::readLocalData(Input&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ostream& operator << (ostream& output, const OldVertexColorNormalRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
*/
|
||||
@@ -1,138 +0,0 @@
|
||||
// OldVertexRecords.h
|
||||
|
||||
#ifndef __FLT_OLD_VERTEX_RECORDS_H
|
||||
#define __FLT_OLD_VERTEX_RECORDS_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SOldVertex
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 v[3];
|
||||
float32x2 t; // optional texture u,v
|
||||
// check record size.
|
||||
};
|
||||
|
||||
|
||||
class OldVertexRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
OldVertexRecord();
|
||||
virtual Record* clone() const { return new OldVertexRecord(); }
|
||||
virtual const char* className() const { return "OldVertexRecord"; }
|
||||
virtual int classOpcode() const { return OLD_VERTEX_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldVertex); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SOldVertex* getData() const { return (SOldVertex*)_pData; }
|
||||
// friend std::ostream& operator << (std::ostream& output, const OldVertexRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~OldVertexRecord();
|
||||
|
||||
virtual void endian();
|
||||
virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexColorRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SOldVertexColor
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 v[3];
|
||||
uint8 edge_flag; // Hard edge flag
|
||||
uint8 shading_flag; // Don<6F>t touch normal when shading flag.
|
||||
uint16 color_index; // Vertex color.
|
||||
float32x2 t; // optional texture u,v
|
||||
// check record size.
|
||||
};
|
||||
|
||||
|
||||
class OldVertexColorRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
OldVertexColorRecord();
|
||||
virtual Record* clone() const { return new OldVertexColorRecord(); }
|
||||
virtual const char* className() const { return "OldVertexColorRecord"; }
|
||||
virtual int classOpcode() const { return OLD_VERTEX_COLOR_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldVertexColor); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SOldVertexColor* getData() const { return (SOldVertexColor*)_pData; }
|
||||
// friend std::ostream& operator << (std::ostream& output, const OldVertexColorRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~OldVertexColorRecord();
|
||||
|
||||
virtual void endian();
|
||||
virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldVertexColorNormalRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SOldVertexColorNormal
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 v[3];
|
||||
uint8 edge_flag; // Hard edge flag
|
||||
uint8 shading_flag; // Don<6F>t touch normal when shading flag.
|
||||
uint16 color_index; // Vertex color.
|
||||
int32 n[3]; // Normal scaled 2**30
|
||||
float32x2 t; // optional texture u,v
|
||||
// check record size.
|
||||
};
|
||||
|
||||
|
||||
class OldVertexColorNormalRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
OldVertexColorNormalRecord();
|
||||
virtual Record* clone() const { return new OldVertexColorNormalRecord(); }
|
||||
virtual const char* className() const { return "OldVertexColorNormalRecord"; }
|
||||
virtual int classOpcode() const { return OLD_VERTEX_COLOR_NORMAL_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldVertexColorNormal); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SOldVertexColorNormal* getData() const { return (SOldVertexColorNormal*)_pData; }
|
||||
// friend std::ostream& operator << (std::ostream& output, const OldVertexColorNormalRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~OldVertexColorNormalRecord();
|
||||
|
||||
virtual void endian();
|
||||
virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_VERTEX_POOL_RECORDS_H
|
||||
@@ -1,322 +0,0 @@
|
||||
// Pool.cpp
|
||||
|
||||
// Modify TexturePool to store a flt::AttrData object instead of a osg::StateSet
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
|
||||
#include "MaterialPaletteRecord.h"
|
||||
#include "OldMaterialPaletteRecord.h"
|
||||
#include "Pool.h"
|
||||
#include "Registry.h"
|
||||
#include "AttrData.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
using namespace flt;
|
||||
|
||||
|
||||
osg::Vec4 ColorPool::getColor(int nColorIntensity)
|
||||
{
|
||||
// nColorIntensity:
|
||||
// bit 0-6: intensity
|
||||
// bit 7-15 color index
|
||||
|
||||
osg::Vec4 col(1,1,1,1);
|
||||
|
||||
if (nColorIntensity >= 0)
|
||||
{
|
||||
ColorName* cn = getColorName(nColorIntensity >> 7);
|
||||
if (cn)
|
||||
col = cn->getColor();
|
||||
|
||||
float intensity = (float)(nColorIntensity & 0x7f)/127.f;
|
||||
col[0] *= intensity;
|
||||
col[1] *= intensity;
|
||||
col[2] *= intensity;
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
// getColor for version 11, 12 & 13.
|
||||
osg::Vec4 ColorPool::getOldColor(int nColorIntensity)
|
||||
{
|
||||
// nColorIntensity:
|
||||
// bit 0-6: intensity
|
||||
// bit 7-11 color index
|
||||
// bit 12 fixed intensity bit
|
||||
|
||||
osg::Vec4 col(1,1,1,1);
|
||||
|
||||
if (nColorIntensity >= 0)
|
||||
{
|
||||
int nIndex;
|
||||
bool bFixedIntensity = (nColorIntensity & 0x1000) ? true : false;
|
||||
|
||||
if (bFixedIntensity)
|
||||
nIndex = (nColorIntensity & 0x0fff)+(4096>>7);
|
||||
else
|
||||
nIndex = nColorIntensity >> 7;
|
||||
|
||||
ColorName* cn = getColorName(nIndex);
|
||||
if (cn)
|
||||
col = cn->getColor();
|
||||
|
||||
// intensity
|
||||
if (!bFixedIntensity)
|
||||
{
|
||||
float intensity = (float)(nColorIntensity & 0x7f)/127.f;
|
||||
col[0] *= intensity;
|
||||
col[1] *= intensity;
|
||||
col[2] *= intensity;
|
||||
}
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
void ColorPool::addColor(int nIndex, const osg::Vec4& color)
|
||||
{
|
||||
if (nIndex >= 0)
|
||||
{
|
||||
ColorName* colorname = new ColorName;
|
||||
colorname->setColor(color);
|
||||
|
||||
_colorNameMap[nIndex] = colorname;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ColorPool::ColorName* ColorPool::getColorName(int nIndex)
|
||||
{
|
||||
ColorNameMap::iterator itr = _colorNameMap.find(nIndex);
|
||||
if (itr != _colorNameMap.end())
|
||||
return (*itr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
flt::AttrData* TexturePool::getTexture(int nIndex, osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
TexturePaletteMap::iterator fitr = _textureMap.find(nIndex);
|
||||
if (fitr != _textureMap.end())
|
||||
{
|
||||
return (*fitr).second.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no existing texture state set set up so lets look
|
||||
// for a file name for this nIndex..
|
||||
TextureNameMap::iterator nitr = _textureNameMap.find(nIndex);
|
||||
if (nitr != _textureNameMap.end())
|
||||
{
|
||||
const std::string& textureName = (*nitr).second;
|
||||
flt::AttrData* textureAttrData = 0;
|
||||
|
||||
if(options->getObjectCacheHint() & osgDB::ReaderWriter::Options::CACHE_IMAGES)
|
||||
{
|
||||
|
||||
// Valid index, find the texture
|
||||
// Get AttrData containing texture from registry pool.
|
||||
textureAttrData = Registry::instance()->getTexture(textureName);
|
||||
|
||||
if (textureAttrData)
|
||||
{
|
||||
// Add texture to local pool to be ab121le to get by index.
|
||||
addTexture(nIndex, textureAttrData);
|
||||
return textureAttrData;
|
||||
}
|
||||
}
|
||||
|
||||
CERR<<"setTexture attempting to load ("<<textureName<<")"<<std::endl;
|
||||
|
||||
unsigned int unit = 0;
|
||||
|
||||
// Read texture and attribute file
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(textureName, options ? options : osgDB::Registry::instance()->getOptions());
|
||||
if (image.valid())
|
||||
{
|
||||
std::string attrName(textureName);
|
||||
attrName += ".attr";
|
||||
|
||||
textureAttrData = dynamic_cast<flt::AttrData*>(osgDB::readObjectFile(attrName, options ? options : osgDB::Registry::instance()->getOptions() ));
|
||||
|
||||
// if not found create default StateSet for the AttrData
|
||||
if (textureAttrData == NULL)
|
||||
{
|
||||
textureAttrData = new flt::AttrData;
|
||||
textureAttrData->stateset = new osg::StateSet;
|
||||
|
||||
osg::Texture2D* osgTexture = new osg::Texture2D;
|
||||
osgTexture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
|
||||
osgTexture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
|
||||
textureAttrData->stateset->setTextureAttributeAndModes( unit, osgTexture,osg::StateAttribute::ON);
|
||||
|
||||
osg::TexEnv* osgTexEnv = new osg::TexEnv;
|
||||
osgTexEnv->setMode(osg::TexEnv::MODULATE);
|
||||
textureAttrData->stateset->setTextureAttribute( unit, osgTexEnv );
|
||||
}
|
||||
|
||||
osg::Texture2D *osgTexture = dynamic_cast<osg::Texture2D*>(textureAttrData->stateset->getTextureAttribute( unit, osg::StateAttribute::TEXTURE));
|
||||
if (osgTexture == NULL)
|
||||
{
|
||||
osgTexture = new osg::Texture2D;
|
||||
textureAttrData->stateset->setTextureAttributeAndModes( unit, osgTexture,osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
osgTexture->setImage(image.get());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// invalid image file, register an empty state set AttrData
|
||||
textureAttrData = new flt::AttrData;
|
||||
textureAttrData->stateset = new osg::StateSet;
|
||||
}
|
||||
|
||||
// Add new texture to registry pool
|
||||
// ( umm... should this have reference to the texture unit? RO. July2002)
|
||||
if(options->getObjectCacheHint() & osgDB::ReaderWriter::Options::CACHE_IMAGES)
|
||||
{
|
||||
Registry::instance()->addTexture(textureName, textureAttrData);
|
||||
}
|
||||
|
||||
// Also add to local pool to be able to get texture by index.
|
||||
// ( umm... should this have reference to the texture unit? RO. July2002)
|
||||
addTexture(nIndex, textureAttrData);
|
||||
|
||||
CERR<<"Registry::instance()->addTexture("<<textureName<<", "<<textureAttrData<<")"<<std::endl;
|
||||
CERR<<"pTexturePool->addTexture("<<nIndex<<", "<<textureAttrData<<")"<<std::endl;
|
||||
|
||||
return textureAttrData;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string* TexturePool::getTextureName(int nIndex)
|
||||
{
|
||||
TextureNameMap::iterator fitr = _textureNameMap.find(nIndex);
|
||||
if (fitr != _textureNameMap.end())
|
||||
return &(*fitr).second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void TexturePool::addTexture(int nIndex, flt::AttrData* attrdata)
|
||||
{
|
||||
_textureMap[nIndex] = attrdata;
|
||||
}
|
||||
|
||||
void TexturePool::addTextureName(int nIndex, const std::string& name)
|
||||
{
|
||||
_textureNameMap[nIndex] = name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
osg::Light* LightPool::getLight(int nIndex)
|
||||
{
|
||||
if (nIndex < 0) return NULL;
|
||||
LightPaletteMap::iterator fitr = _lightMap.find(nIndex);
|
||||
if (fitr != _lightMap.end())
|
||||
return (*fitr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void LightPool::addLight(int nIndex, osg::Light* light)
|
||||
{
|
||||
_lightMap[nIndex] = light;
|
||||
}
|
||||
|
||||
MaterialPool::PoolMaterial* MaterialPool::getMaterial(int nIndex)
|
||||
{
|
||||
if (nIndex < 0) return NULL;
|
||||
MaterialMap::iterator fitr = _MaterialMap.find(nIndex);
|
||||
if (fitr != _MaterialMap.end())
|
||||
return (*fitr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void MaterialPool::addMaterial(int nIndex, PoolMaterial* material)
|
||||
{
|
||||
_MaterialMap[nIndex] = material;
|
||||
}
|
||||
|
||||
osg::Group* InstancePool::getInstance(int nIndex)
|
||||
{
|
||||
InstanceMap::iterator fitr = _instanceMap.find(nIndex);
|
||||
if (fitr != _instanceMap.end())
|
||||
return (*fitr).second.get();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void InstancePool::addInstance(int nIndex, osg::Group* instance)
|
||||
{
|
||||
_instanceMap[nIndex] = instance;
|
||||
}
|
||||
|
||||
|
||||
LtPtAppearancePool::PoolLtPtAppearance* LtPtAppearancePool::get(int nIndex)
|
||||
{
|
||||
if (nIndex < 0)
|
||||
return NULL;
|
||||
|
||||
AppearanceMap::iterator fitr = _appearanceMap.find(nIndex);
|
||||
if (fitr != _appearanceMap.end())
|
||||
return (*fitr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void LtPtAppearancePool::add(int nIndex, PoolLtPtAppearance* appearance)
|
||||
{
|
||||
_appearanceMap[nIndex] = appearance;
|
||||
}
|
||||
|
||||
|
||||
LtPtAnimationPool::PoolLtPtAnimation*
|
||||
LtPtAnimationPool::get( int nIndex )
|
||||
{
|
||||
if (nIndex < 0)
|
||||
return NULL;
|
||||
|
||||
AnimationMap::iterator fitr = _animationMap.find(nIndex);
|
||||
if (fitr != _animationMap.end())
|
||||
return (*fitr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LtPtAnimationPool::add(int nIndex, PoolLtPtAnimation* anim)
|
||||
{
|
||||
_animationMap[nIndex] = anim;
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
#ifndef __FLT_POOL_H
|
||||
#define __FLT_POOL_H
|
||||
|
||||
// Modify TexturePool to store a flt::AttrData object instead of a osg::StateSet
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
#include "flt.h"
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Material>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Light>
|
||||
#include <osg/Group>
|
||||
#include <osgSim/BlinkSequence>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include "AttrData.h"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
class ColorPool : public osg::Referenced
|
||||
{
|
||||
public :
|
||||
|
||||
ColorPool() {}
|
||||
|
||||
osg::Vec4 getColor(int nColorIntensity);
|
||||
osg::Vec4 getOldColor(int nColorIntensity);
|
||||
void addColor(int nIndex, const osg::Vec4& color);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~ColorPool() {}
|
||||
|
||||
private :
|
||||
|
||||
class ColorName : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
void setName( const std::string& name ) { _name = name; }
|
||||
const std::string& getName( void ) { return _name; }
|
||||
void setColor(const osg::Vec4& color ) { _color = color; }
|
||||
osg::Vec4 getColor() { return _color; }
|
||||
|
||||
private:
|
||||
osg::Vec4 _color;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
ColorName* getColorName(int nIndex);
|
||||
|
||||
typedef std::map<int,osg::ref_ptr<ColorName> > ColorNameMap;
|
||||
ColorNameMap _colorNameMap;
|
||||
};
|
||||
|
||||
|
||||
class TexturePool : public osg::Referenced
|
||||
{
|
||||
public :
|
||||
|
||||
TexturePool() {}
|
||||
|
||||
flt::AttrData* getTexture(int nIndex, osgDB::ReaderWriter::Options* options);
|
||||
std::string* getTextureName(int nIndex);
|
||||
void addTexture(int nIndex, flt::AttrData* attrdata);
|
||||
void addTextureName(int nIndex, const std::string& name);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~TexturePool() {}
|
||||
|
||||
private :
|
||||
|
||||
typedef std::map<int,osg::ref_ptr<flt::AttrData> > TexturePaletteMap;
|
||||
TexturePaletteMap _textureMap;
|
||||
typedef std::map<int,std::string > TextureNameMap;
|
||||
TextureNameMap _textureNameMap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LightPool : public osg::Referenced
|
||||
{
|
||||
public :
|
||||
|
||||
LightPool() {}
|
||||
|
||||
osg::Light* getLight(int nIndex );
|
||||
void addLight(int nIndex, osg::Light* light);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~LightPool() {}
|
||||
|
||||
private :
|
||||
|
||||
typedef std::map<int,osg::ref_ptr<osg::Light> > LightPaletteMap;
|
||||
LightPaletteMap _lightMap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MaterialPool : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
struct PoolMaterial : public osg::Referenced
|
||||
{
|
||||
float32x3 Ambient; // Ambient component of material
|
||||
float32x3 Diffuse; // Diffuse component of material
|
||||
float32x3 Specular; // Specular component of material
|
||||
float32x3 Emissive; // Emissive component of material
|
||||
float32 sfShininess; // Shininess. [0.0-128.0]
|
||||
float32 sfAlpha; // Alpha. [0.0-1.0], where 1.0 is opaque
|
||||
};
|
||||
|
||||
MaterialPool() {}
|
||||
|
||||
PoolMaterial* getMaterial(int nIndex);
|
||||
void addMaterial(int nIndex, PoolMaterial* material);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~MaterialPool() {}
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<int, osg::ref_ptr<PoolMaterial> > MaterialMap;
|
||||
MaterialMap _MaterialMap;
|
||||
};
|
||||
|
||||
|
||||
class InstancePool : public osg::Referenced
|
||||
{
|
||||
public :
|
||||
|
||||
InstancePool() {}
|
||||
|
||||
osg::Group* getInstance(int nIndex);
|
||||
void addInstance(int nIndex, osg::Group* instance);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~InstancePool() {}
|
||||
|
||||
private :
|
||||
|
||||
typedef std::map<int,osg::ref_ptr<osg::Group> > InstanceMap;
|
||||
InstanceMap _instanceMap;
|
||||
};
|
||||
|
||||
|
||||
class LtPtAppearancePool : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
struct PoolLtPtAppearance : public osg::Referenced
|
||||
{
|
||||
unsigned int _iBackColorIdx;
|
||||
float _bIntensity;
|
||||
float _sfMinPixelSize;
|
||||
float _sfMaxPixelSize;
|
||||
float _sfActualSize;
|
||||
int _iDirectionality;
|
||||
float _sfHLobeAngle;
|
||||
float _sfVLobeAngle;
|
||||
float _sfLobeRollAngle;
|
||||
};
|
||||
|
||||
LtPtAppearancePool()
|
||||
{}
|
||||
|
||||
PoolLtPtAppearance* get(int nIndex);
|
||||
void add(int nIndex, PoolLtPtAppearance* appearance);
|
||||
|
||||
protected:
|
||||
~LtPtAppearancePool() {}
|
||||
|
||||
private:
|
||||
typedef std::map<int, osg::ref_ptr<PoolLtPtAppearance> > AppearanceMap;
|
||||
AppearanceMap _appearanceMap;
|
||||
};
|
||||
|
||||
class LtPtAnimationPool : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
struct PoolLtPtAnimation : public osg::Referenced
|
||||
{
|
||||
std::string _name;
|
||||
osg::ref_ptr<osgSim::BlinkSequence> _blink;
|
||||
};
|
||||
|
||||
LtPtAnimationPool()
|
||||
{}
|
||||
|
||||
PoolLtPtAnimation* get( int nIndex );
|
||||
void add( int nIndex, PoolLtPtAnimation* anim );
|
||||
|
||||
protected:
|
||||
~LtPtAnimationPool() {}
|
||||
|
||||
private:
|
||||
typedef std::map<int, osg::ref_ptr<PoolLtPtAnimation> > AnimationMap;
|
||||
AnimationMap _animationMap;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,806 +0,0 @@
|
||||
|
||||
//
|
||||
// OpenFlight<68> texture attribute loader for Open Scene Graph
|
||||
//
|
||||
// Copyright (C) 2001 Brede Johansen
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
// The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for
|
||||
// real-time rendering of large 3D photo-realistic models.
|
||||
// The OSG homepage is http://www.openscenegraph.org/
|
||||
//
|
||||
// MultiGen, OpenFlight, and Flight Format are registered trademarks of MultiGen Inc.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <osg/Notify>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/GL>
|
||||
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/Registry>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "AttrData.h"
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef signed int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
|
||||
#define READ(DST) readField(file, (void*)&(DST), sizeof(DST))
|
||||
|
||||
|
||||
static int isLittleEndianMachine()
|
||||
{
|
||||
int a = 1;
|
||||
return (int)(*(char*)&a);
|
||||
}
|
||||
|
||||
|
||||
static void endian2(void* pSrc, int nSrc, void* pDst)
|
||||
{
|
||||
if (nSrc == 2)
|
||||
{
|
||||
short tmp1;
|
||||
tmp1 = *(short *)pSrc;
|
||||
tmp1 = (tmp1 << 8) | ((tmp1 >> 8) & 0xff);
|
||||
*(short *)pDst = tmp1;
|
||||
}
|
||||
else if (nSrc == 4)
|
||||
{
|
||||
uint32 tmp1;
|
||||
tmp1 = *(uint32 *)pSrc;
|
||||
tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
|
||||
*(uint32 *)pDst = tmp1;
|
||||
}
|
||||
else if (nSrc == 8)
|
||||
{
|
||||
uint32 tmp1, tmp2;
|
||||
tmp1 = *(uint32 *)pSrc;
|
||||
tmp2 = *(1 + (uint32 *)pSrc);
|
||||
tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
|
||||
tmp2 = (tmp2 << 24) | ((tmp2 << 8) & 0xff0000) | ((tmp2 >> 8) & 0xff00) | ((tmp2 >> 24) & 0xff);
|
||||
*(uint32 *)pDst = tmp2;
|
||||
*(1 + (uint32 *)pDst) = tmp1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using namespace osg;
|
||||
|
||||
class Attr
|
||||
{
|
||||
public :
|
||||
|
||||
enum MinFilterMode {
|
||||
MIN_FILTER_POINT = 0,
|
||||
MIN_FILTER_BILINEAR = 1,
|
||||
MIN_FILTER_MIPMAP = 2, // (Obsolete)
|
||||
MIN_FILTER_MIPMAP_POINT = 3,
|
||||
MIN_FILTER_MIPMAP_LINEAR = 4,
|
||||
MIN_FILTER_MIPMAP_BILINEAR = 5,
|
||||
MIN_FILTER_MIPMAP_TRILINEAR = 6,
|
||||
MIN_FILTER_NONE = 7,
|
||||
MIN_FILTER_BICUBIC = 8,
|
||||
MIN_FILTER_BILINEAR_GEQUAL = 9,
|
||||
MIN_FILTER_BILINEAR_LEQUAL = 10,
|
||||
MIN_FILTER_BICUBIC_GEQUAL = 11,
|
||||
MIN_FILTER_BICUBIC_LEQUAL = 12
|
||||
};
|
||||
|
||||
enum MagFilterMode {
|
||||
MAG_FILTER_POINT = 0,
|
||||
MAG_FILTER_BILINEAR = 1,
|
||||
MAG_FILTER_NONE = 2,
|
||||
MAG_FILTER_BICUBIC = 3,
|
||||
MAG_FILTER_SHARPEN = 4,
|
||||
MAG_FILTER_ADD_DETAIL = 5,
|
||||
MAG_FILTER_MODULATE_DETAIL = 6,
|
||||
MAG_FILTER_BILINEAR_GEQUAL = 7,
|
||||
MAG_FILTER_BILINEAR_LEQUAL = 8,
|
||||
MAG_FILTER_BICUBIC_GEQUAL = 9,
|
||||
MAG_FILTER_BICUBIC_LEQUAL = 10
|
||||
};
|
||||
|
||||
enum WrapMode {
|
||||
WRAP_REPEAT = 0,
|
||||
WRAP_CLAMP = 1
|
||||
};
|
||||
|
||||
enum TexEnvMode {
|
||||
TEXENV_MODULATE = 0,
|
||||
TEXENV_BLEND = 1,
|
||||
TEXENV_DECAL = 2,
|
||||
TEXENV_COLOR = 3
|
||||
};
|
||||
|
||||
enum Projection {
|
||||
PROJECTION_FLAT = 0,
|
||||
PROJECTION_LAMBERT_CONIC = 3,
|
||||
PROJECTION_UTM = 4,
|
||||
PROJECTION_UNDEFINED = 7
|
||||
};
|
||||
|
||||
enum Datum {
|
||||
DATUM_WGS84 = 0,
|
||||
DATUM_WGS72 = 1,
|
||||
DATUM_BESSEL = 2,
|
||||
DATUM_CLARK_1866 = 3,
|
||||
DATUM_NAD27 = 4
|
||||
};
|
||||
|
||||
|
||||
Attr(int version) : _flt_version(version) { init(); }
|
||||
void init();
|
||||
void readField(std::ifstream& file, void* buf, size_t size);
|
||||
bool readAttrFile(const char* szName);
|
||||
flt::AttrData* createOsgStateSet();
|
||||
|
||||
|
||||
|
||||
int32 texels_u; // Number of texels in u direction
|
||||
int32 textel_v; // Number of texels in v direction
|
||||
int32 direction_u; // Real world size u direction
|
||||
int32 direction_v; // Real world size v direction
|
||||
int32 x_up; // x component of up vector
|
||||
int32 y_up; // y component of up vector
|
||||
int32 fileFormat; // File format type
|
||||
// -1 Not used
|
||||
// 0 AT&T image 8 pattern
|
||||
// 1 AT&T image 8 template
|
||||
// 2 SGI intensity modulation
|
||||
// 3 SGI intensity w/ alpha
|
||||
// 4 SGI RGB
|
||||
// 5 SGI RGB w/ alpha
|
||||
int32 minFilterMode; // Minification filter type
|
||||
// 0 - TX_POINT
|
||||
// 1 - TX_BILINEAR
|
||||
// 2 - TX_MIPMAP (Obsolete)
|
||||
// 3 - TX_MIPMAP_POINT
|
||||
// 4 - TX_MIPMAP_LINEAR
|
||||
// 5 - TX_MIPMAP_BILINEAR
|
||||
// 6 - TX_MIPMAP_TRILINEAR
|
||||
// 7 - None
|
||||
// 8 - TX_BICUBIC
|
||||
// 9 - TX_BILINEAR_GEQUAL
|
||||
// 10 - TX_BILINEAR_LEQUAL
|
||||
// 11 - TX_BICUBIC_GEQUAL
|
||||
// 12 - TX_BICUBIC_LEQUAL
|
||||
int32 magFilterMode; // Magnification filter type
|
||||
// 0 - TX_POINT
|
||||
// 1 - TX_BILINEAR
|
||||
// 2 - None
|
||||
// 3 - TX_BICUBIC
|
||||
// 4 - TX_SHARPEN
|
||||
// 5 - TX_ADD_DETAIL
|
||||
// 6 - TX_MODULATE_DETAIL
|
||||
// 7 - TX_BILINEAR_GEQUAL
|
||||
// 8 - TX_BILINEAR_LEQUAL
|
||||
// 9 - TX_BICUBIC_GEQUAL
|
||||
// 10 - TX_BICUBIC_LEQUAL
|
||||
int32 wrapMode; // Repetition type
|
||||
// 0 - TX_REPEAT
|
||||
// 1 - TX_CLAMP
|
||||
// 2 - (Obsolete)
|
||||
int32 wrapMode_u; // Repetition type in u direction (see above)
|
||||
int32 wrapMode_v; // Repetition type in v direction (see above)
|
||||
int32 modifyFlag; // Modify flag (for internal use)
|
||||
int32 pivot_x; // x pivot point for rotating textures
|
||||
int32 pivot_y; // y pivot point for rotating textures
|
||||
|
||||
// --------------
|
||||
// v11 ends here
|
||||
// --------------
|
||||
|
||||
int32 texEnvMode; // Environment type
|
||||
// 0 - TV_MODULATE
|
||||
// 1 - TV_BLEND
|
||||
// 2 - TV_DECAL
|
||||
// 3 - TV_COLOR
|
||||
int32 intensityAsAlpha; // TRUE if intensity pattern to be loaded in alpha with white in color
|
||||
int32 spare1[8]; // 8 words of spare
|
||||
float64 size_u; // Real world size u for floating point databases
|
||||
float64 size_v; // Real world size v for floating point databases
|
||||
int32 originCode; // Code for origin of imported texture
|
||||
int32 kernelVersion; // Kernel version number
|
||||
int32 intFormat; // Internal format type
|
||||
// 0 - Default
|
||||
// 1 - TX_I_12A_4
|
||||
// 2 - TX_IA_8
|
||||
// 3 - TX_RGB_5
|
||||
// 4 - TX_RGBA_4
|
||||
// 5 - TX_IA_12
|
||||
// 6 - TX_RGBA_8
|
||||
// 7 - TX_RGBA_12
|
||||
// 8 - TX_I_16 (shadow mode only)
|
||||
// 9 - TX_RGB_12
|
||||
int32 extFormat; // External format type
|
||||
// 0 - Default
|
||||
// 1 - TX_PACK_8
|
||||
// 2 - TX_PACK_16
|
||||
int32 useMips; // TRUE if using following 8 floats for MIPMAP kernel
|
||||
float32 _mipMapKernel[8]; // 8 floats for kernel of separable symmetric filter
|
||||
int32 useLodScale; // Boolean if TRUE send:
|
||||
float32 lod0; // LOD0 for TX_CONTROL_POINT
|
||||
float32 scale0; // SCALE0 for TX_CONTROL_POINT
|
||||
float32 lod1; // LOD1 for TX_CONTROL_POINT
|
||||
float32 scale1; // SCALE1 for TX_CONTROL_POINT
|
||||
float32 lod2; // LOD2 for TX_CONTROL_POINT
|
||||
float32 scale2; // SCALE2 for TX_CONTROL_POINT
|
||||
float32 lod3; // LOD3 for TX_CONTROL_POINT
|
||||
float32 scale3; // SCALE3 for TX_CONTROL_POINT
|
||||
float32 lod4; // LOD4 for TX_CONTROL_POINT
|
||||
float32 scale4; // SCALE4 for TX_CONTROL_POINT
|
||||
float32 lod5; // LOD5 for TX_CONTROL_POINT
|
||||
float32 scale5; // SCALE5 for TX_CONTROL_POINT
|
||||
float32 lod6; // LOD6 for TX_CONTROL_POINT
|
||||
float32 scale6; // SCALE6 for TX_CONTROL_POINT
|
||||
float32 lod7; // LOD7 for TX_CONTROL_POINT
|
||||
float32 scale7; // SCALE7 for TX_CONTROL_POINT
|
||||
|
||||
float32 clamp; // Clamp
|
||||
int32 magFilterAlpha; // magfilteralpha:
|
||||
// 0 = TX_POINT
|
||||
// 1 = TX_BILINEAR
|
||||
// 2 = None
|
||||
// 3 = TX_BICUBIC
|
||||
// 4 = TX_SHARPEN
|
||||
// 5 = TX_ADD_DETAIL
|
||||
// 6 = TX_MODULATE_DETAIL
|
||||
// 7 = TX_BILINEAR_GEQUAL
|
||||
// 8 = TX_BILINEAR_LEQUAL
|
||||
// 9 = TX_BICUBIC_GEQUAL
|
||||
// 10 = TX_BIBICUBIC_LEQUAL
|
||||
int32 magFilterColor; // magfiltercolor:
|
||||
// 0 = TX_POINT
|
||||
// 1 = TX_BILINEAR
|
||||
// 2 = None
|
||||
// 3 = TX_BICUBIC
|
||||
// 4 = TX_SHARPEN
|
||||
// 5 = TX_ADD_DETAIL
|
||||
// 6 = TX_MODULATE_DETAIL
|
||||
// 7 = TX_BILINEAR_GEQUAL
|
||||
// 8 = TX_BILINEAR_LEQUAL
|
||||
// 9 = TX_BICUBIC_GEQUAL
|
||||
// 10 = TX_BIBICUBIC_LEQUAL
|
||||
float32 reserved1; // Reserved
|
||||
float32 reserved2[8]; // Reserved
|
||||
float64 lambertMeridian; // Lambert conic projection central meridian
|
||||
float64 lambertUpperLat; // Lambert conic projection upper latitude
|
||||
float64 lambertlowerLat; // Lambert conic projection lower latitude
|
||||
float64 reserved3; // Reserved
|
||||
float32 spare2[5]; // Spare
|
||||
int32 useDetail; // TRUE if using next 5 integers for detail texture
|
||||
int32 txDetail_j; // J argument for TX_DETAIL
|
||||
int32 txDetail_k; // K argument for TX_DETAIL
|
||||
int32 txDetail_m; // M argument for TX_DETAIL
|
||||
int32 txDetail_n; // N argument for TX_DETAIL
|
||||
int32 txDetail_s; // Scramble argument for TX_DETAIL
|
||||
int32 useTile; // TRUE if using next for floats for TX_TILE
|
||||
float32 txTile_ll_u; // Lower-left u value for TX_TILE
|
||||
float32 txTile_ll_v; // Lower-left v value for TX_TILE
|
||||
float32 txTile_ur_u; // Upper-right u value for TX_TILE
|
||||
float32 txTile_ur_v; // Upper-right v value for TX_TILE
|
||||
int32 projection; // Projection
|
||||
// 0 = Flat earth
|
||||
// 3 = Lambert conic
|
||||
// 4 = UTM
|
||||
// 7 = Undefined projection
|
||||
int32 earthModel; // Earth model
|
||||
// 0 = WGS84
|
||||
// 1 = WGS72
|
||||
// 2 = Bessel
|
||||
// 3 = Clark 1866
|
||||
// 4 = NAD27
|
||||
int32 reserved4; // Reserved
|
||||
int32 utmZone; // UTM zone
|
||||
int32 imageOrigin; // Image origin
|
||||
// 0 = Lower-left
|
||||
// 1 = Upper-left
|
||||
int32 geoUnits; // Geospecific points units
|
||||
// 0 = Degrees
|
||||
// 1 = Meters
|
||||
// 2 = Pixels
|
||||
int32 reserved5; // Reserved
|
||||
int32 reserved6; // Reserved
|
||||
int32 hemisphere; // Hemisphere for geospecific points units
|
||||
// 0 = Southern
|
||||
// 1 = Northern
|
||||
int32 reserved7; // Reserved
|
||||
int32 reserved8; // Reserved
|
||||
int32 spare3[149]; // Spare
|
||||
char comments[512]; // Comments
|
||||
|
||||
// --------------
|
||||
// v12 ends here
|
||||
// --------------
|
||||
|
||||
int32 reserved9[13]; // Reserved
|
||||
int32 attrVersion; // Attribute file version number
|
||||
|
||||
int32 controlPoints; // Number of geospecific control points
|
||||
// If the number of geospecific control points is > 0,
|
||||
// the following fields are also in the attribute file:
|
||||
int32 reserved10; // Reserved
|
||||
#if 0
|
||||
// For each geospecific control point:
|
||||
{
|
||||
float64 texel_u; // Texel u of geospecific control point
|
||||
float64 texel_v; // Texel v of geospecific control point
|
||||
float64 geoPoint[2]; // Real earth coordinate of geospecific control point
|
||||
// (this value depends on the projection, earth model,
|
||||
// and geospecific points units)
|
||||
}
|
||||
|
||||
// ----------------
|
||||
// v15.6 ends here
|
||||
// ----------------
|
||||
|
||||
// After all geospecific control points are listed, the following subtexture
|
||||
// information appears:
|
||||
int32 subtextures; // Number of subtexture definitions contained in the
|
||||
// texture attribute file
|
||||
// If the number of subtexture definitions is >0,
|
||||
// the following fields are repeated for each subtexture definition:
|
||||
{
|
||||
char name[32]; // name of subtexture definition
|
||||
int32 left; // Coordinate of left edge of subtexture
|
||||
// definition measured in texels.
|
||||
int32 bottom; // Coordinate of bottom edge of subtexture
|
||||
// definition measured in texels.
|
||||
int32 right; // Coordinate of right edge of subtexture
|
||||
// definition measured in texels.
|
||||
int32 top; // Coordinate of top edge of subtexture
|
||||
// definition measured in texels.
|
||||
}
|
||||
#endif
|
||||
|
||||
void read();
|
||||
|
||||
private :
|
||||
|
||||
int _flt_version;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void Attr::init()
|
||||
{
|
||||
texels_u = 0;
|
||||
textel_v = 0;
|
||||
direction_u = 0;
|
||||
direction_v = 0;
|
||||
x_up = 0;
|
||||
y_up = 0;
|
||||
fileFormat = -1; // -1 Not used
|
||||
minFilterMode = MIN_FILTER_NONE;
|
||||
magFilterMode = MAG_FILTER_POINT;
|
||||
wrapMode = WRAP_REPEAT;
|
||||
wrapMode_u = WRAP_REPEAT;
|
||||
wrapMode_v = WRAP_REPEAT;
|
||||
modifyFlag = 0;
|
||||
pivot_x = 0;
|
||||
pivot_y = 0;
|
||||
texEnvMode = TEXENV_MODULATE;
|
||||
intensityAsAlpha = 0;
|
||||
size_u = 0;
|
||||
size_v = 0;
|
||||
originCode = 0;
|
||||
kernelVersion = 0;
|
||||
intFormat = 0; // 0 - Default
|
||||
extFormat = 0; // 0 - Default
|
||||
useMips = 0;
|
||||
// float32 _mipMapKernel[8];
|
||||
useLodScale = 0;
|
||||
// float32 lod0;
|
||||
// float32 scale0;
|
||||
// ...
|
||||
// float32 lod7;
|
||||
// float32 scale7;
|
||||
clamp = 0;
|
||||
magFilterAlpha = 2; // 2 = None
|
||||
magFilterColor = 2; // 2 = None
|
||||
lambertMeridian = 0;
|
||||
lambertUpperLat = 0;
|
||||
lambertlowerLat = 0;
|
||||
useDetail = 0;
|
||||
txDetail_j = 0;
|
||||
txDetail_k = 0;
|
||||
txDetail_m = 0;
|
||||
txDetail_n = 0;
|
||||
txDetail_s = 0;
|
||||
useTile = 0;
|
||||
txTile_ll_u = 0;
|
||||
txTile_ll_v = 0;
|
||||
txTile_ur_u = 0;
|
||||
txTile_ur_v = 0;
|
||||
projection = PROJECTION_UNDEFINED;
|
||||
earthModel = DATUM_WGS84;
|
||||
utmZone = 0;
|
||||
imageOrigin = 0;
|
||||
geoUnits = 0;
|
||||
hemisphere = 1;
|
||||
comments[0] = '\0';
|
||||
attrVersion = 0;
|
||||
controlPoints = 0;
|
||||
// TODO:
|
||||
}
|
||||
|
||||
|
||||
void Attr::readField(std::ifstream& file, void* buf, size_t size)
|
||||
{
|
||||
if (file.eof()) return;
|
||||
file.read((char*)buf, size);
|
||||
if(::isLittleEndianMachine())
|
||||
::endian2(buf, size, buf);
|
||||
}
|
||||
|
||||
|
||||
bool Attr::readAttrFile(const char* szName)
|
||||
{
|
||||
int n;
|
||||
std::ifstream file;
|
||||
|
||||
file.open (szName, std::ios::in | std::ios::binary);
|
||||
|
||||
READ( texels_u );
|
||||
READ( textel_v );
|
||||
READ( direction_u );
|
||||
READ( direction_v );
|
||||
READ( x_up );
|
||||
READ( y_up );
|
||||
READ( fileFormat );
|
||||
READ( minFilterMode );
|
||||
READ( magFilterMode );
|
||||
READ( wrapMode );
|
||||
READ( wrapMode_u );
|
||||
READ( wrapMode_v );
|
||||
READ( modifyFlag );
|
||||
READ( pivot_x );
|
||||
READ( pivot_y );
|
||||
|
||||
// v11 ends here
|
||||
if (_flt_version <= 11) return true;
|
||||
|
||||
READ( texEnvMode );
|
||||
READ( intensityAsAlpha );
|
||||
for (n=0; n<8; n++) {
|
||||
READ(spare1[n]); }
|
||||
READ( size_u );
|
||||
READ( size_v );
|
||||
READ( originCode );
|
||||
READ( kernelVersion );
|
||||
READ( intFormat );
|
||||
READ( extFormat );
|
||||
READ( useMips );
|
||||
for (n=0; n<8; n++) {
|
||||
READ(_mipMapKernel[n]); }
|
||||
READ( useLodScale );
|
||||
READ( lod0 );
|
||||
READ( scale0 );
|
||||
READ( lod1 );
|
||||
READ( scale1 );
|
||||
READ( lod2 );
|
||||
READ( scale2 );
|
||||
READ( lod3 );
|
||||
READ( scale3 );
|
||||
READ( lod4 );
|
||||
READ( scale4 );
|
||||
READ( lod5 );
|
||||
READ( scale5 );
|
||||
READ( lod6 );
|
||||
READ( scale6 );
|
||||
READ( lod7 );
|
||||
READ( scale7 );
|
||||
READ( clamp );
|
||||
READ( magFilterAlpha );
|
||||
READ( magFilterColor );
|
||||
READ( reserved1 );
|
||||
for (n=0; n<8; n++) {
|
||||
READ(reserved2[n]); }
|
||||
READ( lambertMeridian );
|
||||
READ( lambertUpperLat );
|
||||
READ( lambertlowerLat );
|
||||
READ( reserved3 );
|
||||
|
||||
for (n=0; n<5; n++) {
|
||||
READ(spare2[n]); }
|
||||
|
||||
// I don't know why I get a 4 bytes displacement before reading Detail Texture parameters
|
||||
// My ATTR files have been created with Creator 2.5.1
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
int32 dummyAjust;
|
||||
READ( dummyAjust);
|
||||
|
||||
READ( useDetail );
|
||||
READ( txDetail_j );
|
||||
READ( txDetail_k );
|
||||
READ( txDetail_m );
|
||||
READ( txDetail_n );
|
||||
READ( txDetail_s );
|
||||
READ( useTile );
|
||||
READ( txTile_ll_u );
|
||||
READ( txTile_ll_v );
|
||||
READ( txTile_ur_u );
|
||||
READ( txTile_ur_v );
|
||||
READ( projection );
|
||||
READ( earthModel );
|
||||
READ( reserved4 );
|
||||
READ( utmZone );
|
||||
READ( imageOrigin);
|
||||
READ( geoUnits );
|
||||
READ( reserved5 );
|
||||
READ( reserved6 );
|
||||
READ( hemisphere );
|
||||
READ( reserved7 );
|
||||
READ( reserved8 );
|
||||
for (n=0; n<149; n++) {
|
||||
READ(spare3[n]); }
|
||||
file.read(comments, sizeof(comments));
|
||||
|
||||
// v12 ends here
|
||||
if (_flt_version <= 12) return true;
|
||||
|
||||
for (n=0; n<13; n++) {
|
||||
READ(reserved9[n]); }
|
||||
READ( attrVersion );
|
||||
READ( controlPoints);
|
||||
READ( reserved10 );
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
flt::AttrData* Attr::createOsgStateSet()
|
||||
{
|
||||
TexEnv* osgTexEnv = new TexEnv;
|
||||
Texture2D* osgTexture = new Texture2D;
|
||||
flt::AttrData* attrdata = new flt::AttrData;
|
||||
|
||||
if ((wrapMode_u != WRAP_CLAMP) && ((wrapMode_u != WRAP_REPEAT)))
|
||||
wrapMode_u = wrapMode;
|
||||
if ((wrapMode_v != WRAP_CLAMP) && ((wrapMode_v != WRAP_REPEAT)))
|
||||
wrapMode_v = wrapMode;
|
||||
|
||||
if (wrapMode_u == WRAP_CLAMP) osgTexture->setWrap(Texture2D::WRAP_S,Texture2D::CLAMP);
|
||||
else osgTexture->setWrap(Texture2D::WRAP_S,Texture2D::REPEAT);
|
||||
|
||||
if (wrapMode_v == WRAP_CLAMP) osgTexture->setWrap(Texture2D::WRAP_T,Texture2D::CLAMP);
|
||||
else osgTexture->setWrap(Texture2D::WRAP_T,Texture2D::REPEAT);
|
||||
|
||||
|
||||
switch (texEnvMode)
|
||||
{
|
||||
case TEXENV_MODULATE:
|
||||
osgTexEnv->setMode(TexEnv::MODULATE);
|
||||
break;
|
||||
case TEXENV_BLEND:
|
||||
osgTexEnv->setMode(TexEnv::BLEND);
|
||||
break;
|
||||
case TEXENV_DECAL:
|
||||
osgTexEnv->setMode(TexEnv::DECAL);
|
||||
break;
|
||||
case TEXENV_COLOR:
|
||||
osgTexEnv->setMode(TexEnv::REPLACE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* An email on ATTR mappings to OpenGL : "[osg-news] OpenFlight Texture Filter Modes"
|
||||
from Joseph Steel:
|
||||
|
||||
|
||||
I posted a query on a forum on the Multigen web site re. the OpenFlight
|
||||
texture filer modes. This is the reply:
|
||||
|
||||
Here are the mappings used by Creator under OpenGL:
|
||||
For Minification:
|
||||
Point (0): GL_NEAREST
|
||||
Bilinear (1): GL_LINEAR
|
||||
Mipmap Point (3): GL_NEAREST_MIPMAP_NEAREST
|
||||
Mipmap Linear (4): GL_NEAREST_MIPMAP_LINEAR
|
||||
Mipmap Bilinear (5): GL_LINEAR_MIPMAP_NEAREST
|
||||
Mipmap Trilinear (6): GL_LINEAR_MIPMAP_LINEAR
|
||||
Bicubic (8): GL_LINEAR_MIPMAP_NEAREST
|
||||
Bilinear Greater/Equal (9): GL_LINEAR_MIPMAP_NEAREST
|
||||
Bilinear Less/Equal (10): GL_LINEAR_MIPMAP_NEAREST
|
||||
Bicubic Greater/Equal (11): GL_LINEAR_MIPMAP_NEAREST
|
||||
Bicubic Less/Equal (12): GL_LINEAR_MIPMAP_NEAREST
|
||||
For Magnification:
|
||||
Point (0): GL_NEAREST
|
||||
Bilinear (1): GL_LINEAR
|
||||
Bicubic (3): GL_LINEAR
|
||||
Sharpen (4): GL_LINEAR
|
||||
Add Detail (5): GL_LINEAR
|
||||
Modulate Detail (6): GL_LINEAR
|
||||
Bilinear Greater/Equal (7): GL_LINEAR
|
||||
Bilinear Less/Equal (8): GL_LINEAR
|
||||
Bicubic Greater/Equal (9): GL_LINEAR
|
||||
Bicubic Less/Equal (10): GL_LINEAR
|
||||
|
||||
Note that mode 2 for both minification & magnification are no longer
|
||||
supported.
|
||||
*/
|
||||
|
||||
// -----------
|
||||
// Min filter
|
||||
// -----------
|
||||
|
||||
switch (minFilterMode)
|
||||
{
|
||||
case MIN_FILTER_POINT:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::NEAREST);
|
||||
break;
|
||||
case MIN_FILTER_BILINEAR:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::LINEAR);
|
||||
break;
|
||||
case MIN_FILTER_MIPMAP_POINT:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::NEAREST_MIPMAP_NEAREST);
|
||||
break;
|
||||
case MIN_FILTER_MIPMAP_LINEAR:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::NEAREST_MIPMAP_LINEAR);
|
||||
break;
|
||||
case MIN_FILTER_MIPMAP_BILINEAR:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::LINEAR_MIPMAP_NEAREST);
|
||||
break;
|
||||
case MIN_FILTER_MIPMAP_TRILINEAR:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::LINEAR_MIPMAP_LINEAR);
|
||||
break;
|
||||
case MIN_FILTER_BICUBIC:
|
||||
case MIN_FILTER_BILINEAR_GEQUAL:
|
||||
case MIN_FILTER_BILINEAR_LEQUAL:
|
||||
case MIN_FILTER_BICUBIC_GEQUAL:
|
||||
case MIN_FILTER_BICUBIC_LEQUAL:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::LINEAR_MIPMAP_NEAREST);
|
||||
break;
|
||||
default:
|
||||
osgTexture->setFilter(osg::Texture2D::MIN_FILTER, Texture2D::LINEAR_MIPMAP_LINEAR);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// -----------
|
||||
// Mag filter
|
||||
// -----------
|
||||
|
||||
switch (magFilterMode)
|
||||
{
|
||||
case MAG_FILTER_POINT:
|
||||
osgTexture->setFilter(osg::Texture2D::MAG_FILTER, Texture2D::NEAREST);
|
||||
break;
|
||||
case MAG_FILTER_BILINEAR:
|
||||
case MAG_FILTER_BILINEAR_GEQUAL:
|
||||
case MAG_FILTER_BILINEAR_LEQUAL:
|
||||
case MAG_FILTER_SHARPEN:
|
||||
case MAG_FILTER_BICUBIC:
|
||||
case MAG_FILTER_BICUBIC_GEQUAL:
|
||||
case MAG_FILTER_BICUBIC_LEQUAL:
|
||||
case MAG_FILTER_ADD_DETAIL:
|
||||
case MAG_FILTER_MODULATE_DETAIL:
|
||||
osgTexture->setFilter(osg::Texture2D::MAG_FILTER, Texture2D::LINEAR);
|
||||
break;
|
||||
}
|
||||
|
||||
// I have just ported the two below set*Attribute lines to use the new
|
||||
// texture attribute methods, however this tieing to the texture unit 0
|
||||
// is probably inappropriate. Perhaps it would be better to create a
|
||||
// StateSet to store the texture an modes, it is probably best
|
||||
// to use an intermediate data structure for the flt loader to use to
|
||||
// encapsulate ATTR files. Need to speak to Brede about this issue.
|
||||
// Robert Osfield, July 9th 2002.
|
||||
|
||||
// This is now a bit diferrent. We create a new AttrData object, and StateSet object
|
||||
// is instead with attribute information needed to setup detail texutre
|
||||
//
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
attrdata->stateset = new StateSet;
|
||||
attrdata->stateset->setTextureAttribute( 0, osgTexEnv );
|
||||
attrdata->stateset->setTextureAttributeAndModes( 0, osgTexture, StateAttribute::ON );
|
||||
attrdata->useDetail = useDetail;
|
||||
attrdata->txDetail_j = txDetail_j;
|
||||
attrdata->txDetail_k = txDetail_k;
|
||||
attrdata->txDetail_m = txDetail_m;
|
||||
attrdata->txDetail_n = txDetail_n;
|
||||
attrdata->txDetail_s = txDetail_s;
|
||||
if (magFilterMode == MAG_FILTER_MODULATE_DETAIL)
|
||||
attrdata->modulateDetail = true;
|
||||
else
|
||||
attrdata->modulateDetail = false;
|
||||
|
||||
return attrdata;
|
||||
}
|
||||
|
||||
|
||||
class ReaderWriterATTR : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual const char* className() const { return "ATTR Image Attribute Reader/Writer"; }
|
||||
|
||||
virtual bool acceptsExtension(const std::string& extension) const
|
||||
{
|
||||
return osgDB::equalCaseInsensitive(extension,"attr");
|
||||
}
|
||||
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
int version = 0;
|
||||
|
||||
// Check the options string for the OpenFlight file version
|
||||
if (options)
|
||||
{
|
||||
// Get the character index of the FLT_VER option in the option
|
||||
// string
|
||||
std::string::size_type optionIndex = options->getOptionString().find("FLT_VER");
|
||||
|
||||
// Default to zero for the version if it's not found
|
||||
if (optionIndex == std::string::npos)
|
||||
version = 0;
|
||||
else
|
||||
{
|
||||
// Copy the option string, starting with the F in FLT_VER
|
||||
std::string fltVersionStr(options->getOptionString(),
|
||||
optionIndex);
|
||||
std::string optionText;
|
||||
|
||||
// Read the version from the string
|
||||
std::istringstream ins(fltVersionStr);
|
||||
ins >> optionText >> version;
|
||||
}
|
||||
}
|
||||
|
||||
Attr attr(version);
|
||||
|
||||
if (!attr.readAttrFile(fileName.c_str()))
|
||||
{
|
||||
return "Unable to open \""+fileName+"\"";
|
||||
}
|
||||
|
||||
//StateSet* stateset = attr.createOsgStateSet();
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
flt::AttrData* attrdata = attr.createOsgStateSet();
|
||||
|
||||
notify(INFO) << "texture attribute read ok" << std::endl;
|
||||
return attrdata;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterATTR> g_readerWriter_ATTR_Proxy;
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
// ReaderWriterFLT.cpp
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "ReaderWriterFLT.h"
|
||||
#include "FltFile.h"
|
||||
#include "Registry.h"
|
||||
|
||||
#include <osg/Object>
|
||||
#include <osg/Node>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readObject(const std::string& fileName, const osgDB::ReaderWriter::Options* opt) const
|
||||
{
|
||||
return readNode(fileName,opt);
|
||||
}
|
||||
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
// serialize all access to the OpenFlight plugin as its not thread safe by itself.
|
||||
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::ref_ptr<FltFile> read = new FltFile;
|
||||
|
||||
if (options)
|
||||
{
|
||||
read->setUseTextureAlphaForTransparancyBinning(options->getOptionString().find("noTextureAlphaForTransparancyBinning")==std::string::npos);
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getUseTextureAlphaForTransparancyBinning()=" << read->getUseTextureAlphaForTransparancyBinning() << std::endl;
|
||||
read->setDoUnitsConversion((options->getOptionString().find("noUnitsConversion")==std::string::npos)); // default to true, unless noUnitsConversion is specified.o
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getDoUnitsConversion()=" << read->getDoUnitsConversion() << std::endl;
|
||||
|
||||
if (read->getDoUnitsConversion())
|
||||
{
|
||||
if (options->getOptionString().find("convertToFeet")!=std::string::npos)
|
||||
read->setDesiredUnits( FltFile::ConvertToFeet );
|
||||
else if (options->getOptionString().find("convertToInches")!=std::string::npos)
|
||||
read->setDesiredUnits( FltFile::ConvertToInches );
|
||||
else if (options->getOptionString().find("convertToMeters")!=std::string::npos)
|
||||
read->setDesiredUnits( FltFile::ConvertToMeters );
|
||||
else if (options->getOptionString().find("convertToKilometers")!=std::string::npos)
|
||||
read->setDesiredUnits( FltFile::ConvertToKilometers );
|
||||
else if (options->getOptionString().find("convertToNauticalMiles")!=std::string::npos)
|
||||
read->setDesiredUnits( FltFile::ConvertToNauticalMiles );
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getDesiredUnits()=" << read->getDesiredUnitsString() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_options = options ?
|
||||
static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp(osg::CopyOp::SHALLOW_COPY))) :
|
||||
new osgDB::ReaderWriter::Options;
|
||||
local_options->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
read->setOptions(local_options.get());
|
||||
|
||||
osg::Node* node = read->readNode(fileName);
|
||||
|
||||
flt::Registry::instance()->clearObjectCache();
|
||||
|
||||
if (node) return node;
|
||||
else return ReadResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterFLT> g_fltReaderWriterProxy;
|
||||
@@ -1,70 +0,0 @@
|
||||
//
|
||||
// OpenFlight<68> loader for Open Scene Graph
|
||||
//
|
||||
// Copyright (C) 2000 Brede Johansen
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
// The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for
|
||||
// real-time rendering of large 3D photo-realistic models.
|
||||
// The OSG homepage is http://www.openscenegraph.org/
|
||||
//
|
||||
// MultiGen, OpenFlight, and Flight Format are registered trademarks of MultiGen Inc.
|
||||
//
|
||||
|
||||
#ifndef __FLT_READER_WRITER_FLT_H
|
||||
#define __FLT_READER_WRITER_FLT_H
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <osg/Object>
|
||||
#include <osg/Node>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <OpenThreads/ReentrantMutex>
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
class ReaderWriterFLT : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char* className() const { return "FLT Reader/Writer"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) const
|
||||
{
|
||||
return osgDB::equalCaseInsensitive(extension,"flt");
|
||||
}
|
||||
|
||||
virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options*) const;
|
||||
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const;
|
||||
|
||||
protected:
|
||||
|
||||
mutable OpenThreads::ReentrantMutex _serializerMutex;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_CONTROL_RECORD_H
|
||||
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
// Record.cpp
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <osg/Notify>
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "Record.h"
|
||||
#include "FltRecords.h"
|
||||
#include "UnknownRecord.h"
|
||||
#include "opcodes.h"
|
||||
#include "Input.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Record
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Record::s_numAllocatedRecords=0;
|
||||
|
||||
Record::Record()
|
||||
{
|
||||
_pData = NULL;
|
||||
_pParent = NULL;
|
||||
_pFltFile = NULL;
|
||||
|
||||
++s_numAllocatedRecords;
|
||||
|
||||
flt::Registry::instance()->addRecordForFutureDelete(this);
|
||||
}
|
||||
|
||||
|
||||
Record::~Record()
|
||||
{
|
||||
--s_numAllocatedRecords;
|
||||
|
||||
if (_pData) ::free(_pData);
|
||||
}
|
||||
|
||||
|
||||
int Record::getFlightVersion() const
|
||||
{
|
||||
if (_pFltFile)
|
||||
return _pFltFile->getFlightVersion();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Record* Record::cloneRecord(SRecHeader* pData)
|
||||
{
|
||||
Record* pRec = clone();
|
||||
|
||||
if (pRec->sizeofData() > pData->length())
|
||||
pData = (SRecHeader*)::realloc(pData, pRec->sizeofData());
|
||||
|
||||
pRec->_pData = (SRecHeader*)pData;
|
||||
|
||||
return pRec;
|
||||
}
|
||||
|
||||
|
||||
void Record::accept(RecordVisitor& rv)
|
||||
{
|
||||
rv.apply(*this);
|
||||
}
|
||||
|
||||
|
||||
void Record::postReadInit()
|
||||
{
|
||||
// These two lines used to be the last thing in Input::readCreateRecord().
|
||||
// Some records need a "post read" function called regardless of
|
||||
// the endian of the machine, so I moved it to here.
|
||||
if ( flt::isLittleEndianMachine() ) // From Intel with love :-(
|
||||
this->endian();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void Record::ascend(RecordVisitor& rv)
|
||||
{
|
||||
std::for_each(_parents.begin(),_parents.end(),RecordAcceptOp(rv));
|
||||
}
|
||||
*/
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const Record& rec)
|
||||
{
|
||||
output << rec.className()
|
||||
<< " op=" << rec.getOpcode()
|
||||
<< " size=" << rec.getSize();
|
||||
return output; // to enable cascading
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PrimNodeRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrimNodeRecord::PrimNodeRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
PrimNodeRecord::~PrimNodeRecord()
|
||||
{
|
||||
// removeAllChildren();
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void PrimNodeRecord::accept(RecordVisitor& rv)
|
||||
{
|
||||
rv.apply(*this);
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void PrimNodeRecord::traverse(RecordVisitor& rv)
|
||||
{
|
||||
for (ChildList::iterator itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->accept(rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrimNodeRecord::addChild( Record *child )
|
||||
{
|
||||
if (child==NULL) return;
|
||||
|
||||
#if ENSURE_CHILD_IS_UNIQUE
|
||||
ChildList::iterator itr = std::find(_children.begin(),_children.end(),child);
|
||||
if (itr==_children.end())
|
||||
{
|
||||
#endif
|
||||
// note ref_ptr<> automatically handles incrementing child's reference count.
|
||||
_children.push_back(child);
|
||||
child->_pParent = this;
|
||||
|
||||
#if ENSURE_CHILD_IS_UNIQUE
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Trying to add non unique child, ignoring"<<std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PrimNodeRecord::removeChild( Record *child )
|
||||
{
|
||||
if (child==NULL) return;
|
||||
|
||||
ChildList::iterator itr = std::find(_children.begin(),_children.end(),child);
|
||||
if (itr!=_children.end())
|
||||
{
|
||||
// note ref_ptr<> automatically handles decrementing child's reference count.
|
||||
_children.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrimNodeRecord::removeAllChildren()
|
||||
{
|
||||
_children.clear();
|
||||
}
|
||||
|
||||
|
||||
bool PrimNodeRecord::readExtensionLevel(Input& fr)
|
||||
{
|
||||
int extensionState = 1;
|
||||
Record* pRec;
|
||||
|
||||
while ((pRec=fr.readCreateRecord(_pFltFile)))
|
||||
{
|
||||
if (pRec->isOfType(PUSH_EXTENSION_OP))
|
||||
{
|
||||
++extensionState;
|
||||
}
|
||||
else if (pRec->isOfType(POP_EXTENSION_OP))
|
||||
{
|
||||
--extensionState;
|
||||
if ( !extensionState ) // PUSH'es and POP's have cancelled out
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Read from PUSH to POP
|
||||
bool PrimNodeRecord::readLevel(Input& fr)
|
||||
{
|
||||
Record* pRec;
|
||||
|
||||
pRec = readRecord(fr);
|
||||
|
||||
while (pRec && !pRec->isOfType(POP_LEVEL_OP))
|
||||
{
|
||||
if (!pRec->isPrimaryNode())
|
||||
{
|
||||
osg::notify(osg::WARN) << "Non primary record found as child. op="
|
||||
<< pRec->getOpcode() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
addChild(pRec);
|
||||
|
||||
if (!((PrimNodeRecord*)pRec)->readLocalData(fr))
|
||||
return false;
|
||||
|
||||
pRec = readRecord(fr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Read next record, including extension record
|
||||
Record* PrimNodeRecord::readRecord(Input& fr)
|
||||
{
|
||||
Record* pRec = fr.readCreateRecord(_pFltFile);
|
||||
|
||||
while (pRec && (pRec->getOpcode() == PUSH_EXTENSION_OP))
|
||||
{
|
||||
readExtensionLevel(fr);
|
||||
pRec=fr.readCreateRecord(_pFltFile);
|
||||
}
|
||||
return pRec;
|
||||
}
|
||||
|
||||
#include "UVListRecord.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// virtual
|
||||
bool PrimNodeRecord::readLocalData(Input& fr)
|
||||
{
|
||||
Record* pRec;
|
||||
|
||||
pRec = readRecord(fr);
|
||||
|
||||
// Get ancillary records (if any)
|
||||
while (pRec && pRec->isAncillaryRecord())
|
||||
{
|
||||
addChild(pRec);
|
||||
if ( pRec->getOpcode() == 52 ) {
|
||||
CERR << "Multitexture added to " << this << "(opcode: "
|
||||
<< getOpcode() << ")\n";
|
||||
}
|
||||
if ( pRec->getOpcode() == 53 ) {
|
||||
CERR << "UV list added to " << this << "(opcode: "
|
||||
<< getOpcode() << ")\n";
|
||||
UVListRecord* mtr =
|
||||
dynamic_cast<UVListRecord*>(pRec);
|
||||
assert( mtr );
|
||||
assert( mtr->isAncillaryRecord() );
|
||||
SUVList* mt =
|
||||
reinterpret_cast<SUVList*>(mtr->getData());
|
||||
assert( mt );
|
||||
}
|
||||
pRec = readRecord(fr);
|
||||
}
|
||||
|
||||
if (pRec == NULL)
|
||||
return false;
|
||||
|
||||
// The next record should be PUSH or primary
|
||||
switch (pRec->getOpcode())
|
||||
{
|
||||
case PUSH_LEVEL_OP:
|
||||
readLevel(fr);
|
||||
break;
|
||||
|
||||
default:
|
||||
fr.rewindLast();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ControlRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// virtual
|
||||
void ControlRecord::accept(RecordVisitor& rv)
|
||||
{
|
||||
rv.apply(*this);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AncillaryRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// virtual
|
||||
void AncillaryRecord::accept(RecordVisitor& rv)
|
||||
{
|
||||
rv.apply(*this);
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
#ifndef __FLT_RECORD_H
|
||||
#define __FLT_RECORD_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include "FltRecords.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
//class Record;
|
||||
class Input;
|
||||
class FltFile;
|
||||
class RecordVisitor;
|
||||
class FltFile;
|
||||
class PrimNodeRecord;
|
||||
class FaceRecord;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Record
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Record : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
// used for debugging the number of records created and deleted.
|
||||
static int s_numAllocatedRecords;
|
||||
|
||||
Record();
|
||||
|
||||
virtual Record* clone() const = 0;
|
||||
Record* cloneRecord(SRecHeader* pData);
|
||||
|
||||
virtual const char* className() const { return "Record"; } //const = 0;
|
||||
virtual int classOpcode() const { return 0; } //const = 0;
|
||||
virtual size_t sizeofData() const { return 0; } //const = 0;
|
||||
virtual void accept(RecordVisitor& rv);
|
||||
virtual void traverse(RecordVisitor&) {}
|
||||
|
||||
virtual const std::string getName( void ) const { return std::string("?"); }
|
||||
|
||||
virtual bool isPrimaryNode() const { return false; }
|
||||
virtual bool isControlRecord() const { return false; }
|
||||
virtual bool isAncillaryRecord() const { return false; }
|
||||
virtual void endian() {}
|
||||
|
||||
int getRecordType() const;
|
||||
|
||||
SRecHeader* getData() const;
|
||||
void* getBody() const;
|
||||
int getOpcode() const;
|
||||
size_t getSize() const;
|
||||
size_t getHeaderLength() const;
|
||||
size_t getBodyLength() const;
|
||||
bool isOfType(int op) const;
|
||||
Record* getParent() const { return _pParent; }
|
||||
FltFile* getFltFile() { return _pFltFile; }
|
||||
int getFlightVersion() const;
|
||||
|
||||
virtual void postReadInit();
|
||||
|
||||
friend std::ostream& operator << (std::ostream& output, const Record& rec);
|
||||
|
||||
protected:
|
||||
|
||||
/** disallow creation of Records on the stack.*/
|
||||
virtual ~Record();
|
||||
|
||||
/** Template Method local read and write methods */
|
||||
virtual bool readLocalData(Input& /*fr*/) { return false; }
|
||||
// virtual bool writeLocalData(Output& fw) { return false; }
|
||||
|
||||
SRecHeader* _pData;
|
||||
Record* _pParent;
|
||||
FltFile* _pFltFile;
|
||||
|
||||
friend class Input;
|
||||
friend class FltFile;
|
||||
friend class PrimNodeRecord;
|
||||
|
||||
private:
|
||||
|
||||
/** disallow copy */
|
||||
Record& operator = (const Record&) { return *this;}
|
||||
Record(const Record&) : osg::Referenced() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline
|
||||
SRecHeader* Record::getData() const
|
||||
{
|
||||
return _pData;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void* Record::getBody() const
|
||||
{
|
||||
return (_pData) ? _pData+1 : NULL;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
int Record::getOpcode() const
|
||||
{
|
||||
return (_pData) ? _pData->opcode() : 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Record::getSize() const
|
||||
{
|
||||
return (_pData) ? _pData->length() : 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Record::getHeaderLength() const
|
||||
{
|
||||
return sizeof(SRecHeader);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Record::getBodyLength() const
|
||||
{
|
||||
return getSize() - getHeaderLength();
|
||||
}
|
||||
|
||||
inline
|
||||
bool Record::isOfType(int op) const
|
||||
{
|
||||
return (op == getOpcode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PrimNodeRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class PrimNodeRecord : public Record
|
||||
{
|
||||
public:
|
||||
PrimNodeRecord();
|
||||
virtual bool isPrimaryNode() const { return true; }
|
||||
virtual void accept(RecordVisitor& rv);
|
||||
virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
void addChild( Record* child );
|
||||
void removeChild( Record* child );
|
||||
void removeAllChildren();
|
||||
int getNumChildren( void ) { return _children.size(); }
|
||||
Record* getChild( int i ) { return _children[i].get(); }
|
||||
|
||||
protected:
|
||||
|
||||
/** disallow creation of PrimNodeRecords on the stack.*/
|
||||
virtual ~PrimNodeRecord();
|
||||
|
||||
virtual bool readLocalData(Input& fr);
|
||||
|
||||
private:
|
||||
bool readExtensionLevel(Input& fr);
|
||||
bool readLevel(Input& fr);
|
||||
Record* readRecord(Input& fr);
|
||||
|
||||
typedef std::vector<osg::ref_ptr<Record> > ChildList;
|
||||
ChildList _children;
|
||||
|
||||
friend class FaceRecord;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ControlRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ControlRecord : public Record
|
||||
{
|
||||
public:
|
||||
|
||||
// ControlRecord();
|
||||
virtual bool isControlRecord() const { return true; }
|
||||
virtual void accept(RecordVisitor& rv);
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** disallow creation of ControlRecord on the stack.*/
|
||||
// virtual ~ControlRecord();
|
||||
|
||||
virtual bool readLocalData(Input& /*fr*/) { return true; }
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AncillaryRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AncillaryRecord : public Record
|
||||
{
|
||||
public:
|
||||
|
||||
// AncillaryRecord();
|
||||
virtual bool isAncillaryRecord() const { return true; }
|
||||
virtual void accept(RecordVisitor& rv);
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
/** disallow creation of AncillaryRecord on the stack.*/
|
||||
// virtual ~AncillaryRecord();
|
||||
|
||||
virtual bool readLocalData(Input& /*fr*/) { return true; }
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_RECORD_H
|
||||
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
// RecordVisitor.cpp
|
||||
|
||||
#include "RecordVisitor.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace flt;
|
||||
|
||||
RecordVisitor::RecordVisitor(TraversalMode tm)
|
||||
{
|
||||
_traverseVisitor = NULL;
|
||||
_traverseMode = tm;
|
||||
}
|
||||
|
||||
|
||||
RecordVisitor::~RecordVisitor()
|
||||
{
|
||||
// if (_traverseVisitor) detach from _traverseVisitor;
|
||||
}
|
||||
|
||||
|
||||
void RecordVisitor::setTraverseMode(TraversalMode mode)
|
||||
{
|
||||
if (_traverseMode==mode) return;
|
||||
if (mode==TRAVERSE_VISITOR)
|
||||
{
|
||||
if (_traverseVisitor==NULL) _traverseMode = TRAVERSE_NONE;
|
||||
else _traverseMode = TRAVERSE_VISITOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_traverseVisitor) _traverseVisitor=NULL;
|
||||
_traverseMode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RecordVisitor::setTraverseVisitor(RecordVisitor* rv)
|
||||
{
|
||||
if (_traverseVisitor==rv) return;
|
||||
// if (_traverseVisitor) detach from _traverseVisitor;
|
||||
_traverseVisitor = rv;
|
||||
if (_traverseVisitor) _traverseMode = TRAVERSE_VISITOR;
|
||||
else _traverseMode = TRAVERSE_NONE;
|
||||
// attach to _traverseVisitor;
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
// RecordVisitor.h
|
||||
|
||||
#ifndef __FLT_RECORD_VISITOR_H
|
||||
#define __FLT_RECORD_VISITOR_H
|
||||
|
||||
#include "Record.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
// Palette records
|
||||
class ColorPaletteRecord;
|
||||
class MaterialPaletteRecord;
|
||||
class LightSourcePaletteRecord;
|
||||
class TexturePaletteRecord;
|
||||
class VertexPaletteRecord;
|
||||
class VertexRecord;
|
||||
class NormalVertexRecord;
|
||||
class TextureVertexRecord;
|
||||
class NormalTextureVertexRecord;
|
||||
|
||||
// Primary records
|
||||
class HeaderRecord;
|
||||
class GroupRecord;
|
||||
class LodRecord;
|
||||
class OldLodRecord;
|
||||
class DofRecord;
|
||||
class ObjectRecord;
|
||||
class FaceRecord;
|
||||
class MeshRecord;
|
||||
class MeshPrimitiveRecord;
|
||||
class VertexListRecord;
|
||||
class MorphVertexListRecord;
|
||||
class LightSourceRecord;
|
||||
class LightPointRecord;
|
||||
class LightPointIndexRecord;
|
||||
class LightPointSystemRecord;
|
||||
class SwitchRecord;
|
||||
class ExtensionRecord;
|
||||
class ExternalRecord;
|
||||
|
||||
// Ancillary records
|
||||
class CommentRecord;
|
||||
class LongIDRecord;
|
||||
class VectorRecord;
|
||||
class LocalVertexPoolRecord;
|
||||
class OldVertexRecord;
|
||||
class OldVertexColorRecord;
|
||||
class OldVertexColorNormalRecord;
|
||||
|
||||
// Transformation records (ancillary)
|
||||
class MatrixRecord;
|
||||
class RotatAboutEdgeRecord;
|
||||
class TranslateRecord;
|
||||
class ScaleRecord;
|
||||
class RotatAboutPointRecord;
|
||||
class RotatScaleToPointRecord;
|
||||
class PutTransformRecord;
|
||||
class GeneralMatrixRecord;
|
||||
|
||||
|
||||
/** Visitor for type safe operations on flt::Record's.
|
||||
Based on GOF's Visitor pattern.*/
|
||||
class RecordVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
enum TraversalMode {
|
||||
TRAVERSE_NONE,
|
||||
// TRAVERSE_PARENTS,
|
||||
TRAVERSE_ALL_CHILDREN,
|
||||
TRAVERSE_ACTIVE_CHILDREN,
|
||||
TRAVERSE_VISITOR
|
||||
};
|
||||
|
||||
RecordVisitor(TraversalMode tm=TRAVERSE_NONE);
|
||||
virtual ~RecordVisitor();
|
||||
|
||||
|
||||
/** Set the traversal mode for Node::traverse() to use when
|
||||
deciding which children of a node to traverse. If a
|
||||
NodeVisitor has been attached via setTraverseVisitor()
|
||||
and the new mode is not TRAVERSE_VISITOR then the attached
|
||||
visitor is detached. Default mode is TRAVERSE_NONE.*/
|
||||
void setTraverseMode(TraversalMode mode);
|
||||
/** Get the traversal mode.*/
|
||||
TraversalMode getTraverseMode() { return _traverseMode; }
|
||||
/** Set a visitor to handle traversal.
|
||||
Overides the traverse mode setting it to TRAVERSE_VISITOR.*/
|
||||
|
||||
void setTraverseVisitor(RecordVisitor* rv);
|
||||
/** Get the traverse visitor, returns NULL if none is attached.*/
|
||||
RecordVisitor* getTraverseVisitor() { return _traverseVisitor; }
|
||||
|
||||
/** Inline method for passing handling traversal of a nodes.
|
||||
If you intend to use the visitor for actively traversing
|
||||
the scene graph then make sure the accept() methods call
|
||||
this method unless they handle traversal directly.*/
|
||||
void traverse(Record& rec)
|
||||
{
|
||||
if (_traverseVisitor) rec.accept(*_traverseVisitor);
|
||||
// else if (_traverseMode==TRAVERSE_PARENTS) rec.ascend(*this);
|
||||
else if (_traverseMode!=TRAVERSE_NONE) rec.traverse(*this);
|
||||
}
|
||||
|
||||
virtual void apply(Record& rec) { traverse(rec);}
|
||||
virtual void apply(PrimNodeRecord& rec) { apply((Record&)rec);}
|
||||
|
||||
|
||||
// Palette records
|
||||
virtual void apply(ColorPaletteRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(MaterialPaletteRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(LightSourcePaletteRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(TexturePaletteRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(VertexPaletteRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(VertexRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(NormalVertexRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(TextureVertexRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(NormalTextureVertexRecord& rec) { apply((Record&)rec); }
|
||||
|
||||
// Primary records
|
||||
virtual void apply(HeaderRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(GroupRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LodRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(OldLodRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(DofRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(ObjectRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(FaceRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(MeshRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(MeshPrimitiveRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(VertexListRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(MorphVertexListRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightSourceRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightPointRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightPointIndexRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightPointSystemRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(SwitchRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(ExtensionRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(ExternalRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
|
||||
// Ancillary records
|
||||
virtual void apply(CommentRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(LongIDRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(VectorRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(LocalVertexPoolRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(OldVertexRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(OldVertexColorRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(OldVertexColorNormalRecord& rec) { apply((Record&)rec); }
|
||||
|
||||
// Transformation records (ancillary)
|
||||
virtual void apply(MatrixRecord& rec) { apply((Record&)rec); }
|
||||
/*
|
||||
virtual void apply(RotatAboutEdgeRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(TranslateRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(ScaleRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(RotatAboutPointRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(RotatScaleToPointRecord& rec) { apply((Record&)rec); }
|
||||
virtual void apply(PutTransformRecord& rec) { apply((Record&)rec); }
|
||||
*/
|
||||
virtual void apply(GeneralMatrixRecord& rec) { apply((Record&)rec); }
|
||||
|
||||
protected:
|
||||
|
||||
RecordVisitor* _traverseVisitor;
|
||||
TraversalMode _traverseMode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** Convinience functor for assisting visiting of arrays of flt::Records's.*/
|
||||
struct RecordAcceptOp
|
||||
{
|
||||
RecordVisitor& _rv;
|
||||
RecordAcceptOp(RecordVisitor& rv):_rv(rv) {}
|
||||
void operator () (Record* rec) { rec->accept(_rv); }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,93 +0,0 @@
|
||||
;
|
||||
// Modify Registry to store a flt::AttrData object instead of a osg::StateSet
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "Record.h"
|
||||
#include "Input.h"
|
||||
#include "FltFile.h"
|
||||
#include "AttrData.h"
|
||||
#include "Registry.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
Registry* Registry::instance()
|
||||
{
|
||||
static Registry s_nodeFactory;
|
||||
return &s_nodeFactory;
|
||||
}
|
||||
|
||||
|
||||
void Registry::addPrototype(Record* rec)
|
||||
{
|
||||
if (rec==0L) return;
|
||||
|
||||
osg::notify(osg::INFO) << "flt::Registry::addPrototype("<< rec->className()<<")\n";
|
||||
int op = rec->classOpcode();
|
||||
_recordProtoMap[op] = rec;
|
||||
}
|
||||
|
||||
|
||||
Record* Registry::getPrototype(const int opcode)
|
||||
{
|
||||
RecordProtoMap::iterator itr = _recordProtoMap.find(opcode);
|
||||
if (itr != _recordProtoMap.end()) {
|
||||
return (*itr).second.get();
|
||||
}
|
||||
osg::notify( osg::INFO )
|
||||
<< "flt::Registry::getPrototype: Unkown opcode: " << opcode << "\n";
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void Registry::addTexture(const std::string& name, AttrData* texture)
|
||||
{
|
||||
if (texture == NULL) return;
|
||||
_textureMap[name] = texture;
|
||||
}
|
||||
|
||||
|
||||
AttrData* Registry::getTexture(const std::string name)
|
||||
{
|
||||
TextureMap::iterator itr = _textureMap.find(name);
|
||||
if (itr != _textureMap.end())
|
||||
return (*itr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void Registry::addFltFile(const std::string& name, FltFile* file)
|
||||
{
|
||||
if (file == NULL) return;
|
||||
_fltFileMap[name] = file;
|
||||
}
|
||||
|
||||
|
||||
FltFile* Registry::getFltFile(const std::string& name)
|
||||
{
|
||||
FltFileMap::iterator itr = _fltFileMap.find(name);
|
||||
if (itr != _fltFileMap.end())
|
||||
return (*itr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Registry::clearObjectCache()
|
||||
{
|
||||
_textureMap.clear();
|
||||
_fltFileMap.clear();
|
||||
|
||||
_recordForFutureDeleteList.clear();
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
// Modify Registry to store a flt::AttrData object instead of a osg::StateSet
|
||||
// Julian Ortiz, June 18th 2003.
|
||||
|
||||
#ifndef __FLT_REGISTRY_H
|
||||
#define __FLT_REGISTRY_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include "FltFile.h"
|
||||
#include "AttrData.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace flt {
|
||||
|
||||
// forward declare referenced classes to help avoid mutiple includes
|
||||
class Record;
|
||||
class Input;
|
||||
|
||||
/**
|
||||
Registry is a singleton factory which stores
|
||||
the Objects types available at runtime for loading,
|
||||
and any Object reader or writers which are linked in
|
||||
at runtime for reading non-native file formats.
|
||||
|
||||
The RegisterObjectProxy defined in Object.h can be
|
||||
used to automatically register at runtime a Object
|
||||
with the Registry.
|
||||
|
||||
The RegisterReaderWriterProxy defined in ReaderWriter.h can
|
||||
be used to automatically register at runtime a reader/writer
|
||||
with the Registry.
|
||||
*/
|
||||
|
||||
class Registry
|
||||
{
|
||||
public:
|
||||
|
||||
~Registry() {}
|
||||
|
||||
static Registry* instance();
|
||||
|
||||
void addPrototype(Record* rec);
|
||||
Record* getPrototype(const int opcode);
|
||||
|
||||
//void addTexture(const std::string& name, osg::StateSet* texture);
|
||||
void addTexture(const std::string& name, AttrData* texture);
|
||||
//osg::StateSet* getTexture(const std::string name);
|
||||
AttrData * getTexture(const std::string name);
|
||||
|
||||
void addFltFile(const std::string& name, FltFile* file);
|
||||
FltFile* getFltFile(const std::string& name);
|
||||
|
||||
void clearObjectCache();
|
||||
|
||||
void addRecordForFutureDelete(Record* rec) { _recordForFutureDeleteList.push_back(rec); }
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<int, osg::ref_ptr<Record> > RecordProtoMap;
|
||||
//typedef std::map<std::string, osg::ref_ptr<osg::StateSet> > TextureMap;
|
||||
typedef std::map<std::string, osg::ref_ptr<AttrData> > TextureMap;
|
||||
typedef std::map<std::string, osg::ref_ptr<FltFile> > FltFileMap;
|
||||
|
||||
typedef std::vector<osg::ref_ptr<Record> > RecordsForFutureDeleteList;
|
||||
|
||||
/** constructor is private, as its a singleton, preventing
|
||||
construction other than via the instance() method and
|
||||
therefore ensuring only one copy is ever constructed*/
|
||||
Registry() {}
|
||||
|
||||
RecordProtoMap _recordProtoMap;
|
||||
TextureMap _textureMap;
|
||||
FltFileMap _fltFileMap;
|
||||
|
||||
RecordsForFutureDeleteList _recordForFutureDeleteList;
|
||||
};
|
||||
|
||||
|
||||
/** Proxy class for automatic registration of reader/writers with the
|
||||
Registry.*/
|
||||
template<class T>
|
||||
class RegisterRecordProxy
|
||||
{
|
||||
public:
|
||||
|
||||
RegisterRecordProxy()
|
||||
{
|
||||
if (Registry::instance())
|
||||
{
|
||||
_obj = new T;
|
||||
Registry::instance()->addPrototype(_obj.get());
|
||||
}
|
||||
}
|
||||
|
||||
~RegisterRecordProxy() {}
|
||||
|
||||
protected:
|
||||
|
||||
osg::ref_ptr<T> _obj;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_REGISTRY_H
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// RoadRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "RoadRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadSegmentRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RoadSegmentRecord> g_RoadSegmentProxy;
|
||||
|
||||
RoadSegmentRecord::RoadSegmentRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RoadSegmentRecord::~RoadSegmentRecord()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadConstructionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RoadConstructionRecord> g_RoadConstructionProxy;
|
||||
|
||||
RoadConstructionRecord::RoadConstructionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RoadConstructionRecord::~RoadConstructionRecord()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadPathRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RoadPathRecord> g_RoadPathProxy;
|
||||
|
||||
RoadPathRecord::RoadPathRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RoadPathRecord::~RoadPathRecord()
|
||||
{
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
// RoadRecords.h
|
||||
|
||||
#ifndef __FLT_ROAD_RECORDS_H
|
||||
#define __FLT_ROAD_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadSegmentRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RoadSegmentRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
RoadSegmentRecord();
|
||||
virtual ~RoadSegmentRecord();
|
||||
|
||||
virtual Record* clone() const { return new RoadSegmentRecord(); }
|
||||
virtual const char* className() const { return "RoadSegmentRecord"; }
|
||||
virtual int classOpcode() const { return ROAD_SEGMENT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadConstructionRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RoadConstructionRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
RoadConstructionRecord();
|
||||
virtual ~RoadConstructionRecord();
|
||||
|
||||
virtual Record* clone() const { return new RoadConstructionRecord(); }
|
||||
virtual const char* className() const { return "RoadConstructionRecord"; }
|
||||
virtual int classOpcode() const { return ROAD_CONSTRUCTION_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RoadPathRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RoadPathRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
RoadPathRecord();
|
||||
virtual ~RoadPathRecord();
|
||||
|
||||
virtual Record* clone() const { return new RoadPathRecord(); }
|
||||
virtual const char* className() const { return "RoadPathRecord"; }
|
||||
virtual int classOpcode() const { return ROAD_PATH_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Note: RoadZoneRecord is an ancillary record, so it is left undefined to
|
||||
// be treated as an unknown (ancillary) record, just like the
|
||||
// eyepoint trackplane record or the translate, scale, and rotate
|
||||
// records, whose contents are not interpreted.
|
||||
// The above three types of records are basically treated like
|
||||
// unknown records except that they are primary records and can have
|
||||
// substructures under them.
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_ROAD_RECORDS_H
|
||||
@@ -1,40 +0,0 @@
|
||||
// SwitchRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "SwitchRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SwitchRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<SwitchRecord> g_fltSwitchProxy;
|
||||
|
||||
SwitchRecord::SwitchRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
SwitchRecord::~SwitchRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SwitchRecord::endian()
|
||||
{
|
||||
SSwitch *pSSwitch = (SSwitch*)getData();
|
||||
|
||||
ENDIAN( pSSwitch->nCurrentMask );
|
||||
ENDIAN( pSSwitch->nMasks );
|
||||
ENDIAN( pSSwitch->nWordsInMask );
|
||||
|
||||
for (int m=0; m < pSSwitch->nMasks*pSSwitch->nWordsInMask; m++)
|
||||
{
|
||||
ENDIAN( pSSwitch->aMask[m] );
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// SwitchRecord.h
|
||||
|
||||
#ifndef __FLT_SWITCH_RECORD_H
|
||||
#define __FLT_SWITCH_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SSwitch
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
uint8 reserved[4]; // Reserved
|
||||
uint32 nCurrentMask; // Current mask
|
||||
int32 nMasks; // Number of masks
|
||||
int32 nWordsInMask; // Number of 32 bit words required for each mask
|
||||
// (number of children / 32 + number of children modulo 32)
|
||||
uint32 aMask[1]; // Variable Mask words
|
||||
// (length = number of words per mask * number of masks * 4 bytes)
|
||||
};
|
||||
|
||||
|
||||
|
||||
class SwitchRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
SwitchRecord();
|
||||
|
||||
virtual Record* clone() const { return new SwitchRecord(); }
|
||||
virtual const char* className() const { return "SwitchRecord"; }
|
||||
virtual int classOpcode() const { return SWITCH_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SSwitch); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
SSwitch* getData() const { return (SSwitch*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~SwitchRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// TextureMappingPaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "TextureMappingPaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TextureMappingPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<TextureMappingPaletteRecord> g_TextureMappingPaletteProxy;
|
||||
|
||||
TextureMappingPaletteRecord::TextureMappingPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
TextureMappingPaletteRecord::~TextureMappingPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void TextureMappingPaletteRecord::endian()
|
||||
{
|
||||
STextureMapping *pSMapping = (STextureMapping*)getData();
|
||||
|
||||
if (pSMapping)
|
||||
{
|
||||
ENDIAN( pSMapping->diIndex );
|
||||
ENDIAN( pSMapping->diType );
|
||||
ENDIAN( pSMapping->diWarpFlag );
|
||||
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
ENDIAN( pSMapping->dfMat[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
// TextureMappingPaletteRecord.h
|
||||
|
||||
#ifndef __FLT_TEXTURE_MAPPING_PALETTE_RECORD_H
|
||||
#define __FLT_TEXTURE_MAPPING_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct STextureMapping
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
float32 reserved; // Reserved
|
||||
int32 diIndex; // Texture mapping index
|
||||
char szName[20]; // Texture mapping name
|
||||
int32 diType; // Texture mapping type
|
||||
// 0 = None
|
||||
// 1 = Put
|
||||
// 2 = 4 Point Put
|
||||
// 3 = Reserved
|
||||
// 4 = Spherical Project
|
||||
// 5 = Radial Project
|
||||
// 6 = Reserved
|
||||
int32 diWarpFlag; // Warped flag; if TRUE, 8 point warp applied
|
||||
float64 dfMat[4][4]; // Transformation matrix (valid only for Types 1 & 2)
|
||||
// Variable Variable; // Parameters (see below for parameters for each mapping type)
|
||||
};
|
||||
|
||||
|
||||
// Parameters for Put Texture Mapping (Type 1)
|
||||
struct SPutTextureMapping
|
||||
{
|
||||
uint32 dwState; // State of Put Texture tool
|
||||
// 0 = Start state - no points entered
|
||||
// 1 = One point entered
|
||||
// 2 = Two points entered
|
||||
// 3 = Three points entered
|
||||
int32 active; // Active geometry point
|
||||
// 1 = Origin point
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
float64x3 lower_left; // lower-left corner of bounding box
|
||||
float64x3 upper_right; // upper-right corner of bounding box
|
||||
int32 sizeFlags[3]; // Use real world size flags for each of the three put points
|
||||
float64x3 dfTxtOrigin; // Texture origin point
|
||||
float64x3 dfTxtAlignment; // Texture alignment point
|
||||
float64x3 dfTxtShear; // Texture shear point
|
||||
float64x3 dfGeoOrigin; // Geometry origin point
|
||||
float64x3 dfGeoAlignment; // Geometry alignment point
|
||||
float64x3 dfGeoShear; // Geometry shear point
|
||||
int32 TxtActive; // Active texture point
|
||||
// 1 = Origin point
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
int32 uvDisplayType; // v15.8 (1580) UV display type
|
||||
// 1 = XY
|
||||
// 2 = UV
|
||||
};
|
||||
|
||||
|
||||
//Parameters for 4 Point Put Texture Mapping (Type 2)
|
||||
struct SPointPutTextureMapping
|
||||
{
|
||||
int32 state; // State of Put Texture tool
|
||||
// 0 = Start state - no points entered
|
||||
// 1 = One point entered
|
||||
// 2 = Two points entered
|
||||
// 3 = Three points entered
|
||||
// 4 = Four points entered
|
||||
int32 active; // Active geometry point
|
||||
// 1 = Origin point
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
// 4 = Perspective point
|
||||
float64x3 lower_left; // lower-left corner of bounding box
|
||||
float64x3 upper_right; // upper-right corner of bounding box
|
||||
int32 sizeFlags[4]; // Use real world size flags for each of the four put points
|
||||
float64x3 dfTxtOrigin; // Texture origin point
|
||||
float64x3 dfTxtAlignment; // Texture alignment point
|
||||
float64x3 dfTxtShear; // Texture shear point
|
||||
float64x3 dfTxtPerspective; // Texture perspective point
|
||||
float64x3 dfGeoOrigin; // Geometry origin point
|
||||
float64x3 dfGeoAlignment; // Geometry alignment point
|
||||
float64x3 dfGeoShear; // Geometry shear point
|
||||
float64x3 dfGeoPerspective; // Geometry perspective point
|
||||
|
||||
int32 TxtActive; // Active texture point
|
||||
// 1 = Origin point
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
// 4 = Perspective point
|
||||
int32 uvDisplayType; // v15.8 (1580) UV display type
|
||||
// 1 = XY
|
||||
// 2 = UV
|
||||
float32 sfScale; // Depth scale factor
|
||||
int32 reserved_0; // New for 15.8
|
||||
float64 dfMat[4][4]; // Transformation matrix for the 4 point projection plane
|
||||
float32 sfURep; // U repetition
|
||||
float32 sfVRep; // V repetition
|
||||
};
|
||||
|
||||
|
||||
// Parameters for Spherical Project Mapping (Type 4)
|
||||
struct SSphericalTextureMapping
|
||||
{
|
||||
float32 sfScale; // Scale
|
||||
float64x3 Center; // Center of the projection sphere
|
||||
float32 sfMaxScale; // Scale / (maximum dimension of the mapped geometry
|
||||
// bounding box)
|
||||
float32 sfMaxDimension; // Maximum dimension of the mapped geometry
|
||||
// bounding box
|
||||
};
|
||||
|
||||
|
||||
// Parameters for Radial Project Mapping (Type 5)
|
||||
struct SRadialTextureMapping
|
||||
{
|
||||
int32 active; // Active geometry point
|
||||
// 1 = End point 1 of cylinder center line
|
||||
// 2 = End point 2 of cylinder center line
|
||||
int32 reserved; // Reserved
|
||||
float32 sfRadialScale; // Radial scale
|
||||
float32 sfLengthScale; // Scale along length of cylinder
|
||||
float64 dfMat[4][4]; // Trackplane to XY plane transformation matrix
|
||||
float64x3 endpoint1; // End point 1 of cylinder center line
|
||||
float64x3 endpoint2; // End point 2 of cylinder center line
|
||||
};
|
||||
|
||||
// Parameters for Warped Mapping (Warped Flag Set)
|
||||
struct SWarpedTextureMapping
|
||||
{
|
||||
int32 active; // Active geometry point
|
||||
// 0 = First warp FROM point
|
||||
// 1 = Second warp FROM point
|
||||
// 2 =Third warp FROM point
|
||||
// 3 = Fourth warp FROM point
|
||||
// 4 = Fifth warp FROM point
|
||||
// 5 = Sixth warp FROM point
|
||||
// 6 = Seventh warp FROM point
|
||||
// 7 = Eighth warp FROM point
|
||||
// 8 = First warp TO point
|
||||
// 9 = Second warp TO point
|
||||
// 10 = Third warp TO point
|
||||
// 11 = Fourth warp TO point
|
||||
// 12 = Fifth warp TO point
|
||||
// 13 = Sixth warp TO point
|
||||
// 14 = Seventh warp TO point
|
||||
// 15 = Eighth warp TO point
|
||||
int32 warpState; // Warp tool state
|
||||
// 0 = Start state - no points entered
|
||||
// 1 = One FROM point entered
|
||||
// 2 = Two FROM point entered
|
||||
// 3 = Three FROM point entered
|
||||
// 4 = Four FROM point entered
|
||||
// 5 = Five FROM point entered
|
||||
// 6 = Six FROM point entered
|
||||
// 7 = Seven FROM point entered
|
||||
// 8 = All FROM point entered
|
||||
float64 dfMat[4][4]; // Trackplane to XY plane transformation matrix
|
||||
/*
|
||||
Double 16*2 x, y of the first FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the second FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the third FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the fourth FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the fifth FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the sixth FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the seventh FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the eighth FROM point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the first TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the second TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the third TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the fourth TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the fifth TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the sixth TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the seventh TO point transformed to the XY plane by the above matrix
|
||||
Double 16*2 x, y of the eighth TO point transformed to the XY plane by the above matrix
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TextureMappingPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
TextureMappingPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new TextureMappingPaletteRecord(); }
|
||||
virtual const char* className() const { return "TextureMappingPaletteRecord"; }
|
||||
virtual int classOpcode() const { return TEXTURE_MAPPING_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(STextureMapping); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TextureMappingPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
|
||||
// virtual bool readLocalData(Input& fr);
|
||||
// virtual bool writeLocalData(Output& fw);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
// TexturePaletteRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "TexturePaletteRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TexturePaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<TexturePaletteRecord> g_TexturePaletteProxy;
|
||||
|
||||
TexturePaletteRecord::TexturePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
TexturePaletteRecord::~TexturePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void TexturePaletteRecord::endian()
|
||||
{
|
||||
|
||||
int flightVersion = getFlightVersion();
|
||||
|
||||
if (flightVersion > 13)
|
||||
{
|
||||
STexturePalette *pSTexture = (STexturePalette*)getData();
|
||||
|
||||
ENDIAN( pSTexture->diIndex );
|
||||
ENDIAN( pSTexture->diX );
|
||||
ENDIAN( pSTexture->diY );
|
||||
}
|
||||
else // version 11, 12 & 13
|
||||
{
|
||||
SOldTexturePalette *pSOldTexture = (SOldTexturePalette*)getData();
|
||||
|
||||
ENDIAN( pSOldTexture->diIndex );
|
||||
ENDIAN( pSOldTexture->diX );
|
||||
ENDIAN( pSOldTexture->diY );
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// TexturePaletteRecord.h
|
||||
|
||||
#ifndef __FLT_TEXTURE_PALETTE_RECORD_H
|
||||
#define __FLT_TEXTURE_PALETTE_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct STexturePalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szFilename[200]; // Filename of texture pattern
|
||||
int32 diIndex; // Pattern index
|
||||
int32 diX; // x location in texture palette
|
||||
int32 diY; // y location in texture palette
|
||||
};
|
||||
|
||||
|
||||
// Version 10, 12, 13
|
||||
struct SOldTexturePalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szFilename[80]; // Filename of texture pattern
|
||||
int32 diIndex; // Pattern index
|
||||
int32 diX; // x location in texture palette
|
||||
int32 diY; // y location in texture palette
|
||||
};
|
||||
|
||||
|
||||
class TexturePaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
TexturePaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new TexturePaletteRecord(); }
|
||||
virtual const char* className() const { return "TexturePaletteRecord"; }
|
||||
virtual int classOpcode() const { return TEXTURE_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(STexturePalette); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TexturePaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
// TransformationRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "TransformationRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MatrixRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<MatrixRecord> g_MatrixProxy;
|
||||
|
||||
MatrixRecord::MatrixRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
MatrixRecord::~MatrixRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void MatrixRecord::endian()
|
||||
{
|
||||
SMatrix* pSMatrix = (SMatrix*)getData();
|
||||
|
||||
if (pSMatrix)
|
||||
{
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
ENDIAN( pSMatrix->sfMat[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TranslateRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<TranslateRecord> g_TranslateProxy;
|
||||
|
||||
TranslateRecord::TranslateRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
TranslateRecord::~TranslateRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void TranslateRecord::endian()
|
||||
{
|
||||
STranslate *pSTranslate = (STranslate*)getData() ;
|
||||
if ( pSTranslate)
|
||||
{
|
||||
pSTranslate->From.endian() ;
|
||||
pSTranslate->Delta.endian() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatAboutEdgeRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RotatAboutEdgeRecord> g_RotatAboutEdgeProxy;
|
||||
|
||||
RotatAboutEdgeRecord::RotatAboutEdgeRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RotatAboutEdgeRecord::~RotatAboutEdgeRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void RotatAboutEdgeRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ScaleRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<ScaleRecord> g_ScaleProxy;
|
||||
|
||||
ScaleRecord::ScaleRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
ScaleRecord::~ScaleRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void ScaleRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatAboutPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RotatAboutPointRecord> g_RotatAboutPointProxy;
|
||||
|
||||
RotatAboutPointRecord::RotatAboutPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RotatAboutPointRecord::~RotatAboutPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void RotatAboutPointRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatScaleToPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<RotatScaleToPointRecord> g_RotatScaleToPointProxy;
|
||||
|
||||
RotatScaleToPointRecord::RotatScaleToPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
RotatScaleToPointRecord::~RotatScaleToPointRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void RotatScaleToPointRecord::endian()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PutTransformRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<PutTransformRecord> g_PutTransformProxy;
|
||||
|
||||
PutTransformRecord::PutTransformRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
PutTransformRecord::~PutTransformRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void PutTransformRecord::endian()
|
||||
{
|
||||
SPutTransform *pSPutTransform = (SPutTransform*)getData();
|
||||
|
||||
ENDIAN( pSPutTransform->tmp1 );
|
||||
pSPutTransform->FromOrigin.endian();
|
||||
pSPutTransform->FromAlign.endian();
|
||||
pSPutTransform->FromTrack.endian();
|
||||
pSPutTransform->ToOrigin.endian();
|
||||
pSPutTransform->ToAlign.endian();
|
||||
pSPutTransform->ToTrack.endian();
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GeneralMatrixRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<GeneralMatrixRecord> g_GeneralMatrixProxy;
|
||||
|
||||
GeneralMatrixRecord::GeneralMatrixRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
GeneralMatrixRecord::~GeneralMatrixRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void GeneralMatrixRecord::endian()
|
||||
{
|
||||
SGeneralMatrix* pSMatrix = (SGeneralMatrix*)getData();
|
||||
|
||||
if (pSMatrix)
|
||||
{
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
ENDIAN( pSMatrix->sfMat[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
// TransformationRecords.h
|
||||
|
||||
#ifndef __FLT_TRANSFORMATION_RECORDS_H
|
||||
#define __FLT_TRANSFORMATION_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MatrixRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct MatrixTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
float32 sfMat[4][4]; // 4x4 Single Precision Matrix
|
||||
} SMatrix; // row major order
|
||||
|
||||
|
||||
class MatrixRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
MatrixRecord();
|
||||
|
||||
virtual Record* clone() const { return new MatrixRecord(); }
|
||||
virtual const char* className() const { return "MatrixRecord"; }
|
||||
virtual int classOpcode() const { return MATRIX_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SMatrix); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SMatrix* getData() const { return (SMatrix*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~MatrixRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TranslateRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct TranslateTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diReserved;
|
||||
float64x3 From; // reference FROM point
|
||||
float64x3 Delta; // Delta to translate node by
|
||||
} STranslate;
|
||||
|
||||
|
||||
class TranslateRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
TranslateRecord();
|
||||
|
||||
virtual Record* clone() const { return new TranslateRecord(); }
|
||||
virtual const char* className() const { return "TranslateRecord"; }
|
||||
virtual int classOpcode() const { return TRANSLATE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(STranslate); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual STranslate* getData() const { return (STranslate*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~TranslateRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
#if 0
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatAboutEdgeRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct RotatAboutEdgeTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diReserved;
|
||||
float64x3 Point1; // first point on edge
|
||||
float64x3 Point2; // second point on edge
|
||||
float32 sfAngle; // Angle by which to rotate
|
||||
} SRotatAboutEdge;
|
||||
|
||||
|
||||
class RotatAboutEdgeRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
RotatAboutEdgeRecord();
|
||||
|
||||
virtual Record* clone() const { return new RotatAboutEdgeRecord(); }
|
||||
virtual const char* className() const { return "RotatAboutEdgeRecord"; }
|
||||
virtual int classOpcode() const { return ROTATE_ABOUT_EDGE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SRotatAboutEdge); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SRotatAboutEdge* getData() const { return (SRotatAboutEdge*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~RotatAboutEdgeRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OldTranslateRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SOldTranslate
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diReserved;
|
||||
float64x3 From; // reference FROM point
|
||||
float64x3 Delta; // Delta to translate node by
|
||||
};
|
||||
|
||||
|
||||
class OldTranslateRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
OldTranslateRecord();
|
||||
|
||||
virtual Record* clone() const { return new OldTranslateRecord(); }
|
||||
virtual const char* className() const { return "OldTranslateRecord"; }
|
||||
virtual int classOpcode() const { return OLD_TRANSLATE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SOldTranslate); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SOldTranslate* getData() const { return (SOldTranslate*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~OldTranslateRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ScaleRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SScale
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 Reserved;
|
||||
float64x3 center;
|
||||
float32x3 scale;
|
||||
};
|
||||
|
||||
class ScaleRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
ScaleRecord();
|
||||
|
||||
virtual Record* clone() const { return new ScaleRecord(); }
|
||||
virtual const char* className() const { return "ScaleRecord"; }
|
||||
virtual int classOpcode() const { return SCALE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SScale); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
// virtual SGroup* getData() const { return (SGroup*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~ScaleRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatAboutPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct RotatAboutPointTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
// TODO
|
||||
} SRotatAboutPoint;
|
||||
|
||||
class RotatAboutPointRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
RotatAboutPointRecord();
|
||||
|
||||
virtual Record* clone() const { return new RotatAboutPointRecord(); }
|
||||
virtual const char* className() const { return "RotatAboutPointRecord"; }
|
||||
virtual int classOpcode() const { return ROTATE_ABOUT_POINT_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SRotatAboutPoint); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
// virtual SGroup* getData() const { return (SGroup*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~RotatAboutPointRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RotatScaleToPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct RotatScaleToPointTag
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
// TODO
|
||||
} SRotatScaleToPoint;
|
||||
|
||||
class RotatScaleToPointRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
RotatScaleToPointRecord();
|
||||
|
||||
virtual Record* clone() const { return new RotatScaleToPointRecord(); }
|
||||
virtual const char* className() const { return "RotatScaleToPointRecord"; }
|
||||
virtual int classOpcode() const { return ROTATE_SCALE_TO_POINT_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SRotatScaleToPoint); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
// virtual SGroup* getData() const { return (SGroup*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~RotatScaleToPointRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PutTransformRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct PutTransformTag //follows normally a matrix record to
|
||||
{ //make up the transformation
|
||||
SRecHeader RecHeader;
|
||||
int32 tmp1; //mismatch with spec!
|
||||
float64x3 FromOrigin;
|
||||
float64x3 FromAlign;
|
||||
float64x3 FromTrack;
|
||||
float64x3 ToOrigin; //mismatch !!
|
||||
float64x3 ToAlign;
|
||||
float64x3 ToTrack;
|
||||
} SPutTransform;
|
||||
|
||||
|
||||
class PutTransformRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
PutTransformRecord();
|
||||
|
||||
virtual Record* clone() const { return new PutTransformRecord(); }
|
||||
virtual const char* className() const { return "PutTransformRecord"; }
|
||||
virtual int classOpcode() const { return PUT_TRANSFORM_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SPutTransform); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SPutTransform* getData() const { return (SPutTransform*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~PutTransformRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GeneralMatrixRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SGeneralMatrix
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
float32 sfMat[4][4]; // 4x4 Single Precision Matrix
|
||||
}; // row major order
|
||||
|
||||
|
||||
class GeneralMatrixRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
GeneralMatrixRecord();
|
||||
|
||||
virtual Record* clone() const { return new GeneralMatrixRecord(); }
|
||||
virtual const char* className() const { return "GeneralMatrixRecord"; }
|
||||
virtual int classOpcode() const { return GENERAL_MATRIX_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SGeneralMatrix); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SGeneralMatrix* getData() const { return (SGeneralMatrix*)_pData; }
|
||||
// virtual SGroup* getData() const { return (SGroup*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~GeneralMatrixRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_TRANSFORMATION_RECORDS_H
|
||||
@@ -1,36 +0,0 @@
|
||||
// UVListRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "UVListRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UVListRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<UVListRecord> g_UVListProxy;
|
||||
|
||||
UVListRecord::UVListRecord()
|
||||
{
|
||||
CERR << "UVListRecord created\n";
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
UVListRecord::~UVListRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void UVListRecord::endian()
|
||||
{
|
||||
|
||||
SUVList *pSUVList = (SUVList*)getData();
|
||||
|
||||
ENDIAN( pSUVList->layers );
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// UVListRecord.h
|
||||
|
||||
#ifndef __FLT_UV_LIST_RECORD_H
|
||||
#define __FLT_UV_LIST_RECORD_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
struct SVertexUV {
|
||||
float32x2 coords;
|
||||
void endian() {
|
||||
ENDIAN( coords );
|
||||
};
|
||||
};
|
||||
|
||||
struct SMorphUV {
|
||||
float32x2 coords0;
|
||||
float32x2 coords100;
|
||||
void endian() {
|
||||
ENDIAN( coords0 );
|
||||
ENDIAN( coords100 );
|
||||
};
|
||||
};
|
||||
|
||||
struct SUVList
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint32 layers;
|
||||
|
||||
union {
|
||||
SVertexUV vertex[1];
|
||||
SMorphUV morph[1];
|
||||
} coords;
|
||||
};
|
||||
|
||||
class UVListRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
UVListRecord();
|
||||
|
||||
virtual Record* clone() const { return new UVListRecord(); }
|
||||
virtual const char* className() const { return "UVListRecord"; }
|
||||
virtual int classOpcode() const { return UV_LIST_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SUVList); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~UVListRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// UnknownRecord.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "UnknownRecord.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UnknownRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<UnknownRecord> g_UnknownProxy;
|
||||
|
||||
UnknownRecord::UnknownRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
UnknownRecord::~UnknownRecord()
|
||||
{
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// UnknownRecord.h
|
||||
|
||||
#ifndef __FLT_UNKNOWN_RECORD_H
|
||||
#define __FLT_UNKNOWN_RECORD_H
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class UnknownRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
UnknownRecord();
|
||||
virtual ~UnknownRecord();
|
||||
|
||||
virtual Record* clone() const { return new UnknownRecord(); }
|
||||
virtual const char* className() const { return "UnknownRecord"; }
|
||||
virtual int classOpcode() const { return 0; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
// VertexPoolRecords.cpp
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "VertexPoolRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<VertexPaletteRecord> g_VertexPaletteProxy;
|
||||
|
||||
VertexPaletteRecord::VertexPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
VertexPaletteRecord::~VertexPaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void VertexPaletteRecord::endian()
|
||||
{
|
||||
SVertexTableHeader *pVertexTableHeader = (SVertexTableHeader*)getData();
|
||||
|
||||
ENDIAN( pVertexTableHeader->diVertexTableLength );
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const VertexPaletteRecord& rec)
|
||||
{
|
||||
output << rec.className();
|
||||
return output; // to enable cascading
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<VertexRecord> g_VertexProxy;
|
||||
|
||||
VertexRecord::VertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
VertexRecord::~VertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void VertexRecord::endian()
|
||||
{
|
||||
SVertex *pVertex = (SVertex*)getData();
|
||||
|
||||
ENDIAN( pVertex->swColor );
|
||||
ENDIAN( pVertex->swFlags );
|
||||
pVertex->Coord.endian();
|
||||
ENDIAN( pVertex->dwVertexColorIndex );
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const VertexRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NormalVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<NormalVertexRecord> g_NormalVertexProxy;
|
||||
|
||||
NormalVertexRecord::NormalVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
NormalVertexRecord::~NormalVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void NormalVertexRecord::endian()
|
||||
{
|
||||
SNormalVertex *pVertex = (SNormalVertex*)getData();
|
||||
|
||||
ENDIAN( pVertex->swColor );
|
||||
ENDIAN( pVertex->swFlags );
|
||||
pVertex->Coord.endian();
|
||||
pVertex->Normal.endian();
|
||||
// ENDIAN( pVertex->PackedColor );
|
||||
ENDIAN( pVertex->dwVertexColorIndex );
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const NormalVertexRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TextureVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<TextureVertexRecord> g_TextureVertexProxy;
|
||||
|
||||
TextureVertexRecord::TextureVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
TextureVertexRecord::~TextureVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void TextureVertexRecord::endian()
|
||||
{
|
||||
STextureVertex *pVertex = (STextureVertex*)getData();
|
||||
|
||||
ENDIAN( pVertex->swColor );
|
||||
ENDIAN( pVertex->swFlags );
|
||||
pVertex->Coord.endian();
|
||||
pVertex->Texture.endian();
|
||||
// ENDIAN( pVertex->PackedColor );
|
||||
ENDIAN( pVertex->dwVertexColorIndex );
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const TextureVertexRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NormalTextureVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<NormalTextureVertexRecord> g_NormalTextureVertexProxy;
|
||||
|
||||
NormalTextureVertexRecord::NormalTextureVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
NormalTextureVertexRecord::~NormalTextureVertexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void NormalTextureVertexRecord::endian()
|
||||
{
|
||||
SNormalTextureVertex *pVertex = (SNormalTextureVertex*)getData();
|
||||
|
||||
ENDIAN( pVertex->swColor );
|
||||
ENDIAN( pVertex->swFlags );
|
||||
pVertex->Coord.endian();
|
||||
pVertex->Normal.endian();
|
||||
pVertex->Texture.endian();
|
||||
// ENDIAN( pVertex->PackedColor );
|
||||
ENDIAN( pVertex->dwVertexColorIndex );
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream& output, const NormalTextureVertexRecord& rec)
|
||||
{
|
||||
output << rec.className() << " "
|
||||
<< rec.getData()->swFlags << " "
|
||||
<< rec.getData()->Coord;
|
||||
return output; // to enable cascading
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
// VertexPoolRecords.h
|
||||
|
||||
#ifndef __FLT_VERTEX_POOL_RECORDS_H
|
||||
#define __FLT_VERTEX_POOL_RECORDS_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace flt {
|
||||
|
||||
#define V_HARD_EDGE_BIT BIT15
|
||||
#define V_NORMAL_FROZEN_BIT BIT14
|
||||
#define V_NO_COLOR_BIT BIT13
|
||||
#define V_PACKED_COLOR_BIT BIT12
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexPaletteRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct VertexTableHeaderTag //Vertex Palette Header record
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 diVertexTableLength; //Length of this record plus pool
|
||||
} SVertexTableHeader;
|
||||
|
||||
|
||||
|
||||
class VertexPaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
VertexPaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new VertexPaletteRecord(); }
|
||||
virtual const char* className() const { return "VertexPaletteRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SVertexTableHeader); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
friend std::ostream& operator << (std::ostream& output, const VertexPaletteRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~VertexPaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SVertex // Vertex with Color Record Format
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint16 swColor; // Color Name Index
|
||||
uint16 swFlags; // Flags (bits, from left to right)
|
||||
// 0 = Start Hard Edge
|
||||
// 1 = Normal frozen
|
||||
// 2 = no Vertex Color
|
||||
// 3 = Packed Color
|
||||
// 4-15 Spare
|
||||
float64x3 Coord; // x,y,z coordinate
|
||||
color32 PackedColor; // Packed color (A, B, G, R)
|
||||
uint32 dwVertexColorIndex;
|
||||
};
|
||||
|
||||
|
||||
class VertexRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
VertexRecord();
|
||||
virtual Record* clone() const { return new VertexRecord(); }
|
||||
virtual const char* className() const { return "VertexRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_C_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SVertex); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SVertex* getData() const { return (SVertex*)_pData; }
|
||||
friend std::ostream& operator << (std::ostream& output, const VertexRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~VertexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NormalVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct SNormalVertex // Vertex with Normal Record Format
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint16 swColor; // Color Name Index
|
||||
uint16 swFlags; // Flags (bits, from left to right)
|
||||
// 0 = Start Hard Edge
|
||||
// 1 = Normal frozen
|
||||
// 2 = no Vertex Color
|
||||
// 3 = Packed Color
|
||||
// 4-15 Spare
|
||||
float64x3 Coord; // x,y,z coordinate
|
||||
float32x3 Normal; // Vertex normal
|
||||
color32 PackedColor; // Packed color (A, B, G, R)
|
||||
uint32 dwVertexColorIndex;
|
||||
};
|
||||
|
||||
|
||||
class NormalVertexRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
NormalVertexRecord();
|
||||
virtual Record* clone() const { return new NormalVertexRecord(); }
|
||||
virtual const char* className() const { return "NormalVertexRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_CN_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SNormalVertex); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SNormalVertex* getData() const { return (SNormalVertex*)_pData; }
|
||||
friend std::ostream& operator << (std::ostream& output, const NormalVertexRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~NormalVertexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TextureVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct STextureVertex // Vertex with Texture Record Format
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint16 swColor; // Color Name Index
|
||||
uint16 swFlags; // Flags (bits, from left to right)
|
||||
// 0 = Start Hard Edge
|
||||
// 1 = Normal frozen
|
||||
// 2 = no Vertex Color
|
||||
// 3 = Packed Color
|
||||
// 4-15 Spare
|
||||
float64x3 Coord; // x,y,z coordinate
|
||||
float32x2 Texture; // Texture (u,v)
|
||||
color32 PackedColor; // Packed color (A, B, G, R)
|
||||
uint32 dwVertexColorIndex;
|
||||
};
|
||||
|
||||
|
||||
class TextureVertexRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
TextureVertexRecord();
|
||||
virtual Record* clone() const { return new TextureVertexRecord(); }
|
||||
virtual const char* className() const { return "TextureVertexRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_CT_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(STextureVertex); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual STextureVertex* getData() const { return (STextureVertex*)_pData; }
|
||||
friend std::ostream& operator << (std::ostream& output, const TextureVertexRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~TextureVertexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NormalTextureVertexRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SNormalTextureVertex //Vertex with Normal and Texture Format
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
uint16 swColor; // Color Name Index
|
||||
uint16 swFlags; // Flags (bits, from left to right)
|
||||
// 0 = Start Hard Edge
|
||||
// 1 = Normal frozen
|
||||
// 2 = no Vertex Color
|
||||
// 3 = Packed Color
|
||||
// 4-15 Spare
|
||||
float64x3 Coord; // x,y,z coordinate
|
||||
float32x3 Normal; // Vertex normal
|
||||
float32x2 Texture; // Texture (u,v)
|
||||
color32 PackedColor; // Packed color (A, B, G, R)
|
||||
uint32 dwVertexColorIndex;
|
||||
};
|
||||
|
||||
|
||||
class NormalTextureVertexRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
NormalTextureVertexRecord();
|
||||
virtual Record* clone() const { return new NormalTextureVertexRecord(); }
|
||||
virtual const char* className() const { return "NormalTextureVertexRecord"; }
|
||||
virtual int classOpcode() const { return VERTEX_CNT_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SNormalTextureVertex); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
virtual SNormalTextureVertex* getData() const { return (SNormalTextureVertex*)_pData; }
|
||||
friend std::ostream& operator << (std::ostream& output, const NormalTextureVertexRecord& rec);
|
||||
|
||||
protected:
|
||||
virtual ~NormalTextureVertexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_VERTEX_POOL_RECORDS_H
|
||||
@@ -1,44 +0,0 @@
|
||||
// flt.cpp
|
||||
|
||||
#include "flt.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
int flt::isLittleEndianMachine()
|
||||
{
|
||||
int a = 1;
|
||||
return (int)(*(char*)&a);
|
||||
}
|
||||
|
||||
|
||||
/*nDst*/
|
||||
void flt::endian2(void* pSrc, int nSrc, void* pDst, int )
|
||||
{
|
||||
if (nSrc == 2)
|
||||
{
|
||||
short tmp1;
|
||||
tmp1 = *(short *)pSrc;
|
||||
tmp1 = (tmp1 << 8) | ((tmp1 >> 8) & 0xff);
|
||||
*(short *)pDst = tmp1;
|
||||
}
|
||||
else if (nSrc == 4)
|
||||
{
|
||||
uint32 tmp1;
|
||||
tmp1 = *(uint32 *)pSrc;
|
||||
tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
|
||||
*(uint32 *)pDst = tmp1;
|
||||
}
|
||||
else if (nSrc == 8)
|
||||
{
|
||||
uint32 tmp1, tmp2;
|
||||
tmp1 = *(uint32 *)pSrc;
|
||||
tmp2 = *(1 + (uint32 *)pSrc);
|
||||
tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
|
||||
tmp2 = (tmp2 << 24) | ((tmp2 << 8) & 0xff0000) | ((tmp2 >> 8) & 0xff00) | ((tmp2 >> 24) & 0xff);
|
||||
*(uint32 *)pDst = tmp2;
|
||||
*(1 + (uint32 *)pDst) = tmp1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
|
||||
#ifndef __FLT_H
|
||||
#define __FLT_H
|
||||
|
||||
// include osg/Export simply for the Win32 #pragma to stop VisualStudio barffing
|
||||
// nonesense, other than that there is no need for it...
|
||||
#include <osg/Export>
|
||||
|
||||
#include <osg/Vec4>
|
||||
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <osg/Notify>
|
||||
#define CERR osg::notify( osg::INFO ) << __FILE__ << ":" << __LINE__ << ": "
|
||||
#define CERR2 osg::notify( osg::NOTICE )<< __FILE__ << ":" << __LINE__ << ": "
|
||||
|
||||
namespace flt {
|
||||
|
||||
#define ENDIAN2(SRC, DST) endian2((void*)&(SRC), sizeof(SRC), (void*)&(DST), sizeof(DST))
|
||||
#define ENDIAN(A) ENDIAN2((A), (A))
|
||||
|
||||
#define BIT0 0x0001
|
||||
#define BIT1 0x0002
|
||||
#define BIT2 0x0004
|
||||
#define BIT3 0x0008
|
||||
#define BIT4 0x0010
|
||||
#define BIT5 0x0020
|
||||
#define BIT6 0x0040
|
||||
#define BIT7 0x0080
|
||||
#define BIT8 0x0100
|
||||
#define BIT9 0x0200
|
||||
#define BIT10 0x0400
|
||||
#define BIT11 0x0800
|
||||
#define BIT12 0x1000
|
||||
#define BIT13 0x2000
|
||||
#define BIT14 0x4000
|
||||
#define BIT15 0x8000
|
||||
|
||||
#define BIT16 0x00010000
|
||||
#define BIT17 0x00020000
|
||||
#define BIT18 0x00040000
|
||||
#define BIT19 0x00080000
|
||||
#define BIT20 0x00100000
|
||||
#define BIT21 0x00200000
|
||||
#define BIT22 0x00400000
|
||||
#define BIT23 0x00800000
|
||||
#define BIT24 0x01000000
|
||||
#define BIT25 0x02000000
|
||||
#define BIT26 0x04000000
|
||||
#define BIT27 0x08000000
|
||||
#define BIT28 0x10000000
|
||||
#define BIT29 0x20000000
|
||||
#define BIT30 0x40000000
|
||||
#define BIT31 0x80000000
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef signed int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
extern int isLittleEndianMachine();
|
||||
extern void endian2( void* pSrc, int nSrc, void* pDst, int nDst );
|
||||
|
||||
|
||||
struct float32x2
|
||||
{
|
||||
float32 _v[2];
|
||||
|
||||
inline float32 x() { return _v[0]; }
|
||||
inline float32 y() { return _v[1]; }
|
||||
inline float32 operator [] (int i) { return _v[i]; }
|
||||
void endian() {
|
||||
ENDIAN( _v[0] );
|
||||
ENDIAN( _v[1] );
|
||||
}
|
||||
|
||||
friend inline std::ostream& operator << (std::ostream& output, const float32x2& f)
|
||||
{
|
||||
output << f._v[0] << " "
|
||||
<< f._v[1];
|
||||
return output; // to enable cascading
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct float32x3
|
||||
{
|
||||
float32 _v[3];
|
||||
inline float32 x() { return _v[0]; }
|
||||
inline float32 y() { return _v[1]; }
|
||||
inline float32 z() { return _v[2]; }
|
||||
inline float32 operator [] (int i) { return _v[i]; }
|
||||
void endian() {
|
||||
ENDIAN( _v[0] );
|
||||
ENDIAN( _v[1] );
|
||||
ENDIAN( _v[2] );
|
||||
}
|
||||
|
||||
friend inline std::ostream& operator << (std::ostream& output, const float32x3& f)
|
||||
{
|
||||
output << f._v[0] << " "
|
||||
<< f._v[1] << " "
|
||||
<< f._v[2];
|
||||
return output; // to enable cascading
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct float64x2
|
||||
{
|
||||
float64 _v[2];
|
||||
inline float64 x() { return _v[0]; }
|
||||
inline float64 y() { return _v[1]; }
|
||||
inline float64 operator [] (int i) { return _v[i]; }
|
||||
void endian() {
|
||||
ENDIAN( _v[0] );
|
||||
ENDIAN( _v[1] );
|
||||
}
|
||||
|
||||
friend inline std::ostream& operator << (std::ostream& output, const float64x2& f)
|
||||
{
|
||||
output << f._v[0] << " "
|
||||
<< f._v[1];
|
||||
return output; // to enable cascading
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct float64x3
|
||||
{
|
||||
float64 _v[3];
|
||||
|
||||
inline float64 x() { return _v[0]; }
|
||||
inline float64 y() { return _v[1]; }
|
||||
inline float64 z() { return _v[2]; }
|
||||
inline float64 operator [] (int i) { return _v[i]; }
|
||||
void endian() {
|
||||
ENDIAN( _v[0] );
|
||||
ENDIAN( _v[1] );
|
||||
ENDIAN( _v[2] );
|
||||
}
|
||||
|
||||
friend inline std::ostream& operator << (std::ostream& output, const float64x3& f)
|
||||
{
|
||||
output << f._v[0] << " "
|
||||
<< f._v[1] << " "
|
||||
<< f._v[2];
|
||||
return output; // to enable cascading
|
||||
}
|
||||
};
|
||||
|
||||
struct color32
|
||||
{
|
||||
uint8 _alpha;
|
||||
uint8 _blue;
|
||||
uint8 _green;
|
||||
uint8 _red;
|
||||
|
||||
inline float red() { return (float)_red/255; }
|
||||
inline float green() { return (float)_green/255; }
|
||||
inline float blue() { return (float)_blue/255; }
|
||||
inline float alpha() { return (float)_alpha/255; }
|
||||
inline osg::Vec4 get()
|
||||
{ return osg::Vec4( red(), green(), blue(), alpha()); }
|
||||
};
|
||||
|
||||
|
||||
struct color48 // version 11, 12 & 13
|
||||
{
|
||||
uint16 _red;
|
||||
uint16 _green;
|
||||
uint16 _blue;
|
||||
|
||||
inline float red() { return (float)_red/255; }
|
||||
inline float green() { return (float)_green/255; }
|
||||
inline float blue() { return (float)_blue/255; }
|
||||
inline osg::Vec4 get()
|
||||
{ return osg::Vec4( red(), green(), blue(), 1); }
|
||||
};
|
||||
|
||||
struct SRecHeader
|
||||
{
|
||||
uint16 _wOpcode; // identifies record type
|
||||
uint16 _wLength; // total length of record
|
||||
|
||||
inline int opcode() { return (int)_wOpcode; }
|
||||
inline size_t length() { return (size_t)_wLength; }
|
||||
void endian() {
|
||||
ENDIAN( _wOpcode );
|
||||
ENDIAN( _wLength );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Perform a byte swap.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class PointerType> inline void swapBytes ( const size_t &numBytes, PointerType *pointer )
|
||||
{
|
||||
assert ( numBytes >= 2 );
|
||||
assert ( pointer );
|
||||
flt::endian2 ( (void *) pointer, numBytes, (void *) pointer, numBytes );
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Perform a byte swap on all elements in the array.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class PointerType, class IndexType> inline void swapBytesArray ( const size_t &numBytes, const IndexType &numElements, PointerType *pointer )
|
||||
{
|
||||
// For the way this function is being used, this should be true. If it
|
||||
// becomes necessary to pass in a "numBytes" that is not actually the number
|
||||
// of bytes at this pointer type, then remove this assertion.
|
||||
// I pass in the "numBytes" instead of calculating it here for the purposes
|
||||
// of speeding it up. I didn't test the performance benefits, there may not
|
||||
// be any.
|
||||
assert ( numBytes == sizeof ( PointerType ) );
|
||||
|
||||
// Loop through the array and byte-swap the elements.
|
||||
for ( IndexType i = 0; i < numElements; ++i )
|
||||
{
|
||||
// Swap the byte order at the address of i'th element.
|
||||
flt::swapBytes ( numBytes, &(pointer[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See if the "bits" are in "number".
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class DataTypeNumber, class DataTypeBits> inline bool hasBits
|
||||
( const DataTypeNumber &number, const DataTypeBits &bits )
|
||||
{
|
||||
return ( ( number & bits ) == bits );
|
||||
}
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,229 +0,0 @@
|
||||
#ifndef __FLT_2_OSG_H
|
||||
#define __FLT_2_OSG_H
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Record.h"
|
||||
#include "GeoSetBuilder.h"
|
||||
|
||||
namespace osg {
|
||||
class Object;
|
||||
class Group;
|
||||
class LOD;
|
||||
class Geode;
|
||||
class Material;
|
||||
class Texture;
|
||||
};
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
class Record;
|
||||
class HeaderRecord;
|
||||
class ColorPaletteRecord;
|
||||
class MaterialPaletteRecord;
|
||||
class OldMaterialPaletteRecord;
|
||||
class TexturePaletteRecord;
|
||||
class LtPtAppearancePaletteRecord;
|
||||
class LtPtAnimationPaletteRecord;
|
||||
class VertexPaletteRecord;
|
||||
class VertexRecord;
|
||||
class NormalVertexRecord;
|
||||
class TextureVertexRecord;
|
||||
class NormalTextureVertexRecord;
|
||||
class GroupRecord;
|
||||
class LodRecord;
|
||||
class OldLodRecord;
|
||||
class DofRecord;
|
||||
class SwitchRecord;
|
||||
class ObjectRecord;
|
||||
class FaceRecord;
|
||||
class MeshRecord;
|
||||
class MeshPrimitiveRecord;
|
||||
class MatrixRecord;
|
||||
class GeneralMatrixRecord;
|
||||
class ExternalRecord;
|
||||
class LightPointRecord;
|
||||
class LightPointIndexRecord;
|
||||
class LightPointSystemRecord;
|
||||
class VertexListRecord;
|
||||
class MorphVertexListRecord;
|
||||
class LocalVertexPoolRecord;
|
||||
class LongIDRecord;
|
||||
class CommentRecord;
|
||||
class InstanceDefinitionRecord;
|
||||
class InstanceReferenceRecord;
|
||||
class MultiTextureRecord;
|
||||
class UVListRecord;
|
||||
class LightSourceRecord;
|
||||
class LightSourcePaletteRecord;
|
||||
class BSPRecord;
|
||||
struct SFace;
|
||||
|
||||
//class GeoSetBuilder;
|
||||
|
||||
struct SMaterial;
|
||||
|
||||
#define ADD_NORMAL(DGSET,VERTEX) \
|
||||
(DGSET)->addNormal(osg::Vec3( \
|
||||
(float)(VERTEX)->Normal.x(), \
|
||||
(float)(VERTEX)->Normal.y(), \
|
||||
(float)(VERTEX)->Normal.z()));
|
||||
|
||||
#define ADD_VERTEX_COLOR(DGSET,VERTEX,COLOR_POOL) \
|
||||
{ \
|
||||
if ((VERTEX)->swFlags & V_NO_COLOR_BIT) \
|
||||
(DGSET)->addColor(_faceColor); \
|
||||
else \
|
||||
{ \
|
||||
if ((VERTEX)->swFlags & V_PACKED_COLOR_BIT) \
|
||||
(DGSET)->addColor(pVert->PackedColor.get()); \
|
||||
else \
|
||||
(DGSET)->addColor((COLOR_POOL)->getColor((VERTEX)->dwVertexColorIndex)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ADD_TCOORD(DGSET,VERTEX) \
|
||||
(DGSET)->addTCoord(osg::Vec2( \
|
||||
(float)(VERTEX)->Texture.x(), \
|
||||
(float)(VERTEX)->Texture.y()));
|
||||
|
||||
#define ADD_OLD_COLOR(DGSET,VERTEX,COLOR_POOL) \
|
||||
{ \
|
||||
if (COLOR_POOL) \
|
||||
(DGSET)->addColor((COLOR_POOL)->getOldColor((VERTEX)->color_index)); \
|
||||
else \
|
||||
(DGSET)->addColor(osg::Vec4(1,1,1,1)); \
|
||||
}
|
||||
|
||||
#define ADD_OLD_TCOORD(DGSET,VERTEX) \
|
||||
(DGSET)->addTCoord(osg::Vec2( \
|
||||
(float)(VERTEX)->t[0], \
|
||||
(float)(VERTEX)->t[1]));
|
||||
|
||||
#define ADD_OLD_NORMAL(DGSET,VERTEX) \
|
||||
(DGSET)->addNormal(osg::Vec3( \
|
||||
(float)pVert->n[0] / (1<<30), \
|
||||
(float)pVert->n[1] / (1<<30), \
|
||||
(float)pVert->n[2] / (1<<30)));
|
||||
|
||||
|
||||
class ConvertFromFLT
|
||||
{
|
||||
public:
|
||||
|
||||
ConvertFromFLT();
|
||||
virtual ~ConvertFromFLT();
|
||||
|
||||
osg::Group* convert(HeaderRecord* rec);
|
||||
|
||||
osg::Group* visitAncillary(osg::Group& osgParent, osg::Group& osgPrimary, PrimNodeRecord* rec);
|
||||
osg::Group* visitPrimaryNode(osg::Group& osgParent, PrimNodeRecord* rec);
|
||||
|
||||
// Ancillary records
|
||||
osg::Group* visitMatrix(osg::Group& osgParent, const osg::Group& osgPrimary, MatrixRecord* rec);
|
||||
osg::Group* visitGeneralMatrix(osg::Group& osgParent, const osg::Group& osgPrimary, GeneralMatrixRecord* rec);
|
||||
void visitLongID(osg::Group& osgParent, LongIDRecord* rec);
|
||||
void visitComment(osg::Node& osgParent, CommentRecord* rec);
|
||||
|
||||
// Palette records
|
||||
void visitColorPalette(osg::Group& osgParent, ColorPaletteRecord* rec);
|
||||
void visitLightSourcePalette(osg::Group& osgParent, LightSourcePaletteRecord* rec);
|
||||
void visitMaterialPalette(osg::Group& osgParent, MaterialPaletteRecord* rec);
|
||||
void visitOldMaterialPalette(osg::Group& osgParent, OldMaterialPaletteRecord* rec);
|
||||
void visitTexturePalette(osg::Group& osgParent, TexturePaletteRecord* rec);
|
||||
void visitLtPtAppearancePalette(osg::Group& osgParent, LtPtAppearancePaletteRecord* rec);
|
||||
void visitLtPtAnimationPalette(osg::Group& osgParent, LtPtAnimationPaletteRecord* rec);
|
||||
void visitVertexPalette(osg::Group& osgParent, VertexPaletteRecord* rec);
|
||||
void visitVertex(osg::Group& osgParent, VertexRecord* rec);
|
||||
void visitNormalVertex(osg::Group& osgParent, NormalVertexRecord* rec);
|
||||
void visitTextureVertex(osg::Group& osgParent, TextureVertexRecord* rec);
|
||||
void visitNormalTextureVertex(osg::Group& osgParent, NormalTextureVertexRecord* rec);
|
||||
|
||||
// Primary records
|
||||
osg::Group* visitHeader(HeaderRecord* rec);
|
||||
osg::Group* visitGroup(osg::Group& osgParent, GroupRecord* rec);
|
||||
osg::Group* visitBSP(osg::Group& osgParent, BSPRecord* rec);
|
||||
osg::Group* visitLightSource(osg::Group& osgParent, LightSourceRecord* rec);
|
||||
osg::Group* visitRoadConstruction(osg::Group& osgParent, GroupRecord* rec);
|
||||
osg::Group* visitRoadSegment(osg::Group& osgParent, GroupRecord* rec);
|
||||
osg::Group* visitLOD(osg::Group& osgParent, LodRecord* rec);
|
||||
osg::Group* visitOldLOD(osg::Group& osgParent, OldLodRecord* rec);
|
||||
osg::Group* visitDOF(osg::Group& osgParent, DofRecord* rec);
|
||||
osg::Group* visitSwitch(osg::Group& osgParent, SwitchRecord* rec);
|
||||
osg::Group* visitObject(osg::Group& osgParent, ObjectRecord* rec);
|
||||
osg::Group* visitExternal(osg::Group& osgParent, ExternalRecord* rec);
|
||||
osg::Group* visitInstanceDefinition(osg::Group& osgParent,InstanceDefinitionRecord* rec);
|
||||
osg::Group* visitInstanceReference(osg::Group& osgParent,InstanceReferenceRecord* rec);
|
||||
|
||||
void visitFace(GeoSetBuilder* pParent, osg::Group& osgParent, FaceRecord* rec);
|
||||
void visitMesh(osg::Group& osgParent,GeoSetBuilder* pParent, MeshRecord* rec);
|
||||
void visitMeshPrimitive(osg::Group& osgParent, GeoSetBuilder* pBuilder, MeshPrimitiveRecord* rec);
|
||||
void visitLightPoint(GeoSetBuilder* pBuilder, osg::Group& osgParent, LightPointRecord* rec);
|
||||
void visitLightPoint(osg::Group& osgParent, LightPointRecord* rec);
|
||||
void visitLightPointIndex(osg::Group& osgParent, LightPointIndexRecord* rec);
|
||||
osg::Group* visitLightPointSystem(osg::Group& osgParent, LightPointSystemRecord* rec);
|
||||
int visitVertexList(GeoSetBuilder* pParent, VertexListRecord* rec);
|
||||
int visitMorphVertexList(GeoSetBuilder* pParent, MorphVertexListRecord* rec);
|
||||
int visitLocalVertexPool(GeoSetBuilder* pBuilder, LocalVertexPoolRecord* rec);
|
||||
|
||||
|
||||
void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTranspancyBinning=flag; }
|
||||
bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTranspancyBinning; }
|
||||
void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; }
|
||||
bool getDoUnitsConversion() const { return _doUnitsConversion; }
|
||||
|
||||
private:
|
||||
|
||||
int addMeshPrimitives ( osg::Group &osgParent, GeoSetBuilder *pBuilder, MeshRecord *rec );
|
||||
int addVertices(GeoSetBuilder* pBuilder, osg::Group& osgParent, PrimNodeRecord* primRec);
|
||||
int addVertex(DynGeoSet* dgset, Record* rec);
|
||||
int addVertex(GeoSetBuilder* pBuilder, Record* rec) {return addVertex( pBuilder->getDynGeoSet(), rec);} ;
|
||||
Record* getVertexFromPool(int nOffset);
|
||||
void regisiterVertex(int nOffset, Record* pRec);
|
||||
void visitFaceOrMeshCommonCode(GeoSetBuilder* pBuilder, FaceRecord* rec);
|
||||
uint32 setMeshCoordinates ( const uint32 &numVerts, const LocalVertexPoolRecord *pool, MeshPrimitiveRecord *mesh, osg::Geometry *geometry );
|
||||
uint32 setMeshNormals ( const uint32 &numVerts, const LocalVertexPoolRecord *pool, MeshPrimitiveRecord *mesh, osg::Geometry *geometry );
|
||||
uint32 setMeshColors ( const uint32 &numVerts, const LocalVertexPoolRecord *pool, MeshPrimitiveRecord *mesh, osg::Geometry *geometry );
|
||||
void setMeshTexCoordinates ( const uint32 &numVerts, const LocalVertexPoolRecord *pool, MeshPrimitiveRecord *mesh, osg::Geometry *geometry );
|
||||
|
||||
void setCullFaceAndWireframe ( const SFace *pSFace, osg::StateSet *osgStateSet, DynGeoSet *dgset );
|
||||
void setDirectionalLight();
|
||||
void setLightingAndColorBinding ( const FaceRecord *rec, const SFace *pSFace, osg::StateSet *osgStateSet, DynGeoSet *dgset );
|
||||
void setColor ( FaceRecord *rec, SFace *pSFace, DynGeoSet *dgset, bool &bBlend );
|
||||
void setMaterial ( FaceRecord *rec, SFace *pSFace, osg::StateSet *osgStateSet, bool &bBlend );
|
||||
void setTexture ( FaceRecord *rec, SFace *pSFace, osg::StateSet *osgStateSet, DynGeoSet *dgset, bool &bBlend );
|
||||
void setTransparency ( osg::StateSet *osgStateSet, bool &bBlend );
|
||||
|
||||
// multitexturing
|
||||
void addMultiTexture( DynGeoSet* dgset, MultiTextureRecord* mtr );
|
||||
void addUVList( DynGeoSet* dgset, UVListRecord* mtr );
|
||||
|
||||
typedef std::map<int,Record*> VertexPaletteOffsetMap;
|
||||
VertexPaletteOffsetMap _VertexPaletteOffsetMap;
|
||||
|
||||
int _diOpenFlightVersion;
|
||||
int _diCurrentOffset;
|
||||
unsigned short _wObjTransparency;
|
||||
int _nSubfaceLevel;
|
||||
double _unitScale;
|
||||
bool _bHdrRgbMode;
|
||||
osg::Vec4 _faceColor;
|
||||
bool _useTextureAlphaForTranspancyBinning;
|
||||
bool _doUnitsConversion;
|
||||
|
||||
osg::Group* _osgParent;
|
||||
|
||||
LocalVertexPoolRecord* _currentLocalVertexPool;
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif // __FLT_2_OSG_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user