[Solved] RigidBodyDesigner

Dirso

02-06-2007 21:42:26

Hi,

I would like to use the .rb format that looks like great!!! For the loading stuff, the StuntPlayground is great, but for saving the files in the right format, I'm having problems.
Can you help me a little bit? Given a mesh (or a node) how do I write the xml file? I had a hard time trying to figure out all by my own.

Thanks,
Dirso

walaber

03-06-2007 01:11:55

I made an application to make rigid body files when I was making Stunt Playground. you should be able to use it still... however it's a bit old, so it may not load very new .mesh files, you may need an old version of the OgreMeshXmlConverter to get it to work.

http://walaber.com/misc/RigidBodyDesigner.rar

Dirso

03-06-2007 02:01:11

Hi,

I got your application and I'm having problems to understand what to do. I can't use your application, I need to incorporate the algorithm in my framework (that I'll realease for free soon) due to several tools I had to build to make the development of my game easier. Can you explain me how can I convert a mesh file (that could or couldn't be represented as a convex shape). I think, that reading your code, I could do if I was sure that the body is convex, but if I load a car or a street sign it wouldn't be convex, so as I saw in your .rb files it is splitted in two or more shapes... how can I do that?
I need to write a function that I can pass a node and the .rb filename and it saves the .rb file.
Can you help me with that?
Thanks,
Dirso.

walaber

03-06-2007 07:57:53

I do not have an automated way of doing that. I used a tool to build the collision shapes by hand.

Dirso

03-06-2007 16:23:26

If I decide not to use to .rb files, will the following code in the initialization have the same effect?
OgreNewt::CollisionPrimitives::TreeCollisionSceneParser *parser;
parser = new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(world);
parser->parseScene(node);
OgreNewt::Body *body;
body = new OgreNewt::Body(world, parser);
delete parser;

Thanks,
Dirso.

walaber

03-06-2007 17:42:54

CollisionTree can only be used for static objects that will never move.

if you objects need to move (be dynamic), you will need to use convex shapes to define them.

Dirso

04-06-2007 00:53:23

Hi,

Thanks for your help!! I think I'm almost there.... But my car is floating :(
void GS_Racing::createScene()
{
createDebugOverlay(USC_DEBUG_OVERLAY);

m_World = new OgreNewt::World();

mSceneMgr->setWorldGeometry(Ogre::String("NewLA_track.scene"));

OgreNewt::CollisionPrimitives::TreeCollisionSceneParser *tree =
new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(m_World);
tree->parseScene(mSceneMgr->getRootSceneNode());
OgreNewt::Body *me = new OgreNewt::Body(m_World, tree);
delete tree;

_car = new CarUSC("Flame.car", "Dirso", Ogre::Vector3(0,300,0), m_World, mSceneMgr);
_car->SetCamera(mCamera);
}

bool GS_Racing::frameStarted(GameManager* game, const FrameEvent& evt)
{
if(isKeyDown(OIS::KC_ESCAPE))
return false;

if(isKeyDown(OIS::KC_P))
showDebugOverlay(true);

updateDebugOverlay(true);

MoveCamera(evt);

m_World->update(evt.timeSinceLastFrame);
_car->UpdateCamera();

return true;
}


CarUSC::CarUSC(Ogre::String sFileName, Ogre::String sName, Ogre::Vector3 pos,
OgreNewt::World *_world, Ogre::SceneManager *mgr):OgreNewt::Vehicle(),mSceneMgr(mgr),
_cam(0), m_sName(sName)
{
_car.LoadCar(sFileName);

// create the modes and thing like that
_carBody = eCGFW::RBD::getInstance()->createBody(_world, mgr, _car.carMesh, sName,3000,NULL, pos);
_carNode = (Ogre::SceneNode*)_carBody->getOgreNode();

SetKeyCmd(OIS::KC_A, OIS::KC_D, OIS::KC_W, OIS::KC_S);
}


OgreNewt::Body* RBD::createBody(OgreNewt::World *world, Ogre::SceneManager *mgr, Ogre::String mesh,
Ogre::String entName, Ogre::Real mass, Ogre::SceneNode *parent,
Ogre::Vector3 pos, Ogre::Quaternion or)
{
Ogre::Entity *ent = mgr->createEntity(entName, mesh);
Ogre::SceneNode *node;
if(parent)
node = parent->createChildSceneNode(pos, or);
else
node = mgr->getRootSceneNode()->createChildSceneNode(pos, or);
node->attachObject(ent);
OgreNewt::CollisionPrimitives::Box *box;
box = new OgreNewt::CollisionPrimitives::Box(world, ent->getBoundingBox().getSize());
OgreNewt::Body* res = new OgreNewt::Body(world, box);
res->attachToNode(node);
if(mass > 0.0f)
{
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid(mass, ent->getBoundingBox().getSize());
res->setMassMatrix(mass, inertia);
}
res->setPositionOrientation(pos, or);
res->setStandardForceCallback();
delete box;
return res;
}


Do you have any idea what I have missed?

Thanks,
Dirso

Dirso

04-06-2007 01:10:52

Here is a screenshot of the game (the floating car)

walaber

04-06-2007 01:35:26

do you have the OgreNewt::Debugger working in your scene?

try looking at the OgreNewt world with the debugger to make sure that all of the collision shapes are where you expect them to be.

Dirso

04-06-2007 02:26:52

I changed the line where I used the setWorldGeometry because I had no debuglines for the terrain mesh, so I'm using this right now:
Ogre::Entity *entWorld = mSceneMgr->createEntity("ground", "NewLA_track.mesh");
Ogre::SceneNode *nodeWorld = mSceneMgr->getRootSceneNode()->createChildSceneNode();
nodeWorld->attachObject(entWorld);


But the car is still flying :(


BTW: I got a exception on "m_debugnode->detachAllObjects();" Is it normal?

Please, more ideas?
Thanks,
Dirso.

walaber

04-06-2007 04:12:42

what is the starting position of the car?

and yes, that exception is normal... make sure you call OgreNewt::Debugger::deInit() before you shut Ogre down.

Dirso

04-06-2007 13:16:31

what is the starting position of the car?
0,200,0

walaber

04-06-2007 17:27:16

the OgreNewt::World defaults to a size of (-100,-100,-100) to (100,100,100).

anything outside those bounds will not be updated, which is why your car is not falling.


you need to increase the size of the world to be bigger!

IIRC the function is world->setWorldSize()... or maybe world->setSize().

Dirso

04-06-2007 20:17:39

I can't thank you enough!!!!

Thank you very much!!!
Dirso!!!