### Author Topic: 3D - PolyCircle  (Read 1615 times)

#### backslider

• Community Developer
• Prof. Inline
• Posts: 892
##### 3D - PolyCircle
« on: 2012-Apr-17 »
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.

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

• Community Developer
• Prof. Inline
• Posts: 2558
##### Re: 3D - PolyCircle
« Reply #1 on: 2012-Apr-17 »
Always nice to see a new snippet! Thank you!
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)