Collision problem...

me_go_fast

18-05-2006 20:39:36

Hello, I am having problems with the collision for the wheels of a vehicle. The orientation of the collision object is different than the orientation of the wheel mesh. I have tried and looked everywhere I can think of, and could not figure it out because I couldnt find where the collision for the wheels is done. If someone could please tell me how to change the orientation of the collision object for the wheel. Thanks!

danharibo

18-05-2006 20:53:14

bod->setpositionorientation()

me_go_fast

18-05-2006 21:02:08

I cannot seem to find the body for the tire, that is the problem I am having. I set the position and orientation of the chassis already, but my tire collision objects are oriented incorrectly. Here is the code I used, based on the vehicle demo:

for (int x=-1;x<=1;x+=2)
{
for (int z=-1;z<=1;z+=2)
{
// All the parameters for the tire class
Ogre::Quaternion tireorient;
if (x > 0)
tireorient = Ogre::Quaternion(Ogre::Degree(0), Ogre::Vector3::UNIT_Y);
else
tireorient = Ogre::Quaternion(Ogre::Degree(180), Ogre::Vector3::UNIT_Y);

Ogre::Vector3 tirepos;
if (x == -1 && z == -1)
tirepos = Ogre::Vector3(0,-0.5f,-0.025);
if (x == -1 && z == 1)
tirepos = Ogre::Vector3(0,-0.5f,2.65);
if (x == 1 && z == -1)
tirepos = Ogre::Vector3(2.05,-0.5f,-0.025);
if (x == 1 && z == 1)
tirepos = Ogre::Vector3(2.05,-0.5f,2.65);
Ogre::Vector3 pin(x,0,0);
Ogre::Real mass = 10;
Ogre::Real width = 0.27432;
Ogre::Real radius = 0.327152;
Ogre::Real susShock = 80.0;
Ogre::Real susSpring = 700.0;
Ogre::Real susLength = 6.0;
bool steering;

Ogre::Entity* ent = sceneMgr->createEntity("Tire"+Ogre::StringConverter::toString(mEntityCount++), "Wheel03.mesh");
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(ent);

node->setScale(0.0008,0.0008,0.0008);
steering = false;

if (x == 1 && z == -1)
steering = true;
if (x == -1 && z == -1)
steering = true;

tire* cTire = new tire(this, tireorient, tirepos, pin, mass, width, radius,
susShock, susSpring, susLength, 0, steering);
cTire->attachToNode(node);


This is the code where I need to change the orientation; I think. Thanks for your help!

danharibo

18-05-2006 21:38:23

change tireorient

me_go_fast

18-05-2006 22:24:56

Thanks, but all that did was change the orientation of the wheel mesh. Below is a picture which may be helpful to finding out what the problem is. Thanks for all your suggestions!

danharibo

18-05-2006 22:30:12

what is tire orient now?

me_go_fast

18-05-2006 22:34:02

In the above picture the tire orientation is the same as it is in the code. The tires on the left side of the car are set to 180 degrees about the Y-axis, which is the up direction and the right side tires are set to 0 degrees about the y-axis. They need to be different because these tires have rims, which would be on the inside if they were both the same orientation. Thanks for your help! :D

danharibo

18-05-2006 22:39:07

so are the tirs on the other side working?

me_go_fast

18-05-2006 22:44:23

no! same problem. :(

danharibo

18-05-2006 22:46:18

try rotating tires another 90o again.

me_go_fast

18-05-2006 22:54:01

That didn't work, it oriented the tires the same as collision object, but they were facing the wrong direction. (They were facing toward the car body) Furthermore, when I went to drive the car the tires (and collision object) started to go side over side instead of rolling. Thanks for the suggestion!

danharibo

18-05-2006 22:55:41

did you rotate the entity or the collision?

me_go_fast

18-05-2006 22:57:16

It rotated the entity.

[edit] it rotated both the entity and the collision. the collision was now facing the right direction but the the entity.

danharibo

18-05-2006 22:58:30

:lol:
Rotate te body, not the entity!

me_go_fast

18-05-2006 23:01:25

Thats what I am having problems with, I can't get just the collision body to rotate! Thanks!

danharibo

19-05-2006 16:52:48

ok,u know where it says if(x > 10)
change the angle to 90!

me_go_fast

19-05-2006 18:55:26

ok, I am assuming that you meant in the section where it says if (x > 0). But when I change it to 90 the entity and the collision are still not oriented the same way. I did notice that the tire collision shapes do not match the shape of my tire, almost like it is still using the collision from the previous tires I had on there, but I could not find any code where that is set. Anyway thanks for your suggestion.

danharibo

19-05-2006 18:58:04

they don't match cos they are probably the wron way round, swap the 90 with the 180

me_go_fast

19-05-2006 19:07:41

switching them resulted in a quite weird result. The entities and the collision were still not oriented the same way. This just created for some tires facing forward and others facing toward the car body. Thanks for the suggestion though!

danharibo

19-05-2006 19:32:48

can u post a pic of them swaped?

me_go_fast

19-05-2006 19:51:47

Here is what happens...

Left Side:


Right Side:

danharibo

19-05-2006 20:12:13

can i see the tire class?

me_go_fast

19-05-2006 20:18:33

Here is the code for the tire class, it is the same as the demos:

class tire : public OgreNewt::Vehicle::Tire
{
public:

// Constructor
tire( OgreNewt::Vehicle* vehicle, Ogre::Quaternion localorient, Ogre::Vector3 localpos,
Ogre::Vector3 pin, Ogre::Real mass, Ogre::Real width, Ogre::Real radius, Ogre::Real susShock,
Ogre::Real susSpring, Ogre::Real susLength, int colID, bool steer)
: OgreNewt::Vehicle::Tire(vehicle, localorient, localpos, pin, mass, width, radius, susShock, susSpring, susLength, colID )
{
steeringTire = steer;
}
// Destructor
~tire();
bool steeringTire;
};


It is a sub-class of the vehicle class

danharibo

19-05-2006 20:35:38

keep trying diffrewnt valuse in tire orient, its the only reason i can think of

me_go_fast

19-05-2006 21:07:25

Finally, I got it WORKING. YAY :D , Apon thinking, I thought of going into 3dsmax and changing the orientation of the tire entities there! Then when i exported it was the same as the collision objects. Thanks for all your help, I would probably be bleading from the skull had you not given me suggestions, :lol: Thanks again!