|
Another way of looping through all an object polygon is by using the FOREACH_OBJECT_POLYGON macro.
Example:
FOREACH_OBJECT_POLYGON(obj, poly) {
do something with the polygon. For rxsmple lets check its name
char *name=STATE_polygon_get_name(poly);
}
Note that this 2 functions wont work if the flag CREATE_BSP_FOR_DYNAMIC_OBJECTS
is given when calling STATE_engine_load_world() (you will probably never use this flag ...)
In this rare case use the function STATE_object_get_all_polygons() instead
#define FOREACH_OBJECT_POLYGON(obj, poly) for(DWORD poly=STATE_object_get_first_polygon(obj); poly!=NULL; poly=STATE_object_get_next_polygon(obj, poly))
polygons_array[] is an array of DWORD. This array will be filled with handles to
all the polygons of the object.
NOTE: you must allocate memory for the array before calling this function
Example:
int num_of_polys=STATE_object_get_number_of_polygons(obj_handle);
allocating mem using new or malloc etc ...
DWORD *poly_array=(DWORD *)malloc(num_of_polys*sizeof(DWORD));
STATE_object_get_all_polygons(obj_handle, poly_array);
|