Main sections
X_OBJ...
X_OBJSTART num#
X_OBJADDVERTEX x#, y#, z#, tx#, ty#, col#
X_OBJNEWGROUP
X_OBJEND
Creates 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.
x#, y#, z# specify a vertices coordinates.
tx#, ty# set the texture coordinates for this point - 0=top/left, 1.0=bottom/right.
col# is the color to apply to this point.
Triangles n, n-1, n-2 will be connected. For each group n-2 triangles will be drawn. Every other triangle will be drawn in opposite orientation, so the up vector will be correct again.
1---3---5
.\ / \ /|
..2---4 |
.......\|
........6
Triangles:
1,2,3 - 3,2,4 - 3,4,5 - 5,4,6
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
Pyramid.ddd