09-21-2005, 05:38 AM
:lol: I was bored one day, found Rel's tuts I printed off,. read the furmula for 3D rots,. and it clicked.... Why I didn't see it b4 beats me, sorta one of those "Ouch, I feel dumb" moments, but, who cares, its 3D in Pur FB with a few things I picked up over the last few weeks to make it nice and smooth (Pixel Per Second Delay, and Double buffering) :wink:
PS: THe PPS delay should be better than a FPS delay,.. Its easier to get a solid running speed with it anyway... This code is locked at 50 PPS... :wink: ... Or at least should be,. I'm trusting the theory of my calculations... heh.. *gulp* :roll:
PS: THe PPS delay should be better than a FPS delay,.. Its easier to get a solid running speed with it anyway... This code is locked at 50 PPS... :wink: ... Or at least should be,. I'm trusting the theory of my calculations... heh.. *gulp* :roll:
Code:
SCREENRES 800, 600, 32, 2, 1
DIM SHARED AS INTEGER P1, P2 = 1
DEFSNG A-Z
CONST LENS = 256
CONST PI = 3.14
TYPE CORD3D
X AS SINGLE
Y AS SINGLE
Z AS SINGLE
END TYPE
DIM SHARED AS CORD3D Cam, Points(1000), S(1000), OS(1000), Ang
DIM SHARED CENTX, CENTY
CENTX = 400
CENTY = 300
FOR i = 0 TO (UBOUND(Points))
Points(i).X = (INT(RND * 200) + 1) - 100
Points(i).Y = (INT(RND * 200) + 1) - 100
Points(i).Z = (INT(RND * 200) + 1) - 100
NEXT
Cam.X = 0
Cam.Y = 0
Cam.Z = -200
Ang.X = 0
Ang.Y = 0
Ang.Z = 0
'########################################
'######## SPEED (Pixels Per Second) #####
'########################################
RATE = 50 'Pixels Per Second
'########################################
T! = TIMER
DO
SCREENSET P2, P1
SWAP P2, P1
CLS
FOR i = 0 TO (UBOUND(Points))
X = Points(i).X
Y = Points(i).Y
Z = Points(i).Z
NY = Y * COS(Ang.X * PI / 180) - Z * SIN(Ang.X * PI / 180)
NZ = Z * COS(Ang.X * PI / 180) + Y * SIN(Ang.X * PI / 180)
Y = NY
Z = NZ
NZ = Z * COS(Ang.Y * PI / 180) - X * SIN(Ang.Y * PI / 180)
NX = X * COS(Ang.Y * PI / 180) + Z * SIN(Ang.Y * PI / 180)
X = NX
NX = X * COS(Ang.Z * PI / 180) - Y * SIN(Ang.Z * PI / 180)
NY = Y * COS(Ang.Z * PI / 180) + X * SIN(Ang.Z * PI / 180)
RX = NX - Cam.X
RY = NY - Cam.Y
RZ = NZ - Cam.Z
Dist = LENS - RZ
IF Dist < 256 AND Dist > 0 THEN
S(i).X = CENTX + (LENS * RX / Dist)
S(i).Y = CENTY - (LENS * RY / Dist)
PSET (S(i).X, S(i).Y), RGB(RZ, RZ, RZ)
END IF
NEXT
IF (TIMER - T!) <> 0 THEN FPS = F / (TIMER - T!)
IF FPS <> 0 THEN V = RATE / FPS
F += 1
Ang.X += V
Ang.Y += V
Ang.Z += V
LOOP UNTIL INKEY$ = CHR$(27)