TriangleMeshShape blowing up

__bf_ddc__

13-10-2007 16:22:00

Hello, I'm currently trying to revamp my code from over a year ago with the new OGRE&NxOgre engines...

I have mesh images loading in from a database and am trying to create bodies with them as well:

Old Code:
sprintf(nBuffer, "%s_physics_%d", curRoom, atoi(objID));
body *pBody = m_pScene->createStaticBody(nBuffer, "", new meshShape(q.getstr("mesh_img"), m_pScene), objCoords);


New Code:
sprintf(nBuffer, "%s_physics_%d", curRoom, atoi(objID));
sprintf(nBuffer2, "%s; %s", nBuffer, q.getstr("mesh_img"));
Body *pBody = m_pScene->createBody(nBuffer2, new TriangleMeshShape(q.getstr("mesh_img")), objCoords, "static: yes");


Perhaps I'm a bit rusty, or just don't understand the new code -- I've searched many forum threads and the Wiki never really nets me any results so I figured I'd post here. Be easy on a rusty NxOgre user. :P

__bf_ddc__

14-10-2007 15:34:36

I guess I'll clarify more:

The .mesh files I have are mostly exported and loaded into their correct positions, so no translation/rotations need to be done originally [static bodies]; we basically load in rooms of a house, such as the floors, walls, etc. of each room and when exported they're in place automatically. So when creating a body, the collisions and such should be placed through the meshShape -- but of course meshShape struct is no longer available -- hence why I tried TriangleMeshShape -- please let me know if that's the wrong way at going at this?

I know all the .mesh's are exported as triangulated. So what other requirements would be causing this to blow up? Or what other way can I achieve this? Please help~ Thanks!


EDIT:
I tried doing the following:

TriangleMeshShape *tm = new TriangleMeshShape(q.getstr("mesh_img"));
m_pScene2->createBody(nBuffer2, tm, objCoords, "static: yes");


Through debugging, creating the TriangleMeshShape wasn't blowing up but creating the body after that was...

It blows up in _file.c:
void __cdecl _lock_file (
void *pf
)
{
.
.
.
EnterCriticalSection( &(((_FILEX *)pf)->lock) );
}

betajaen

14-10-2007 16:21:59

Few questions/remarks.

1. Define: Blowing up. Crashing?

2. MeshShape is TriangleMeshShape. It's just a different name.

3. Are you sure your passing on the right filename to the code. Because if it's crashing in _file.c of all places it's obviously your file.

__bf_ddc__

14-10-2007 16:23:13

Yet another thing...

With more debugging:

I've got the .mesh files in a subfolder, e.g. Folder/File.mesh

With the files in a root folder, the meshes and bodies build fine; with them in the subfolders, reading through Folder/File.mesh it blows up.

Here's my example:

I'm reading a filename through a MySQL db:
"showhome/chair.mesh"

The TriangleMeshShape() creates when reading in "showhome/chair.mesh",

The createBody() on the other hand, blows up on the first param, if this "showhome/chair.mesh" or anything reading through tokenised "/" subfolders...

I've tried putting the mesh file in the root folder and reading it off like that and it's fine... Is this a bug of some sort? Or is there a way around it?


EDIT:
Sorry yes, blowing up = crashing.

betajaen

14-10-2007 17:03:24

It's just the filename of the mesh, not the path. It uses the Ogre Resource System to load in the mesh, so you must make sure it's loaded through the Ogre Resource system first.

__bf_ddc__

15-10-2007 14:58:12

I figured as much.
I wanted to avoid that though, as about 2-3k rows in our database have the *.mesh layed out in folder/file structure in the mesh row... :(
Oh well, I'll write a MySQL script to fix that all and have to add a dynamic resource loading path for each individual unit...
Thanks for clarifying.