2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 15:55:06 +01:00
|
|
|
#include "loader_x.hpp"
|
|
|
|
|
#include "animation.hpp"
|
2019-01-18 17:04:17 +01:00
|
|
|
#include "meshmodel.hpp"
|
2019-01-18 15:55:06 +01:00
|
|
|
#include "pivot.hpp"
|
2019-01-18 17:04:17 +01:00
|
|
|
#include "std.hpp"
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2017-04-09 05:35:18 +02:00
|
|
|
#include <windows.h>
|
|
|
|
|
//#include <dxfile.h>
|
|
|
|
|
#include <d3d9types.h>
|
|
|
|
|
#include <d3dx9xof.h>
|
2014-01-31 08:23:00 +13:00
|
|
|
#include <rmxfguid.h>
|
|
|
|
|
#include <rmxftmpl.h>
|
2019-01-18 17:04:17 +01:00
|
|
|
#include "../gxruntime/GraphicsRuntime.hpp"
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
extern gxRuntime* gx_runtime;
|
|
|
|
|
static map<string, MeshModel*> frames_map;
|
|
|
|
|
static int anim_len;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static bool conv, flip_tris;
|
2014-01-31 08:23:00 +13:00
|
|
|
static Transform conv_tform;
|
2019-01-18 17:04:17 +01:00
|
|
|
static bool collapse, animonly;
|
|
|
|
|
|
|
|
|
|
static void parseAnimKey(ID3DXFileData* fileData, MeshModel* e)
|
|
|
|
|
{
|
|
|
|
|
DWORD sz;
|
|
|
|
|
int* data;
|
|
|
|
|
if (fileData->GetData(0, &sz, (void**)&data) < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int type = *data++;
|
|
|
|
|
int cnt = *data++;
|
|
|
|
|
Animation anim = e->getAnimation();
|
|
|
|
|
for (int k = 0; k < cnt; ++k) {
|
|
|
|
|
int time = *data++;
|
|
|
|
|
int n = *data++;
|
|
|
|
|
if (time > anim_len)
|
|
|
|
|
anim_len = time;
|
|
|
|
|
switch (type) {
|
2014-01-31 08:23:00 +13:00
|
|
|
case 0:
|
2019-01-18 17:04:17 +01:00
|
|
|
if (n == 4) {
|
|
|
|
|
Quat rot = *(Quat*)data;
|
|
|
|
|
if (conv) {
|
|
|
|
|
if (fabs(rot.w) < 1 - FLT_EPSILON) {
|
2014-01-31 08:23:00 +13:00
|
|
|
rot.normalize();
|
|
|
|
|
//quat-to-axis/angle
|
2019-01-18 17:04:17 +01:00
|
|
|
float half = acosf(rot.w);
|
|
|
|
|
if (flip_tris)
|
|
|
|
|
half = -half;
|
|
|
|
|
rot = Quat(cosf(half), (conv_tform.m * rot.v).normalized() * sinf(half));
|
|
|
|
|
} else
|
|
|
|
|
rot = Quat();
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
anim.setRotationKey(time, rot);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2019-01-18 17:04:17 +01:00
|
|
|
if (n == 3) {
|
|
|
|
|
Vector scl = *(Vector*)data;
|
|
|
|
|
if (conv)
|
|
|
|
|
scl = conv_tform.m * scl;
|
|
|
|
|
scl.x = fabs(scl.x);
|
|
|
|
|
scl.y = fabs(scl.y);
|
|
|
|
|
scl.z = fabs(scl.z);
|
|
|
|
|
anim.setScaleKey(time, scl);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2019-01-18 17:04:17 +01:00
|
|
|
if (n == 3) {
|
|
|
|
|
Vector pos = *(Vector*)data;
|
|
|
|
|
if (conv)
|
|
|
|
|
pos = conv_tform * pos;
|
|
|
|
|
anim.setPositionKey(time, pos);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
data += n;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
e->setAnimation(anim);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static void parseAnim(ID3DXFileData* fileData)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
|
|
|
|
IDirectXFileDataReference* childRef;
|
|
|
|
|
MeshModel* frame = 0;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
//find the frame reference
|
2019-01-18 17:04:17 +01:00
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileDataReference, (void**)&childRef) >= 0) {
|
|
|
|
|
if (childRef->Resolve(&childData) >= 0) {
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMFrame) {
|
|
|
|
|
char name[80];
|
|
|
|
|
DWORD len = 80;
|
|
|
|
|
if (childData->GetName(name, &len) >= 0) {
|
|
|
|
|
map<string, MeshModel*>::iterator it = frames_map.find(name);
|
|
|
|
|
if (it != frames_map.end())
|
|
|
|
|
frame = it->second;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
childRef->Release();
|
2019-01-18 17:04:17 +01:00
|
|
|
} else if (frame && childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) >= 0) {
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMAnimationKey) {
|
|
|
|
|
parseAnimKey(childData, frame);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static void parseAnimSet(IDirectXFileData* fileData)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
|
|
|
|
|
|
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMAnimation) {
|
|
|
|
|
parseAnim(childData);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static Brush parseMaterial(IDirectXFileData* fileData)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
Brush brush;
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
DWORD sz;
|
|
|
|
|
float* data;
|
|
|
|
|
if (fileData->GetData(0, &sz, (void**)&data) < 0)
|
|
|
|
|
return brush;
|
|
|
|
|
|
|
|
|
|
brush.setColor(Vector(data[0], data[1], data[2]));
|
|
|
|
|
if (data[3])
|
|
|
|
|
brush.setAlpha(data[3]);
|
|
|
|
|
|
|
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMTextureFilename) {
|
|
|
|
|
DWORD sz;
|
|
|
|
|
char** data;
|
|
|
|
|
if (childData->GetData(0, &sz, (void**)&data) >= 0) {
|
|
|
|
|
brush.setTexture(0, Texture(*data, 0), 0);
|
|
|
|
|
brush.setColor(Vector(1, 1, 1));
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return brush;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static void parseMaterialList(IDirectXFileData* fileData, vector<Brush>& mats)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
|
|
|
|
IDirectXFileDataReference* childRef;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
//iterate through child objects...
|
2019-01-18 17:04:17 +01:00
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) >= 0) {
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMMaterial) {
|
|
|
|
|
mats.push_back(parseMaterial(childData));
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
}
|
2014-01-31 08:23:00 +13:00
|
|
|
childData->Release();
|
2019-01-18 17:04:17 +01:00
|
|
|
} else if (childObj->QueryInterface(IID_IDirectXFileDataReference, (void**)&childRef) >= 0) {
|
|
|
|
|
if (childRef->Resolve(&childData) >= 0) {
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMMaterial) {
|
|
|
|
|
mats.push_back(parseMaterial(childData));
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
childRef->Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
struct FaceX {
|
|
|
|
|
int *data, mat_index;
|
|
|
|
|
FaceX(int* d) : data(d), mat_index(0) {}
|
2014-01-31 08:23:00 +13:00
|
|
|
};
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static void parseMesh(IDirectXFileData* fileData, MeshModel* mesh)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
DWORD sz;
|
|
|
|
|
int* data;
|
|
|
|
|
if (fileData->GetData(0, &sz, (void**)&data) < 0)
|
|
|
|
|
return;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
//stuff...
|
|
|
|
|
vector<FaceX> faces;
|
|
|
|
|
vector<Brush> mats;
|
|
|
|
|
|
|
|
|
|
MeshLoader::beginMesh();
|
|
|
|
|
|
|
|
|
|
//setup vertices
|
2019-01-18 17:04:17 +01:00
|
|
|
int num_verts = *data++;
|
2014-01-31 08:23:00 +13:00
|
|
|
int k;
|
2019-01-18 17:04:17 +01:00
|
|
|
for (k = 0; k < num_verts; ++k) {
|
2014-01-31 08:23:00 +13:00
|
|
|
Surface::Vertex v;
|
2019-01-18 17:04:17 +01:00
|
|
|
v.coords = *(Vector*)data;
|
|
|
|
|
if (conv)
|
|
|
|
|
v.coords = conv_tform * v.coords;
|
|
|
|
|
v.color = 0xffffffff; //Vector(1,1,1);
|
|
|
|
|
MeshLoader::addVertex(v);
|
|
|
|
|
data += 3;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//setup faces
|
2019-01-18 17:04:17 +01:00
|
|
|
int num_faces = *data++;
|
|
|
|
|
for (k = 0; k < num_faces; ++k) {
|
|
|
|
|
faces.push_back(FaceX(data));
|
|
|
|
|
data += *data + 1;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
bool normals = false;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
//get material and texture info
|
2019-01-18 17:04:17 +01:00
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
DWORD sz;
|
|
|
|
|
int* data;
|
|
|
|
|
if (childData->GetData(0, &sz, (void**)&data) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMMeshMaterialList) {
|
|
|
|
|
int num_mats = *data++;
|
|
|
|
|
int num_faces = *data++;
|
|
|
|
|
for (int k = 0; k < num_faces; ++k) {
|
|
|
|
|
faces[k].mat_index = *data++;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
parseMaterialList(childData, mats);
|
|
|
|
|
} else if (*guid == TID_D3DRMMeshTextureCoords) {
|
|
|
|
|
int num_coords = *data++;
|
|
|
|
|
if (num_coords == num_verts) {
|
|
|
|
|
float* coords = (float*)data;
|
|
|
|
|
for (int k = 0; k < num_coords; ++k) {
|
|
|
|
|
Surface::Vertex& v = MeshLoader::refVertex(k);
|
|
|
|
|
float tu = *coords++;
|
|
|
|
|
float tv = *coords++;
|
|
|
|
|
v.tex_coords[0][0] = v.tex_coords[1][0] = tu;
|
|
|
|
|
v.tex_coords[0][1] = v.tex_coords[1][1] = tv;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
} else if (*guid == TID_D3DRMMeshVertexColors) {
|
|
|
|
|
int num_colors = *data++;
|
|
|
|
|
if (num_colors == num_verts) {
|
|
|
|
|
for (int k = 0; k < num_colors; ++k) {
|
|
|
|
|
Surface::Vertex& v = MeshLoader::refVertex(*data++);
|
|
|
|
|
float* t = (float*)data;
|
|
|
|
|
v.color = 0xff000000 | (int(t[0] * 255) << 16) | (int(t[1] * 255) << 8) | int(t[2] * 255);
|
|
|
|
|
// v.color=Vector( t[0],t[1],t[2] );
|
|
|
|
|
data += 4;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
} else if (*guid == TID_D3DRMMeshNormals) {
|
|
|
|
|
int num_normals = *data++;
|
|
|
|
|
if (num_normals == num_verts) {
|
|
|
|
|
Matrix co = conv_tform.m.cofactor();
|
|
|
|
|
for (int k = 0; k < num_normals; ++k) {
|
|
|
|
|
Surface::Vertex& v = MeshLoader::refVertex(k);
|
|
|
|
|
v.normal = (co * *(Vector*)data).normalized();
|
|
|
|
|
data += 3;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
normals = true;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
if (!mats.size())
|
|
|
|
|
mats.push_back(Brush());
|
|
|
|
|
|
|
|
|
|
for (size_t k = 0; k < faces.size(); ++k) {
|
|
|
|
|
const FaceX& f = faces[k];
|
|
|
|
|
int* data = f.data;
|
|
|
|
|
int cnt = *data++;
|
|
|
|
|
if (cnt < 3)
|
|
|
|
|
continue;
|
2014-01-31 08:23:00 +13:00
|
|
|
int tri[3];
|
2019-01-18 17:04:17 +01:00
|
|
|
tri[0] = data[0];
|
|
|
|
|
for (int j = 2; j < cnt; ++j) {
|
|
|
|
|
tri[1] = data[j - 1 + flip_tris];
|
|
|
|
|
tri[2] = data[j - flip_tris];
|
|
|
|
|
MeshLoader::addTriangle(tri, mats[f.mat_index]);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
MeshLoader::endMesh(mesh);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
if (!normals)
|
|
|
|
|
mesh->updateNormals();
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static MeshModel* parseFrame(IDirectXFileData* fileData)
|
|
|
|
|
{
|
|
|
|
|
MeshModel* e = new MeshModel();
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFileObject* childObj;
|
|
|
|
|
IDirectXFileData* childData;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
char name[80];
|
|
|
|
|
DWORD len = 80;
|
|
|
|
|
if (fileData->GetName(name, &len) < 0)
|
|
|
|
|
return e;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
e->SetName(name);
|
|
|
|
|
frames_map[name] = e;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
//iterate through child objects...
|
2019-01-18 17:04:17 +01:00
|
|
|
for (; fileData->GetNextObject(&childObj) >= 0; childObj->Release()) {
|
|
|
|
|
if (childObj->QueryInterface(IID_IDirectXFileData, (void**)&childData) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (childData->GetType(&guid) >= 0) {
|
|
|
|
|
if (*guid == TID_D3DRMFrameTransformMatrix) {
|
|
|
|
|
DWORD size;
|
|
|
|
|
D3DMATRIX* data;
|
|
|
|
|
if (childData->GetData(0, &size, (void**)&data) >= 0) {
|
|
|
|
|
Transform tform = Transform(Matrix(Vector(data->_11, data->_12, data->_13),
|
|
|
|
|
Vector(data->_21, data->_22, data->_23),
|
|
|
|
|
Vector(data->_31, data->_32, data->_33)),
|
|
|
|
|
Vector(data->_41, data->_42, data->_43));
|
|
|
|
|
if (conv)
|
|
|
|
|
tform = conv_tform * tform * -conv_tform;
|
|
|
|
|
e->SetLocalTransform(tform);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
} else if (*guid == TID_D3DRMMesh) {
|
|
|
|
|
if (!animonly)
|
|
|
|
|
parseMesh(childData, e);
|
|
|
|
|
} else if (*guid == TID_D3DRMFrame) {
|
|
|
|
|
MeshModel* t = parseFrame(childData);
|
|
|
|
|
t->SetParent(e);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
childData->Release();
|
|
|
|
|
}
|
|
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
static MeshModel* parseFile(const string& file)
|
|
|
|
|
{
|
|
|
|
|
const GUID* guid;
|
|
|
|
|
IDirectXFile* xfile;
|
|
|
|
|
IDirectXFileData* fileData;
|
|
|
|
|
IDirectXFileEnumObject* enumObj;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
if (DirectXFileCreate(&xfile) < 0)
|
|
|
|
|
return 0;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
if (xfile->RegisterTemplates((VOID*)D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES) < 0) {
|
|
|
|
|
xfile->Release();
|
|
|
|
|
return 0;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
if (xfile->CreateEnumObject((void*)file.c_str(), DXFILELOAD_FROMFILE, &enumObj) < 0) {
|
|
|
|
|
xfile->Release();
|
|
|
|
|
return 0;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
anim_len = 0;
|
|
|
|
|
MeshModel* e = new MeshModel();
|
|
|
|
|
for (; enumObj->GetNextDataObject(&fileData) >= 0; fileData->Release()) {
|
|
|
|
|
if (fileData->GetType(&guid) < 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (*guid == TID_D3DRMMesh) {
|
|
|
|
|
if (!animonly)
|
|
|
|
|
parseMesh(fileData, e);
|
|
|
|
|
} else if (*guid == TID_D3DRMFrame) {
|
|
|
|
|
MeshModel* t = parseFrame(fileData);
|
|
|
|
|
t->SetParent(e);
|
|
|
|
|
} else if (*guid == TID_D3DRMAnimationSet) {
|
|
|
|
|
if (!collapse)
|
|
|
|
|
parseAnimSet(fileData);
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
}
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
if (!collapse) {
|
|
|
|
|
e->setAnimator(new Animator(e, anim_len));
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enumObj->Release();
|
|
|
|
|
xfile->Release();
|
|
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
MeshModel* Loader_X::load(const string& filename, const Transform& t, int hint)
|
|
|
|
|
{
|
|
|
|
|
conv_tform = t;
|
|
|
|
|
conv = flip_tris = false;
|
|
|
|
|
if (conv_tform != Transform()) {
|
|
|
|
|
conv = true;
|
|
|
|
|
if (conv_tform.m.i.cross(conv_tform.m.j).dot(conv_tform.m.k) < 0)
|
|
|
|
|
flip_tris = true;
|
2014-01-31 08:23:00 +13:00
|
|
|
}
|
2019-01-18 17:04:17 +01:00
|
|
|
collapse = !!(hint & MeshLoader::HINT_COLLAPSE);
|
|
|
|
|
animonly = !!(hint & MeshLoader::HINT_ANIMONLY);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
MeshModel* e = parseFile(filename);
|
2014-01-31 08:23:00 +13:00
|
|
|
frames_map.clear();
|
|
|
|
|
return e;
|
|
|
|
|
}
|