summaryrefslogtreecommitdiffstats
path: root/tools/DSGmaker
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/DSGmaker/DSGList.cpp389
-rw-r--r--tools/DSGmaker/DSGList.hpp29
-rw-r--r--tools/DSGmaker/DSGmaker.dsp176
-rw-r--r--tools/DSGmaker/DynaDSGList.cpp53
-rw-r--r--tools/DSGmaker/DynaDSGList.hpp22
-rw-r--r--tools/DSGmaker/InstaEntityDSGList.cpp53
-rw-r--r--tools/DSGmaker/InstaEntityDSGList.hpp20
-rw-r--r--tools/DSGmaker/InstaStaticPhysDSGList.cpp53
-rw-r--r--tools/DSGmaker/InstaStaticPhysDSGList.hpp20
-rw-r--r--tools/DSGmaker/dsgmaker.cpp807
10 files changed, 1622 insertions, 0 deletions
diff --git a/tools/DSGmaker/DSGList.cpp b/tools/DSGmaker/DSGList.cpp
new file mode 100644
index 0000000..700497f
--- /dev/null
+++ b/tools/DSGmaker/DSGList.cpp
@@ -0,0 +1,389 @@
+#include <cstring>
+#include <stdio.h>
+#include <..\..\..\tools\dsgmaker\DSGList.hpp>
+#include <tlDataChunk.hpp>
+#include <..\constants\srrchunks.h>
+
+
+const int MAX_DSG = 100;
+
+DSGList::DSGList ()
+{
+ mbNoInstanceChunks = false;
+ mindex =0;
+ mp_list = new tlDataChunk* [MAX_DSG];
+ mp_list[0]=NULL;
+}
+
+DSGList::~DSGList ()
+{
+ delete [] mp_list;
+}
+
+//input DynaDSG name and it should return a pointer to the dsg or null if failure
+tlDataChunk* DSGList::GetDSG(const char * name)
+{
+
+ //search the array for the name.
+ for(unsigned int i=0;i<mindex;i++)
+ {
+ //printf(" Searching for %s, against %s\n",name,mp_list[i]->GetName());
+ //if we find it return pointer otherwise it will return null by default
+ if (strcmp ( mp_list[i]->GetName(),name)==0)
+ {
+ return( mp_list[i] );
+ }
+ }
+ return NULL;
+
+}
+
+// add a dynaphyschunk to the list
+int DSGList::AddDSG (tlDataChunk* p_dsg)
+{
+ if(mindex < MAX_DSG -1)
+ {
+ mp_list[mindex++]=p_dsg;
+ return 0;
+ }
+ else
+ {
+ printf(" ERROR: ====> DSGList if FULL! Unable to add entery! \n");
+ return 1;
+ }
+
+}
+
+
+//returns the number of enteries in list.
+unsigned int DSGList::GetIndexCount()
+{
+ return mindex;
+}
+
+//input index and it should return a pointer to the dsg or null if failure
+tlDataChunk* DSGList::GetDSGByIndex(unsigned int i)
+{
+
+ //search the array for the name.
+ if ( i >=0 && i <mindex)
+ {
+ return( mp_list[i] );
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+//resorts the DSGchunks so according the the priority set in the toollib_extras.hpp file
+void DSGList::ReSortDSGChunks(void)
+{
+ printf ("Resorting DSG Chunks\n");
+ //sort the DSGchunks internally so InstanceChunks are last
+
+ for( unsigned int i=0;i<GetIndexCount();i++)
+ {
+
+ tlDataChunk* p_dsg=NULL;
+ p_dsg=GetDSGByIndex(i);
+ if (p_dsg == NULL)
+ {
+ printf(" ERROR: ==== > Sorting DSG! \n");
+ }
+ else
+ {
+ p_dsg->SortSubChunks();
+ }
+ }
+
+}
+
+//checks the DSG chunks for missing Chunks that will cause the game loaders to crash.
+unsigned int DSGList::VerifyChunks(void)
+{
+ tlDataChunk* p_datachunk=NULL;
+ bool badart = false;
+
+ printf("\nVerifying Chunks arent missing components....\n");
+
+ for (unsigned int i=0; i<mindex;i++)
+ {
+ p_datachunk=mp_list[i];
+ switch(p_datachunk->ID())
+ {
+ case SRR2::ChunkID::DYNA_PHYS_DSG:
+ {
+ tlDataChunk* p_subchunk=NULL;
+ int subcount=p_datachunk->SubChunkCount();
+
+ if (subcount<5)
+ {
+ bool meshchunk =false;
+ bool physicschunk=false;
+ bool collisionchunk= false;
+ bool otc = false;
+ bool instancechunk = false;
+
+
+ for( int j=0;j<subcount;j++)
+ {
+ p_subchunk=p_datachunk->GetSubChunk(j);
+
+ switch(p_subchunk->ID())
+ {
+ case Pure3D::Mesh::MESH:
+ {
+ meshchunk = true;
+ break;
+ }
+ case Simulation::Physics::OBJECT:
+ {
+ physicschunk = true;
+ break;
+ }
+ case SRR2::ChunkID::OBJECT_ATTRIBUTES:
+ {
+ otc = true;
+ break;
+ }
+ case Simulation::Collision::OBJECT:
+ {
+ collisionchunk = true ;
+ break;
+ }
+ case SRR2::ChunkID::INSTANCES:
+ {
+ instancechunk= true;
+ break;
+ }
+ default:
+ {
+ printf(" Unexpected ChunkType %d \n",p_subchunk->ID() );
+ break;
+ }
+ }//end of switch for sub chunk check
+ }//end of for loop to subchunk iteration
+
+ if (meshchunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s DynaDSGChunk is missing MeshChunk\n",p_datachunk->GetName());
+ }
+
+ if (physicschunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s DynaDSGChunk is missing PhysicsChunk\n",p_datachunk->GetName());
+ }
+
+ if(otc != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s DynaDSGChunk is missing Object Attribute Chunk\n",p_datachunk->GetName());
+
+ }
+
+ if(collisionchunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s DynaDSGChunk is missing BoundingVolume\n",p_datachunk->GetName());
+
+ }
+
+ if( instancechunk != true)
+ {
+ if (mbNoInstanceChunks == true)
+ {
+
+ }
+ else
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s DynaPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName());
+ }
+ }
+ }//end if
+ break;
+ }//end case
+ case SRR2::ChunkID::INSTA_STATIC_PHYS_DSG:
+ {
+ tlDataChunk* p_subchunk=NULL;
+ int subcount=p_datachunk->SubChunkCount();
+
+ if (subcount<4)
+ {
+ bool meshchunk =false;
+ bool collisionchunk= false;
+ bool otc = false;
+ bool instancechunk = false;
+
+ for( int j=0;j<subcount;j++)
+ {
+ p_subchunk=p_datachunk->GetSubChunk(j);
+
+ switch(p_subchunk->ID())
+ {
+ case Pure3D::Mesh::MESH:
+ {
+ meshchunk = true;
+ break;
+ }
+ case SRR2::ChunkID::OBJECT_ATTRIBUTES:
+ {
+ otc = true;
+ break;
+ }
+ case Simulation::Collision::OBJECT:
+ {
+ collisionchunk = true ;
+ break;
+ }
+ case SRR2::ChunkID::INSTANCES:
+ {
+ instancechunk= true;
+ break;
+ }
+ default:
+ {
+ printf(" Unexpected ChunkType %d \n",p_subchunk->ID() );
+ break;
+ }
+ }//end of switch for sub chunk check
+ }//end of for loop to subchunk iteration
+
+ if (meshchunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing MeshChunk\n",p_datachunk->GetName());
+ }
+
+ if(otc != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Object Attribute Chunk\n",p_datachunk->GetName());
+
+ }
+
+ if(collisionchunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Bounding Volume\n",p_datachunk->GetName());
+
+ }
+
+ if( instancechunk != true)
+ {
+ if (mbNoInstanceChunks == true)
+ {
+
+ }
+ else
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName());
+ }
+ }
+ }//end if
+ break;
+ }//end of InstaStatPhyscase
+
+ case SRR2::ChunkID::INSTA_ENTITY_DSG:
+ {
+ tlDataChunk* p_subchunk=NULL;
+ int subcount=p_datachunk->SubChunkCount();
+
+ if (subcount<2)
+ {
+ bool meshchunk =false;
+ bool instancechunk = false;
+
+
+ for( int j=0;j<subcount;j++)
+ {
+ p_subchunk=p_datachunk->GetSubChunk(j);
+
+ switch(p_subchunk->ID())
+ {
+ case Pure3D::Mesh::MESH:
+ {
+ meshchunk = true;
+ break;
+ }
+ case SRR2::ChunkID::INSTANCES:
+ {
+ instancechunk= true;
+ break;
+ }
+ default:
+ {
+ printf(" Unexpected ChunkType %d \n",p_subchunk->ID() );
+ break;
+ }
+ }//end of switch for sub chunk check
+ }//end of for loop to subchunk iteration
+
+ if (meshchunk != true)
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaEntityDSGChunk is missing MeshChunk\n",p_datachunk->GetName());
+ }
+
+ if( instancechunk != true)
+ {
+ if (mbNoInstanceChunks == true)
+ {
+
+ }
+ else
+ {
+ badart =true;
+ DSGList::PrintErrors();
+ printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName());
+ }
+ }
+ }//end if
+ break;
+ }//end case
+
+ }//end switch
+
+ }//end for
+if (badart == true)
+{
+ return 1;
+}
+
+return 0;
+
+}//end of VerifyChunks method
+
+
+// formatted IO Header for errors.
+void DSGList::PrintErrors(void)
+{
+ printf("\n");
+ printf("===============================================================================================\n");
+ printf("\n");
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/DSGmaker/DSGList.hpp b/tools/DSGmaker/DSGList.hpp
new file mode 100644
index 0000000..e7ba78d
--- /dev/null
+++ b/tools/DSGmaker/DSGList.hpp
@@ -0,0 +1,29 @@
+#ifndef DSGLIST_H
+#define DSGLIST_H
+
+//custom list class,stores the address of DynaPhysDSG in a array,that i create in DSGmaker
+
+class tlDataChunk ;
+
+
+
+class DSGList
+{
+ public:
+
+ bool mbNoInstanceChunks;
+ DSGList();
+ virtual ~DSGList();
+ int AddDSG(tlDataChunk* p_dsg);
+ unsigned int GetIndexCount();
+ tlDataChunk* GetDSG(const char* name);
+ tlDataChunk* GetDSGByIndex(unsigned int i);
+ unsigned int VerifyChunks(void);
+ void ReSortDSGChunks(void);
+
+ private:
+ void PrintErrors(void);
+ tlDataChunk** mp_list;
+ unsigned int mindex;
+};
+#endif //end of file \ No newline at end of file
diff --git a/tools/DSGmaker/DSGmaker.dsp b/tools/DSGmaker/DSGmaker.dsp
new file mode 100644
index 0000000..91d041c
--- /dev/null
+++ b/tools/DSGmaker/DSGmaker.dsp
@@ -0,0 +1,176 @@
+# Microsoft Developer Studio Project File - Name="DSGmaker" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 60000
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=DSGmaker - Win32 Tools Debug
+!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 "DSGmaker.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 "DSGmaker.mak" CFG="DSGmaker - Win32 Tools Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "DSGmaker - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "DSGmaker - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "DSGmaker - Win32 Tools Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "DSGmaker - Win32 Tools Release" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "DSGmaker"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "DSGmaker - 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 "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "RAD_RELEASE" /D "RAD_WIN32" /D "RAD_PC" /YX /FD /c
+# ADD BASE RSC /l 0x1009 /d "NDEBUG"
+# ADD RSC /l 0x1009 /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 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 /subsystem:console /machine:I386
+# ADD LINK32 mysql++.lib 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 /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "DSGmaker - 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 "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS_DEBUG" /D "RAD_WIN32" /D "RAD_PC" /D "RAD_DEBUG" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x1009 /d "_DEBUG"
+# ADD RSC /l 0x1009 /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 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 mysql++.lib 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "DSGmaker - Win32 Tools Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DSGmaker___Win32_Tools_Debug"
+# PROP BASE Intermediate_Dir "DSGmaker___Win32_Tools_Debug"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS_DEBUG" /D "RAD_WIN32" /D "RAD_PC" /D "RAD_DEBUG" /YX /FD /GZ /c
+# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "RAD_WIN32" /D "RAD_PC" /D "RAD_DEBUG" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x1009 /d "_DEBUG"
+# ADD RSC /l 0x1009 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 mysql++.lib 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 mysql++.lib 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "DSGmaker - Win32 Tools Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "DSGmaker___Win32_Tools_Release"
+# PROP BASE Intermediate_Dir "DSGmaker___Win32_Tools_Release"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\game\libs\pure3d\toollib\inc" /I "..\..\game\libs\pure3d\constants" /I "..\..\game\code\constants" /I "..\..\game\libs\radmath" /I "..\..\game\libs\pure3d\toollib\chunks16\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "RAD_RELEASE" /D "RAD_WIN32" /D "RAD_PC" /YX /FD /c
+# ADD BASE RSC /l 0x1009 /d "NDEBUG"
+# ADD RSC /l 0x1009 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 mysql++.lib 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 /subsystem:console /machine:I386
+# ADD LINK32 mysql++.lib 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 /subsystem:console /machine:I386
+
+!ENDIF
+
+# Begin Target
+
+# Name "DSGmaker - Win32 Release"
+# Name "DSGmaker - Win32 Debug"
+# Name "DSGmaker - Win32 Tools Debug"
+# Name "DSGmaker - Win32 Tools Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\DSGList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\dsgmaker.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\DSGList.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\game\code\constants\phyprop.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"
+# End Group
+# Begin Group "libs"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE="C:\mysql++\lib\mysql++.lib"
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/tools/DSGmaker/DynaDSGList.cpp b/tools/DSGmaker/DynaDSGList.cpp
new file mode 100644
index 0000000..d99f1b2
--- /dev/null
+++ b/tools/DSGmaker/DynaDSGList.cpp
@@ -0,0 +1,53 @@
+#include <cstring>
+#include <stdio.h>
+#include <..\..\..\tools\dsgmaker\DynaDSGList.hpp>
+#include <tlDynaPhysDSGChunk.hpp>
+
+
+const int MAX_DYNA_DSG = 50;
+
+DynaPhysDSGList::DynaPhysDSGList ()
+{
+ mindex =0;
+ mp_list = new tlDynaPhysDSGChunk* [MAX_DYNA_DSG];
+ mp_list[0]=NULL;
+}
+
+DynaPhysDSGList::~DynaPhysDSGList ()
+{
+ delete [] mp_list;
+}
+
+//input DynaDSG name and it should return a pointer to the dsg or null if failure
+tlDynaPhysDSGChunk* DynaPhysDSGList::GetDyna(const char * name)
+{
+
+ //search the array for the name.
+ for(unsigned int i=0;i<mindex;i++)
+ {
+ printf(" Searching for %s, against %s\n",name,mp_list[i]->GetName());
+ //if we find it return pointer otherwise it will return null by default
+ if (strcmp ( mp_list[i]->GetName(),name)==0)
+ {
+ return( mp_list[i] );
+ }
+ }
+ return NULL;
+
+}
+
+// add a dynaphyschunk to the list
+int DynaPhysDSGList::AddDyna (tlDynaPhysDSGChunk* p_dyna)
+{
+ if(mindex < MAX_DYNA_DSG -1)
+ {
+ mp_list[mindex++]=p_dyna;
+ return 0;
+ }
+ else
+ {
+ printf("ERROR: DynaDSGList if FULL! Unable to add entery! \n");
+ return 1;
+ }
+
+}
diff --git a/tools/DSGmaker/DynaDSGList.hpp b/tools/DSGmaker/DynaDSGList.hpp
new file mode 100644
index 0000000..3ba56a6
--- /dev/null
+++ b/tools/DSGmaker/DynaDSGList.hpp
@@ -0,0 +1,22 @@
+#ifndef DYNADSGLIST_H
+#define DYNADSGLIST_H
+
+//custom list class,stores the address of DynaPhysDSG in a array,that i create in DSGmaker
+
+class tlDynaPhysDSGChunk ;
+
+class DynaPhysDSGList
+{
+ public:
+ DynaPhysDSGList();
+ virtual ~DynaPhysDSGList();
+ int AddDyna(tlDynaPhysDSGChunk* p_dyna);
+ unsigned int GetIndexCount();
+ tlDynaPhysDSGChunk* GetDyna(const char* name);
+
+
+ private:
+ tlDynaPhysDSGChunk** mp_list;
+ unsigned int mindex;
+};
+#endif //end of file \ No newline at end of file
diff --git a/tools/DSGmaker/InstaEntityDSGList.cpp b/tools/DSGmaker/InstaEntityDSGList.cpp
new file mode 100644
index 0000000..83271fa
--- /dev/null
+++ b/tools/DSGmaker/InstaEntityDSGList.cpp
@@ -0,0 +1,53 @@
+#include <cstring>
+#include <stdio.h>
+#include <..\..\..\tools\dsgmaker\InstaEntityDSGList.hpp>
+#include <tlInstaEntityDSGChunk.hpp>
+
+
+const int MAX_INSTA_DSG = 50;
+
+InstaEntityDSGList::InstaEntityDSGList ()
+{
+ mindex =0;
+ mp_list = new tlInstaEntityDSGChunk* [MAX_INSTA_DSG];
+ mp_list[0]=NULL;
+}
+
+InstaEntityDSGList::~InstaEntityDSGList ()
+{
+ delete [] mp_list;
+}
+
+//input DSG name and it should return a pointer to the dsg or null if failure
+tlInstaEntityDSGChunk* InstaEntityDSGList::GetInstaEntity(const char * name)
+{
+
+ //search the array for the name.
+ for(unsigned int i=0;i<mindex;i++)
+ {
+ printf(" Searching for %s, against %s\n",name,mp_list[i]->GetName());
+ //if we find it return pointer otherwise it will return null by default
+ if (strcmp ( mp_list[i]->GetName(),name)==0)
+ {
+ return( mp_list[i] );
+ }
+ }
+ return NULL;
+
+}
+
+// add a InstaEntitychunk to the list
+int InstaEntityDSGList::AddInstaEntity (tlInstaEntityDSGChunk* p_insta)
+{
+ if(mindex < MAX_INSTA_DSG -1)
+ {
+ mp_list[mindex++]=p_insta;
+ return 0;
+ }
+ else
+ {
+ printf("ERROR: InstaEntityDSGList if FULL! Unable to add entery! \n");
+ return 1;
+ }
+
+}
diff --git a/tools/DSGmaker/InstaEntityDSGList.hpp b/tools/DSGmaker/InstaEntityDSGList.hpp
new file mode 100644
index 0000000..033e8a9
--- /dev/null
+++ b/tools/DSGmaker/InstaEntityDSGList.hpp
@@ -0,0 +1,20 @@
+#ifndef INSTAENTITYDSGLIST_H
+#define INSTAENTITYDSGLIST_H
+
+//custom list class,stores the address of InstaEntityDSG's in a array,that i create in DSGmaker
+
+class tlInstaEntityDSGChunk ;
+
+class InstaEntityDSGList
+{
+ public:
+ InstaEntityDSGList();
+ virtual ~InstaEntityDSGList();
+ int AddInstaEntity(tlInstaEntityDSGChunk* p_insta);
+ tlInstaEntityDSGChunk* GetInstaEntity(const char* name);
+
+ private:
+ tlInstaEntityDSGChunk** mp_list;
+ unsigned int mindex;
+};
+#endif //end of file \ No newline at end of file
diff --git a/tools/DSGmaker/InstaStaticPhysDSGList.cpp b/tools/DSGmaker/InstaStaticPhysDSGList.cpp
new file mode 100644
index 0000000..a9674b5
--- /dev/null
+++ b/tools/DSGmaker/InstaStaticPhysDSGList.cpp
@@ -0,0 +1,53 @@
+#include <cstring>
+#include <stdio.h>
+#include <..\..\..\tools\dsgmaker\InstaStaticPhysDSGList.hpp>
+#include <tlInstaStaticPhysDSGChunk.hpp>
+
+
+const int MAX_INSTA_DSG = 50;
+
+InstaStaticPhysDSGList::InstaStaticPhysDSGList ()
+{
+ mindex =0;
+ mp_list = new tlInstaStaticPhysDSGChunk* [MAX_INSTA_DSG];
+ mp_list[0]=NULL;
+}
+
+InstaStaticPhysDSGList::~InstaStaticPhysDSGList ()
+{
+ delete [] mp_list;
+}
+
+//input DSG name and it should return a pointer to the dsg or null if failure
+tlInstaStaticPhysDSGChunk* InstaStaticPhysDSGList::GetInstaStaticPhys(const char * name)
+{
+
+ //search the array for the name.
+ for(unsigned int i=0;i<mindex;i++)
+ {
+ printf(" Searching for %s, against %s\n",name,mp_list[i]->GetName());
+ //if we find it return pointer otherwise it will return null by default
+ if (strcmp ( mp_list[i]->GetName(),name)==0)
+ {
+ return( mp_list[i] );
+ }
+ }
+ return NULL;
+
+}
+
+// add a InstaStaticPhyschunk to the list
+int InstaStaticPhysDSGList::AddInstaStaticPhys (tlInstaStaticPhysDSGChunk* p_insta)
+{
+ if(mindex < MAX_INSTA_DSG -1)
+ {
+ mp_list[mindex++]=p_insta;
+ return 0;
+ }
+ else
+ {
+ printf("ERROR: InstaStaticPhysDSGList if FULL! Unable to add entery! \n");
+ return 1;
+ }
+
+} \ No newline at end of file
diff --git a/tools/DSGmaker/InstaStaticPhysDSGList.hpp b/tools/DSGmaker/InstaStaticPhysDSGList.hpp
new file mode 100644
index 0000000..2f9fc1a
--- /dev/null
+++ b/tools/DSGmaker/InstaStaticPhysDSGList.hpp
@@ -0,0 +1,20 @@
+#ifndef INSTAPHYSDSGLIST_H
+#define INSTAPHYSDSGLIST_H
+
+//custom list class,stores the address of InstaEntityDSG's in a array,that i create in DSGmaker
+
+class tlInstaStaticPhysDSGChunk ;
+
+class InstaStaticPhysDSGList
+{
+ public:
+ InstaStaticPhysDSGList();
+ virtual ~InstaStaticPhysDSGList();
+ int AddInstaStaticPhys(tlInstaStaticPhysDSGChunk* p_insta);
+ tlInstaStaticPhysDSGChunk* GetInstaStaticPhys(const char* name);
+
+ private:
+ tlInstaStaticPhysDSGChunk** mp_list;
+ unsigned int mindex;
+};
+#endif //end of file \ No newline at end of file
diff --git a/tools/DSGmaker/dsgmaker.cpp b/tools/DSGmaker/dsgmaker.cpp
new file mode 100644
index 0000000..9624e04
--- /dev/null
+++ b/tools/DSGmaker/dsgmaker.cpp
@@ -0,0 +1,807 @@
+//DSGmaker a tool to traverse the the inventory of a Pure3d file and creates
+//DSGchucks and bundles mesh,phys,BV,instance chunk together. Supports multiple objects in a file.
+
+#pragma warning(disable:4786)
+
+#include <iostream>
+#include <cstring>
+#include <iomanip>
+#include <mysql++>
+#include <..\..\..\tools\artchecker\artobject.h>
+#include <..\..\..\tools\artchecker\artlimits.h>
+#include <..\..\..\tools\artchecker\badlist.hpp>
+#include <..\..\..\tools\artchecker\outputbuffer.hpp>
+
+
+#include <toollib.hpp>
+#include <tlCollisionObjectChunk.hpp>
+#include <tlPhysicsObjectChunk.hpp>
+#include <tlMeshChunk.hpp>
+#include <..\constants\srrchunks.h>
+#include <..\..\..\tools\dsgmaker\DSGList.hpp>
+using namespace std;
+
+//function that strips all the extra crap(prefixes and appended junk)
+//and returns actual object name in output pointer.
+
+unsigned int rootname(const char* input,char* output);
+
+
+int main(int argc, char* argv[])
+{
+
+ //char* arguements [4];
+ char* filename;
+ char querybuffer [1000];
+ bool badart = false;
+ bool showall= false;
+ Result::iterator sql_iterator;
+ DSGList* p_dsglist =new DSGList();
+ bool mbIgnoreMissingInstanceChunk = false;
+
+ tlDataChunk::RegisterDefaultChunks();
+
+ //processes arguements
+
+ //no options
+ if (argc ==1)
+ {
+ cout<<"Usage:Dsgmaker filename \n";
+ exit (1);
+ }
+
+ filename= argv[1];
+
+ if ( argc ==3)
+ {
+ if (strcmp( argv[2],"-nI") == 0)
+ {
+ mbIgnoreMissingInstanceChunk = true;
+ //printf("Ignoring Missing Chunks!\n");
+ }
+ else
+ {
+ printf("Error: unknown arguement %s \n",argv[2]);
+ }
+ }
+
+/*
+ for (i=2;i<argc;i++)
+ {
+ arguements[i]=argv[i];
+
+ // user set strict
+ if (strcmp(arguements[i],"strict")== 0)
+ {
+ strict =true;
+ debugstring("strict option set");
+ break;
+ }
+
+ //user set add
+
+ else if (strcmp (arguements[i],"add")==0)
+ {
+ add=true;
+ debugstring("add option set");
+ break;
+ }
+
+ else if (strcmp (arguements[i],"all")==0)
+ {
+ showall =true;
+ break;
+ }
+ //illegal option
+ else
+ {
+ cout <<arguements[i] <<" is an illegal option \n";
+ exit (1);
+ }
+
+#ifdef DEBUG
+ cout<< i ;
+ cout<< arguements [i] << "\n";
+#endif
+
+ } //end for
+
+ */
+
+ //read in the pure3d file name
+
+ tlFile input(new tlFileByteStream(filename,omREAD), tlFile::FROMFILE);
+ if(!input.IsOpen())
+ {
+ printf("Could not open %s\n", filename);
+ exit(-1);
+ }
+
+ cout<<"Processing Filename:"<<filename<<endl;
+
+ //desend into the file and look at each object until no more objects left
+
+ // make a tlDataChunk from the file
+ // this is the wrapper chunk for the input
+ tlDataChunk* inchunk = new tlDataChunk(&input);
+ // we don't need the tlFile anymore
+ // this cleans up the tlFile object including the
+ // tlFileByteStream
+ input.Close();
+
+
+ // build an output chunk
+ tlDataChunk* outchunk = new tlDataChunk;
+ int ch;
+
+ //connect to the Art DB
+ try
+ {
+ //setup artrb variables
+ bool dbconnect=false;
+ Row row;
+
+ //creat connection and query objects
+ Connection con (use_exceptions);
+ Query query=con.query( );
+ dbconnect=con.connect ("srr2test","radit","root","custom47");
+
+
+ if (dbconnect == true)
+ {
+ cout<<"Connection to Artdb established proceeding.\n";
+ }
+ else
+ {
+ cout<<"Cant connection to ArtDB Aborting! \n";
+ exit (1);
+ }
+
+
+ // go through all the sub-chunks of the input and
+ // process the ones you care about
+ for(ch=0; ch < inchunk->SubChunkCount(); ch++)
+ {
+ // create the next sub-chunk
+ tlDataChunk* sub = inchunk->GetSubChunk(ch);
+
+ // look at the id of the subchunk to decide if we
+ // want to do something with it or not
+ switch(sub->ID())
+ {
+
+
+ case Pure3D::Mesh::MESH:
+ {
+
+ //printf("\n");
+ tlMeshChunk* p_mesh = (tlMeshChunk* ) sub;
+ char mesh_name[max_length];
+
+ //get object name and remove extra appended crap
+ ::rootname(p_mesh->GetName(),mesh_name);
+
+
+ //query ArtDB for info on this mesh
+ sprintf(querybuffer, "SELECT * FROM objects WHERE name = '%s' ",mesh_name);
+ query<< querybuffer;
+ Result myresult = query.store ( );
+
+ //check results,
+ //if not found in ArtDB make it a into a StaticEntityDSG as a default.
+ if (myresult.size ( ) ==0 )
+ {
+ //create StaticEntityDSG chunk and append mesh
+ printf("%s : Mesh not found in ArtDB creating EntityDSGChunk !\n",mesh_name);
+ tlEntityDSGChunk* p_entitydsg =new tlEntityDSGChunk();
+ p_entitydsg->SetName(p_mesh->GetName());
+ p_entitydsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_entitydsg,FALSE);
+
+ }
+ // its found in the ArtDB, need to determine what kind of DSG to make.
+ else
+ {
+
+ for (sql_iterator=myresult.begin ( ); sql_iterator!= myresult.end ( ); sql_iterator++)
+ {
+ row =*sql_iterator;
+ char classtypeID [max_length];
+ strcpy(classtypeID, row["ClassType"]);
+ printf("Found %s meshchunk \n",p_mesh->GetName());
+ //printf("Classtype ID: %s \n",classtypeID);
+
+ //make the correct DSG chunktype
+ if (
+ (strcmp(classtypeID,"PROP_MOVEABLE")==0) ||
+ (strcmp(classtypeID,"PROP_BREAKABLE")==0) ||
+ (strcmp(classtypeID,"PROP_ONETIME_MOVEABLE")==0)
+ )
+ {
+ printf(" %s is of type %s creating DynaPhysDSGChunk \n",mesh_name,classtypeID);
+ tlDynaPhysDSGChunk* p_dynaphysdsg =new tlDynaPhysDSGChunk ();
+ p_dynaphysdsg->SetName(p_mesh->GetName());
+ p_dynaphysdsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_dynaphysdsg,FALSE);
+ p_dsglist->AddDSG(p_dynaphysdsg);
+ //printf(" Finished making chunk\n");
+ }
+
+ else if (strcmp(classtypeID,"PROP_STATIC")==0)
+ {
+ printf(" %s is of type %s creating InstaStaticPhysDSGChunk \n",mesh_name,classtypeID);
+ tlInstaStaticPhysDSGChunk* p_instaphysdsg =new tlInstaStaticPhysDSGChunk ();
+ p_instaphysdsg->SetName(p_mesh->GetName());
+ p_instaphysdsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_instaphysdsg,FALSE);
+ p_dsglist->AddDSG(p_instaphysdsg);
+ }
+
+ else if (strcmp(classtypeID,"PROP_DRAWABLE")==0)
+ {
+ printf(" %s is of type %s creating InstaEntityDSGChunk \n",mesh_name,classtypeID);
+ tlInstaEntityDSGChunk* p_instaentitydsg =new tlInstaEntityDSGChunk();
+ p_instaentitydsg->SetName(p_mesh->GetName());
+ p_instaentitydsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_instaentitydsg,FALSE);
+ p_dsglist->AddDSG(p_instaentitydsg);
+ }
+
+ else if (strcmp(classtypeID,"STATIC")==0)
+ {
+ printf(" %s is of type %s creating EntityDSGChunk \n",mesh_name,classtypeID);
+ tlEntityDSGChunk* p_entitydsg =new tlEntityDSGChunk();
+ p_entitydsg->SetName(p_mesh->GetName());
+ p_entitydsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_entitydsg,FALSE);
+ }
+
+ else if (strcmp(classtypeID,"DRAWABLE")==0)
+ {
+ printf(" %s is of type %s creating EntityDSGChunk \n",mesh_name,classtypeID);
+ tlEntityDSGChunk* p_entitydsg =new tlEntityDSGChunk();
+ p_entitydsg->SetName(p_mesh->GetName());
+ p_entitydsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(p_entitydsg,FALSE);
+ }
+
+ else if (strcmp(classtypeID,"ANIMATED_BV")==0)
+ {
+ printf(" %s is of type %s creating AnimatedBvDSGChunk \n",mesh_name,classtypeID);
+
+ //Need to finalize class specs with Greg, Devin and Trav TBD still
+
+ //tlDynaPhysDSGChunk* p_dynaphysdsg =new tlDynaPhysDSGChunk ();
+ //p_dynaphysdsg->SetName(p_mesh->GetName());
+ //p_dynaphysdsg->AppendSubChunk(sub,FALSE);
+ outchunk->AppendSubChunk(sub,FALSE);
+ }
+ else
+ {
+ printf("\n===================================================\n");
+ printf("\n=\tError unknown %s ClasstypeID \n",classtypeID);
+ printf("\n===================================================\n");
+ }
+
+
+ }//end for loop
+
+ }//end else
+ //printf("exiting Mesh case\n");
+ break;
+ }
+ case Simulation::Physics::OBJECT:
+ {
+ tlPhysicsObjectChunk *p_physobject = (tlPhysicsObjectChunk*) sub;
+ tlDataChunk* p_dsg=NULL;
+ char name[max_length];
+
+ ::rootname(p_physobject->GetName(),name);
+ printf("\n");
+ printf("Phys Chunk: %s \n",p_physobject->GetName());
+
+ p_dsg =p_dsglist->GetDSG(p_physobject->GetName());
+
+ if( p_dsg ==NULL)
+ {
+ badart=true;
+ printf("\n===================================================\n");
+ printf("\n=\tERROR: Cant find Parent DSG for %s, This Physics Volume is MISSING its mesh!!\n",p_physobject->GetName());
+ printf("\n===================================================\n");
+ }
+ else
+ {
+ printf(" Found the parent for %s\n",p_physobject->GetName());
+ p_dsg->AppendSubChunk(sub,FALSE);
+ }
+ break;
+ }
+
+
+ case Simulation::Collision::OBJECT:
+ {
+ //printf("entering Collision object \n");
+ //temp local variables
+
+ tlCollisionObjectChunk* p_collisionobject= (tlCollisionObjectChunk*)sub;
+ bv_data bv_object;
+ tlDataChunk* p_dsg=NULL;
+ char sound [64] ="nosound"; //default vaule
+
+ bool errors =false;
+ char querybuffer [1000];
+
+
+ ::rootname(p_collisionobject->GetName(),bv_object.name);
+
+ printf("\n");
+ printf("BV name: %s \t ",p_collisionobject->GetName());
+
+ //seting default vaules, 7 is the default for staticphysDSG's,
+ //and physprop 0 is bogus vaule and should get filled in if BV object is know in the artdb.
+ bv_object.classtype=7;
+ bv_object.physpropid=0;
+
+ sprintf(querybuffer, "SELECT * FROM objects WHERE name = '%s' ",bv_object.name);
+ query<< querybuffer;
+ Result myresult= query.store ( );
+
+ // cout << "Records Found: " << myresult.size() << endl ;
+
+ for (sql_iterator=myresult.begin ( ); sql_iterator!= myresult.end ( ); sql_iterator++)
+ {
+
+ row =*sql_iterator;
+ char classtypeID [max_length];
+ strcpy(classtypeID, row["ClassType"]);
+ bv_object.physpropid=row["physpropid"];
+ strcpy(sound,row["Sound"]);
+
+ //make the correct DSG chunktype
+ if (strcmp(classtypeID,"PROP_MOVEABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 3\n",bv_object.name,classtypeID);
+ bv_object.classtype=3;
+ }
+
+ else if (strcmp(classtypeID,"PROP_BREAKABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 4\n",bv_object.name,classtypeID);
+ bv_object.classtype=4;
+ }
+
+ else if (strcmp(classtypeID,"PROP_STATIC")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 2\n",bv_object.name,classtypeID);
+ bv_object.classtype=2;
+ }
+
+ else if (strcmp(classtypeID,"DRAWABLE")==0)
+ {
+ printf(" %s is of type %s ERROR Drawable Objects DO NOT HAVE BV'S!!!\n",bv_object.name,classtypeID);
+ badart=true;
+ }
+ else if (strcmp(classtypeID,"PROP_DRAWABLE")==0)
+ {
+ printf(" %s is of type %s ERROR PROP_DRAWABLE Objects DO NOT HAVE BV'S!!!\n",bv_object.name,classtypeID);
+ badart=true;
+ }
+
+ else if (strcmp(classtypeID,"ANIMATED_BV")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 5\n",bv_object.name,classtypeID);
+ bv_object.classtype=5;
+ }
+ else if (strcmp(classtypeID,"STATIC")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 2\n",bv_object.name,classtypeID);
+ bv_object.classtype=7;
+ }
+ else if (strcmp (classtypeID,"PROP_ONETIME_MOVEABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 10\n",bv_object.name,classtypeID);
+ bv_object.classtype=10;
+ }
+
+
+
+ }//end for iterator loop
+
+
+
+ //creating object attribute chunk
+ tlObjectAttributeChunk* p_otc =new tlObjectAttributeChunk ();
+ p_otc->SetClassType(bv_object.classtype);
+ p_otc->SetPhyPropID(bv_object.physpropid);
+ p_otc->SetSound(sound);
+
+ //if object is a static then create a StaticPhysDSGChunk
+ if(bv_object.classtype == 7)
+ {
+ tlStaticPhysDSGChunk* p_statdsg =new tlStaticPhysDSGChunk ();
+ p_statdsg->AppendSubChunk(sub,FALSE);
+ p_statdsg->AppendSubChunk(p_otc);
+ p_statdsg->SetName(p_collisionobject->GetName());
+ outchunk->AppendSubChunk(p_statdsg,FALSE);
+ }
+
+ //otherwise find the Parent DSG and add OTC and
+ else
+ {
+ //printf(" Need to find Parent DSG \n");
+ // find the parent DynaDSG object
+ p_dsg=p_dsglist->GetDSG(p_collisionobject->GetName());
+ if(p_dsg ==NULL)
+ {
+ printf("\n===================================================\n");
+ printf("\n=\tERROR: Cant Find Parent DSG for %s, This Bounding Volume is MISSING its Mesh!! \n",p_collisionobject->GetName());
+ printf("\n===================================================\n");
+ badart=true;
+ }
+ else
+ {
+ printf(" Found the parent for %s\n",p_collisionobject->GetName());
+ p_dsg->AppendSubChunk(p_otc,FALSE);
+ p_dsg->AppendSubChunk(sub,FALSE);
+ }
+ }
+ //printf("exiting collision\n");
+ break;
+ }
+
+
+ case SRR2::ChunkID::ANIM_DSG_WRAPPER:
+ {
+ bv_data bv_object;
+ char sound[64] = "nosound"; //setting default vaule
+ char chunkname [64];
+
+
+ //tlAnimDSGWrapperChunk* p_animwrapper = dynamic_cast<tlAnimDSGWrapperChunk*>(sub);
+
+ printf("Found %s AnimWrapperChunk \n",sub->GetName());
+ ::rootname(sub->GetName(),chunkname);
+
+ //query ArtDB for info on this instanced Animated object
+ sprintf(querybuffer, "SELECT * FROM objects WHERE name = '%s' ",chunkname);
+ query<< querybuffer;
+ Result myresult = query.store ( );
+
+
+ //check if animwrapper found in artDB
+ if (myresult.size ( ) ==0 )
+
+ {
+ //object not found in the art db
+ printf(" ERROR: Object not found in the artDB,Skipping InstAnimDSGChuck Creation!\n");
+ break;
+ }
+
+
+ //getting the phys properties
+ for (sql_iterator=myresult.begin ( ); sql_iterator!= myresult.end ( ); sql_iterator++)
+ {
+ row =*sql_iterator;
+
+ //set classtype to prop_breakable
+ bv_object.classtype =4;
+ bv_object.physpropid=row["physpropid"];
+ strcpy(sound,row["Sound"]);
+
+ }
+
+ printf(" %s is of type InstaAnimDynaPhysDSG creating InstaEntityDSGChunk \n",sub->GetName());
+
+ //create InstaAnimDSGChunk and OTC
+ tlInstAnimDynaPhysDSGChunk* p_instanimdsg = new tlInstAnimDynaPhysDSGChunk ();
+ tlObjectAttributeChunk* p_otc = new tlObjectAttributeChunk ();
+
+ //fill in data for the newly created chunks
+ p_instanimdsg->SetName(sub->GetName());
+ p_otc->SetClassType(bv_object.classtype);
+ p_otc->SetPhyPropID(bv_object.physpropid);
+ p_otc->SetSound(sound);
+
+ //append chunks into the InstaAnimDynaPhysDSGChunk
+ p_instanimdsg->AppendSubChunk(sub,FALSE);
+ p_instanimdsg->AppendSubChunk(p_otc,FALSE);
+
+ //append InstaAnimDynaPhysDSGChunk to the outchunk
+ outchunk->AppendSubChunk(p_instanimdsg,FALSE);
+ p_dsglist->AddDSG(p_instanimdsg);
+
+ break;
+ }
+
+ case SRR2::ChunkID::ANIM_OBJ_DSG_WRAPPER:
+ {
+ bv_data bv_object;
+ char sound[64] = "nosound"; //setting default vaule
+ char chunkname [64];
+
+
+ //tlAnimDSGWrapperChunk* p_animwrapper = dynamic_cast<tlAnimDSGWrapperChunk*>(sub);
+
+ printf("Found %s AnimObjWrapperChunk \n",sub->GetName());
+ ::rootname(sub->GetName(),chunkname);
+
+ //query ArtDB for info on this instanced Animated object
+ sprintf(querybuffer, "SELECT * FROM objects WHERE name = '%s' ",chunkname);
+ query<< querybuffer;
+ Result myresult = query.store ( );
+
+
+ //check if animobjwrapper found in artDB
+ if (myresult.size ( ) ==0 )
+
+ {
+ //object not found in the art db
+ printf(" ERROR: Object not found in the artDB,Skipping InstAnimDSGChuck Creation!\n");
+ break;
+ }
+
+
+ //getting the phys properties
+ for (sql_iterator=myresult.begin ( ); sql_iterator!= myresult.end ( ); sql_iterator++)
+ {
+
+ row =*sql_iterator;
+
+ char classtypeID [max_length];
+ strcpy(classtypeID, row["ClassType"]);
+ bv_object.physpropid=row["physpropid"];
+ strcpy(sound,row["Sound"]);
+ strcpy(bv_object.name,sub->GetName());
+
+ //set the correct classtypeID
+ if (strcmp(classtypeID,"PROP_MOVEABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 3\n",bv_object.name,classtypeID);
+ bv_object.classtype=3;
+ }
+
+ else if (strcmp(classtypeID,"PROP_BREAKABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 4\n",bv_object.name,classtypeID);
+ bv_object.classtype=4;
+ }
+
+ else if (strcmp(classtypeID,"PROP_STATIC")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 2\n",bv_object.name,classtypeID);
+ bv_object.classtype=2;
+ }
+
+ else if (strcmp(classtypeID,"DRAWABLE")==0)
+ {
+ printf(" %s is of type %s ERROR Drawable Objects DO NOT HAVE BV'S!!!\n",bv_object.name,classtypeID);
+ badart=true;
+ }
+ else if (strcmp(classtypeID,"PROP_DRAWABLE")==0)
+ {
+ printf(" %s is of type %s ERROR PROP_DRAWABLE Objects DO NOT HAVE BV'S!!!\n",bv_object.name,classtypeID);
+ badart=true;
+ }
+
+ else if (strcmp(classtypeID,"ANIMATED_BV")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 5\n",bv_object.name,classtypeID);
+ bv_object.classtype=5;
+ }
+ else if (strcmp(classtypeID,"STATIC")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 2\n",bv_object.name,classtypeID);
+ bv_object.classtype=7;
+ }
+
+ else if (strcmp(classtypeID,"PROP_ANIM_BREAKABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 9 \n",bv_object.name,classtypeID);
+ bv_object.classtype=9;
+ }
+
+ else if (strcmp(classtypeID,"PROP_ONETIME_MOVEABLE")==0)
+ {
+ printf(" %s is of type %s Setting Classtype to 10\n",bv_object.name,classtypeID);
+ bv_object.classtype=10;
+ }
+
+
+
+ }//end for loop
+
+ printf(" %s is of type InstaAnimDynaPhysDSG creating InstaAnimDynaPhysDSGChunk \n",sub->GetName());
+
+ //create InstaAnimDSGChunk and OTC
+ tlInstAnimDynaPhysDSGChunk* p_instanimdsg = new tlInstAnimDynaPhysDSGChunk ();
+ tlObjectAttributeChunk* p_otc = new tlObjectAttributeChunk ();
+
+ //fill in data for the newly created chunks
+ p_instanimdsg->SetName(sub->GetName());
+ p_otc->SetClassType(bv_object.classtype);
+ p_otc->SetPhyPropID(bv_object.physpropid);
+ p_otc->SetSound(sound);
+
+ //append chunks into the InstaAnimDynaPhysDSGChunk
+ p_instanimdsg->AppendSubChunk(sub,FALSE);
+ p_instanimdsg->AppendSubChunk(p_otc,FALSE);
+
+ //append InstaAnimDynaPhysDSGChunk to the outchunk
+ outchunk->AppendSubChunk(p_instanimdsg,FALSE);
+ p_dsglist->AddDSG(p_instanimdsg);
+
+ break;
+ }
+
+
+ case SRR2::ChunkID::INSTANCES:
+ {
+ tlDataChunk* p_dsg=NULL;
+ tlDataChunk* subchunk= sub->GetSubChunk(0);
+ tlScenegraphChunk* p_scenegraphchunk= dynamic_cast<tlScenegraphChunk *>(subchunk);
+
+ printf("\n");
+ printf("Found %s instance chunk,looking for Parent DSG.\n",p_scenegraphchunk->GetName());
+ p_dsg=p_dsglist->GetDSG(p_scenegraphchunk->GetName());
+ if(p_dsg ==NULL)
+ {
+ printf("\n===================================================\n");
+ printf("\n=\tERROR: Cant Find Parent DSG Chunk for %s, SceneGraph is MISSING its Mesh!! \n",p_scenegraphchunk->GetName());
+ printf("\n===================================================\n");
+ badart=true;
+ }
+ else
+ {
+ printf(" Found the parent for %s\n",p_scenegraphchunk->GetName());
+ p_dsg->AppendSubChunk(sub,FALSE);
+ }
+ break;
+ }
+
+ default:
+ {
+ // this is not a chunk that we care about
+ // so simply copy it to the output wrapper chunk
+ // the optional parameter to AppendSubChunk
+ // indicates that we have merely copied a pointer
+ // so the destructor of outchunk should not
+ // destroy this sub-chunk as that duty will be
+ // taken care of by the destructor of inchunk
+ outchunk->AppendSubChunk(sub,FALSE);
+ break;
+ }
+ }//end switch
+ }//end for
+
+ p_dsglist->ReSortDSGChunks();
+
+ if ( mbIgnoreMissingInstanceChunk == true)
+ {
+ p_dsglist->mbNoInstanceChunks = true;
+ //printf("Ignore chunk is set!\n");
+ }
+
+ if(p_dsglist->VerifyChunks() == 1)
+ {
+ badart=true;
+ }
+
+
+
+ } //end of try
+
+
+
+ catch (BadQuery er)
+ {
+ cout<<"Error: " <<er.error<< endl;
+ return 1;
+ }
+
+ if (badart)
+ {
+
+ printf("\n=======================================================\n");
+ printf("\n=\tERROR: %s is missing Chunks for DSG objects Aborting DSG Prop Creation !!! \n",filename);
+ printf("\n=======================================================\n");
+
+/*
+ // create the new output file
+ tlFile output(new tlFileByteStream(filename, omWRITE), tlFile::CHUNK32);
+
+ if(!output.IsOpen())
+ {
+ printf("Could not open %s for writing,unable to Save\n", filename);
+ exit(-1);
+ }
+
+ // get the output wrapper chunk to write its data out
+ // to the file
+ outchunk->Write(&output);
+*/
+ delete inchunk;
+ delete outchunk;
+ delete p_dsglist;
+ return 1;
+ }
+ else
+ {
+
+ printf("\n=======================================================\n");
+ printf("\n=\tDSGmaker: Completed without ERRORS \n");
+ printf("\n=======================================================\n");
+
+ // create the new output file
+ tlFile output(new tlFileByteStream(filename, omWRITE), tlFile::CHUNK32);
+
+ if(!output.IsOpen())
+ {
+ printf("Could not open %s for writing\n", filename);
+ exit(-1);
+ }
+
+ // get the output wrapper chunk to write its data out
+ // to the file
+ outchunk->Write(&output);
+
+ // cleanup the no-longer-needed chunks
+ delete inchunk;
+ delete outchunk;
+ delete p_dsglist;
+
+
+ return 0;
+ }
+} //end of main
+
+
+
+/********************************************************************/
+/* Helper Function to strip extra crap from the string */
+/********************************************************************/
+
+
+unsigned int rootname(const char * input,char* output)
+{
+ char source_name[max_length];
+ char object_name1[max_length];
+ char object_name2[max_length];
+ char* token =NULL;
+
+ //printf("Phase 1 get name \n");
+
+ //get the name of collision object
+ strcpy(source_name,input);
+ //cout<<"Source name: "<<source_name<<endl;
+
+ //printf("smashing %s\n",source_name);
+ //smash up string to remove the number appended by Maya
+ //printf("strtok1\n");
+ token=strtok(source_name,"_");
+ strcpy(object_name1,token);
+ //printf("After stringtok :%s \n",object_name1);
+
+ //printf("strcat1\n");
+ //reform string
+ strcat(object_name1,"_");
+
+
+ //printf("strtok2\n");
+ token=strtok(NULL,"_");
+
+ if(token != NULL)
+ {
+ strcpy(object_name2,token);
+ //printf("After stringtok :%s \n",object_name2);
+ // printf("strcat2\n");
+ strcat(object_name1,object_name2);
+ }
+
+ //printf("strcpy\n");
+ //set default vaules
+
+ strcpy(output,object_name1);
+ //printf("processed name : %s\n",output);
+ return 0;
+}
+