Controlling car on twisted track
Controlling car on crazy, twisted tracks using physics engine
Welcome to the new Ogre Wiki!
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
Problem
Controlling car on crazy, twisted tracks using a physics engine.
Solution
1. Stick the car to the track:
2. Controlling the car
- In case of simple, flat tracks, you can just set the torque .Y value in the force callback. But twisted tracks require a little more work. Look at the How to drive a car, and create right and left nodes, but move them forward along with the car to it's front. Create also one more child node exactly on front of the car. You should have something like this
Now, when applying torque and forces, when turning left, obtain Ogre::Quaternion
Ogre::Quaternion torqueBase = centerNode.getWorldPosition().getRotationTo(leftNode.getWorldPosition())
And when turning right:
Ogre::Quaternion torqueBase = centerNode.getWorldPosition().getRotationTo(rightNode.getWorldPosition())
Pay attention on position you are getting from nodes. It should be world position, not the relative one. Now just apply torque using function coming with a physics engine, i.e:
Car->ApplyTorque(torqueBase.getPitch().valueRadians() * f, torqueBase.getYaw().valueRadians() * f, torqueBase.getRoll().valueRadians() * f);
Where "f" is a factor (like mass * torqueSpeed).
Alias: Controlling_car_on_twisted_track
Contributors to this page: JustBoo
,
jacmoe
and
Beauty
.
Page last modified on Tuesday 29 of June, 2010 15:55:45 GMT by JustBoo.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.
Sidebar
Search box
Online users
102
online users


