Main sections
X_OBJSTART
X_OBJSTART num#
X_OBJSTART is used to create a user defined 3D object at runtime.
num# specifies the ID number of the object to be created. Any existing object with that ID number will be overwritten.
Use X_OBJADDVERTEX to add each vertex to the object, X_OBJNEWGROUP to split the verticies into groups, and X_OBJEND to indicate all verticies have been specified.
The object will be made from triangles between the verticies specified. For each vertex (n) a triangle will be created between it and the verticies (n-1) and (n-2). As a result, for each group of verticies, n-2 triangles will be drawn (ie. if 8 verticies are specified, 6 triangles will be drawn).
Example:
<CODE>
1---2---5
\ / \ /|
3---4 |
\|
6
</CODE>
Sample:
// Pyramid demo
// ------------
// Create a Pyramid
X_OBJSTART 5
X_OBJADDVERTEX -5, -10, -5, 0,0,RGB(0,0,255)
X_OBJADDVERTEX 5, -10, -5, 0,0,RGB(0,0,255)
X_OBJADDVERTEX 0, 0, 0, 0,0,RGB(255,255,255) // Peak
X_OBJADDVERTEX 5, -10, 5, 0,0,RGB(0,0,255)
X_OBJADDVERTEX -5, -10, 5, 0,0,RGB(0,0,255)
// ..new Group
X_OBJNEWGROUP
// ...or Bottom
// X_OBJADDVERTEX 5, -10, -5, 0,0,RGB(0,0,255)
// X_OBJADDVERTEX -5, -10, -5, 0,0,RGB(0,0,255)
X_OBJADDVERTEX -5, -10, -5, 0,0,RGB(0,0,255)
X_OBJADDVERTEX 0, 0, 0, 0,0,RGB(255,255,255)
X_OBJADDVERTEX -5, -10, 5, 0,0,RGB(0,0,255)
X_OBJEND
// X_SAVEOBJ "Pyramid.ddd", 5
// X_LOADOBJ "Pyramid.ddd", 5
WHILE TRUE
MOUSESTATE mx, my, b1 ,b2
phi=mx*360 / 640
X_MAKE3D
X_CAMERA 0, 150, -300, 0 ,0 ,0
X_DRAWAXES 0, 0, 0
X_AMBIENT_LT 0, RGB(255,255,0)
X_MOVEMENT mx-230, 0, 0
X_SCALING 3, 3, 3
X_ROTATION phi, 0, 1, 0
X_DRAWOBJ 5, 0
SHOWSCREEN
WEND
END