[Contest] Cubular  
	 
	
		Author 
		Message 
	 
		 
		Catalyst     
		 
		
		
			
				 Posted:  Sun May 25, 2003 12:13 am     Post subject: [Contest] Cubular  
	
				
				 
			 
			 
				 
			 
			
				Ill give +50 bits  to the first person who can make a 3d spinning cube (ill give another +25 bits  to the person that can do it in <50 lines without stacking commands)
 
 
rules: 
 
cant use any 3d engine (including mine)
 
must spin on all axes AND have perspective
 
 
No end date on this one  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
		 
		Sponsor Sponsor  
		 
		 
		
 
 
	 
	 
		 
	 
				 
		Asok     
		 
		
		
			
				 Posted:  Sun May 25, 2003 12:40 am     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				I'm sure one has allready been posted somewhere on the forum by you.  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Catalyst     
		 
		
		
			
				 Posted:  Sun May 25, 2003 12:44 am     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				nope, not in source form  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Tony     
		 
		
		 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Catalyst     
		 
		
		
			
				 Posted:  Sun May 25, 2003 12:59 am     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				it has to have a perspective deformation
 
i.e. it gets smaller as it goes back,etc  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Homer_simpson     
		 
		
		
			
				 Posted:  Sun May 25, 2003 11:43 am     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				i'm almost done and everything works so perfectly but one question... how do i caculate the origin of my cube to be rotated on ?  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Homer_simpson     
		 
		
		
			
				 Posted:  Sun May 25, 2003 11:46 am     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				this is what it looks like so far...
 
 	  code:  	 		  procedure rotate (OriginX, OriginY : real, var secondpartX, secondpartY : real, Rotaion : real)
 
    var tempx := (((OriginX - secondpartX) * cosd (Rotaion)) + ((OriginY - secondpartY) * sind (Rotaion)))
 
    var tempy := (((OriginY - secondpartY) * cosd (Rotaion)) - ((OriginX - secondpartX) * sind (Rotaion)))
 
    secondpartY := OriginY - tempy
 
    secondpartX := OriginX - tempx
 
end rotate
 
type dot :
 
    record
 
        x, y, z : real
 
    end record
 
type cube :
 
    record
 
        d : array 1 .. 10 of dot
 
        center : dot
 
    end record
 
var cube1 : cube
 
procedure movecube (var c : cube, x, y, z : real)
 
    for i : 1 .. 8
 
        c.d (i).x += x
 
        c.d (i).y += y
 
        c.d (i).z /= z
 
    end for
 
    c.center.x += x
 
    c.center.y += y
 
    c.center.z /= z
 
end movecube
 
procedure draw3dline (d1, d2 : dot, c : int)
 
    drawline (round (d1.x / d1.z), round (d1.y / d1.z), round (d2.x / d2.z), round (d2.y / d2.z), c)
 
end draw3dline
 
procedure drawcube (var c : cube, col : int)
 
    draw3dline (c.d (1), c.d (2), col)
 
    draw3dline (c.d (2), c.d (3), col)
 
    draw3dline (c.d (3), c.d (4), col)
 
    draw3dline (c.d (4), c.d (1), col)
 
    draw3dline (c.d (5), c.d (6), col)
 
    draw3dline (c.d (6), c.d (7), col)
 
    draw3dline (c.d (7), c.d (8), col)
 
    draw3dline (c.d (8), c.d (5), col)
 
    draw3dline (c.d (1), c.d (5), col)
 
    draw3dline (c.d (2), c.d (6), col)
 
    draw3dline (c.d (3), c.d (7), col)
 
    draw3dline (c.d (4), c.d (8), col)
 
end drawcube
 
procedure rotatecubexy (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.x, c.center.y, c.d (i).x, c.d (i).y, d)
 
    end for
 
end rotatecubexy
 
procedure rotatecubexz (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.x, c.center.z, c.d (i).x, c.d (i).z, d)
 
    end for
 
end rotatecubexz
 
procedure rotatecubeyz (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.y, c.center.z, c.d (i).y, c.d (i).z, d)
 
    end for
 
end rotatecubeyz
 
procedure assign3d (var d : dot, x, y, z : real)
 
    d.x := x
 
    d.y := y
 
    d.z := z + 10
 
end assign3d
 
assign3d (cube1.d (1), -1, 1, -1)
 
assign3d (cube1.d (2), 1, 1, -1)
 
assign3d (cube1.d (3), 1, 1, 1)
 
assign3d (cube1.d (4), -1, 1, 1)
 
assign3d (cube1.d (5), -1, -1, -1)
 
assign3d (cube1.d (6), 1, -1, -1)
 
assign3d (cube1.d (7), 1, -1, 1)
 
assign3d (cube1.d (8), -1, -1, 1)
 
assign3d (cube1.center, cube1.d (1).x, cube1.d (1).y, cube1.d (1).z)
 
movecube (cube1, 10, 10, 200)
 
loop
 
    rotatecubexy (cube1, 10)
 
    drawcube (cube1, 9)
 
    delay (100)
 
    cls
 
end loop
 
 	 
 
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		bugzpodder     
		 
		
		
			
				 Posted:  Sun May 25, 2003 12:00 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				Nice!
 
using the formulas i showed you a while back?     
 
 
 	  code:  	 		   drawline (round (d1.x / d1.z), round (d1.y / d1.z), round (d2.x / d2.z), round (d2.y / d2.z), c) 
 
 	 
 
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
		 
		Sponsor Sponsor  
		 
		 
		
 
 
	 
	 
		 
	 
				 
		Catalyst     
		 
		
		
			
				 Posted:  Sun May 25, 2003 1:03 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				still need to rotate on 2 more axes if u want the bits  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Homer_simpson     
		 
		
		
			
				 Posted:  Sun May 25, 2003 1:12 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				ya i know... 
 
Quote: 
using the formulas i showed you a while back? 
 
 
are there any other formulas?
 
 
 
how do i caculate the origin of my cube to be rotated on ?   
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Catalyst     
		 
		
		
			
				 Posted:  Sun May 25, 2003 1:21 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				same way ud find the center of a 2d polygon  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Homer_simpson     
		 
		
		
			
				 Posted:  Sun May 25, 2003 1:33 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				how da hell do u do that?  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		JSBN     
		 
		
		
			
				 Posted:  Sun May 25, 2003 1:42 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				well... I loose at this contest.....  
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		Homer_simpson     
		 
		
		
			
				 Posted:  Sun May 25, 2003 10:53 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				whooooooohooooooooo!!!!  
 
i did it(still have some bugs tho
 
	  code:  	 		  const norm := 1000
 
procedure rotate (OriginX, OriginY : real, var secondpartX, secondpartY : real, Rotaion : real)
 
    var tempx := (((OriginX - secondpartX) * cosd (Rotaion)) + ((OriginY - secondpartY) * sind (Rotaion)))
 
    var tempy := (((OriginY - secondpartY) * cosd (Rotaion)) - ((OriginX - secondpartX) * sind (Rotaion)))
 
    secondpartY := OriginY - tempy
 
    secondpartX := OriginX - tempx
 
end rotate
 
type dot :
 
    record
 
        x, y, z : real
 
        xD, yD : int
 
    end record
 
type cube :
 
    record
 
        d : array 1 .. 10 of dot
 
        center : dot
 
    end record
 
var cube1 : cube
 
procedure movecube (var c : cube, x, y, z : real)
 
    for i : 1 .. 8
 
        c.d (i).x += x
 
        c.d (i).y += y
 
        c.d (i).z += z
 
    end for
 
    c.center.x += x
 
    c.center.y += y
 
    c.center.z += z
 
end movecube
 
procedure assign3d (var d : dot, x, y, z : real)
 
    d.x := x
 
    d.y := y
 
    d.z := z + 10
 
end assign3d
 
procedure draw3dline (d1, d2 : dot, c : int)
 
    drawline (round (d1.x / (d1.z / norm)) + 320, round (d1.y / (d1.z / norm)) + 200, round (d2.x / (d2.z / norm)) + 320, round (d2.y / (d2.z / norm)) + 200, c)
 
end draw3dline
 
procedure drawcube (var c : cube, col : int)
 
    assign3d (cube1.center, cube1.d (1).x, cube1.d (1).y, cube1.d (1).z)
 
    draw3dline (c.d (1), c.d (2), col)
 
    draw3dline (c.d (2), c.d (3), col)
 
    draw3dline (c.d (3), c.d (4), col)
 
    draw3dline (c.d (4), c.d (1), col)
 
    draw3dline (c.d (5), c.d (6), col)
 
    draw3dline (c.d (6), c.d (7), col)
 
    draw3dline (c.d (7), c.d (8), col)
 
    draw3dline (c.d (8), c.d (5), col)
 
    draw3dline (c.d (1), c.d (5), col)
 
    draw3dline (c.d (2), c.d (6), col)
 
    draw3dline (c.d (3), c.d (7), col)
 
    draw3dline (c.d (4), c.d (8), col)
 
end drawcube
 
procedure rotatecubexy (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.x, c.center.y, c.d (i).x, c.d (i).y, d)
 
    end for
 
end rotatecubexy
 
procedure rotatecubexz (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.x, c.center.z, c.d (i).x, c.d (i).z, d)
 
    end for
 
end rotatecubexz
 
procedure rotatecubeyz (var c : cube, d : real)
 
    for i : 1 .. 8
 
        rotate (c.center.y, c.center.z, c.d (i).y, c.d (i).z, d)
 
    end for
 
end rotatecubeyz
 
assign3d (cube1.d (1), -10, 10, -10)
 
assign3d (cube1.d (2), 10, 10, -10)
 
assign3d (cube1.d (3), 10, 10, 10)
 
assign3d (cube1.d (4), -10, 10, 10)
 
assign3d (cube1.d (5), -10, -10, -10)
 
assign3d (cube1.d (6), 10, -10, -10)
 
assign3d (cube1.d (7), 10, -10, 10)
 
assign3d (cube1.d (8), -10, -10, 10)
 
%assign3d (cube1.center, cube1.d (1).x + 1, cube1.d (1).y - 1, cube1.d (1).z + 1)
 
assign3d (cube1.center, cube1.d (1).x, cube1.d (1).y, cube1.d (1).z)
 
 
movecube (cube1, 10, 10, 200)
 
loop
 
    if hasch then
 
        cls
 
        case getchar of
 
            label "a" :
 
                rotatecubexy (cube1, 1)
 
            label "s" :
 
                rotatecubexz (cube1, 1)
 
            label "d" :
 
                rotatecubeyz (cube1, 1)
 
            label "q" :
 
                rotatecubexy (cube1, -1)
 
            label "w" :
 
                rotatecubexz (cube1, -1)
 
            label "e" :
 
                rotatecubeyz (cube1, -1)
 
            label :
 
        end case
 
    end if
 
    drawcube (cube1, 9)
 
end loop
 
 	 
 
I'll be fixing the bugs shortly
 
controls are a,s,d,q,w,e   
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		JSBN     
		 
		
		
			
				 Posted:  Sun May 25, 2003 10:56 pm     Post subject: (No subject)  
	
				
				 
			 
			 
				 
			 
			
				nice, very nice
 
+15 bits   
			 
			
				 
			 
		
 
	 
	 
		 
		
		 
	 
	  
		 
	 
				 
		 
	 
	Page 1  of 2    [ 28 Posts ] 
	Goto page 1 , 2   Next