Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wee!!, I did it...
#1
: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:

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)
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#2
Wow, that pretty good for a first try....I think you're definitaly learning that fast ;-)....I like it...
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#3
A Beautiful Accedent was a first try.... How long ago was that? :lol: I beleive Mitth was posting back then,.. But I put it aside to take a brake, this was me getting back into it,.. :roll: .... If I don't hang up again I should learn fast tho... ^_^
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#4
Hi Rattrapmax6,
really nice but if you will render one from your 3d cars you must change one line.
If not then the cars stand on the head.
S(i).Y = CENTY - (LENS * RY / Dist)

I know in the universe there is none above and down. :lol:

Joshy
sorry about my english
Reply
#5
Wow, looks interesting. Big Grin
[Image: f.jpg]
Reply
#6
exegenate. :*)

Glad to see those are still useful ;*)

Someday, I should be the one asking questions here. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#7
Nice 8)
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#8
Quote:Hi Rattrapmax6,
really nice but if you will render one from your 3d cars you must change one line.
If not then the cars stand on the head.
S(i).Y = CENTY - (LENS * RY / Dist)

I know in the universe there is none above and down. :lol:

Joshy

:o :oops: .... I missed that bit.... :lol: ,.. I'll edited it here, hang on...

Edit: Code fixed,.. :wink: ... Next stop, FBGL? :king:

:lol:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#9
http://members.aol.com/rattrapmax6/download/3DStars.exe
@ Relsoft: /\ /\ the EXE... :wink:

Also, it looks way better after fixing the error d.j.peters found, try the EXE or retry the edited source above.. 8)
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#10
wow, cool 8)
[Image: freebasic.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)