Main sections
X_AUTONORMALS
X_AUTONORMALS mode#
X_AUTONORMALS selects which mode to use for light normal calculations. It will affect any objects created after this point.
mode#:
0: none
1: flat
2: surface normals
Mode 1 allows you to create objects as cubes with real edges.
Mode 2 assumes that all triangles which share a common point belong to the same surface. One normal vertex for this surface will be used for each shared point, thus the edges get smoothed on bends.
// --------------------------------- //
// Project: AutoNormals
// Start: Thursday, September 30, 2004
// IDE Version: 2.40924
X_AUTONORMALS 1
Cube(0)
X_AUTONORMALS 2
Cube(1)
WHILE TRUE
X_MAKE3D 1, 100, 45
X_CAMERA 0,2,7, 0,.5,0
X_SPOT_LT 0, RGB(255,255,255), 0,2,7, 0,0,-1, 45
phi=phi+GETTIMER()/50
X_MOVEMENT -2, 0, 0
X_ROTATION phi, 0,1,0
X_DRAWOBJ 0, 0
X_MOVEMENT 2, 0, 0
X_ROTATION phi, 0,1,0
X_DRAWOBJ 1, 0
SHOWSCREEN
WEND
// ------------------------------------------------------------- //
// -=# CREATECUBE #=-
// ------------------------------------------------------------- //
FUNCTION Cube: num
LOCAL col
col=RGB(0xff, 0xff, 0xff) // white
X_OBJSTART num
// Front Face
X_OBJADDVERTEX .5, -.5, .5, 1, 0, col
X_OBJADDVERTEX -.5, -.5, .5, 0, 0, col
X_OBJADDVERTEX .5, .5, .5, 1, 1, col
X_OBJADDVERTEX -.5, .5, .5, 0, 1, col
X_OBJNEWGROUP
// Back Face
X_OBJADDVERTEX -.5, .5, -.5, 1, 1, col
X_OBJADDVERTEX -.5, -.5, -.5, 1, 0, col
X_OBJADDVERTEX .5, .5, -.5, 0, 1, col
X_OBJADDVERTEX .5, -.5, -.5, 0, 0, col
X_OBJNEWGROUP
// Top Face
X_OBJADDVERTEX -.5, .5, .5, 0, 0, col
X_OBJADDVERTEX -.5, .5, -.5, 0, 1, col
X_OBJADDVERTEX .5, .5, .5, 1, 0, col
X_OBJADDVERTEX .5, .5, -.5, 1, 1, col
X_OBJNEWGROUP
// Bottom Face
X_OBJADDVERTEX .5, -.5, -.5, 0, 1, col
X_OBJADDVERTEX -.5, -.5, -.5, 1, 1, col
X_OBJADDVERTEX .5, -.5, .5, 0, 0, col
X_OBJADDVERTEX -.5, -.5, .5, 1, 0, col
X_OBJNEWGROUP
// Right face
X_OBJADDVERTEX .5, .5, -.5, 1, 1, col
X_OBJADDVERTEX .5, -.5, -.5, 1, 0, col
X_OBJADDVERTEX .5, .5, .5, 0, 1, col
X_OBJADDVERTEX .5, -.5, .5, 0, 0, col
X_OBJNEWGROUP
// Left Face
X_OBJADDVERTEX -.5, -.5, .5, 1, 0, col
X_OBJADDVERTEX -.5, -.5, -.5, 0, 0, col
X_OBJADDVERTEX -.5, .5, .5, 1, 1, col
X_OBJADDVERTEX -.5, .5, -.5, 0, 1, col
X_OBJNEWGROUP
X_OBJEND
ENDFUNCTION // sz