My level editor generates one solid object for worlds. Part of the process in doing that is inspecting custom objects for limbs and textures so it can preserve them properly.
However I have been getting really odd results which do not match what I would expect - in some cases crashes.
So i've made a test c++ program to inspect 2 different models. Both are trees I made in Tree Magik g3. The first is a .dbo object exported directly from tree magik. It works great, both in my real editor and in this test program - everything is as you would expect when it comes to mesh count and texture count per mesh.
The second however is a .x file. Tree Magik generates trees that a re far far to big for my games scale so I exported an ascii ms3d file, opened it in milkshape 3D, changed it how I wanted and then exported a .x (JT). I've tried giving it bones/joints as well. Result when I open it in my level editor and inspect it is a complete crash and in my lightweight test program is results that are plain wrong. 1 Mesh reported instead of 2, 1 texture reported instead of 2.
The last bit is weird because I *swear* at one point I ran it and it said meshes: 1 - textures: 2 which at least makes SOME kind of sense - but I cant make it repeat it!
As a final test I opened the .x file in a dgdk app and then saved it off as a .dbo to convert it. It converts fine, but still 1 mesh 1 texture despite it quite obviously being a 2 texture mesh which should have two seperate groups (trunk, leaves).
Can someone perform this same test and see if you get matching results? Or does anyone know WTH is going on here? Mike even?
Ok, create a new dgdk project and just paste this over the main.cpp:
#include "DarkGDK.h"
#include <String>
#include "..\Iro2 - vc2k8\DBOData.h"
sObject* dbGetObject ( int iID );
using namespace std;
void DarkGDK(void) {
dbSyncOn();
dbSyncRate(60);
string szFileToOpen = "treeeeeeee.x";
//string szFileToOpen = "Tree02.dbo";
dbLoadObject((char *)szFileToOpen.c_str(), 1);
dbSetObjectTransparency(1, 1);
sObject* pThisObject = dbGetObject(1);
int nMeshes = pThisObject->iMeshCount;
char szOut[512];
int nTextures = 0;
while (LoopGDK()) {
sprintf_s(szOut, 512, "Num Meshes: %d", nMeshes);
dbText(0, 0, szOut);
for (int n = 0; n < nMeshes; n++) {
nTextures = pThisObject->ppMeshList[n]->dwTextureCount;
sprintf_s(szOut, 512, "Mesh (%d) Texture Count: %d", n, nTextures);
dbText(0, 14 + (n * 14), szOut);
dbYRotateObject(1, dbObjectAngleY(1) + 0.05f);
}
dbSync();
}
return;
}
fix the #include line for DBOData.h so it reflects where-ever you have it. There should be a copy hidden away in <your path>/The Game Creators/DarkGDK Freeware/DBO Format/ if you havnt found it yet
I've attached a zip with the models i was using for testing to this post.
I'm at a bit of a loss, any help appreiciated!