3D - PolyCircle

Previous topic - Next topic

backslider

Hi guys,

I wrote a little function to draw a Polyvector circle in the 3D world. :)
You can only draw it on the z-axis = 0, but it's really cool. :D

Code (glbasic) Select

LOCAL rotationZ# = 0

WHILE TRUE
CLEARSCREEN RGB(0xff, 0xff, 0xff)
Make3D()

INC rotationZ, 1
IF rotationZ > 360 THEN rotationZ = 0

PolyCircle3D(-6, 2, 4, rotationZ/2, RGB(0xbc, 0xf8, 0x94), 90)
PolyCircle3D(2, 5, 3, rotationZ, RGB(0xff, 0x8c, 0x8c), 45)
PolyCircle3D(-8, 10, 3, rotationZ*2, RGB(0x78, 0x6f, 0xee), 1)
SHOWSCREEN
WEND

FUNCTION Make3D:
X_MAKE3D 1, 1000, 45
X_CAMERA 25,25,25,0,0,0
X_AMBIENT_LT 0, RGB(0xff, 0xf9, 0xea)

X_DRAWAXES 0,0,0
ENDFUNCTION

//Draw a 3D circle with this amazing function xD
FUNCTION PolyCircle3D: posX#, posY#, diameter#, rotationZ#, col%, _step%=1
STARTPOLY -1, 0
FOR i%=0 TO 360 STEP _step //_step=1 -> full detail
POLYVECTOR posX + COS(i - rotationZ) * diameter, posY + SIN(i - rotationZ) * diameter, 0, 0, col
NEXT
ENDPOLY
ENDFUNCTION


cheers
backslider

bigsofty

Always nice to see a new snippet! Thank you! :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)