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-18 17:26:57 +01:00
|
|
|
|
2014-12-27 23:18:10 +01:00
|
|
|
#include <new>
|
2014-12-18 17:26:57 +01:00
|
|
|
|
|
|
|
#include "rw.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
// Rw::Version = 0x31000;
|
|
|
|
// Rw::Build = 0;
|
|
|
|
|
2014-12-19 16:24:29 +01:00
|
|
|
registerNodeNamePlugin();
|
2014-12-24 23:52:03 +01:00
|
|
|
registerBreakableModelPlugin();
|
2014-12-20 18:13:45 +01:00
|
|
|
registerNativeDataPlugin();
|
2014-12-30 17:39:39 +01:00
|
|
|
// Ps2::registerNativeDataPlugin();
|
2014-12-20 20:18:41 +01:00
|
|
|
registerMeshPlugin();
|
2014-12-18 17:26:57 +01:00
|
|
|
Rw::Clump *c;
|
|
|
|
|
2014-12-27 23:18:10 +01:00
|
|
|
// ifstream in(argv[1], ios::binary);
|
2014-12-30 17:39:39 +01:00
|
|
|
|
|
|
|
// Rw::StreamFile in;
|
|
|
|
// in.open(argv[1], "rb");
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-12-27 23:18:10 +01:00
|
|
|
Rw::FindChunk(&in, Rw::ID_CLUMP, NULL, NULL);
|
|
|
|
c = Rw::Clump::streamRead(&in);
|
2014-12-25 19:37:36 +01:00
|
|
|
assert(c != NULL);
|
2014-12-30 17:39:39 +01:00
|
|
|
|
2014-12-18 17:26:57 +01:00
|
|
|
in.close();
|
2014-12-30 17:39:39 +01:00
|
|
|
delete[] data;
|
2014-12-18 17:26:57 +01:00
|
|
|
|
2014-12-28 12:06:19 +01:00
|
|
|
// Rw::Image *tga = Rw::readTGA("b.tga");
|
|
|
|
// assert(tga != NULL);
|
|
|
|
// Rw::writeTGA(tga, "out.tga");
|
2014-12-25 19:37:36 +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
|
|
|
|
2014-12-27 23:18:10 +01:00
|
|
|
// ofstream out(argv[2], ios::binary);
|
2014-12-30 17:39:39 +01:00
|
|
|
// Rw::StreamFile out;
|
|
|
|
// out.open(argv[2], "wb");
|
|
|
|
data = new Rw::uint8[256*1024];
|
|
|
|
Rw::StreamMemory out;
|
|
|
|
out.open(data, 0, 256*1024);
|
2014-12-27 23:18:10 +01:00
|
|
|
c->streamWrite(&out);
|
2014-12-30 17:39:39 +01:00
|
|
|
|
|
|
|
cf = fopen(argv[2], "wb");
|
|
|
|
assert(cf != NULL);
|
|
|
|
fwrite(data, out.getLength(), 1, cf);
|
|
|
|
fclose(cf);
|
2014-12-18 17:26:57 +01:00
|
|
|
out.close();
|
2014-12-30 17:39:39 +01:00
|
|
|
delete[] data;
|
2014-12-18 17:26:57 +01:00
|
|
|
|
|
|
|
delete c;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|