librw/tools/dffwrite/dffwrite.cpp

96 lines
2.0 KiB
C++
Raw Normal View History

2014-12-18 16:26:57 +00:00
#include <cstdio>
#include <cstdlib>
#include <cstring>
2014-12-25 18:37:36 +00:00
#include <cassert>
#include <new>
2014-12-18 16:26:57 +00:00
#include <rw.h>
#include <src/gtaplg.h>
2014-12-18 16:26:57 +00:00
using namespace std;
int
main(int argc, char *argv[])
{
// rw::version = 0x31000;
// rw::build = 0;
// rw::version = 0x32000;
// rw::version = 0x33002;
2015-08-16 22:23:41 +01:00
// rw::version = 0x30200;
gta::registerEnvSpecPlugin();
rw::registerMatFXPlugin();
rw::registerMaterialRightsPlugin();
rw::registerAtomicRightsPlugin();
rw::registerHAnimPlugin();
gta::registerNodeNamePlugin();
2015-08-17 09:24:24 +01:00
gta::registerExtraNormalsPlugin();
2015-08-16 15:44:59 +01:00
gta::registerBreakableModelPlugin();
gta::registerExtraVertColorPlugin();
rw::ps2::registerADCPlugin();
2015-08-01 22:03:10 +01:00
rw::ps2::registerPDSPlugin();
rw::registerSkinPlugin();
rw::xbox::registerVertexFormatPlugin();
rw::registerNativeDataPlugin();
// rw::ps2::registerNativeDataPlugin();
rw::registerMeshPlugin();
2015-08-03 17:30:10 +01:00
rw::Atomic::init();
rw::Clump *c;
2014-12-18 16:26:57 +00:00
// rw::StreamFile in;
2014-12-30 16:39:39 +00:00
// in.open(argv[1], "rb");
FILE *cf = fopen(argv[1], "rb");
assert(cf != NULL);
fseek(cf, 0, SEEK_END);
rw::uint32 len = ftell(cf);
2014-12-30 16:39:39 +00:00
fseek(cf, 0, SEEK_SET);
rw::uint8 *data = new rw::uint8[len];
2014-12-30 16:39:39 +00:00
fread(data, len, 1, cf);
fclose(cf);
rw::StreamMemory in;
2014-12-30 16:39:39 +00:00
in.open(data, len);
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
rw::debugFile = argv[1];
c = rw::Clump::streamRead(&in);
2014-12-25 18:37:36 +00:00
assert(c != NULL);
2014-12-30 16:39:39 +00:00
2014-12-18 16:26:57 +00:00
in.close();
2014-12-30 16:39:39 +00:00
delete[] data;
2014-12-18 16:26:57 +00:00
rw::Image::setSearchPath("./;/home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/");
2015-06-17 20:51:33 +01:00
/*
// rw::Image *tga = rw::readTGA("b.tga");
rw::Image *tga = rw::readTGA("player.tga");
assert(tga != NULL);
rw::writeTGA(tga, "out.tga");
2015-06-17 20:51:33 +01:00
*/
2014-12-25 18:37:36 +00:00
// for(rw::int32 i = 0; i < c->numAtomics; i++)
// rw::Gl::Instance(c->atomicList[i]);
// ofstream out(argv[2], ios::binary);
// rw::StreamFile out;
2014-12-30 16:39:39 +00:00
// out.open(argv[2], "wb");
data = new rw::uint8[1024*1024];
rw::StreamMemory out;
out.open(data, 0, 1024*1024);
c->streamWrite(&out);
2014-12-30 16:39:39 +00:00
cf = fopen(argv[2], "wb");
assert(cf != NULL);
fwrite(data, out.getLength(), 1, cf);
fclose(cf);
2014-12-18 16:26:57 +00:00
out.close();
2014-12-30 16:39:39 +00:00
delete[] data;
2014-12-18 16:26:57 +00:00
delete c;
return 0;
}