Re: [XBox360] Dynasty Warriors 8 (Early Access)
Posted: Thu Jun 12, 2014 1:10 am
oh and here is my testing code for the data i sent you. sorry it's not python, but it should be easy to follow.
Code: Select all
bool TestNUNO(void)
{
// pathnames
using namespace std;
STDSTRING pathname = TEXT("X:\\WORKSPACE\\[PS3] Sengoku Musou 4\\LINKDATA_B_CHARS\\7834\\");
STDSTRING savepath = TEXT("X:\\WORKSPACE\\[PS3] Sengoku Musou 4\\LINKDATA_B_CHARS\\7834\\");
// control point filename
STDSTRING cpf_name = pathname;
cpf_name += TEXT("nuno1_cp.bin");
// influence data filename
STDSTRING inf_name = pathname;
inf_name += TEXT("nuno1_inf.bin");
// vertex buffer filename
STDSTRING vbf_name = pathname;
vbf_name += TEXT("vbuffer1.bin");
// properties
uint32 n_cp = 0x23; // number of control points
uint32 n_verts = 0x60; // number of vertices
uint32 vtxsize = 0x7C; // vertex size in bytes
uint32 offset1 = 0x00; // vertex offset #1
uint32 offset2 = 0x10; // vertex offset #2
uint32 offset3 = 0x24; // vertex offset #3
uint32 offset4 = 0x34; // vertex offset #4
uint32 offset5 = 0x44; // vertex offset #5 (indices)
//
// create output file
//
STDSTRING ofname = pathname;
ofname += TEXT("output.obj");
ofstream ofile(ofname.c_str());
if(!ofile) return error("Failed to create output file.");
// output obj header
ofile << "o output" << endl;
ofile << endl;
//
// read control point data
//
boost::shared_array<boost::shared_array<real32>> cp_data;
cp_data.reset(new boost::shared_array<real32>[n_cp]);
// open control point file
ifstream cpf(cpf_name.c_str(), ios::binary);
if(!cpf) return error("Failed to open file.");
for(uint32 i = 0; i < n_cp; i++) {
cp_data[i].reset(new real32[4]);
if(!BE_read_array(cpf, cp_data[i].get(), 4)) return error("Read failure.");
}
//
// read vertex data
//
uint32 vb_size = n_verts * vtxsize;
boost::shared_array<char> vb_data(new char[vb_size]);
// open vertex buffer file
ifstream vbf(vbf_name.c_str(), ios::binary);
if(!vbf) return error("Failed to open file.");
// read vertex buffer data
vbf.read(vb_data.get(), vb_size);
if(vbf.fail()) return error("Read failure.");
// create vertex buffer stream
binary_stream bs(vb_data, vb_size);
uint32 position = 0;
// read vertex buffer data
for(uint32 i = 0; i < n_verts; i++)
{
// move to offset #1
bs.seek(position + offset1);
if(bs.fail()) return error("Stream seek failure.");
// read vector
real32 v1[4];
bs.BE_read_array(&v1[0], 4);
if(bs.fail()) return error("Stream read failure.");
// move to offset #2
bs.seek(position + offset2);
if(bs.fail()) return error("Stream seek failure.");
// read vector
real32 v2[4];
bs.BE_read_array(&v2[0], 4);
if(bs.fail()) return error("Stream read failure.");
// move to offset #3
bs.seek(position + offset3);
if(bs.fail()) return error("Stream seek failure.");
// read vector
real32 v3[4];
bs.BE_read_array(&v3[0], 4);
if(bs.fail()) return error("Stream read failure.");
// move to offset #4
bs.seek(position + offset4);
if(bs.fail()) return error("Stream seek failure.");
// read vector
real32 v4[4];
bs.BE_read_array(&v4[0], 4);
if(bs.fail()) return error("Stream read failure.");
// move to offset #5
bs.seek(position + offset5);
if(bs.fail()) return error("Stream seek failure.");
// read indices
uint08 i1[4]; bs.BE_read_array(&i1[0], 4);
uint08 i2[4]; bs.BE_read_array(&i2[0], 4);
uint08 i3[4]; bs.BE_read_array(&i3[0], 4);
uint08 i4[4]; bs.BE_read_array(&i4[0], 4);
if(bs.fail()) return error("Stream seek failure.");
// determine if anchor point
bool is_anchor = ((v3[0] == 0.0f) && (v3[1] == 0.0f) &&
(v3[2] == 0.0f) && (v3[3] == 0.0f));
// anchor point
if(is_anchor)
{
ofile << "v " << v1[0] << " " << v1[1] << " " << v1[2] << endl;
}
// non-anchor point
else
{
// first control point index set
uint32 cpidx1 = i1[0];
uint32 cpidx2 = i1[1];
uint32 cpidx3 = i1[2];
uint32 cpidx4 = i1[3];
// first control point set
auto cp1 = cp_data[cpidx1];
auto cp2 = cp_data[cpidx2];
auto cp3 = cp_data[cpidx3];
auto cp4 = cp_data[cpidx4];
// cp1 * v1[0] + cp2 * v1[1]
real32 x = (cp1[0] * v1[0]) + (cp2[0] * v1[1]) + (cp3[0] * v1[2]) + (cp4[0] * v1[3]);
real32 y = (cp1[1] * v1[0]) + (cp2[1] * v1[1]) + (cp3[1] * v1[2]) + (cp4[1] * v1[3]);
real32 z = (cp1[2] * v1[0]) + (cp2[2] * v1[1]) + (cp3[2] * v1[2]) + (cp4[2] * v1[3]);
real32 w = (cp1[3] * v1[0]) + (cp2[3] * v1[1]) + (cp3[3] * v1[2]) + (cp4[3] * v1[3]);
ofile << "v " << x << " " << y << " " << z << endl;
cout << "v " << x << " " << y << " " << z << " " << w << endl;
}
// update position
position += vtxsize;
}
return true;
}
};
#endif