2015-07-12 21:57:05 +01:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cassert>
|
|
|
|
#include <new>
|
|
|
|
|
2015-09-06 12:31:42 +01:00
|
|
|
#include <rw.h>
|
|
|
|
#include <src/gtaplg.h>
|
2015-07-12 21:57:05 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace rw;
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2015-09-09 22:26:16 +01:00
|
|
|
gta::attachPlugins();
|
2015-07-12 21:57:05 +01:00
|
|
|
|
2015-09-19 18:28:23 +01:00
|
|
|
rw::version = 0x34003;
|
|
|
|
// rw::platform = rw::PLATFORM_PS2;
|
2015-09-06 12:31:42 +01:00
|
|
|
// rw::platform = rw::PLATFORM_OGL;
|
2015-09-19 18:28:23 +01:00
|
|
|
rw::platform = rw::PLATFORM_XBOX;
|
2015-09-08 08:47:21 +01:00
|
|
|
// rw::platform = rw::PLATFORM_D3D8;
|
2015-09-08 09:29:24 +01:00
|
|
|
// rw::platform = rw::PLATFORM_D3D9;
|
2015-07-12 21:57:05 +01:00
|
|
|
|
|
|
|
int uninstance = 0;
|
|
|
|
int arg = 1;
|
|
|
|
|
|
|
|
if(argc < 2){
|
2015-09-06 12:31:42 +01:00
|
|
|
printf("usage: %s [-u] in.dff\n", argv[0]);
|
2015-07-12 21:57:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(argv[arg], "-u") == 0){
|
|
|
|
uninstance++;
|
2015-09-19 18:28:23 +01:00
|
|
|
arg++;
|
2015-07-12 21:57:05 +01:00
|
|
|
if(argc < 3){
|
2015-09-06 12:31:42 +01:00
|
|
|
printf("usage: %s [-u] in.dff\n", argv[0]);
|
2015-07-12 21:57:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Clump *c;
|
|
|
|
uint32 len;
|
|
|
|
uint8 *data = getFileContents(argv[arg], &len);
|
|
|
|
assert(data != NULL);
|
|
|
|
StreamMemory in;
|
|
|
|
in.open(data, len);
|
2015-09-09 22:26:16 +01:00
|
|
|
|
|
|
|
ChunkHeaderInfo header;
|
|
|
|
readChunkHeaderInfo(&in, &header);
|
|
|
|
if(header.type == ID_UVANIMDICT){
|
|
|
|
UVAnimDictionary *dict = UVAnimDictionary::streamRead(&in);
|
|
|
|
currentUVAnimDictionary = dict;
|
|
|
|
readChunkHeaderInfo(&in, &header);
|
|
|
|
}
|
|
|
|
assert(header.type == ID_CLUMP);
|
2015-07-12 21:57:05 +01:00
|
|
|
debugFile = argv[arg];
|
|
|
|
c = Clump::streamRead(&in);
|
|
|
|
assert(c != NULL);
|
|
|
|
|
2015-08-01 22:03:10 +01:00
|
|
|
// printf("%s\n", argv[arg]);
|
|
|
|
|
2015-08-03 20:33:35 +01:00
|
|
|
/*
|
2015-08-01 22:03:10 +01:00
|
|
|
for(int32 i = 0; i < c->numAtomics; i++){
|
|
|
|
Atomic *a = c->atomicList[i];
|
|
|
|
Pipeline *ap = a->pipeline;
|
|
|
|
Geometry *g = a->geometry;
|
|
|
|
for(int32 j = 0; j < g->numMaterials; j++){
|
|
|
|
Pipeline *mp = g->materialList[j]->pipeline;
|
|
|
|
if(ap && mp)
|
|
|
|
printf("%s %x %x\n", argv[arg], ap->pluginData, mp->pluginData);
|
|
|
|
}
|
|
|
|
}
|
2015-08-03 20:33:35 +01:00
|
|
|
*/
|
2015-08-01 22:03:10 +01:00
|
|
|
|
2015-07-12 21:57:05 +01:00
|
|
|
for(int32 i = 0; i < c->numAtomics; i++){
|
|
|
|
Atomic *a = c->atomicList[i];
|
2015-08-03 17:30:10 +01:00
|
|
|
ObjPipeline *p = a->getPipeline();
|
|
|
|
if(uninstance)
|
|
|
|
p->uninstance(a);
|
|
|
|
else
|
|
|
|
p->instance(a);
|
2015-07-12 21:57:05 +01:00
|
|
|
}
|
|
|
|
|
2015-09-19 18:28:23 +01:00
|
|
|
if(uninstance)
|
|
|
|
rw::platform = rw::PLATFORM_D3D8;
|
|
|
|
|
2015-09-06 12:31:42 +01:00
|
|
|
data = new rw::uint8[1024*1024];
|
2015-07-12 21:57:05 +01:00
|
|
|
rw::StreamMemory out;
|
2015-09-06 12:31:42 +01:00
|
|
|
out.open(data, 0, 1024*1024);
|
2015-09-09 22:26:16 +01:00
|
|
|
if(currentUVAnimDictionary)
|
|
|
|
currentUVAnimDictionary->streamWrite(&out);
|
2015-07-12 21:57:05 +01:00
|
|
|
c->streamWrite(&out);
|
|
|
|
|
2015-09-19 18:28:23 +01:00
|
|
|
FILE *cf;
|
|
|
|
if(arg+1 < argc)
|
|
|
|
cf = fopen(argv[arg+1], "wb");
|
|
|
|
else
|
|
|
|
cf = fopen("out.dff", "wb");
|
2015-07-12 21:57:05 +01:00
|
|
|
assert(cf != NULL);
|
|
|
|
fwrite(data, out.getLength(), 1, cf);
|
|
|
|
fclose(cf);
|
|
|
|
out.close();
|
|
|
|
delete[] data;
|
|
|
|
|
|
|
|
delete c;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|