get angle from objects

Started by dutch_delight, November 25, 2012, 09:38:48 PM

Previous topic - Next topic

dutch_delight

Here's a problem I'm having.

I want a car to align to a surface. so what I've got is 4 dummy objects that are in position of the wheels.
These dummies are always on the ground polygon where the wheels intersect the ground.
That all works fine but how do I align my car to the angle created by these?

I've got this (forward angle only) but it doesnt quite work:

forward_angle = collision_fr_dummy.getTransformedCenter().calcAngle(collision_fl_dummy.getTransformedCenter()););
player_vectortest_matrix = player.getRotationMatrix();

if (player_vectortest_matrix.getYAxis().z > forward_angle) {
car_angle_current_frame.z = forward_angle;
} else if (player_vectortest_matrix.getYAxis().z < forward_angle) {
car_angle_current_frame.z = -forward_angle;
} else {
car_angle_current_frame.z = 0;
}

player.rotateZ(car_angle_current_frame.x*2);



any help much appreciated

EgonOlsen

The car example that comes with desktop jPCT does something like that...maybe it's worth a look. It might not be applicable directly, but maybe it gives some ideas. You should find the code in the place()-method of the Car class.