Problem with Triangle Mesh

Rom1FromMars

02-12-2008 13:07:38

Hi All !

Config : Ogre 1.6 and NxOgre 1.0 R21

First, wonderful work for this NxOgre !!

So, i have got a problem with TriangleMesh :

Ogre::Entity* mSol = mSceneMgr->createEntity("Ground", "nx.floor.mesh");
mSol->setCastShadows(true);
TriangleMesh *mesh = new TriangleMesh("nx.floor.mesh");
mScene->createBody("Ground", mesh, Vector3(0, 0, 0),"model: Ground, model-type: reference", "static: yes");


This makes the app crashing.
Whereas with :
mScene->createBody("Ground2", new NxOgre::Cube(500,10,500),Vector3(0,-5,0),"","static:yes");
;

It works fine.

Is there some known issues with triangle mesh and .mesh ?
I just want to load a .mesh and made it static.

Thank you very much in advance !!

betajaen

02-12-2008 13:11:27

You have to convert it into a nxs using flour.

Rom1FromMars

02-12-2008 13:51:31

I convert my cube using :
flour convert in:cube.mesh, into :triangle, out :test.nxs

I copy my NXS to the root of my c:

And then add to my App:
Ogre::Entity* mSol = mSceneMgr->createEntity("Ground", "nx.floor.mesh");
mSol->setCastShadows(true);
TriangleMesh *mesh = new TriangleMesh("c:/test.nxs");
mScene->createBody("Ground", mesh, Vector3(0, 0, 0),"model: Ground, model-type: reference", "static: yes");


Still crashing... :( My mesh is not null but seems not be well instantiated...
Thank you for your help BetaJaen

betajaen

02-12-2008 14:30:18

Your nearly there. You have to load it in through the resource system; give it a name, and give triangle mesh the name.

Rom1FromMars

02-12-2008 14:43:30


NxOgre::Resources::ResourceSystem::getSingleton()->addMeshAs("file://c:/test.nxs","TryNXS");
NxOgre::TriangleMesh* mTriangleShape = new NxOgre::TriangleMesh("TryNXS");
mScene->createBody("BodyNXS", mTriangleShape , Ogre::Vector3(0, 0, 0), "","static:yes");


:evil: Crash :evil:

I need more advices BetaJaen lool :D and if you have an exemple that would be great...

Rom1FromMars

02-12-2008 15:49:16

Try with your sample code :

NxOgre::Resources::ManualMesh* cube_test = new Resources::ManualMesh(Resources::MT_Triangle);
cube_test->begin();
const float size = 2;

cube_test->vertex(-size,size,-size); //0 position
cube_test->vertex(size,size,-size); //1 position
cube_test->vertex(size,-size,-size); //2 position
cube_test->vertex(-size,-size,-size); //3 position
cube_test->vertex(-size,size,size); //4 position
cube_test->vertex(size,size,size); //5 position
cube_test->vertex(size,-size,size); //6 position
cube_test->vertex(-size,-size,size); //7 position

cube_test->triangle(0, 2, 3);
cube_test->triangle(0, 1, 2);
cube_test->triangle(1, 6, 2);
cube_test->triangle(1, 5, 6);
cube_test->triangle(4, 6, 5);
cube_test->triangle(4, 7, 6);
cube_test->triangle(0, 7, 4);
cube_test->triangle(0, 3, 7);
cube_test->triangle(0, 5, 1);
cube_test->triangle(0, 4, 5);
cube_test->triangle(2, 7, 3);
cube_test->triangle(2, 6, 7);

NxOgre::Resources::Mesh* mesh = cube_test->end();
mesh->save("file://cube.nxs");

Resources::ResourceSystem::getSingleton()->addMeshAs("file://cube.nxs", "Cube");
mScene->createActor("Cube Test", new TriangleMesh("Cube"), Vector3(0, 1, 0), "static: yes");


Still crashing on create actor...
Are you sure that TriangleMesh isstable with 1.0 R21 ??

betajaen

02-12-2008 15:52:48

You did apply the patches to fix the mesh system right?

Rom1FromMars

02-12-2008 15:55:12

I downloaded the revision 21 from your download website : http://svn.nxogre.org/branches/1.0/

You talk about these fixes : http://www.ogre3d.org/phpBB2addons/view ... sc&start=0
Didn't do it...I thought that was done in the last release...

mcaden

03-12-2008 08:44:57

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=6891

and look at page 2 of the post you mentioned, there was a bug still after '21 was released

Rom1FromMars

03-12-2008 10:31:26

I Add this line in zero() of MeshData (NxOgreMEsh.cpp):
mMaterialAlias = 0;

and the two mMesh.zero() in constructors


NxOgre::Resources::ResourceSystem::getSingleton()->addMeshAs("file://test.nxs","TryNXS");
NxOgre::TriangleMesh* mTriangleShape = new NxOgre::TriangleMesh("TryNXS");
mScene->createBody("BodyNXS", mTriangleShape , Ogre::Vector3(0, 0, 0), "","static:yes");


Still crashing on
mShapeDescription.meshData = mMesh->mMesh.mTriangleMesh;


Very annoying... :(

betajaen

03-12-2008 10:43:21

Just upgrade to T5 then. It's much better and doesn't have the bug.

Rom1FromMars

03-12-2008 10:46:11

Ok i found something very strange to make it work :shock:


NxOgre::Resources::ResourceSystem::getSingleton()->addMesh("file://test.nxs");
mScene->createBody("test.nxs",new TriangleMesh(NxOgre::Resources::ResourceSystem::getSingleton()->getMesh("test.nxs")),Vector3(0,0,0),"static:yes");


I use this code. Put my test.nxs at the exe root. And put test.mesh -> rename in test.nxs in media/models folder to make it work !!

I am going to make some more investigation...

[EDIT] Confirm the "trick", works perfectly ! Thank you for your help !! :D

betajaen

03-12-2008 11:06:01

You had test.nxs in a media folder all this time? You do know that NxOgre doesn't use the Ogre's resource system? Everything has to be specified in absolute or relative paths.

Rom1FromMars

03-12-2008 11:09:11

Yes. I know that. As i said i put the test.nxs in root of my Exe.
But for visual (Ogre) i have to put test.mesh in media/models and rename it to test.nxs to make it work.

mcaden

03-12-2008 19:13:20

use this:

NxOgre::Resources::ResourceSystem::getSingleton()->addMeshAs("file://../../media/models/test.nxs", "test.nxs");

You may have to add or remove some of the ../ in order to get it right, basically use 1 ../ for every level up the chain from your working directory. For example, I use:

/
/media/models
/Bin/Release
/Bin/Debug

So, I use

file://../../

to get from Release (or Debug) back to

/

then media/models to get to the directory I want.