diff --git a/Libraries/FileHandler/CMakeLists.txt b/Libraries/FileHandler/CMakeLists.txt index 8b9132f..e4b532b 100644 --- a/Libraries/FileHandler/CMakeLists.txt +++ b/Libraries/FileHandler/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(FileHandler) +add_subdirectory(iff) add_subdirectory(libexpat) add_subdirectory(libfar) add_subdirectory(libjpeg-turbo) diff --git a/Libraries/FileHandler/iff/CMakeLists.txt b/Libraries/FileHandler/iff/CMakeLists.txt new file mode 100644 index 0000000..356c4fa --- /dev/null +++ b/Libraries/FileHandler/iff/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6) +project(iff) + +set(IFF_SOURCES + chunks.c + iff.c + iffexport.c +) + +add_executable(iffexport ${IFF_SOURCES}) \ No newline at end of file diff --git a/Libraries/FileHandler/iff/chunks.c b/Libraries/FileHandler/iff/chunks.c new file mode 100644 index 0000000..36f80e5 --- /dev/null +++ b/Libraries/FileHandler/iff/chunks.c @@ -0,0 +1,24 @@ +/* + chunks.c - Copyright (c) 2012 Fatbag + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#include +#include +#include "iff.h" + +int iff_read_rsmp(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize, unsigned IFFSize){ + return 1; +} \ No newline at end of file diff --git a/Libraries/FileHandler/iff/iff.c b/Libraries/FileHandler/iff/iff.c new file mode 100644 index 0000000..9b4d38c --- /dev/null +++ b/Libraries/FileHandler/iff/iff.c @@ -0,0 +1,150 @@ +/* + iff.c - Copyright (c) 2012 Fatbag + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#include +#include +#include "iff.h" + +#ifndef __inline +#define __inline +#endif +#ifndef __restrict +#define __restrict +#endif + +IFFFile * iff_create() +{ + IFFFile *ptr = malloc(sizeof(IFFFile)); + if(ptr == NULL) return NULL; + + memset(ptr, 0, sizeof(IFFFile)); + + return ptr; +} + +int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize) +{ + unsigned offset; + + if(!FileSize) FileSize = ~0; + else if(FileSize < 64) + return 0; + + if(memcmp(Buffer, Header_IFF, 60)) + return 0; + memcpy(IFFFileInfo->Header, Buffer, 60); + + offset = read_uint32be(Buffer+60); + if(offset > FileSize - 28) + return 0; + + return 1; +} + +IFFChunkNode * iff_add_chunk(IFFFile * IFFFileInfo, int Position) +{ + IFFChunkNode *ptr = malloc(sizeof(IFFChunkNode)), *node; + if(ptr == NULL) return NULL; + memset(ptr, 0, sizeof(IFFChunkNode)); + if(IFFFileInfo == NULL) return ptr; + + if(Position >= 0){ + node = IFFFileInfo->FirstChunk; + + if(node == NULL){ + IFFFileInfo->FirstChunk = ptr; + IFFFileInfo->LastChunk = ptr; + }else{ + /* Find the node we will take the place of */ + while(Position-- && node->NextChunk != NULL) + node = node->NextChunk; + + if(node->PrevChunk == NULL) + IFFFileInfo->FirstChunk = ptr; + + /* Shift this node and all nodes after it above us */ + ptr->PrevChunk = node->PrevChunk; + ptr->NextChunk = node; + node->PrevChunk = ptr; + } + }else{ + node = IFFFileInfo->LastChunk; + + if(node == NULL){ + IFFFileInfo->FirstChunk = ptr; + IFFFileInfo->LastChunk = ptr; + }else{ + /* Find the node we will take the place of */ + while(++Position && node->PrevChunk != NULL) + node = node->PrevChunk; + + if(node->NextChunk == NULL) + IFFFileInfo->LastChunk = ptr; + + /* Shift this node and all nodes before it below us */ + ptr->PrevChunk = node; + ptr->NextChunk = node->NextChunk; + node->NextChunk = ptr; + } + } + + IFFFileInfo->ChunkCount++; + return ptr; +} + +int iff_read_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize) +{ + if(MaxChunkSize == 0) MaxChunkSize = ~0; + + if(MaxChunkSize < 76) + return 0; + + memcpy(ChunkInfo->Type, Buffer+0, 4); + ChunkInfo->Size = read_uint32be(Buffer+4); + ChunkInfo->ChunkID = read_uint16be(Buffer+8); + ChunkInfo->Flags = read_uint16be(Buffer+10); + memcpy(ChunkInfo->Label, Buffer+12, 64); + + if(ChunkInfo->Size < 76 || ChunkInfo->Size > MaxChunkSize) + return 0; + + if(ChunkInfo->Size > 76){ + ChunkInfo->Data = malloc(ChunkInfo->Size - 76); + if(ChunkInfo->Data == NULL) + return 0; + memcpy(ChunkInfo->Data, Buffer+76, ChunkInfo->Size - 76); + } + + return 1; +} + +int iff_enumerate_chunks(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned BufferSize) +{ + while(BufferSize){ + IFFChunkNode * chunk = iff_add_chunk(IFFFileInfo, -1); + if(chunk == NULL) + return 0; + if(!iff_read_chunk(&chunk->Chunk, Buffer, BufferSize)){ + free(chunk); + return 0; + } + + Buffer += chunk->Chunk.Size; + BufferSize -= chunk->Chunk.Size; + } + return 1; +} \ No newline at end of file diff --git a/Libraries/FileHandler/iff/iff.h b/Libraries/FileHandler/iff/iff.h new file mode 100644 index 0000000..2b630f9 --- /dev/null +++ b/Libraries/FileHandler/iff/iff.h @@ -0,0 +1,85 @@ +/* + iff.h - Copyright (c) 2012 Fatbag + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef read_uint32be + #define read_uint32be(x) (unsigned)(((x)[0]<<(8*3)) | ((x)[1]<<(8*2)) | ((x)[2]<<(8*1)) | ((x)[3]<<(8*0))) + #define read_uint24be(x) (unsigned)(((x)[0]<<(8*2)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*0))) + #define read_uint16be(x) (unsigned)(((x)[0]<<(8*1)) | ((x)[1]<<(8*0))) + #define read_uint8be(x) (unsigned)(((x)[0]<<(8*0))) + #define read_uint32le(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3))) + #define read_uint24le(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2))) + #define read_uint16le(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1))) + #define read_uint8le(x) (unsigned)(((x)[0]<<(8*0))) +#endif + +typedef struct IFFChunk_struct +{ + char Type[5]; + uint32_t Size; + uint16_t ChunkID; + uint16_t Flags; + char Label[65]; + uint8_t * Data; + void * FormattedData; +} IFFChunk; + +typedef struct IFFChunkNode_struct +{ + IFFChunk Chunk; + struct IFFChunkNode_struct * PrevChunk; + struct IFFChunkNode_struct * NextChunk; +} IFFChunkNode; + +typedef struct IFFFile_struct +{ + uint8_t Header[64]; + + uint32_t ChunkCount; + IFFChunkNode * FirstChunk; + IFFChunkNode * LastChunk; + IFFChunkNode * ResourceMap; +} IFFFile; + +static const uint8_t Header_IFF[] = "IFF FILE 2.5:TYPE FOLLOWED BY SIZE\0 JAMIE DOORNBOS & MAXIS 1"; + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** IFF file functions +*/ + +IFFFile * iff_create(); +int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize); + +IFFChunkNode * iff_add_chunk(IFFFile * IFFFileInfo, int Position); +int iff_read_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize); +int iff_enumerate_chunks(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned BufferSize); + +void iff_delete_chunk(IFFFile * IFFFileInfo, int Position); +void iff_delete(IFFFile * IFFFileInfo); + + +/* +** IFF chunk functions +*/ + +int iff_read_rsmp(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize, unsigned IFFSize); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/Libraries/FileHandler/iff/iffexport.c b/Libraries/FileHandler/iff/iffexport.c new file mode 100644 index 0000000..5a850ef --- /dev/null +++ b/Libraries/FileHandler/iff/iffexport.c @@ -0,0 +1,142 @@ +/* + iffexport.c - Copyright (c) 2012 Fatbag + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#include +#include +#include "iff.h" + +int main(int argc, char *argv[]){ + HANDLE hFile; + int overwrite = 0; + char *InFile, *OutDirectory; + HANDLE ProcessHeap = GetProcessHeap(); + DWORD FileSize; + DWORD bytestransferred = 0; + uint8_t * IFFData; + unsigned chunkcount, chunk = 0; + IFFFile * IFFFileInfo; + IFFChunkNode * ChunkNode; + + if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){ + printf("Usage: iffexport [-f] infile OutDirectory\n" + "Export the resources of an EA IFF file.\n" + "Use -f to force overwriting without confirmation.\n" + "\n" + "Report bugs to .\n" + "iffexport is maintained by the Niotso project.\n" + "Home page: \n"); + return 0; + } + + if(argc >= 4 && !strcmp(argv[1], "-f")){ + overwrite++; + InFile = argv[2]; + OutDirectory = argv[3]; + }else{ + InFile = argv[1]; + OutDirectory = argv[2]; + } + + /**** + ** Open the file and read in entire contents to memory + */ + + hFile = CreateFile(InFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if(hFile == INVALID_HANDLE_VALUE){ + if(GetLastError() == ERROR_FILE_NOT_FOUND){ + printf("%sThe specified input file does not exist.", "iffexport: error: "); + return -1; + } + printf("%sThe input file could not be opened for reading.", "iffexport: error: "); + return -1; + } + FileSize = GetFileSize(hFile, NULL); + if(FileSize < 64){ + printf("%sNot a valid IFF file.", "iffexport: error: "); + return -1; + } + IFFData = HeapAlloc(ProcessHeap, HEAP_NO_SERIALIZE, FileSize); + if(IFFData == NULL){ + printf("%sMemory for this file could not be allocated.", "iffexport: error: "); + return -1; + } + if(!ReadFile(hFile, IFFData, FileSize, &bytestransferred, NULL) || bytestransferred != FileSize){ + printf("%sThe input file could not be read.", "iffexport: error: "); + return -1; + } + CloseHandle(hFile); + + /**** + ** Load header information + */ + + IFFFileInfo = iff_create(); + if(IFFFileInfo == NULL){ + printf("%sMemory for this file could not be allocated.", "iffexport: error: "); + return -1; + } + if(!iff_read_header(IFFFileInfo, IFFData, FileSize)){ + printf("%sNot a valid IFF file.", "iffexport: error: "); + return -1; + } + + /**** + ** Load entry information + */ + + if(!iff_enumerate_chunks(IFFFileInfo, IFFData+64, FileSize-64)){ + printf("%sChunk data is corrupt.", "iffexport: error: "); + return -1; + } + + chunkcount = IFFFileInfo->ChunkCount; + printf("This IFF file contains %u chunks.\n\nExporting\n", chunkcount); + + /**** + ** Extract each entry + */ + for(ChunkNode = IFFFileInfo->FirstChunk; ChunkNode; ChunkNode = ChunkNode->NextChunk){ + char name[256], destination[256]; + char filter[] = "\\/:*?\"<>|"; + int i; + + chunk++; + sprintf(name, "%03u-%s-%04X-%s", chunk, ChunkNode->Chunk.Type, ChunkNode->Chunk.ChunkID, ChunkNode->Chunk.Label); + for(i=0; i<9; i++){ + char * c = name; + while((c = strchr(c, filter[i])) != NULL) + *c = '.'; + } + sprintf(destination, "%s/%s.%s", OutDirectory, name, (!memcmp(ChunkNode->Chunk.Type, "BMP_", 4)) ? "bmp" : "dat"); + + hFile = CreateFile(destination, GENERIC_WRITE, 0, NULL, CREATE_NEW+overwrite, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if(hFile == INVALID_HANDLE_VALUE){ + printf(" (%u/%u) Skipped (%s): %s\n", chunk, chunkcount, + (!overwrite && GetLastError() == ERROR_FILE_EXISTS) ? "file exists" : "could not open", + name); + continue; + } + + printf(" (%u/%u) %s (%u bytes)\n", chunk, chunkcount, name, ChunkNode->Chunk.Size-76); + + WriteFile(hFile, ChunkNode->Chunk.Data, ChunkNode->Chunk.Size-76, &bytestransferred, NULL); + CloseHandle(hFile); + } + + return 0; +} \ No newline at end of file diff --git a/Libraries/libvitaboy/AUTHORS b/Libraries/libvitaboy/AUTHORS new file mode 100644 index 0000000..256626b --- /dev/null +++ b/Libraries/libvitaboy/AUTHORS @@ -0,0 +1 @@ +Fatbag \ No newline at end of file diff --git a/Libraries/libvitaboy/CHANGES b/Libraries/libvitaboy/CHANGES new file mode 100644 index 0000000..83015da --- /dev/null +++ b/Libraries/libvitaboy/CHANGES @@ -0,0 +1,8 @@ +libvitaboy 1.0.0 (2012-03-04) Fatbag + + * first stable release + * read support for ANIM, APR, BND, COL, HAG, MESH, OFT, PO, SKEL + * working rendering and animation of characters in OpenGL + * basic keyboard controls + * support for environments: MinGW + * support for platforms: i686, x86-64 \ No newline at end of file diff --git a/Libraries/libvitaboy/COPYING b/Libraries/libvitaboy/COPYING new file mode 100644 index 0000000..0b7b942 --- /dev/null +++ b/Libraries/libvitaboy/COPYING @@ -0,0 +1,13 @@ +libfar - Copyright (c) 2011-2012 Fatbag + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/Libraries/libvitaboy/README b/Libraries/libvitaboy/README new file mode 100644 index 0000000..19b2290 --- /dev/null +++ b/Libraries/libvitaboy/README @@ -0,0 +1,67 @@ +*************************************************************************** +* ** libvitaboy - Open source OpenGL TSO character animation library ** * +* ** Copyright (c) 2012 Drew D'Addesio ("Fatbag", ) ** * +* * +* Use and distribution of all files in the "include" and "lib" folders * +* are governed under the ISC License, included with this source code in * +* "COPYING". * +* * +* All other files included but not aforementioned are not copyrighted, * +* and are distributed into the public domain. * +*************************************************************************** + + +libvitaboy is a cross-platform C++ library for parsing the various character rendering formats used in The Sims Online and using +that information to render and animate the 3D characters of the game using OpenGL. + +Formats include: + (*) ANIM (Animation) + (*) APR (Appearance) + (*) BND (Binding) + (*) COL (Collection) + (*) HAG (Hand Group) + (*) MESH (Mesh) + (*) OFT (Outfit) + (*) PO (Purchasable Outfit) + (*) SKEL (Skeleton) + + +1. What this library will do for you + +You can use this library to render a character in a fixed location. + + +2. Compiling + +Compiling is straightforward. The Makefiles and project files should already be set up for you, and are easy to tweak. +Before compiling the library, make your changes to config.h to specify what's compiled in. + + a. Compiling from a Makefile + + Makefiles are listed in the top directory in the format Makefile.$(PLATFORM). Just copy the one applicable to your platform + to the destination file "Makefile" and run GNU make. + + b. Compiling from a project file + + Project files are held within their own directories. They can be opened up with the target IDE and be compiled by + invoking the compile action of that IDE. + + c. Compiling using your own Makefile or project file + + It's possible no such file exists for your platform. In this case, look at whichever Makefile is most relevant to your + platform, copy all source files down (.cpp, .hpp, ...), and add it your own Makefile or project. In theory, + it should work. :) + +libvitaboy is intended to work with any C++ compiler. If not, and the compiler is not only modern and popular but also free +software (gratis, libre, open source software), please report it as a bug. + + +3. Useful links + +libvitaboy is hosted by and maintained by the Niotso project. +Home page: +Don Hopkins documentation: + (*) http://www.donhopkins.com/drupal/node/20 [Sims Character Animation File Format] + (*) http://www.donhopkins.com/drupal/node/21 [Details on The Sims Character Animation File Format and Rendering] + (*) http://www.donhopkins.com/drupal/node/19 [Sims VitaBoy Character Animation Library Documentation] + (*) http://www.donhopkins.com/home/movies/ [Index of Archived Streaming QuickTime Movies] \ No newline at end of file diff --git a/Libraries/libvitaboy/THANKS b/Libraries/libvitaboy/THANKS new file mode 100644 index 0000000..e8aa6b1 --- /dev/null +++ b/Libraries/libvitaboy/THANKS @@ -0,0 +1,10 @@ + --------------------------------|---------------------------------------------------------------- +| Thanks to | for | +|--------------------------------|----------------------------------------------------------------| +| Don Hopkins | Kickstarting The Sims 1 customization, encouraging fine | +| | individuals to document the game, and most importantly, | +| | sharing with us his documentation of his VitaBoy skeletal | +| | character animation library used in The Sims 1, in the form | +| | of articles and videos. Dozens of thanks from each one of us. | +| (*) | + ------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/Tools/misc/CMakeLists.txt b/Tools/misc/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tools/zbuffer/Instructions.txt b/Tools/zbuffer/Instructions.txt new file mode 100644 index 0000000..77b87c7 --- /dev/null +++ b/Tools/zbuffer/Instructions.txt @@ -0,0 +1,8 @@ +Add these files: + +* Chair-Liv-Deco_large_front_a.png +* Chair-Liv-Deco_large_front_p.png +* Chair-Liv-Deco_large_front_z.png +* tower_large_ne_a.png +* tower_large_ne_p.png +* tower_large_ne_z.png \ No newline at end of file diff --git a/Tools/zbuffer/background.png b/Tools/zbuffer/background.png new file mode 100644 index 0000000..ef4c612 Binary files /dev/null and b/Tools/zbuffer/background.png differ diff --git a/Tools/zbuffer/index.html b/Tools/zbuffer/index.html new file mode 100644 index 0000000..e863077 --- /dev/null +++ b/Tools/zbuffer/index.html @@ -0,0 +1,152 @@ + + +
+ \ No newline at end of file