|
*** very useful.
Drops the object down till it hits the floor\ground.
Use this function when you want to put an object in a certain location.
In many cases you will know the X,Y of the location but not the height.
In these cases simple put the object high up For example: (X,Y, 10000000)
and just drop it down.
Return Value.
Returns a handle to the polygon bellow.
Parameters:
object_handle: the object to be dropped.
object_height: The height of our object.
You can calculate the height of the object using the object bounding box
Give a value bigger than the object height if you want the object to be above the ground
Give a value smaller than the object height if you want the object to be sunken in the ground
Calculating the height should be a one time operation that should be done at the beginning of the program.
The fact that this function doesnt have to do calculate the height on its own
make this function a little bit faster then STATE_object_drop_down(). Except that the functions are the same
fall_through_dynamic_objects: Could be set to YES or NO.
Notice the following code sample:
Lets assume that we have a terrain world and we want to move our character forward
STATE_object_move(my_object, OBJECT_SPACE, -10, 0, 0); Move the object 10 units forward. If we are in front
of a mountain slope, it could get us into the mountain.
STATE_object_move(my_object, WORLD_SPACE, 0, 0, 10000000); Move the object up in the air so if we have penetrated the mountain
with our previous move then now we are above the mountain
STATE_object_drop_down(my_object, NO); Drop the player nicely on the ground
The code above will work very nicely till there is a helicopter or a bird that
flies above our player. If so, our player will drop down on a the helicopter instead
of on the ground. In this case of this game we better call with fall_through_dynamic_objects==YES
match_ground_angle: YES or NO. If YES is given then the object will turned so it matches the ground surface
for example if we drop a car on a road going uphill then giving YES will insure that
the car will be positioned according to the road incline and that its four wheel will contact the road
Note that if we drop a tree on a mountain side that we should give NO since trees grow upwards ...
Example:
calculate the height:
This is a one time operation that should be done at the beginning of the program.
The fact that this function doesnt have to do
double box[2][3];
STATE_object_get_bounding_box(my_object, box);
double height= box[1][2]-box[0][2];
STATE_object_drop_down_fast(my_object, height, NO, YES);
|