can't create convex body from ogre mesh?(*.nxs)

caifie

17-05-2010 08:49:18

hi!

i get the *.nxs file from ogre *.mesh by ogrexmltoflower and flour 0.4,(like robot.mesh to robot.nxs).

when i using --cupcake in flour 0.4 to view the robot.nxs, i found it was very big and auto move slowly(LinearVelocity change slowly).
and there will be some problem when using robot.nxs in nxogre app, with below code,(create convex body)

NxOgre::Mesh* robot = meshMan->load("ogre://Popular/robot.nxs", "robot");
Critter::BodyDescription bodyDescriptionb;
bodyDescriptionb.reset();
bodyDescriptionb.mMass = 40.0f;
bodyDescriptionb.mLinearVelocity .zero();

Critter::Body* bodyb=mRenderSystem->createBody(NxOgre::ConvexDescription(robot), Vec3(2,13,7), "robot.mesh", bodyDescriptionb);
bodyb->getSceneNode()->setScale(0.1,0.1,0.1);

the robot will fall down the floor and then fly into the sky(looks like by some unknown force or something other)

but when i using the other code, the robot will stand in the floor well.(create box body)

Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f;
bodyDescription.mLinearVelocity=Vec3(1,0,0);
body = mRenderSystem->createBody(NxOgre::BoxDescription(3,4,3), Vec3(8,11,9), "robot.mesh", bodyDescription);
body->getSceneNode()->setScale(0.1,0.1,0.1);


so what wrong with this. seems i can not using ConvexDescription to create convex body?

ps: i get the robot.nxs by using convex syntax in rb script and flour.

anybody know this?
if can't create the convex body like this, how can i create a body suit with the mesh entity exactly?
thans in advance!

betajaen

17-05-2010 10:50:12

1. The Ogre meshes given in the examples are typically too large, somewhere in the several hundred metre range -- Nobody should use them with NxOgre.

2. The Robot isn't a convex mesh. If your not sure what Convex meshes actually are or supposed to look like; Google image search for "convex hull".

caifie

17-05-2010 11:06:33

OK, thanks very much!

1. you mean that we should develop new mesh file? is there method to scale the current sample mesh in 3dmax or some other? how did you do in your app? :D

2. about the convex, i'm affected by ogrenewt, it can use convex with these entity.(before nxogre, i pick the ogrenewt for a while ) so in nxogre, how should i do to create body suit with the size of mesh?
i have search the forum, some said that it should get the entity size using ogre's method, and then create the body using the size. is it right?

betajaen

17-05-2010 11:24:47

Ogre uses "Ogre units" where 1 could be 1 metre, 1 inch, 1 kilometre, etc. NxOgre uses "mks" units, where 1 is 1 metre.

1. If you like, or at least scale them with MeshMagick or something.

2. Convex means the same in OgreNewt too. If you turn one of your meshes into a convex shape (that isn't particularly convex looking) the PhysX cooker will pick out the bits that are most convex like. If you think of it as wrapping on of your meshes with stiff cardboard and taping it up, it probably look like that.

What the professionals do is; make up various parts of their meshes with different shapes (Compound shapes). Using capsules for legs, spheres for heads, and anything fiddly with convexes.

caifie

17-05-2010 12:32:31

thanks! i hope that i'll be aprofessional someday. :D

and i found the code from this forum,

Ogre::Entity *mEntity = mSceneMgr->createEntity( "myplayer" ,"robot.mesh");
Ogre::SceneNode* mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mNode->attachObject( mEntity );
mNode->setScale(0.1,0.1,0.1);
mNode->setPosition( 8,11,9);

//get mesh size from bouding box :
Ogre::AxisAlignedBox spbox = mNode->getAttachedObject("myplayer")->getBoundingBox();
Ogre::Vector3 min = spbox.getMinimum()*mNode->getScale();
Ogre::Vector3 max = spbox.getMaximum()*mNode->getScale();
Ogre::Real paddingFactor = Ogre::MeshManager::getSingleton().getBoundsPaddingFactor();
Ogre::Vector3 newMin = min+(max-min)*paddingFactor;
Ogre::Vector3 newMax = max+(min-max)*paddingFactor;
Ogre::Vector3 box_size = newMax - newMin;

Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f;
bodyDescription.mLinearVelocity=Vec3(1,0,0);

body = mRenderSystem->createBody(NxOgre::BoxDescription(box_size), Vec3(8,11,9), "robot.mesh", bodyDescription);
body->getSceneNode()->setScale(0.1,0.1,0.1);


this code makes two problem,
1.two entity
2.entity float over the floor for a short distance

what wrong with it? how can we create the body and entity mamually in nxogre1.6?