Prefab Vehicle Movement

DjStunt

05-05-2008 22:43:15

I'm fairly new to the Ogre and OgreOde world and currently working on a project for university with 2 other people. so this could be a very simple mistake which i haven't noticed. Using the Simplescene and Gran Turismo demos i'm trying to get the same movement as created in both these demos (Simplescene_Buggy.h from simplescene) to work for our own model.

However, the model seems to be stuck in the one position. The back tyres rotate and the front tyres allow for steering but the model remains still. The collision seems to be working fine as the model is dropped from above. However i can't seem to figure out why it's not moving.

What are the obvious things to check when using the prefab vehicles?

Note: I have played around with the friction settings and mass settings for the model. Although didn't seem to get much success from it.

Any help appreciated!

rewb0rn

05-05-2008 22:54:46

I havent used vehicles yet so I can barely help but why dont you try to exactly rebuild the setting from the demos and from that point change it to what you need?

DjStunt

06-05-2008 13:33:12

We have done that pretty much, rewb0rn. However there's some other things added in which make the structure of our code a little bit different.

We have managed to get a little closer to figuring out what is going on but it leads to another question, our model and track needed to be scaled in order for them to be seen. However somewhere down the line this has made the bounding boxes around the model and wheels a bit wrong.

Here is how we scaled:


goKart->getSceneNode()->scale(0.1,0.1,0.1);


goKart->getWheel(0)->getSceneNode()->scale(0.1, 0.1,0.1);
goKart->getWheel(1)->getSceneNode()->scale(0.1, 0.1, 0.1);
goKart->getWheel(2)->getSceneNode()->scale(0.1, 0.1, 0.1);
goKart->getWheel(3)->getSceneNode()->scale(0.1,0.1,0.1);


And here is the result from mWorld->showDebugGeometrys(); (We still need to fix the way the tyres are facing, but it's the same story if we try using the subaru tryes with this model)

http://img84.imageshack.us/img84/5566/b ... boxrt5.jpg

Any help much appreciated!

rewb0rn

07-05-2008 10:10:52

I'm not sure if setScale() actually rescales the geometries, too. Maybe you should scale the model down first and then create the tires.

DjStunt

07-05-2008 11:22:26

I'm not sure if setScale() actually rescales the geometries, too. Maybe you should scale the model down first and then create the tires.

The wheels and the model are all defined as one. It's done in an .ogreode file which sets it all up in the prefabs.

I've tried some ways like this to scale the Bounding Box:


Ogre::AxisAlignedBox abb = goKart->getGeometry()->getAxisAlignedBox();
abb.scale(Vector3(0.1,0.1,0.1));
Vector3 size = abb.getSize();
OgreOde::Geometry *Geom3;
Geom3 = new OgreOde::BoxGeometry(size,mWorld,mSpace);
goKart->setGeometry(Geom3);



But it doesn't seem to do anything at all.

I've also tried the shorter way:


goKart->getGeometry()->getAxisAlignedBox().scale(Vector3(0.1,0.1,0.1);


But this throws up conversion errors.

rewb0rn

07-05-2008 11:50:55

Please show the complete code for creating the car with its geometries and the .ogreode file. Probably rescaling objects that are defined in an ogreode file is not completely supported. Is the car in the demo rescaled in some way?

DjStunt

07-05-2008 12:09:23

ODE code - >

The scaling up of the wheels is done because with this code we are testing the model with the subaru wheels. To see if it made a difference.

mWorld = new OgreOde::World(primarySceneMgr);
mWorld->setGravity(Vector3(0,-9.80665,0));
mWorld->setCFM(10e-10);
mWorld->setERP(0.25);
mWorld->setAutoSleep(true);
mWorld->setAutoSleepAverageSamplesCount(10);
mWorld->setContactCorrectionVelocity(5.0);

mWorld->setCollisionListener(this);

mWorld->setShowDebugGeometries(true);

mSpace = mWorld->getDefaultSpace();
//mSpace->setInternalCollisions(true);

dotLoader = new OgreOde_Loader::DotLoader(mWorld);


goKart = static_cast <OgreOde_Prefab::Vehicle *> (dotLoader->loadObject("goKart.ogreode", "goKart"));

goKart->setPosition(Vector3(120*SCALE_VALUE,1000, 9*SCALE_VALUE));

goKart->getSceneNode()->scale(0.01,0.01,0.01);

goKart->getWheel(0)->getSceneNode()->scale(15, 15, 15);
goKart->getWheel(1)->getSceneNode()->scale(15, 15, 15);
goKart->getWheel(2)->getSceneNode()->scale(15, 15, 15);
goKart->getWheel(3)->getSceneNode()->scale(15, 15, 15);

goKart->getWheel(0)->setPowerFactor(1);
goKart->getWheel(1)->setPowerFactor(1);
goKart->getWheel(2)->setPowerFactor(1);
goKart->getWheel(3)->setPowerFactor(1);


And in the frame listener:


Ogre::Real time = evt.timeSinceLastFrame;



if (Stepper->step(time))
{
World->synchronise();
}

goKart->update(time);


OgreOde File


<ogreode>


<!-- Create the vehicle using the supplied name and body mesh, make it 1.5 units heavy
e.g. tonnes and offset the center of gravity by half (a metre) to make it more stable
This puts the CoG somewhere around the wheel hubs, which is probably reasonably
realistic for a sports-car -->
<vehicle name="goKart">

<body mesh="goKartBody.mesh">
<mass value="0.05" x="0" y="-0.5" z="0" />
</body>

<!-- Create all the wheels, using the supplied mesh and with the specified offset
relative to the car. The mass is 0.02 units, in our case that's around 20Kg -->
<wheel mesh="scooby_wheell.mesh" x="15" y="-0.46698" z="-10" mass="0.02">
<steer factor="1" force="8.0" speed="4.0" limit="0.75" />
<brake factor="0.75" />
<contact bouncyness="0.9" friction="1.5" fds="0.002" />
</wheel>
<wheel mesh="scooby_wheelr.mesh" x="-15" y="-0.46698" z="-10" mass="0.02">
<steer factor="1" force="8.0" speed="4.0" limit="0.75" />
<brake factor="0.75" />
<contact bouncyness="0.9" friction="1.5" fds="0.002" />
</wheel>
<wheel mesh="scooby_wheell.mesh" x="15" y="-0.46698" z="10" mass="0.02">
<power factor="1" />
<brake factort="0.25" />
<contact bouncyness="0.9" friction="1.5" fds="0.002" />
</wheel>
<wheel mesh="scooby_wheelr.mesh" x="-15" y="-0.46698" z="10" mass="0.02">
<power factor="1" />
<brake factor="0.25" />
<contact bouncyness="0.9" friction="1.5" fds="0.002" />
<suspension spring="90" damping="0.95" step="0.01" />
</wheel>

<!-- Set up the suspension spring and damping constants, passing the rate we're going to
be stepping the world so it can work out the forces needed each step
We could do this per-wheel, like the other factors, but it's easier to do it this way.
N.B. You must create the wheels before you can do this! -->
<suspension spring="90" damping="0.95" step="0.01" />

<!-- Set the engine (and other drivetrain) parameters, lots of work still to do here! -->
<engine redline="70.0" brake="10.0">
<torque min="0.25" max="5.0" />
</engine>
</vehicle>

</ogreode>


Pretty much the same code as for the subaru, except switching the meshes. Initially before we noticed bounding box problem we were messing with these values, but these are back to the original subaru values.

DjStunt

07-05-2008 12:10:13

Please show the complete code for creating the car with its geometries and the .ogreode file. Probably rescaling objects that are defined in an ogreode file is not completely supported. Is the car in the demo rescaled in some way?

The car in the demo is not scaled at all. Which is what leads me to believe it's the scaling causing the problems.

Edit: I think you're right, seems like it's just not supported. One of our guys has started working on scaling the models down to a managable size outside the code and it seems to be making a good difference.

Cheers for the help mate!

rewb0rn

09-05-2008 16:26:28

You're welcome