Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Contest] Cubular
Index -> Contests
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Catalyst




PostPosted: Sun May 25, 2003 11:25 pm   Post subject: (No subject)

See 3d isnt hard...

Very nice work

+50 bits
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Sun May 25, 2003 11:27 pm   Post subject: (No subject)

oh btw

to find the origin of any 3d object all you have to do is sum up all the values from each axis (x,y,z) then average them
Homer_simpson




PostPosted: Mon May 26, 2003 7:38 am   Post subject: (No subject)

aaaaaaaahhhh... i wanted to do that but then i thought it wouldn't work... =/...
i mean wouldn't the negative numbers in x,y,z mess it up?
Homer_simpson




PostPosted: Mon May 26, 2003 7:45 am   Post subject: (No subject)

fixed out the origin finding problem as well =)


cube3d.t
 Description:

Download
 Filename:  cube3d.t
 Filesize:  3.64 KB
 Downloaded:  214 Time(s)

Catalyst




PostPosted: Tue May 27, 2003 11:04 pm   Post subject: (No subject)

since no one went for the 50-line version, here it is

note: the drawline code should only be 2 lines long

code:
View.Set ("offscreenonly,graphics:640;640")
var x : array 1 .. 8 of real := init (100, 100, 100, 100, 500, 500, 500, 500)
var y : array 1 .. 8 of real := init (100, 100, 500, 500, 100, 100, 500, 500)
var z : array 1 .. 8 of real := init (-250, -750, -250, -750, -250, -750, -250, -750)
var px, py, pz,X, Y, Z, relZ, relX, relY : real := maxx div 2
var x0, y0, z0, x9, y9, diffx, diffy : int := 0
loop
    X := 0
    Y := 0
    Z := 0
    x9 := x0
    y9 := y0
    mousewhere (x0, y0, z0)
    diffx := x0 - x9
    diffy := y0 - y9
    for i : 1 .. 8
        X += x (i)
        Y += y (i)
        Z += z (i)
    end for
    X /= 8
    Y /= 8
    Z /= 8
    for i : 1 .. 8
        relZ := (((Z - z (i)) * cosd (-diffx * z0)) + ((X - x (i)) * sind (-diffx * z0)))
        relX := (((X - x (i)) * cosd (-diffx * z0)) - ((Z - z (i)) * sind (-diffx * z0)))
        x (i) := X - relX
        z (i) := Z - relZ
        relZ := (((Z - z (i)) * cosd (-diffy * z0)) + ((Y - y (i)) * sind (-diffy * z0)))
        relY := (((Y - y (i)) * cosd (-diffy * z0)) - ((Z - z (i)) * sind (-diffy * z0)))
        y (i) := Y - relY
        z (i) := Z - relZ
        relX := (((X - x (i)) * cosd (-diffy * z0)) + ((Y - y (i)) * sind (-diffy * z0)))
        relY := (((Y - y (i)) * cosd (-diffy * z0)) - ((X - x (i)) * sind (-diffy * z0)))
        y (i) := Y - relY
        x (i) := X - relX
    end for
    for i : 1 .. 8
        for k : 1 .. 8
            drawline (round ((100 - (z (i) - (((z (i) - pz) / (x (i) - px) + 0.001) * x (i))) / ((z (i) - pz) / (x (i) - px) + 0.001))),round ((100 * ((y (i) - py) / (z (i) - pz) + 0.001)) + (y (i) - (((y (i) - py) / (z (i) - pz) + 0.001) * z (i)))),
            round ((100 - (z (k) - (((z (k) - pz) / (x (k) - px) + 0.001) * x (k))) / ((z (k) - pz) / (x (k) - px) + 0.001))),round ((100 * ((y (k) - py) / (z (k) - pz) + 0.001)) + (y (k) - (((y (k) - py) / (z (k) - pz) + 0.001) * z (k)))), black)
        end for
    end for
    View.Update
    cls
end loop
Homer_simpson




PostPosted: Wed May 28, 2003 4:35 pm   Post subject: (No subject)

lol i could do the under 50 line thing...or could i?!
hmmmm i'll give it a try
Asok




PostPosted: Wed May 28, 2003 4:36 pm   Post subject: (No subject)

Homer_simpson wrote:
lol i could do the under 50 line thing...or could i?!
hmmmm i'll give it a try


catalyst already posted the solution.
JSBN




PostPosted: Wed May 28, 2003 5:07 pm   Post subject: (No subject)

Catalys scares me.....
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Wed May 28, 2003 5:23 pm   Post subject: (No subject)

y is that?
Asok




PostPosted: Wed May 28, 2003 5:31 pm   Post subject: (No subject)

he probably meant to say "Catalyst owns me"
DJ




PostPosted: Wed May 28, 2003 5:54 pm   Post subject: (No subject)

that crazy ass code went over my head
Homer_simpson




PostPosted: Wed May 28, 2003 6:54 pm   Post subject: (No subject)

welll whadaya know i just created my own 3d engine...


engine.zip
 Description:

Download
 Filename:  engine.zip
 Filesize:  271.65 KB
 Downloaded:  202 Time(s)

Catalyst




PostPosted: Wed May 28, 2003 6:57 pm   Post subject: (No subject)

well wasnt that easy?
try to add some features:
- hidden polygon removal (culling)
- lighting
- painter's algo
- optimizations
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 28 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: