[bleeding] vehicle setup
somehow my vehicle is acting very strange with bleeding. i used the wheelset with 0.9 so maybe i'm doing something wrong, but the vehicle behaves like the wheel params had no influence at all. it's jumping around like crazy, and the suspension seems much too long...
here's how i setup the vehicle:
m_car = target->createBody("playerCar", new CubeShape(1.8f,1.0f,3.05f), Vector3(0,4,0), "model: racecar.mesh", "mass: 1500");
m_car->setInterpolation(RenderableSource::I_Linear);
m_car->setCMassOffsetLocalPosition(Vector3(0,-1.0f,0));
m_car->setSleepEnergyThreshold(0.0); // make sure the car doesn't fall asleep
m_node = static_cast<NxOgre::OgreNodeRenderable*>(m_car->getRenderable())->getNode();
WheelParams wp;
wp.setToNormal();
wp.suspension_damper = 0.2f;
wp.suspension_spring = 25000.0f;
wp.suspension_target = 0.0f;
wp.suspension_travel = 0.3f;
wp.clamped_friction = false;
wp.emulate_legacy_wheel = false;
wp.unscaled_spring_behavior = false;
wp.axle_speed_override = false;
wp.input_lat_slipvelocity = true;
wp.input_long_slipvelocity = true;
wp.lateral_tire_asymptoteSlip = 2.0f;
wp.lateral_tire_asymptoteValue = 0.7f;
wp.lateral_tire_extremumSlip = 0.15f;
wp.lateral_tire_extremumValue = 0.6f;
wp.lateral_tire_stiffnessFactor = 300.0f;
wp.longitudal_tire_asymptoteSlip = 2.0f;
wp.longitudal_tire_asymptoteValue = 0.7f;
wp.longitudal_tire_extremumSlip = 0.15f;
wp.longitudal_tire_extremumValue = 1.0f;
wp.longitudal_tire_stiffnessFactor = 2500.0f;
wp.inverseWheelMass = 0.2f;
m_wheelFL = static_cast<Wheel*>(m_car->addShape(new WheelShape(0.25f , "offset: 0.9f -0.1f 1.25f", wp, "model: wheel50cmx10cmx50cm.mesh")));
m_wheelFR = static_cast<Wheel*>(m_car->addShape(new WheelShape(0.25f , "offset: -0.9f -0.1f 1.25f", wp, "model: wheel50cmx10cmx50cm.mesh")));
m_wheelRL = static_cast<Wheel*>(m_car->addShape(new WheelShape(0.25f , "offset: 0.9f -0.1f -1.25f", wp, "model: wheel50cmx10cmx50cm.mesh")));
m_wheelRR = static_cast<Wheel*>(m_car->addShape(new WheelShape(0.25f , "offset: -0.9f -0.1f -1.25f", wp, "model: wheel50cmx10cmx50cm.mesh")));
betajaen
12-12-2007 15:56:01
I'll investigate, but I don't think I've touched the params in wheels at all, and Luis (who works with the wheels all the time) hasn't said anything when he converted his game over to bleeding.
I'll investigate, but I don't think I've touched the params in wheels at all, and Luis (who works with the wheels all the time) hasn't said anything when he converted his game over to bleeding.
thx for taking a look. i hope Luis can comment on this as he should have noticed something.
for example i've tried to change the suspension_travel to 2.3 (should equal 2.3 meters in my setup) and the car is still hitting the ground. it's like wp is completely ignored for whatever reason.
betajaen
12-12-2007 19:57:11
I've doubled check the WheelShape and Wheel constructor and construction code and it looks okay. It has barely changed since the new renderable bits, and the wheelparams are being passed through.
I've doubled check the WheelShape and Wheel constructor and construction code and it looks okay. It has barely changed since the new renderable bits, and the wheelparams are being passed through.
that's strange. i've used getSuspensionTravel() at runtime and it returns 1.0. my wheel params should set it to 0.3. maybe the wheelparams get reset later or something like that.
betajaen
12-12-2007 20:30:26
It could be, but I'm looking at the code now and I can't see how it could not be set to 0.3. Besides the radius of wheel is the radius you want right? And that follows in an almost exact way of assignment.
thx for your effort. i was following in the debugger and you're right, the params get passed on. but i noticed something in _bindToNxActor()
the new Wheel is created with the right wheel params, but what's that NxShape* s for?
it gets created with mShapeDescription passed, which seems to be some kind of wheel description, and the suspension value is 1.0 which corresponds to the return value i got earlier.
Shape* WheelShape::_bindToNxActor(Actor* actor, NxShapeIndex id) {
__paramsToDescription(mShapeDescription, mParams, actor->getScene());
Wheel* wheel = new Wheel(*this, wheelParams, renderableParams, actor);
actor->mDynamicCollisionModel.insert(actor->mDynamicCollisionModel.count(), wheel);
actor->mCollisionModel.insert(id, wheel);
actor->mCollisionModel.lock(id, true);
NxShape* s = actor->getNxActor()->createShape(mShapeDescription);
wheel->_bindNxShapeToShape(s);
return wheel;
}
betajaen
12-12-2007 21:49:09
It's a little complicated and weird; "NxShape* s" creates the NxShape (the NxWheelShape) and the "new Wheel" just creates the NxOgre representation of the NxWheelShape. It should create it in the Wheel constructor, looking at it now, but all of the shapes are like that.
But you've made me think about something, which may be the problem. Maybe.
betajaen
12-12-2007 22:01:55
Wheel(WheelShape, WheelParams, NodeRenderableParams, Actor*);
Should be:
Wheel(WheelShape*, WheelParams, NodeRenderableParams, Actor*);
What I think is happening, is the WheelShape class is being copied to the Wheel constructor, the changes are being made but to the copy of the class. I've tried it with the suspension (it being 0.5f and you can see visually it does work).
The problem is, ALL of the NxOgre shape classes work this way, and have done for a while; perhaps since the beginning of 0.9.
All, I can say is whoops.
seems you're right. i've changed the Wheel constructor, rebuild the nxogre dll and it works now.
betajaen
12-12-2007 22:19:48
With these changes I have to make to the other Shapes. I'm seriously of thinking of dropping the "nameShape" classes, all they do is act as a carrier of information and don't really do much that the implementation shape would do.
So:
mScene->createActor("name", new CubeShape(1), Vector3(0,5,0), "mass: 10");
Becomes:
mScene->createActor("name", new Cube(1), Vector3(0,5,0), "mass: 10");
Of course with the name "bleeding edge" such changes are expected. Be warned though, everyone's programs will be effected.
Of course with the name "bleeding edge" such changes are expected. Be warned though, everyone's programs will be effected.
who isn't expecting such changes shouldn't use a svn version anyway. i say no compromises when it comes to design decisions
sorry but i couldnt join the chat before.... but it is good to hear about a new bugfix
I wasnt having that problem because i'm setting wheels params
after wheel creation......
another thing i've noticed is that the suspension seems to allow some kind of
lateral car movement. i don't understand it as a car suspension shouldn't allow lateral movement?
here's a video where you can see what i mean. notice how the body is pushed closer to the tires in the corner:
http://fraglab.at/tmp/lateral.avi (3.9M)
betajaen
13-12-2007 16:35:46
Nothing to do with your wheel problem.
But I hate you guys, I really do. After working through
400 separate compile errors, literally ripping out a massive shapes system, and completely and utterly disabling the serialisation system...
I have two shapes now working; Ground and Cube.
Like I said, I hate you guys; Weak the most.
Nothing to do with your wheel problem.
i know, just didn't want to open another thread, sry.
Like I said, I hate you guys; Weak the most.
i know, i'm a pita
betajaen
13-12-2007 17:01:35
weak, try this:
Wheel->setLevelOfDetail( NxOgre::RenderableSource::LOD_High );
Like I said, I hate you guys; Weak the most.
Weak the most ?? why !!! hmmm seems i have to work harder.....
weak, try this:
Wheel->setLevelOfDetail( NxOgre::RenderableSource::LOD_High );
thx Luis, that did indeed help. there's much less lateral movement now if any at all.
but it's still a bit strange. the car tilts a bit to the inside. kinda strange, shouldn't the pressure be higher on the outside suspension? so shouldn't it tilt to the left?
i dont understand.... if you turn to the right, the car *should* tilt to the right also (to the outside of the corner). Isn't it?
i dont understand.... if you turn to the right, the car *should* tilt to the right also (to the outside of the corner). Isn't it?
you mean it should tilt to the left if i make a turn to right, don't you? take a look at the screenshot. i'm making a turn to the right there and it's tilting to the inside of the corner.
very strange, did you tried to see the car in the visual remote debuger? to check if the problem is in the simulation?
very strange, did you tried to see the car in the visual remote debuger? to check if the problem is in the simulation?
yes, but i'm not familiar with the remote debugger yet. it just shows the collision geometry (cube) and the wheels. driving around a bit i didn't notice any tilting of the cube though.
HexiDave
15-12-2007 09:40:14
Just thought I'd poke my nose in: after getting NxOgre to compile from the latest (as of today) SVN checkout, I went through and set up just like the OP and betajaen as from this post:
http://www.ogre3d.org/phpBB2addons/viewtopic.php?p=34665#34665. Both setups resulted in leaning into the turn. I also checked it out in the remote debugger and it looked the same (inward lean).
Since I run with double-precision compiled Ogre, I can't use OgreNewt, and I prefer NxOgre, but does one of the earlier versions work with cars well? I need to set up a car simulation and I haven't gotten one to work with NxOgre before.
betajaen
15-12-2007 10:02:48
Both the current version of Bleeding and 0.9, work with the wheels properly (minus the bug - but there is a workaround). The lean is calculated with PhysX, and not NxOgre so if you manage to fix it with the Params, it'll work with both versions.
HexiDave & weak:
maybe this helps... download and install:
http://www.g-boot.com/index.php?option= ... elect&id=1
then go and read one of the CFGs in:
c:\program files\ThunderWheels\media\cars
an explanation about the meaning of those params could be found here:
http://www.g-boot.com/modules/phpBB2/viewtopic.php?t=5
Demo 0.3 runs with 0.9, but i'm using 1.0-18 since a week and the gameplay is exactly the same....
The only problem in 1.0-18 version is the jittering....
HexiDave
15-12-2007 18:50:35
Appreciate it - I'll give it a shot. It just seemed weird with basic setup code to see such weird behavior.
reptor
15-12-2007 21:45:55
shouldn't the pressure be higher on the outside suspension? so shouldn't it tilt to the left?
Yes it should. Load on inside springs reduces, and increases on outside springs.
When you sit in a car and take a corner, your weight too wants to go straight instead of turning, thus you have to "fight" against it.
the problem is the negative center of mass. if you use a positie value the car behaves like it should.
i think we may need to simulate downforce or something to prevent the car from tilting upside down.
betajaen
15-12-2007 22:18:06
Nice find. I always thought cars had a low centre of mass, hense the almost de facto setCMassLocalPosition everyone does when they first create a vehicle.
Down force should be pretty to pull of though; addForce every frame right?
i should have thought of it earlier. all forces were inversed, so actually it was pretty obvious what was happening. but AGEIA is doing it in their samples and i wasn't expecting they'd suggest something that kinda breaks the sim
i'll look into downforce tomorrow. shouldn't be too tough to implement some front and rear downforce. i just hope that will be enough to get somewhat realistic results...
edit:
if i use more moderate values to offset the local mass (like -0.5) it seems to work better. maybe it has to do with the position in relation to the wheels...
i've also noticed that the NxWheelDesc has a wheelWidth field. seems it's currently not set. should it be set? what is it good for?
syedhs
16-12-2007 18:39:15
i think we may need to simulate downforce or something to prevent the car from tilting upside down.
That is right - it is even recommended by Ageia in their website - they say something like exerting impulse of several times of the weight of the car downward - but I have never got it right. I will try to tackle this later but if anyone got this solved, I would be very glad to hear it
Edit: NxWheelDesc has a constructor which initializes among of them: wheelWidth - so I am not sure what you are asking? And to the second question: true, I have no idea what is the use of tyre width.
Edit: NxWheelDesc has a constructor which initializes among of them: wheelWidth - so I am not sure what you are asking?
i asked because it doesn't look like NxOgre allows to pass a value for the wheel width to the constructor. or maybe i've just missed it?
betajaen
16-12-2007 19:36:35
Are you sure your wheelWidth actually exists; There is nothing of that in NxWheelShapeDesc.h, and nothing I can remember in 0.9/Bleeding.
Are you sure your wheelWidth actually exists; There is nothing of that in NxWheelShapeDesc.h, and nothing I can remember in 0.9/Bleeding.
you're right, there's no wheelWidth defined in the header. seems like the documentation isn't really up to date.
betajaen
16-12-2007 20:11:57
I expect somebody took it out, and forgot to tell the guys who do the documentation.