DrawX = xpos + math.cos(ModelRotation+Rotation)*(MAPIModelPartDist[i]*size)
DrawY = ypos + math.sin(ModelRotation+Rotation)*(MAPIModelPartDist[i]*size)
{ 0 3 1 }
{ 1 0 2 }
{ 2 1 3 }
{ 3 2 0 }
-- store data about a square
-- point data
pointX[0] = 25
pointY[0] = 25
pointX[1] = 25
pointY[1] = -25
pointX[2] = -25
pointY[2] = -25
pointX[3] = -25
pointY[3] = 25
numberofpoints = 3
-- line data
lines[0][0] = 3
lines[0][1] = 1
lines[1][0] = 0
lines[1][1] = 2
lines[2][0] = 1
lines[2][1] = 3
lines[3][0] = 2
lines[3][1] = 0
-- for each point, draw all its lines
for i = 0,numberofpoints do
-- we need to calculate how many lines this point is part of
linenumber = -1
for numberoflinescheck = 0,100 do
if lines[i][linenumber] ~= nil then
linenumber = linenumber + 1
else
break
end
end
-- we now know this point is connected to "linenumber" other points by lines
for j = 0,linenumber do
-- now we take each of the other points...
destinationpoint = lines[i][j]
-- and retrieve the coordinates of that point
destX = pointX[destinationpoint]
destY = pointY[destinationpoint]
-- then we draw the line from the current point to the stored point.
DrawLine(pointX[i], pointY[i], destX, destY, 1,1,1,1,1,1,1,1,10)
end
end
Drawing a line to the shape of a box ain't this hard, just have four points, draw from point 1 to point 2 and so on
Init:
LineX1 = {} --X1 of the line
LineY1 = {}
LineX2 = {}
LineY2 = {}
LinesInSide = {} --How many lines are there in the square
LinesInSideIDs = {}
LineDrawn = {}
draw code:
function BlahBlah()
LineDrawn = {}
for square = 0,numsquares do -- or the amount of boxes!!!
for side = 0,NumSides[square] do
for line = 0,LinesInSide[side] do
if LineDrawn[LinesInSideIDs[line]] ~= true then
DrawLine(LineX1[LinesInSideIDs[line]],LineY1[LinesInSideIDs[line]],LineX2[LinesInSideIDs[line]],LineY2[LinesInSideIDs[line]],..(do the rest of the variables!))
LineDrawn[LinesInSideIDs[line]]
end
end
end
end
end
-- for each point, draw all its lines
for i = 0,numberofpoints do
-- we need to calculate how many lines this point is part of
linenumber = -1
for numberoflinescheck = 0,100 do
if lines[i][linenumber] ~= nil then
linenumber = linenumber + 1
else
break
end
end
-- we now know this point is connected to "linenumber" other points by lines
for j = 0,linenumber do
-- Only draw the line if the opposing vertex's ID is greater than this vertex's ID
if lines[i][j] > i then
-- now we take each of the other points...
destinationpoint = lines[i][j]
-- and retrieve the coordinates of that point
destX = pointX[destinationpoint]
destY = pointY[destinationpoint]
-- then we draw the line from the current point to the stored point.
DrawLine(pointX[i], pointY[i], destX, destY, 1,1,1,1,1,1,1,1,10)
end
end
end
function RotateX(firstvertex,lastvertex,rotate, centerX, centerY, centerZ)
for i = firstvertex, lastvertex do
vertex3dY[i] = vertex3dY[i] - centerY
vertex3dZ[i] = vertex3dZ[i] - centerZ
vertex3dY[i] = (vertex3dY[i] * math.cos(rotate)) - (vertex3dZ[i] * math.sin(rotate))
vertex3dZ[i] = (old3dy * math.sin(rotate)) + (vertex3dZ[i] * math.cos(rotate))
vertex3dY[i] = vertex3dY[i] + centerY
vertex3dZ[i] = vertex3dZ[i] + centerZ
end
end
vertex3dY[i] = (vertex3dY[i] * math.cos(rotate)) - (vertex3dZ[i] * math.sin(rotate))
vertex3dZ[i] = (vertex3dY[i] * math.sin(rotate)) + (vertex3dZ[i] * math.cos(rotate))
old3dy = vertex3dY[i]
vertex3dY[i] = (vertex3dY[i] * math.cos(rotate)) - (vertex3dZ[i] * math.sin(rotate))
vertex3dZ[i] = (old3dy * math.sin(rotate)) + (vertex3dZ[i] * math.cos(rotate))
//timer EAX;// div EAX,8;
//fsin EAX,EAX;
//mul EAX,512;
//fabs EAX,EAX;
//neg EAX;
//add EAX,512;
dcvxpipe 3; //-1..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;
//modelViewMatrix = ViewMatrix * modelMatrx
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; //ZSorting
denable 2; //Lighting
denable 3; //Face culling
//render cube
dcolor fg_color;
dvxdata_3f cube2,12;
dvxflush;
ddisable 0; //Disable everything!
ddisable 1;
ddisable 2;
ddisable 3;
dcvxpipe 0;
dvxpipe 0;
//You can write some text here now
//<right here>
dexit;
//========
cube2:
db -1,-1,-1;
db 1,-1,-1;
db 1,1,-1;
cube3:
db -1,-1,-1;
db 1,1,-1;
db -1,1,-1;
cube4:
db 1,-1,1;
db -1,-1,1;
db 1,1,1;
cube5:
db -1,-1,1;
db -1,1,1;
db 1,1,1;
cube6:
db 1,-1,-1;
db -1,-1,-1;
db 1,-1,1;
cube7:
db -1,-1,-1;
db -1,-1,1;
db 1,-1,1;
cube8:
db -1,1,-1;
db 1,1,-1;
db 1,1,1;
cube9:
db -1,1,1;
db -1,1,-1;
db 1,1,1;
cube10:
db -1,-1,-1;
db -1,1,-1;
db -1,1,1;
cube11:
db -1,-1,1;
db -1,-1,-1;
db -1,1,1;
cube12:
db 1,1,-1;
db 1,-1,-1;
db 1,1,1;
cube13:
db 1,-1,-1;
db 1,-1,1;
db 1,1,1;
lightdata:
vector4f lightpos, 0,50,-50, 0; //x y z <unused, will be falloff>
color lightcol,255,255,255, 1; //R G B Brightness
//========
matrix mRotateMatrix;
matrix mTranslateMatrix;
matrix mProjectionMatrix; //This defines our projection to 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, 0, 1, 0; //<AXIS X Y Z> <ANGLE W>
vector4f vTranslate, 0, 0, 0, 0; //<TRANLSATION X Y Z> <0>
vector4f vPerspective, 30, 1.6, 1, 20; //<FOV> <ASPECT RATIO> <ZNEAR> <ZFAR>
vLookAt:
vector3f vLookAt_Eye, -5, 0, 0; //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,255,255,25;
color bg_color,64,32,12;
Oooh, there's some good stuff on the road ahead. Wikipedia says (http://upload.wikimedia.org/math/d/7/b/d7bd43cc28a7bf17b38020729b108c71.png) :D
Oooh, there's some good stuff on the road ahead. Wikipedia says (http://upload.wikimedia.org/math/d/7/b/d7bd43cc28a7bf17b38020729b108c71.png) :D
baah wtf is that lol i gotz a headache now lol