summaryrefslogtreecommitdiffstats
path: root/tools/CreateSetChunk
diff options
context:
space:
mode:
Diffstat (limited to 'tools/CreateSetChunk')
-rw-r--r--tools/CreateSetChunk/SetChunk.dsp155
-rw-r--r--tools/CreateSetChunk/SetChunk.dsw122
-rw-r--r--tools/CreateSetChunk/SetChunk.sc22
-rw-r--r--tools/CreateSetChunk/main.cpp494
-rw-r--r--tools/CreateSetChunk/version.cpp21
-rw-r--r--tools/CreateSetChunk/version.hpp15
6 files changed, 829 insertions, 0 deletions
diff --git a/tools/CreateSetChunk/SetChunk.dsp b/tools/CreateSetChunk/SetChunk.dsp
new file mode 100644
index 0000000..45bc869
--- /dev/null
+++ b/tools/CreateSetChunk/SetChunk.dsp
@@ -0,0 +1,155 @@
+# Microsoft Developer Studio Project File - Name="Image2LUT" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 60000
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Image2LUT - Win32 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 "SetChunk.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 "SetChunk.mak" CFG="Image2LUT - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Image2LUT - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Image2LUT - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "Image2LUT"
+# PROP Scc_LocalPath "."
+CPP=snCl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Image2LUT - 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 /MT /W3 /GX /O2 /I "../perl" /I "../../game/libs/pure3d/toollib/inc" /I "../../game/libs/pure3d/constants" /I "../../game/libs/pure3d/toollib/chunks16/inc" /I "../../game/code/constants" /I "../../game/libs/radmath" /I "../../game/libs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "P3DDEBUG" /D "P3DWIN95" /D "RAD_RELEASE" /D "RAD_WIN32" /D "RAD_PC" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=snBsc.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=snLink.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 /subsystem:console /machine:I386
+# ADD 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 /subsystem:console /machine:I386 /nodefaultlib:"LIBC.lib" /out:"..\bin\CreateSetChunk.exe"
+# SUBTRACT LINK32 /nodefaultlib
+
+!ELSEIF "$(CFG)" == "Image2LUT - 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 /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../perl" /I "../../game/libs/pure3d/toollib/inc" /I "../../game/libs/pure3d/constants" /I "../../game/libs/pure3d/toollib/chunks16/inc" /I "../../game/libs/radmath" /I "../../game/code/constants" /I "../../game/libs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "P3DDEBUG" /D "P3DWIN95" /D "RAD_DEBUG" /D "RAD_WIN32" /D "RAD_PC" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=snBsc.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=snLink.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 /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD 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 /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBC.lib LIBCMTD.lib" /pdbtype:sept
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF
+
+# Begin Target
+
+# Name "Image2LUT - Win32 Release"
+# Name "Image2LUT - Win32 Debug"
+# Begin Group "Source"
+
+# PROP Default_Filter "*.cpp, *.c"
+# Begin Source File
+
+SOURCE=.\main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Param.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\version.cpp
+# End Source File
+# End Group
+# Begin Group "Include"
+
+# PROP Default_Filter "*.hpp, *.h"
+# Begin Source File
+
+SOURCE=.\Param.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\version.hpp
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\SetChunk.sc
+
+!IF "$(CFG)" == "Image2LUT - Win32 Release"
+
+# Begin Custom Build - ToolsParamCreator
+InputPath=.\SetChunk.sc
+InputName=SetChunk
+
+BuildCmds= \
+ ..\..\game\libs\pure3d\tools\commandline\bin\ToolsParamCreator -s $(InputName).sc
+
+"Param.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Param.hpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Image2LUT - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\SetChunk.sc
+InputName=SetChunk
+
+BuildCmds= \
+ ..\..\game\libs\pure3d\tools\commandline\bin\ToolsParamCreator -s $(InputName).sc
+
+"Param.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Param.hpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/tools/CreateSetChunk/SetChunk.dsw b/tools/CreateSetChunk/SetChunk.dsw
new file mode 100644
index 0000000..6e2d18e
--- /dev/null
+++ b/tools/CreateSetChunk/SetChunk.dsw
@@ -0,0 +1,122 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Image2LUT"=.\SetChunk.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name freetype
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libpng
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name zlib
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name toollib
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name toollib_extras
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name radmath
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "freetype"=..\..\game\libs\pure3d\lib\freetype\builds\win32\visualc\freetype.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libpng"=..\..\game\libs\pure3d\build\win32\libpng.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name zlib
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "radmath"=..\..\game\libs\radmath\build\win32\radmath.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "toollib"=..\..\game\libs\pure3d\toollib\toollib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "toollib_extras"=..\..\game\libs\pure3d\toollib\toollib_extras.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "zlib"=..\..\game\libs\pure3d\build\win32\zlib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/tools/CreateSetChunk/SetChunk.sc b/tools/CreateSetChunk/SetChunk.sc
new file mode 100644
index 0000000..d7b5092
--- /dev/null
+++ b/tools/CreateSetChunk/SetChunk.sc
@@ -0,0 +1,22 @@
+tool SetChunk :
+ description( "This tool turns a texture animation into a set chunk." )
+{
+}
+
+parameter OutputFile :
+ short( o ),
+ long( "output-file" ),
+ arg( name ),
+ description( "Specify output file." ),
+ type( string )
+{
+}
+
+parameter ShaderName :
+ short( s ),
+ long( "shader-name" ),
+ arg( name ),
+ description( "Specify the shader with texture animation whose textures will become set chunk." ),
+ type( string )
+{
+}
diff --git a/tools/CreateSetChunk/main.cpp b/tools/CreateSetChunk/main.cpp
new file mode 100644
index 0000000..62228a4
--- /dev/null
+++ b/tools/CreateSetChunk/main.cpp
@@ -0,0 +1,494 @@
+/*===========================================================================
+ File: main.cpp
+
+ This tool turns a greyscale image into a raw look up table.
+
+ Copyright (c) Radical Entertainment, Inc. All rights reserved.
+
+===========================================================================*/
+
+#include <stdio.h>
+#include <assert.h>
+#include <toollib.hpp>
+#include <dospath.hpp>
+#include <tlFrameControllerChunk16.hpp>
+#include <tlAnimationChunk.hpp>
+#include <atenum.hpp>
+#include <chunkids.hpp>
+
+#include "Param.hpp"
+#include <tlSetChunk.hpp>
+
+Parameters* Param;
+char outFile[P3DMAXNAME];
+
+struct TextureData
+{
+ TextureData() :
+ m_TextureID( 0 ),
+ m_NumIDs( 0 ),
+ m_ShaderID( 0 ),
+ m_AnimationChunk( 0 ),
+ m_ControllerChunk( 0 ),
+// m_MultiControllerChunk( 0 ),
+ m_pSetChunk( 0 ),
+ m_WritenOut( false ) {};
+ ~TextureData() { delete m_TextureID; } // Set chunk is deleted by the output chunk.
+ TLUID* m_TextureID; // List of texture chunks to put into set chunk.
+ int m_NumIDs; // Number in list. If number is negative then just the animation/controller chunk are removed and multicontroller modified.
+ TLUID m_ShaderID; // The shader this data is for.
+ TLUID m_AnimationChunk; // Texture animation chunk to remove.
+ TLUID m_ControllerChunk; // Texture frame controller chunk to remove.
+// TLUID m_MultiControllerChunk; // MultiController to remove texture frame controller from.
+ tlSetChunk* m_pSetChunk; // Set chunk which will be written to file.
+ bool m_WritenOut; // Has the set chunk been written out?
+};
+
+static const int TEXTURE_COLLECTION_SIZE = 256;
+static TextureData* g_TextureCollection[ TEXTURE_COLLECTION_SIZE ];
+static int g_TextureCollectionCount = 0;
+
+int main(int argc, char* argv[])
+{
+ Param = new Parameters(argc,argv);
+ bool sameFile = false; // Have we switched to a new output file.
+
+ tlDataChunk::RegisterDefaultChunks();
+
+ tlFile* output = 0;
+
+ for( int i = 0; i < TEXTURE_COLLECTION_SIZE; ++i )
+ {
+ g_TextureCollection[ i ] = 0;
+ }
+
+ if( Param->Files.Count() < 1 )
+ {
+ printf( "Must specify at least one input file.\n" );
+ exit( -1 );
+ }
+ if( Param->ShaderName == 0 )
+ {
+ printf( "Must specify the name of the shader with texture animation.\n" );
+ exit( -1 );
+ }
+
+ bool wildCardShader = false;
+ int shaderNameLen = strlen( Param->ShaderName );
+ if( Param->ShaderName[ shaderNameLen - 1 ] == '*' )
+ {
+ wildCardShader = true;
+ --shaderNameLen;
+ Param->ShaderName[ shaderNameLen ] = '\0';
+ }
+
+ // for each file on the command-line, do the following:
+ for(int curFile = 0; curFile < Param->Files.Count(); curFile++)
+ {
+ tlFile input(new tlFileByteStream(Param->Files[ curFile ], omREAD), tlFile::FROMFILE);
+ if(!input.IsOpen())
+ {
+ printf("Could not open %s\n", Param->Files[ curFile ]);
+ exit( -1 );
+ }
+ tlDataChunk* inChunk = new tlDataChunk( &input );
+
+ char outFileName[256];
+ if( output == 0 )
+ {
+ if( Param->OutputFile )
+ {
+ strcpy(outFileName, Param->OutputFile);
+ }
+ else
+ {
+ strcpy(outFileName, Param->Files[curFile]);
+ RemoveExtension(outFileName);
+ strcat(outFileName, ".p3d");
+ }
+ output = new tlFile(new tlFileByteStream(outFileName, omWRITE), tlFile::CHUNK32);
+ if( ( output == 0 ) || ( !output->IsOpen() ) )
+ {
+ printf("Could not open %s for writing\n", outFileName);
+ exit(-1);
+ }
+ sameFile = false;
+ }
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ delete g_TextureCollection[ i ];
+ g_TextureCollection[ i ] = 0;
+ }
+
+ /*************************************************/
+ // First pass for input file, nose through the frame controllers.
+ // Go through all the sub-chunks of the input and look for shader name
+ //in heirarchy of texture frame controller.
+ int inChunkIndex;
+ for( inChunkIndex = 0; inChunkIndex < inChunk->SubChunkCount(); inChunkIndex++ )
+ {
+ tlDataChunk* sub = inChunk->GetSubChunk( inChunkIndex );
+ if( sub->ID() == Pure3D::Animation::FrameControllerData::FRAME_CONTROLLER )
+ {
+ // We have a frame controller...
+ tlFrameControllerChunk* controller = static_cast<tlFrameControllerChunk*>( sub );
+ if( controller->GetType() == Pure3DAnimationTypes::TEXTURE_TEX )
+ {
+ // and it's a texture controller. So check the hierarchy name.
+ bool foundShader = false;
+ const char* heirName = controller->HierarchyName();
+ if( wildCardShader )
+ {
+ foundShader = strncmp( heirName, Param->ShaderName, shaderNameLen ) == 0;
+ }
+ else
+ {
+ foundShader = strcmp( heirName, Param->ShaderName ) == 0;
+ }
+ if( foundShader )
+ {
+ // We found the shader so remember the texture animation data.
+ TextureData* texData = new TextureData();
+ if( texData == 0 )
+ {
+ printf( "Unable to allocate texture data.\n" );
+ exit( -1 );
+ }
+ texData->m_ShaderID = tlEntity::MakeUID( heirName );
+ texData->m_ControllerChunk = tlEntity::MakeUID( controller->GetName() );
+ texData->m_AnimationChunk = tlEntity::MakeUID( controller->AnimationName() );
+ // Look to see if we already have this shader.
+ //If we do, we'll just erase the controller and animation and modify the multicontroller.
+ //The first texData will be used to create the chunk set.
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ if( g_TextureCollection[ i ]->m_ShaderID == texData->m_ShaderID )
+ {
+ texData->m_NumIDs = -1;
+ break;
+ }
+ }
+ g_TextureCollection[ g_TextureCollectionCount ] = texData;
+ ++g_TextureCollectionCount;
+ }
+ }
+ }
+ }
+ /*************************************************/
+ // Second pass. Now we look for the animation to go with all those texture frame controllers
+ //we found.
+ for( inChunkIndex = 0; inChunkIndex < inChunk->SubChunkCount(); inChunkIndex++ )
+ {
+ tlDataChunk* sub = inChunk->GetSubChunk( inChunkIndex );
+ // Is this an animation?
+ if( sub->ID() != Pure3D::Animation::AnimationData::ANIMATION )
+ {
+ // No, not interested.
+ continue;
+ }
+ tlAnimationChunk* anim = static_cast<tlAnimationChunk*>( sub );
+ // Is it a texture animation?
+ if( anim->GetAnimationType() != Pure3DAnimationTypes::TEXTURE_TEX )
+ {
+ // No, not interested.
+ continue;
+ }
+ // We've found a texture animation. Check if it's one we are looking for.
+ TLUID animID = tlEntity::MakeUID( anim->GetName() );
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ if( ( g_TextureCollection[ i ]->m_NumIDs == 0 ) && ( g_TextureCollection[ i ]->m_AnimationChunk == animID ) )
+ {
+ // We've found the animation to match a frame controller. Let the mess begin.
+ TextureData* texData = g_TextureCollection[ i ]; // just for convience.
+ // Examine the sub chunks...there should be a goup list in there...
+ for( int subChunkIndex = 0; subChunkIndex < anim->SubChunkCount(); ++subChunkIndex )
+ {
+ tlDataChunk* animSub = anim->GetSubChunk( subChunkIndex );
+ if( animSub->ID() == Pure3D::Animation::AnimationData::GROUP_LIST )
+ {
+ // Found the group list. Now we'll nose around the groups...
+ tlAnimationGroupListChunk* groupList = static_cast<tlAnimationGroupListChunk*>( animSub );
+ for( int listChunkIndex = 0; listChunkIndex < groupList->SubChunkCount(); ++listChunkIndex )
+ {
+ // Look at all the channels in the groups in the group list.
+ tlDataChunk* listSub = groupList->GetSubChunk( listChunkIndex );
+ if( listSub->ID() == Pure3D::Animation::AnimationData::GROUP )
+ {
+ tlAnimationGroupChunk* group = static_cast<tlAnimationGroupChunk*>( listSub );
+ for( int channelIndex = 0; channelIndex < (int)group->GetNumChannels(); ++channelIndex )
+ {
+ int i;
+ // In the group (whew), look at all the channels.
+ // Is it an entity channel?
+ tlDataChunk* channelSub = group->GetSubChunk( channelIndex );
+ if( channelSub->ID() != Pure3D::Animation::ChannelData::ENTITY )
+ {
+ // No, not interested.
+ continue;
+ }
+ // Is the entity channel a texture?
+ tlEntityChannelChunk* entityChannel = static_cast<tlEntityChannelChunk*>( channelSub );
+ if( entityChannel->Param() != Pure3DAnimationTypes::TEXTURE_TEX )
+ {
+ // No, not interested.
+ continue;
+ }
+ // Okay we have the entity channel for a texture animation, now we
+ //record the texture names.
+ // We might end up allocating extra space for textures, but we'll
+ //leave the UIDs at zero at the end of the array.
+ texData->m_TextureID = new TLUID[ entityChannel->GetNumFrames() ];
+ if( texData->m_TextureID == 0 )
+ {
+ printf( "Unable to allocate texture array.\n" );
+ exit( -1 );
+ }
+ for( i = 0; i < (int)entityChannel->GetNumFrames(); ++i )
+ {
+ texData->m_TextureID[ i ] = 0;
+ }
+ // Get all the frame values.
+ char** values = entityChannel->GetValues();
+ for( i = 0; i < (int)entityChannel->GetNumFrames(); ++i )
+ {
+ TLUID textureID = tlEntity::MakeUID( values[ i ] );
+ // We have the texture tUID, look if it's a duplicate.
+ bool textureDup = false;
+ for( int j = 0; j < texData->m_NumIDs; ++j )
+ {
+ if( texData->m_TextureID[ j ] == textureID )
+ {
+ // this one is a duplicate, skip it.
+ textureDup = true;
+ break;
+ }
+ }
+ if( !textureDup )
+ {
+ // It's not a duplicate so remember it.
+ texData->m_TextureID[ texData->m_NumIDs ] = textureID;
+ ++texData->m_NumIDs;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /*************************************************/
+ // Third pass, create the set chunks from the textures we got from those texture animations.
+ for( inChunkIndex = 0; inChunkIndex < inChunk->SubChunkCount(); inChunkIndex++ )
+ {
+ tlDataChunk* sub = inChunk->GetSubChunk( inChunkIndex );
+ if( sub->ID() == Pure3D::Texture::TEXTURE )
+ {
+ // We've found a texture, check to see if it's one of the textures we are looking for.
+ TextureData* texData = 0;
+ int textureIDIndex = 0;
+ TLUID textureID = tlEntity::MakeUID( sub->GetName() );
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ texData = g_TextureCollection[ i ];
+ for( textureIDIndex = 0; textureIDIndex < texData->m_NumIDs; ++textureIDIndex )
+ {
+ if( textureID == texData->m_TextureID[ textureIDIndex ] )
+ {
+ if( texData->m_pSetChunk == 0 )
+ {
+ texData->m_pSetChunk = new tlSetChunk();
+ if( texData->m_pSetChunk == 0 )
+ {
+ printf( "Unable to create tlSetChunk.\n" );
+ exit( -1 );
+ }
+ }
+ if( textureIDIndex == 0 )
+ {
+ // This is the first texture in the set so we'll use the name for
+ //the set.
+ texData->m_pSetChunk->SetName( sub->GetName() );
+ }
+ texData->m_pSetChunk->AppendSubChunk( sub, 0 );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /*************************************************/
+ // Forth pass, process the file. Copy all the chunks over,
+ //except the texture frame controllers, texture animations,
+ //and textures we've used. Also, modify the multicontrollers
+ //to exclude the texture frame controllers.
+ tlDataChunk* outChunk = new tlDataChunk;
+
+ if( Param->WriteHistory && !sameFile )
+ {
+ // put a history chunk in the output
+ // a history chunk shows what version of the tool
+ // was run on the file with what command-line
+ // parameters
+ outChunk->AppendSubChunk(Param->HistoryChunk());
+ sameFile = true;
+ }
+
+ if( outChunk == 0 )
+ {
+ printf( "Unable to create output chunk.\n" );
+ exit( -1 );
+ }
+ for( inChunkIndex = 0; inChunkIndex < inChunk->SubChunkCount(); inChunkIndex++ )
+ {
+ tlDataChunk* sub = inChunk->GetSubChunk( inChunkIndex );
+ if( sub->ID() == Pure3D::Texture::TEXTURE )
+ {
+ bool inAnySet = false;
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ // Theorically a texture can go into multiple sets so go through them all.
+ bool found = false;
+ TextureData* texData = g_TextureCollection[ i ];
+ for( int j = 0; j < texData->m_NumIDs; ++j )
+ {
+ // Look to see if this texture is in this set.
+ if( tlEntity::MakeUID( sub->GetName() ) == texData->m_TextureID[ j ] )
+ {
+ found = true;
+ inAnySet = true;
+ break;
+ }
+ }
+ if( found && ( texData->m_NumIDs > 0 ) )
+ {
+ // This texture has gone into this set chunk. We'll write the
+ //set chunk out at this point so it's roughly in the same place in
+ //file to protect against load order dependency problems.
+ if( texData->m_WritenOut == false )
+ {
+ texData->m_pSetChunk->SetChildCount( texData->m_NumIDs );
+ outChunk->AppendSubChunk( texData->m_pSetChunk );
+ texData->m_WritenOut = true; // Only write it once.
+ }
+ }
+ }
+ if( !inAnySet )
+ {
+ // This isn't a texture we're interested in so write it out.
+ outChunk->AppendSubChunk( sub );
+ }
+ }
+ else if( sub->ID() == Pure3D::Animation::FrameControllerData::FRAME_CONTROLLER )
+ {
+ // This is a frame controller. If it's one we've used then don't include it.
+ bool found = false;
+ TLUID controllerID = tlEntity::MakeUID( sub->GetName() );
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ if( controllerID == g_TextureCollection[ i ]->m_ControllerChunk )
+ {
+ found = true;
+ break;
+ }
+ }
+ if( !found )
+ {
+ outChunk->AppendSubChunk( sub );
+ }
+ }
+ else if( sub->ID() == Pure3D::Animation::AnimationData::ANIMATION )
+ {
+ // This is an animation. If it's one we've used then don't include it.
+ bool found = false;
+ TLUID animID = tlEntity::MakeUID( sub->GetName() );
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ if( animID == g_TextureCollection[ i ]->m_AnimationChunk )
+ {
+ found = true;
+ break;
+ }
+ }
+ if( !found )
+ {
+ outChunk->AppendSubChunk( sub );
+ }
+ }
+ else if( sub->ID() == P3D_MULTI_CONTROLLER )
+ {
+ // This is a multicontroller. If a track references an framecontroller we
+ //used then exclude that track.
+ tlMultiControllerChunk16* multiCont = static_cast<tlMultiControllerChunk16*>( sub );
+ for( int subIndex = 0; subIndex < multiCont->SubChunkCount(); ++subIndex )
+ {
+ tlDataChunk* subChunk = multiCont->GetSubChunk( subIndex );
+ if( subChunk->ID() == P3D_MULTI_CONTROLLER_TRACKS )
+ {
+ tlMultiControllerTracksChunk16* tracks = static_cast<tlMultiControllerTracksChunk16*>( subChunk );
+ unsigned long numTracks = tracks->GetNumTracks();
+ tlMultiControllerTrackData* trackArray = tracks->GetTracks();
+ for( int i = 0; i < numTracks; ++i )
+ {
+ TLUID trackID = tlEntity::MakeUID( trackArray[ i ].name );
+ for( int j = 0; j < g_TextureCollectionCount; ++j )
+ {
+ if( trackID == g_TextureCollection[ j ]->m_ControllerChunk )
+ {
+ // Remove this track.
+ --numTracks;
+ tracks->SetNumTracks( numTracks );
+ multiCont->SetNumTracks( multiCont->GetNumTracks() - 1 );
+ if( i < numTracks )
+ {
+ trackArray[ i ] = trackArray[ numTracks ];
+ --i;
+ }
+ }
+ }
+ }
+ }
+ else if( subChunk->ID() == P3D_MULTI_CONTROLLER_TRACK )
+ {
+ tlMultiControllerTrackChunk16* track = static_cast<tlMultiControllerTrackChunk16*>( subChunk );
+ TLUID trackID = tlEntity::MakeUID( track->GetName() );
+ for( int i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ if( trackID == g_TextureCollection[ i ]->m_ControllerChunk )
+ {
+ multiCont->RemoveSubChunk( subIndex );
+ multiCont->SetNumTracks( multiCont->GetNumTracks() - 1 );
+ }
+ }
+ }
+ }
+ outChunk->AppendSubChunk( sub );
+ }
+ else
+ {
+ outChunk->AppendSubChunk( sub );
+ }
+ }
+ outChunk->Write( output );
+ delete outChunk;
+ outChunk = 0;
+ if( Param->OutputFile == 0 )
+ {
+ // We have multiple output files so get rid of the
+ //the output file now.
+ delete output;
+ output = 0;
+ }
+ for( i = 0; i < g_TextureCollectionCount; ++i )
+ {
+ delete g_TextureCollection[ i ];
+ g_TextureCollection[ i ] = 0;
+ }
+ } // end of main for loop
+
+ delete Param;
+ return 0;
+}
diff --git a/tools/CreateSetChunk/version.cpp b/tools/CreateSetChunk/version.cpp
new file mode 100644
index 0000000..ac9ae2b
--- /dev/null
+++ b/tools/CreateSetChunk/version.cpp
@@ -0,0 +1,21 @@
+/*===========================================================================
+
+ File:: version.cpp
+
+ Copyright (c) Radical Entertainment, Inc. All rights reserved.
+
+===========================================================================*/
+
+#include <stdio.h>
+#include "version.hpp"
+
+char* version = "1.0.1";
+
+/* History */
+
+char* versioninfo[] = {
+ "1.0.1 Perserve tMultiControllers, just remove texture animation.",
+ "1.0.0 Initial version.",
+ NULL
+};
+
diff --git a/tools/CreateSetChunk/version.hpp b/tools/CreateSetChunk/version.hpp
new file mode 100644
index 0000000..076e5ec
--- /dev/null
+++ b/tools/CreateSetChunk/version.hpp
@@ -0,0 +1,15 @@
+/*===========================================================================
+
+ File:: version.hpp
+
+ Copyright (c) Radical Entertainment, Inc. All rights reserved.
+
+===========================================================================*/
+
+#ifndef _VERSION_HPP
+#define _VERSION_HPP
+
+extern char* version;
+extern char* versioninfo[];
+
+#endif