|
*** very usefull.(Note also STATE_object_auto_add_shadows() which uses stencil shadow volume technique)
This function is everything you'll need to create lighs and shadows
The function creates and adds new polygons which are the shadow of "entity_creating_shadow"
on "entity_receiving_shadow" according to the given light source location.
Those new added polygons are called patches.
entity_receiving_shadow and entity_creating_shadow could be handles to any one of the following
types POLYGON, OBJECT or GROUP. If a NULL is given the function would treat it as a handle to group
a(note that a NULL group means the whole world)
Note that the new added polygons get the same properties
of the "entity_creating_shadow" (i.e. the same bitmap, the same translucent etc ...)
Usually you would like to change those properties. For example:
double light[3]={0,0,200}
STATE_engine_create_shadow(room_group, chair_group, light, 255);
setting the color of the shadows. Note that by changing the color
you can simulate changes in light intensity
STATE_group_set_patches_color(room_group, 70,70,70, ALL_PATCHES);
If we dont call STATE_group_set_patches_color() we wont get a dark shadow on the room floor
instead we will get the shape of the shadow but with the colors and bitmaps of the chair.
Note that the last argument in the call to STATE_engine_create_shadow() is called serial_number
serial_number is a number in the range [10 - 255]
The number is relevant only if we will call
STATE_group_set_patches_color(..., serial_number)
and the function STATE_group_set_patches_bitmap(..., serial_number)
This will allow us to have a room with several shadows and to change only one of them.
Use STATE_polygon_delete_patches() to remove the shadow
For example: STATE_polygon_delete_patches(room_handle, ALL_PATCHES) will
delete all the shadows in the room while STATE_polygon_delete_patches(room_handle, 255) will
delete just the shadows that were created with serial number 255.
Performance note:
If you create the shadow in real time and you want it to be fast
then call this function with polygon handles. for example
STATE_engine_create_shadow(polygon_to_get_shadow, polygon_obscaring_light, light, 255);
Note that function like STATE_polygon_add_patch_easy() are also creating patches though for
different purposes.
Examples:
A)
double light[3]={100,200,300}
STATE_engine_create_shadow(wall_polygon, blocking_polygon, light, 255);
Example B:
while(user did not press ESC) {
STATE_polygon_delete_patches(wall_polygon, ALL_PATCHES);
light[0]+=10; move the light source
STATE_engine_create_shadow(wall_polygon, blocking_polygon, light, 255);
STATE_polygon_set_bitmap_fill(shadow_polygon_handle, flare_bitmap);
STATE_polygon_set_translucent(shadow_polygon_handle, NORMAL_GLASS);
}
See also:
STATE_object_auto_add_shadows() this function uses a totaly different method for creating shadows,
STATE_engine_set_patches_offset(),
STATE_engine_create_dynamic_shadow(),
STATE_polygon_delete_patches(),
STATE_polygon_delete_patches(),
STATE_group_delete_patches(), STATE_group_set_patches_translucent(),
STATE_group_set_color(), STATE_group_set_patches_bitmap()
STATE_polygon_add_patch_easy().
|