Rage (idTech5) model format md6
Posted: Tue Oct 11, 2011 2:27 pm
Hello! Does anyone know how to open a model of Rage? Here are some examples of models:
Code: Select all
ifstream ifile("hands.bmd6model", ios::binary);
if(!ifile) return error("Could not open file.");
// use offset #1 = 0x0151C for arms
// use offset #2 = 0x3C15F for gauntlet
// open file
ofstream ofile("output2.ls");
ofile << "main" << endl;
ofile << "{" << endl;
ofile << " editbegin();" << endl;
ofile << " uvmap = VMap(\"texture\", \"" << "texture" << "\", 2);" << endl;
ifile.seekg(0x151C);
size_t n_points = BE_read_uint16(ifile); // number of points (2524)
BE_read_uint16(ifile);
size_t n_triangles = BE_read_uint16(ifile); // number of triangles (4602)
BE_read_float(ifile);
BE_read_float(ifile);
BE_read_float(ifile);
BE_read_float(ifile);
BE_read_float(ifile);
BE_read_float(ifile);
cout << endl;
for(size_t i = 0; i < n_points; i++)
{
float x = BE_read_float(ifile);
float y = BE_read_float(ifile);
float z = BE_read_float(ifile);
float u = BE_read_float(ifile);
float v = BE_read_float(ifile);
BE_read_uint16(ifile);
BE_read_uint16(ifile);
BE_read_uint16(ifile);
BE_read_uint16(ifile);
BE_read_uint16(ifile);
BE_read_uint16(ifile);
cout << endl;
ofile << " pointlist[" << i + 1 << "]" << " = " << "addpoint(" << x << "," << y << "," << z << ");" << endl;
ofile << " uvmap.setValue(pointlist[" << (i + 1) << "]," << "@" << u << "," << v << "@);" << endl;
}
// read triangles
boost::shared_array<unsigned short> data(new unsigned short[n_triangles*3]);
ifile.read((char*)&data.get()[0], n_triangles*3*sizeof(unsigned short));
for(size_t i = 0; i < 3*n_triangles; i++) reverse_byte_order(&data.get()[i]);
size_t index = 0;
for(size_t i = 0; i < n_triangles; i++) {
unsigned short a = data.get()[index++] + 1;
unsigned short b = data.get()[index++] + 1;
unsigned short c = data.get()[index++] + 1;
ofile << " addtriangle(pointlist[" << a << "], pointlist[" << c << "], pointlist[" << b << "]);" << endl;
}
ofile << " editend();" << endl;
ofile << "}" << endl;
no, this is PC versionhowfie wrote:format of vertices and index buffer are pretty clear. however, without more models it's impossible to tell where the data starts. thus, for now you gotta hard code offsets. i don't have $60 to spend on a game at the moment so maybe someone else can pick it up. here is code idea for the hand model. BE_ means big endian. Sample must be from PS3?
Code: Select all
.BMD6MODEL
File header:
0x00 - 0x04 : [ tag ] - file id
0x04 - 0x08 : [ -?- ] - unknown
0x08 - 0x20 : [FLOAT] - model bounds, [min3,max3]
0x20 - 0x24 : [ int ] - unknown, always '1'*
0x24 - 0x28 : [ -?- ] - unknown, always '0'
0x28 - 0x29 : [char ] - unknown, possibly version id, always '5'
0x29 - 0x2a : [SHORT] - unknown, always '0'
0x2a - 0x2d : [SHORT] - offset to joint names
Code: Select all
Model header:
0x2d - 0x2f : [SHORT] - offset to joint names again
0x2f - 0x31 : [SHORT] - number of joints*
0x31 - 0x33 : [SHORT] - unknown, always '0'
0x33 - 0x35 : [SHORT] - unknown, roughly points to the mesh data but is off by enough to be an unusable link
0x35 - 0x37 : [SHORT] - offset to default pose data
0x37 - 0x39 : [SHORT] - offset to joint hierarchy
0x39 - 0x5d : [SHORT] - more offsets, several joint channel structures, many repeats
Code: Select all
Surfaces:
0x00 - 0x04 : [ INT ] - number of surfaces
ea. surface:
[nstring] - surface name
[nstring] - material name
[char ] - flags, 1 appears to indicate deformable surface but does not change structure
[ INT ] - number of vertices
[ INT ] - number of triangles
[bounds] - bounds for this surface (6 floats).
ea. vertex:
0x00 - 0x0c : [FLOAT] - vertex xyz
0x0c - 0x14 : [FLOAT] - vertex tex coordinates
0x14 - 0x20 : [ -?- ] - weight data, unknown format
ea. triangle:
0x00 - 0x06 : [SHORT] - vertex indices
following vertex and triangle data:
0x00 - 0x04 : [ INT ] - unknown, always 0
0x04 - 0x08 : [ INT ] - unknown, always numJoints
0x08 - 0x09 : [char ] - unknown, always 0 or 1
[4 bytes of data for each vertex] (only if previous field is 1!)
0x09 - 0x0d : [ INT ] - unknown, always 0
(next surface)
Don't do that. You don't have the rights to distribute that content, even for 'academic' purposes.This is ALL models
http://www.multiupload.com/FQYQXSR2RM
COOL!!! It's work!!!howfie wrote:works with bmodel now too.