Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualShawn619

Posted 18 June 2013 - 07:40 PM

I'm trying to make my car 'hug' the terrain. I figure I should use the normal vector of the car's current surface(the terrain portion it stands on) in order to determine the orientation of the car. I have tried many different methods and exhausted all of them, and now I am out of ideas. I have a full understanding of vectors, normal, cross product, dot product, so feel free to suggest any idea you may have. 

 

Given my car standing on a surface(triangle) whose normalized normal vector is (vn1, vn2, vn3), how do I arrive at rotations(in degrees) (rx1, ry2, rz3) such that my car stands as it should(in real life) on the surface? 

 

I rotate my car with glRotatef:

glRotatef(rx1,1.0f,0.0f,0.0f);
glRotatef(ry2,0.0f,1.0f,0.0f);//not needed(I will specify this myself)
glRotatef(rz3,0.0f,0.0f,1.0f);

To give you an idea of how my game is laid out:(redline=surface normal, black line=ray trace to calculate which triangle the car stands on, car=sitting at rotation(0.0f,0.0f,0.0f))

2dt7gn8.jpg


#4Shawn619

Posted 18 June 2013 - 07:39 PM

I'm trying to make my car 'hug' the terrain. I figure I should use the normal vector of the car's current surface(the terrain portion it stands on) in order to determine the orientation of the car. I have tried many different methods and exhausted all of them, and now I am out of ideas. I have a full understanding of vectors, normal, cross product, dot product, so feel free to suggest any idea you may have. 

 

Currently, say my car stands on a surface(triangle) whose normalized normal vector is (vn1, vn2, vn3).

 

Now, how do I arrive at rotations(in degrees) (rx1, ry2, rz3) such that the car stands as it should(in real life) on the surface? 

 

I rotate my car with glRotatef:

glRotatef(rx1,1.0f,0.0f,0.0f);
glRotatef(ry2,0.0f,1.0f,0.0f);//not needed(I will specify this myself)
glRotatef(rz3,0.0f,0.0f,1.0f);

To give you an idea of how my game is laid out:(redline=surface normal, black line=ray trace to calculate which triangle the car stands on, car=sitting at rotation(0.0f,0.0f,0.0f))

2dt7gn8.jpg


#3Shawn619

Posted 18 June 2013 - 07:38 PM

I'm trying to make my car 'hug' the terrain. I figure I should use the normal vector of the car's current surface(the terrain portion it stands on) in order to determine the orientation of the car. I have tried many different methods and exhausted all of them, and now I am out of ideas. I have a full understanding of vectors, normal, cross product, dot product, so feel free to suggest any idea you may have. 

 

Currently, say my car stands on a surface(triangle) whose normalized normal vector is (vn1, vn2, vn3).

 

Now, how do I arrive at rotations(in degrees) (rx1, ry2, rz3) such that the car stands as it should(in real life) on the surface? 

 

I rotate my car with glRotatef:

glRotatef(rx1,1.0f,0.0f,0.0f);
glRotatef(ry2,0.0f,1.0f,0.0f);//not needed(I will specify this myself)
glRotatef(rz3,0.0f,0.0f,1.0f);

To give you an idea of how my game is laid out:(redline=surface normal, black line=ray trace to calculate which triangle the car stands on, car=sitting at rotation(0.0f,0.0f,0.0f))

2dt7gn8.jpg


#2Shawn619

Posted 18 June 2013 - 07:37 PM

I'm trying to make my car 'hug' the terrain. I figure I should use the normal vector of the car's current surface(the terrain portion it stands on) in order to determine the orientation of the car. I have tried many different methods and exhausted all of them, and now I am out of ideas. I have a full understanding of vectors, normal, cross product, dot product, so feel free to suggest any idea you may have. 

 

Currently, say my car stands on a surface(triangle) whose normalized normal vector is (vn1, vn2, vn3).

 

Now, how do I arrive at rotations(in degrees) (rx1, ry2, rz3) such that the car stands as it should(in real life) on the surface? 

 

I rotate my car with glRotatef:

glRotatef(rx1,1.0f,0.0f,0.0f);
glRotatef(ry2,0.0f,1.0f,0.0f);//not needed(I will specify this myself)
glRotatef(rz3,0.0f,0.0f,1.0f);

To give you an idea of how my game is laid out:

2dt7gn8.jpg


#1Shawn619

Posted 18 June 2013 - 07:36 PM

I'm trying to make my car 'hug' the terrain. I figure I should use the normal vector of the car's current surface(the terrain portion it stands on). I have tried many different methods, but I am now out of ideas. I have a full understanding of vectors, normal, cross product, dot product, so feel free to suggest any idea you may have. 

 

Currently, say my car stands on a surface(triangle) whose normalized normal vector is (vn1, vn2, vn3).

 

Now, how do I arrive at rotations(in degrees) (rx1, ry2, rz3) such that the car stands as it should(in real life) on the surface? 

 

I rotate my car with glRotatef:

 

glRotatef(rx1,1.0f,0.0f,0.0f);
glRotatef(ry2,0.0f,1.0f,0.0f);//not needed(I will specify this myself)
glRotatef(rz3,0.0f,0.0f,1.0f);

 

To give you an idea of how my game is laid out:

2dt7gn8.jpg


PARTNERS