nx material problem on triangle shapes with nxogre 0.938

toglia

29-10-2009 21:36:48

Hi, I know its a really old version, but, does anyone remeber if there was something wrong with (nx) materials on triangle mesh shapes? They don't seem to work for me...

I`m doing this:
mFloorMaterial = mScene->createMaterial("floorMaterial");
mFloorMaterial->setRestitution(10);
mScene->createActor("FloorShape",new NxOgre::TriangleMeshShape("floorShape.mesh","material:floorMaterial"),Vector3(0,0,0),"mass: 1000, static:yes");

And I call tell cause objects don't seem to bounce...

On the other hand:
mScene->createActor("BorderShape",new NxOgre::ConvexShape("borderShape.nxs","material:floorMaterial"),Vector3(0,0,0),"mass: 1000, static:yes");
seems to work ok;

Any ideas, or maybe where should I be looking?

betajaen

29-10-2009 21:52:01

NxTriangleMeshes have materials per triangles in the mesh (so you can have multiple materials assigned to the same mesh), I guess it's not implemented in 0.9.

The newer tools (flour 0.4) can save the materials in the NxTriangleMeshes for you, but you need an exporter to save them in the flower file for you. Unfortantly, the flower blender exporter doesn't do that - unless you modify it, and use some sort of system in Blender to assign each face with a material index.

I'm afraid, that's the best that is available I'm afraid. I doubt the PhysX exporting tools are better.

toglia

31-10-2009 15:34:25

Thanks betajaen, but it seems very weird cause that almost leaves triangle meshes unusable for that version. All I need is to remove the friction and set the restitution of one single but most important shape of my game ("the floor" which has some holes, so ...) I don't really need a UI for this, doing it by hand could be OK, its only one mesh, are flower files ascii?

betajaen

31-10-2009 15:43:30

Flower files are ascii yes. Literally, you could just copy and paste the line

material 1

Where 1 is your material index at the end of the file; for each triangle in the mesh.

toglia

31-10-2009 16:17:36

Thanks man. So when loading with nxogre 0.9 I should do it the normal way without any shape params and get the material implicitly attached, right?

toglia

31-10-2009 16:47:31

One more thing, could you please give me an example of how should I define the material in the flower file. I read the flower documentation but its not clearly stated.

Does it look something like this:
type triangle
vertices -100.0,100.0,-100.0 #0
#material 1 <----------------------------here?
vertices 100.0,100.0,-100.0 #1
vertices 100.0,-100.0,-100.0 #2
vertices -100.0,-100.0,-100.0 #3

indexes 0,2,3, 0,1,2

<-then I should declare material 1 here, but I didn't see how?

betajaen

31-10-2009 16:57:29

No, material per triangle, not materials for all the triangles.

so it goes.

type triangle
vertices -100.0,100.0,-100.0 #0
vertices 100.0,100.0,-100.0 #1
vertices 100.0,-100.0,-100.0 #2
vertices -100.0,-100.0,-100.0 #3

indexes 0,2,3, 0,1,2

material 1, 1


Because there are two triangles, so two "materials" for each triangle. Where you put material in the file isn't important.

toglia

31-10-2009 17:23:54

material 1, 1
So that means I'm assigning material 1, to triangle index 1. But how do I define "material 1" in terms of restitution, friction and stuff?

betajaen

31-10-2009 17:40:30

No it means your assigning material index 1 to triangles 1 and 2.

As for restitution, friction; You do that normally in c++.

toglia

04-11-2009 20:53:48

It worked perfectly! Thanks again betajaen. :P