|
This function doesn't change the size of the speed but only changes the speed direction according to the given value
Relevant only for CHASE_PHYSICS
Why do we need this function
----------------------------
Consider the following example: You use CHASE_PHYSICS for moving a car \ missile \ bullet or whatever.
now you want to change the direction of the missile. If you call STATE_object_set_direction()
or STATE_object_rotate_z() it will only change orientation of the car \ missile model.
It is not going to change the direction in which it is heading. For example if your
car turns in 90 degrees it will continue going in the same direction as before according to the car speed vector
(only that after you turn it, it will look as if the car is sliding sideways)
For these cases we actually want to do several things. To turn the car (shapewize) but
also to turn the direction in which it is heading. We might also want to change the
direction of the force (simulating the car engine). The car engine pushes the car
forward in the direction of the car so if our object is a car or a missile we would like
to also adjust the force direction according to the new direction. If the source of force
is external (gravity force for example) then we would not want to change the direction of the force
since gravity is not influenced by the car turning ...
Example A:
double direction[3];
STATE_object_get_direction(obj, &direction[0], &direction[1], &direction[2]);
set the direction of movement to the direction of the object
STATE_object_set_speed_direction(obj, direction);
Example B:
STATE_object_set_speed_direction() code is equivalent to the following code
STATE_object_set_speed_direction(DWORD object_handle, double direction[3])
{
double save_speed_size=STATE_object_get_absolute_speed(object_handle);
STATE_object_set_speed(object_handle, direction);
restore speed size
STATE_object_set_absolute_speed(object_handle, save_speed_size);
}
|