Constructing ConvexShape manually

solaris1912

21-02-2008 00:27:46

Hello! Is there a way to form convexshape without specifying a .mesh file? There are samples in Physix SDK but I'm unable to convert them to NxOgre.

My plan is to create an array of road blocks by this manner, to construct a race circuit.

Thanks!

betajaen

21-02-2008 00:33:34

You can just construct it the PhysX way and save it as a NXS, then load it in as you would as a mesh. (Assuming your using NxOgre 0.9)

solaris1912

21-02-2008 00:37:54

You can just construct it the PhysX way and save it as a NXS, then load it in as you would as a mesh. (Assuming your using NxOgre 0.9)

Thanks for the fast reply :) I'll try it right away.

solaris1912

21-02-2008 01:58:02

I did something slightly different than your suggestion.

First, I created a mesh (without using a file, just vertices and indices) using the code described in here -> http://www.ogre3d.org/wiki/index.php/GeneratingAMesh

Later on, I created a TriangleMeshShape, which uses the mesh I previously created

NxOgre::ShapeParams sp;
sp.setToDefault();

NxOgre::ActorParams ap;
ap.setToDefault();
ap.mMass = 0;
mScene->createBody( "ColourCube", new NxOgre::TriangleMeshShape( "ColourCube", sp ), NxOgre::Pose( position, orientation ), ap );


However, physics is OK but the mesh is not displayed. So, here is the code to display the mesh



Entity* thisEntity = mSceneMgr->createEntity("cc", "ColourCube");
thisEntity->setMaterialName("nx.flag");
Ogre::SceneNode* thisSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();

thisSceneNode->setPosition(position);
thisSceneNode->setOrientation(orientation);

thisSceneNode->attachObject(thisEntity);


The object is static, which is fine for me.

So, my code directly reads an xml file (which holds road map data), and dynamically construct visual and physical stuff in this manner.

8)

betajaen

21-02-2008 08:39:45

Try calling "ColourCube" to "ColourCube.mesh", it'll pick up on that it's not a name but rather a reference to an existing mesh you created.

[Edit]

Oh. If you don't want to use any Parameters just leave it out. Like the ShapeParams there.