|
#define SHAPE_OUTSIDE 1
#define SHAPE_INSIDE 2
#define SHAPE_BOTH_SIDES 3
*** quite useful
This function creates simple 3D primatives such as a room a box a tunnel and a line.
Based on two points that are given to the function, the engine builds a shape around the two points.
by selecting the number of polygons used and the inside/outside flag one can control the shape created.
If you thing of it the only difference between a room and a box is that in a room the polygons are seen
from inside while in the box they are seen from the outside (remember, in the 3D world, polygons have
only one side.) The different between a box and a line is that a line is longer and made with more polygons
so that it looks more rounded.
Parameters:
object_name:
The name of the object that will be created. Give any name you want.
Like with all tother names in the 3DSTATE engine there is no limit on the length of the string.
P1,P2:
Two points that define the a line/segment. A long this segment the shape will be built
radius:
Determines how thick the line will be (or the height of a box / room)
close_edges:
could be YES or NO . If close_edges==YES the function will add
two more polygons to seal the edges of the shape.
sides:
This parameter can be one of the three following options: SHAPE_OUTSIDE, SHAPE_INSIDE ,SHAPE_BOTH_SIDES
If you build a room , you should choose SHAPE_INSIDE since you will look at the walls of the room
from inside the room. If you build a box or a 3D line then select SHAPE_OUTSIDE.
If SHAPE_BOTH_SIDES is used then the function will use double the number of polygons
so that the shape can be viewd from the inside and from the outside
number_of_bitmaps_along_the_line:
Controls the tiling of the bitmap coordination along the line
from P1 to P2. Usually after calling this function you would
want to call STATE_object_set_bitmap() in order to wrap a bitmap
around the created line (use the bitmap as one skin for the whole object).
number_of_bitmaps_along_the_line, number_of_bitmaps_around_the_line
control how the bitmap will be wraped around the created object.
If number_of_bitmaps_along_the_line==0 or number_of_bitmaps_around_the_line==0
then each polygon will have its bitmap coordinate set with 0,0 at one
corner and 1,1 at the other (in other words, the polygons will be set so that a full bitmap is mapped on each polygon)
For example if building a room you might want to set each wall with a different bitmap so in this case use
number_of_bitmaps_along_the_line=0. If you create a 3D line and you want to wrap around a bitmap of shiny metal then use
different values (such as 2,3,4,5 etc ...) depending on how densed you want the texture to appear.
number_of_bitmaps_around_the_line:
Exactly like number_of_bitmaps_along_the_line only that it controls the density of the bitmap around the created
line and not along the line (as done by number_of_bitmaps_along_the_line);
use_one_bitmap:
This parameter can be YES or NO. It controls how the function set the bitmap coordination of the polygon created.
If use_one_bitmap==YES then the function will build the polygons so that one bitmap can be served as a skin and
cover the whole shape. Use STATE_object_set_bitmap() to set all the polygons of the shape with one bitmap/skin .
If use_one_bitmap==NO, then each polygon will have its bitmap coordinate set with 0,0 at one
corner and 1,1 at the other (in other words, the polygons will be set so that a full bitmap is mapped on each polygon)
For example if building a room you might want to set each wall with a different bitmap so in this case use
use_one_bitmap=NO. If you create a 3D line and you want to wrap around a bitmap of shiny metal then use
use_one_bitmap=YES.
Return value:
Returns a handle to the created object
Example A:
creating a room
double P1[3]={0,0,0};
double P2[3]={10,0,0};
STATE_object_create_line("my_room", P1, P2, 5, 4, YES, SHAPE_INSIDE ,0,0);
Example B:
creating a box
double P1[3]={0,0,0};
double P2[3]={10,0,0};
STATE_object_create_line("my_box", P1, P2, 5, 4, YES, SHAPE_OUTSIDE ,0,0);
Example C:
creating a 3D line
double P1[3]={0,0,0};
double P2[3]={10,0,0};
STATE_object_create_line("my_3d_line", P1, P2, 1, 20, YES, SHAPE_OUTSIDE ,4,2);
Example D:
Creating a line from a track data
for(int i=1; i
|