2014-12-18 17:26:57 +01:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
2014-12-25 19:37:36 +01:00
|
|
|
#include <cassert>
|
2014-12-27 23:18:10 +01:00
|
|
|
#include <new>
|
2014-12-18 17:26:57 +01:00
|
|
|
|
2015-09-06 13:31:42 +02:00
|
|
|
#include <rw.h>
|
|
|
|
#include <src/gtaplg.h>
|
2014-12-18 17:26:57 +01:00
|
|
|
|
|
|
|
using namespace std;
|
2015-12-14 18:52:50 +01:00
|
|
|
using namespace rw;
|
2014-12-18 17:26:57 +01:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2015-01-25 22:27:03 +01:00
|
|
|
// rw::version = 0x31000;
|
|
|
|
// rw::build = 0;
|
|
|
|
|
2015-09-06 13:31:42 +02:00
|
|
|
// rw::version = 0x32000;
|
2015-12-14 18:52:50 +01:00
|
|
|
rw::version = 0x33002;
|
|
|
|
rw::platform = PLATFORM_D3D8;
|
2015-08-16 23:23:41 +02:00
|
|
|
// rw::version = 0x30200;
|
2015-01-25 22:27:03 +01:00
|
|
|
|
2015-12-18 01:10:42 +01:00
|
|
|
int lcs = 1;
|
|
|
|
matFXGlobals.hack = lcs;
|
|
|
|
|
2015-09-09 23:26:16 +02:00
|
|
|
gta::attachPlugins();
|
2015-01-25 22:27:03 +01:00
|
|
|
|
|
|
|
rw::Clump *c;
|
2014-12-18 17:26:57 +01:00
|
|
|
|
2015-01-25 22:27:03 +01:00
|
|
|
// rw::StreamFile in;
|
2014-12-30 17:39:39 +01:00
|
|
|
// in.open(argv[1], "rb");
|
|
|
|
|
2015-12-14 18:52:50 +01:00
|
|
|
if(0){
|
|
|
|
FILE *cf = fopen(argv[1], "rb");
|
|
|
|
assert(cf != NULL);
|
|
|
|
fseek(cf, 0, SEEK_END);
|
|
|
|
rw::uint32 len = ftell(cf);
|
|
|
|
fseek(cf, 0, SEEK_SET);
|
|
|
|
rw::uint8 *data = new rw::uint8[len];
|
|
|
|
fread(data, len, 1, cf);
|
|
|
|
fclose(cf);
|
|
|
|
rw::StreamMemory in;
|
|
|
|
in.open(data, len);
|
|
|
|
|
|
|
|
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
|
|
|
|
rw::debugFile = argv[1];
|
|
|
|
c = rw::Clump::streamRead(&in);
|
|
|
|
assert(c != NULL);
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
delete[] data;
|
|
|
|
}else{
|
|
|
|
rw::StreamFile in;
|
|
|
|
if(in.open(argv[1], "rb") == NULL){
|
|
|
|
printf("couldn't open file\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
debugFile = argv[1];
|
|
|
|
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-12-18 01:10:42 +01:00
|
|
|
if(lcs)
|
|
|
|
c = clumpStreamReadRsl(&in);
|
|
|
|
else
|
|
|
|
c = Clump::streamRead(&in);
|
2015-12-14 18:52:50 +01:00
|
|
|
assert(c != NULL);
|
|
|
|
}
|
|
|
|
|
2015-12-18 01:10:42 +01:00
|
|
|
if(lcs)
|
|
|
|
for(int32 i = 0; i < c->numAtomics; i++)
|
|
|
|
convertRslGeometry(c->atomicList[i]->geometry);
|
2015-12-14 18:52:50 +01:00
|
|
|
|
|
|
|
// rw::Image::setSearchPath("./;/home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/");
|
2015-01-20 14:48:18 +01:00
|
|
|
|
2015-06-17 21:51:33 +02:00
|
|
|
/*
|
2015-01-25 22:27:03 +01:00
|
|
|
// rw::Image *tga = rw::readTGA("b.tga");
|
|
|
|
rw::Image *tga = rw::readTGA("player.tga");
|
2015-01-20 14:48:18 +01:00
|
|
|
assert(tga != NULL);
|
2015-01-25 22:27:03 +01:00
|
|
|
rw::writeTGA(tga, "out.tga");
|
2015-06-17 21:51:33 +02:00
|
|
|
*/
|
2014-12-25 19:37:36 +01:00
|
|
|
|
2015-01-25 22:27:03 +01:00
|
|
|
// for(rw::int32 i = 0; i < c->numAtomics; i++)
|
|
|
|
// rw::Gl::Instance(c->atomicList[i]);
|
2014-12-25 11:14:36 +01:00
|
|
|
|
2015-12-14 18:52:50 +01:00
|
|
|
if(0){
|
|
|
|
uint8 *data = new rw::uint8[1024*1024];
|
|
|
|
rw::StreamMemory out;
|
|
|
|
out.open(data, 0, 1024*1024);
|
|
|
|
|
|
|
|
c->streamWrite(&out);
|
|
|
|
|
|
|
|
FILE *cf = fopen(argv[2], "wb");
|
|
|
|
assert(cf != NULL);
|
|
|
|
fwrite(data, out.getLength(), 1, cf);
|
|
|
|
fclose(cf);
|
|
|
|
out.close();
|
|
|
|
delete[] data;
|
|
|
|
}else{
|
|
|
|
rw::StreamFile out;
|
|
|
|
if(argc > 2)
|
|
|
|
out.open(argv[2], "wb");
|
|
|
|
else
|
|
|
|
out.open("out.dff", "wb");
|
2015-12-18 17:34:12 +01:00
|
|
|
// if(lcs)
|
|
|
|
// clumpStreamWriteRsl(&out, c);
|
|
|
|
// else
|
2015-12-18 01:10:42 +01:00
|
|
|
c->streamWrite(&out);
|
2015-12-14 18:52:50 +01:00
|
|
|
out.close();
|
|
|
|
}
|
2014-12-18 17:26:57 +01:00
|
|
|
|
|
|
|
delete c;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|