Crash when loading a triangle mesh

mikachu

08-04-2008 21:48:34

Hi all,

I'm a NxOgre newbie. I'm trying to create a body from a procedurally generated Ogre mesh (in the code below, it's just a sample mesh, just for tests).

Here is the code:

mWorld = new World("time-controller: ogre");
mScene = mWorld->createScene(
"Eddie",
"renderer: ogre, controller: accumulator, gravity: yes, floor: yes");


TriangleMesh* tm = new NxOgre::TriangleMesh("cube.1m.mesh");

Body* body = mScene->createBody("test; cube.1m.mesh", tm, Vector3(0,0,0), "static: yes");


I'm using latest 1.0 branch version of NxOgre, with appropriate PhysX SDK, and latest stable Ogre.

The crash I get is an access violation in the createBody part.
The debugger gives me 195th line of "NxOgreShapeMeshes.cpp" as the crash point.

Any idea?

betajaen

08-04-2008 22:22:31

You have to convert the Ogre mesh file into a PhysX mesh file before you can load it. Usually using Flour.

mikachu

08-04-2008 22:30:02

Well, the problem is that the mesh will be procedurally generated at load time...
Shall I write the generated mesh to a file, apply Flour on it and then load the PhysX mesh, everything at load time, or is it simple enough to use Flour as a lib in my program?

betajaen

08-04-2008 22:42:18

Procedural generation? Then you should use the "ManualMesh" class, which it was designed to just that. ;)

http://www.nxogre.org/How_to_build_a_Co ... _from_code
http://www.nxogre.org/How_to_build_a_Tr ... _from_code

mikachu

09-04-2008 07:19:24

Thanks, exactly what I want. :D

mikachu

09-04-2008 21:49:20

Oops, I have an unresolved link and I don't really understand why..

when I add this line :

NxOgre::Resources::ManualMesh* cube_test = new Resources::ManualMesh(Resources::MT_Triangle);


I get this :

1>Main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall NxOgre::Resources::MeshParams::MeshFlags::parse(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?parse@MeshFlags@MeshParams@Resources@NxOgre@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Main.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall NxOgre::Resources::MeshParams::MeshFlags::toNxU32(void)const " (?toNxU32@MeshFlags@MeshParams@Resources@NxOgre@@UBEIXZ)
1>Main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall NxOgre::Resources::MeshParams::MeshFlags::fromNxU32(unsigned int)" (?fromNxU32@MeshFlags@MeshParams@Resources@NxOgre@@UAEXI@Z)

betajaen

09-04-2008 21:56:31

Those functions do exist and defined in NxOgreMeshParams.cpp are you sure you've linked it correct?

mikachu

09-04-2008 22:36:12

Yes, I also found it was in NxOgreMeshParams.cpp, I guess I may have mistaken..
I link my program dynamically to NxOgre, with the freshly compiled (from 1.0'21) 'NxOgre.lib' in additional dependencies.
I already tried to rebuild solution, to rebuild NxOgre, to redownload NxOgre but the problem is still there..

mikachu

13-04-2008 21:46:00

Well, I find the problem, in NxOgre, at least in the 1.0'21 version.

In 'NxOgre.h', I replace

struct MeshFlags : Flags {

with

struct NxPublicClass MeshFlags : Flags {


I recompile the dll.. and it works! :)