Code:
dcvxpipe 3; // -1,0,1 (opengl screen)
dvxpipe 5; // matrix projection
// initialize transform
mperspective mProjectionMatrix,vPerspective;
// render starts
dclrscr bg_color;
mlookat mViewMatrix,vLookAt; // view matrix
timer eax;
mov #vRotate.w,eax;
// rotate translate
mrotate mRotateMatrix,vRotate;
mtranslate mTranslateMatrix,vTranslate;
// create model matrix
mmov mModelMatrix,mTranslateMatrix;
mmul mModelMatrix,mRotateMatrix;
mmov mModelViewMatrix,mViewMatrix;
mmul mModelViewMatrix,mModelMatrix;
// load matrix
mload mModelViewMatrix
mloadproj mProjectionMatrix;
// setup light
dsetlight 0,lightdata;
// setup buffer
denable 0; // vertex buffer
denable 1; // z sorting
denable 2; // lighting
denable 3; // face culling
// render cube
dcolor fg_color;
dvxdata_3f drawpyramid,6;
dvxflush;
ddisable 0; // disable everything now
ddisable 1;
ddisable 2;
ddisable 3;
dcvxpipe 0;
dvxpipe 0;
dexit; // exit drawing
// pyramid points
drawpyramid:
db 0,-1,0; // t (font)
db 1,1,-1;// br (front)
db -1,1,-1; // bl (front)
db 0,-1,0; // t (right)
db 1,1,1;// br (right)
db 1,1,-1; // bl (right)
db 0,-1,0; // t (left)
db -1,1,-1; // bl (left)
db -1,1,1; // br (left)
db 0,-1,0;// t (back)
db -1,1,1;// bl (back)
db 1,1,1;// br (back)
db -1,1,-1; // bottom (left)
db 1,1,1;
db -1,1,1;
db -1,1,-1; // bottom (right)
db 1,1,-1;
db 1,1,1;
lightdata:
vector4f lightpos, 0,50,-50,0; // x y z <unused>
color lightcol,0,255,255,1; // R G B brightness
matrix mRotateMatrix;
matrix mTranslateMatrix;
matrix mProjectionMatrix; // this defines our projetion to the screen
matrix mViewMatrix; // this defines our camera transformations
matrix mModelMatrix; // this is our model transformations
matrix mModelViewMatrix; // this is our model relatively to camera transform
vector4f vRotate, 0,1,0,0; // axis X Y Z angle
vector4f vTranslate, 0,0,0,0; // translation X Y Z 0
vector4f vPerspective, 30,1.6,1,20; // <FOV> <ASPECT RATIO> <ZNEAR> <ZFAR>
vLookAt:
vector3f vLookAt_Eye, 0,0,-5; // where our camera is
vector3f vLookAt_Center, 0,0,0; // what we look at
vector3f vLookAt_Up, 0,1,0; // where our matt-hat is
color fg_color,69,69,69;
color bg_color,255,0,125;
Bookmarks