Vechile Bouncing

frier

24-09-2007 02:12:40

I just finished creating a very basic form of my Vechile in cake box and imported it into my gameframe.

I found the car just bounces continually, off the wheels. Up and Down. It worked fine in the CakeBox. But i implemented it in my GameFrame a bit different

CakeBox:

mBody = mNxScene->createBody("racecar.mesh", new NxOgre::CubeShape(1,1,3) , NxOgre::Pose(Vector3(0,5,0),Quaternion(Radian(Degree(90)),Vector3(0,0,0))),"mass: 1000");
mBody->setCMassOffsetLocalPosition(Vector3(0,-2,0));


GameFrame:

NxOgre::ActorParams tmpParams;
tmpParams.setToDefault();
tmpParams.mass = 3000;
mBugz[index] = new Player("Player" + index, TheBugz::HOPPER ,mRenderWindow,mSceneMgr,mNxScene,new NxOgre::CubeShape(1,1,3),NxOgre::Pose(Ogre::Vector3(0,40,-20)),tmpParams);
playerJoysticks[InputManager::getSingletonPtr()->getJoystick(index)] = mBugz[index];


The Player class is inherited from actor and customized to suit my player needs. But yeah any ideas on why its got this perpetual bounce in GameFrame?

betajaen

24-09-2007 09:50:13

The only things I can see are different; is the masses are different between both sets of code, and only cakebox adjusts the COM.

Both are quite important to suspensions in wheels.

frier

24-09-2007 12:40:08

Ok shes fixed. i had to explicity set the mass within my inherited actor class, not in the ActorParams. For example.

Actor Params:
tmpParams.setToDefault();
tmpParams.mass = 1000;

mBugz[index] = new Player("Player" + index, TheBugz::HOPPER ,mRenderWindow,mSceneMgr,mNxScene,new NxOgre::CubeShape(2,1,3),NxOgre::Pose(Ogre::Vector3(0,25,-20)),tmpParams);


then i check the mass in the Inherited class and its 60kgs.

So i put this line in

Explicit Mass in Inherited Class:
this->setMass(1000);

And works perfect!

-----

Next Question! :)

I created my own motor class. And just wondering how can i register my Motor class with NxOgre so NxOgre calls Simulate and Update for me? or don't i

betajaen

24-09-2007 12:49:07

You really need to set the mass in the params. Setting the mass after it's been recorded messes up the shapes unless you update them.

You have to subclass it as a "DriveShaft" like the NxOgre motor. Create an instance then assign it to a wheelset

frier

24-09-2007 13:31:02

I agree i need to set it up in the ActorParams at the start. But it doesnt seem to work. When i set the params like so

tmpParams.mass = 1000;


it says the mass is "59.99996" or similar when i do the following piece of code

Ogre::Real m = this->getMass();

im not sure if its assigning the mass correctly in NxOgreActor::_createActor

It hits the if and skips the part where its spose to assign the mass?
ad.body = &bd;
if (params.density) {
ad.density = params.density;
bd.mass = 0.0f;
}
else if (params.mass) {
bd.mass = params.mass;
ad.density = 0.0f;
}
else {
bd.mass = 1.0f;
ad.density = 0.0f;
}

betajaen

24-09-2007 13:47:44

You need to set the density to zero when you assign the mass; else it uses the calculates the mass from the density and volume of the shape(s).

frier

24-09-2007 13:57:09

I see!.. Ok works good now.. thanks betajaen!

betajaen

24-09-2007 14:04:56

I should point out, that could of been found out in the comments.

Or running Doxygen through NxOgre, which in that case, several pages are created for the params, with full information of what they do, how they work and how to use them in string based params.

frier

24-09-2007 14:28:11

wow cool to know.. ill have to grab deoxygen again!. this will save me time