Here is something I made 2 years ago...
//
// Sprite Lines 3D box
// By: Øystein De Lumeau
// support@minportal.net
// Initialize display
SetVirtualResolution (1280,800)
SetClearColor (0,0,0)
SetOrientationAllowed (0,0,1,1)
SetResolutionMode (1)
SetSyncRate (60,1)
// Define center coordinates
XMID#=640
YMID#=400
DIST#=50
ZOOM#=800
// Set up the vector XYZ positions relative to the center coordinates XMID# and YMID#
dim XP#[8]
dim YP#[8]
dim ZP#[8]
dim XP2#[8]
dim YP2#[8]
dim ZP2#[8]
dim xt#[8]
dim yt#[8]
// Virtual size of the vector
I=12
// XYZ Data
XP#[1]=-I
YP#[1]=-I
ZP#[1]=-I
XP#[2]=I
YP#[2]=-I
ZP#[2]=-I
XP#[3]=I
YP#[3]=I
ZP#[3]=-I
XP#[4]=-I
YP#[4]=I
ZP#[4]=-I
XP#[5]=-I
YP#[5]=-I
ZP#[5]=I
XP#[6]=I
YP#[6]=-I
ZP#[6]=I
XP#[7]=I
YP#[7]=I
ZP#[7]=I
XP#[8]=-I
YP#[8]=I
ZP#[8]=I
// Demo loop
do
// Rotate the X Y Z axises, change to get different rotation patterns
S1#=S1#+0.6
if S1#>360 then S1#=S1#-360
S2#=S2#+0.4
if S2#>360 then S2#=S2#-360
S3#=S3#+0.8
if S3#>360 then S3#=S3#-360
// 3D vector math and draw cube
for I=1 To 8
ZA#=(ZP#[I]*cos(S3#)-XP#[I]*sin(S3#))
XA#=(XP#[I]*cos(S3#)+ZP#[I]*sin(S3#))
YA#=(YP#[I]*cos(S2#)-ZA#*sin(S2#))
XP2#[I]=(XA#*cos(S1#)-YA#*sin(S1#))
YP2#[I]=(XA#*sin(S1#)+YA#*cos(S1#))
ZP2#[I]=(YP#[I]*sin(S2#)+ZA#*cos(S2#))
xt#[I]=XMID#+(XP2#[I]*ZOOM#)/(ZP2#[I]+DIST#)
yt#[I]=YMID#+(YP2#[I]*ZOOM#)/(ZP2#[I]+DIST#)
next I
thick#=2
spriteline(1,xt#[1],yt#[1],xt#[2],yt#[2],thick#,255,255,0)
spriteline(2,xt#[2],yt#[2],xt#[3],yt#[3],thick#,255,255,0)
spriteline(3,xt#[3],yt#[3],xt#[4],yt#[4],thick#,255,255,0)
spriteline(4,xt#[4],yt#[4],xt#[1],yt#[1],thick#,255,255,0)
spriteline(5,xt#[5],yt#[5],xt#[6],yt#[6],thick#,255,255,0)
spriteline(6,xt#[6],yt#[6],xt#[7],yt#[7],thick#,255,255,0)
spriteline(7,xt#[7],yt#[7],xt#[8],yt#[8],thick#,255,255,0)
spriteline(8,xt#[8],yt#[8],xt#[5],yt#[5],thick#,255,255,0)
spriteline(9,xt#[1],yt#[1],xt#[5],yt#[5],thick#,255,255,0)
spriteline(10,xt#[2],yt#[2],xt#[6],yt#[6],thick#,255,255,0)
spriteline(11,xt#[3],yt#[3],xt#[7],yt#[7],thick#,255,255,0)
spriteline(12,xt#[4],yt#[4],xt#[8],yt#[8],thick#,255,255,0)
// Check for ESC
if getrawkeypressed(27) then exit
sync()
loop
end
// Function for drawing line:
// id = sprite number
// x1,y1 = Start coordinates of the line
// x2,y2 = End coordinates of the line
// th = Thickness of the line in pixels
// r,g,b = Color of the line in RGB values
function spriteline(id,x1#,y1#,x2#,y2#,th#,r,g,b)
// Create the line sprite
if getspriteexists(id)=0
createsprite(id,0)
setspriteoffset(id,0,0)
endif
// w# = sprite width a# = sprite rotation angle
w#=sqrt((x2#-x1#)^2+(y2#-y1#)^2)
a#=atan((y2#-y1#)/(x2#-x1#))
// Calculate angle ofsett
if x2#=>x1# then ao#=0
if x2#<x1# then ao#=180
// Draw sprite line
setspriteangle(id,a#+ao#)
setspritesize(id,w#,th#)
setspritepositionbyoffset(id,x1#,y1#)
setspritecolor(id,r,g,b,255)
endfunction
----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.