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

Username:   Password: 
 RegisterRegister   
 3D in turing??
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jonny Tight Lips




PostPosted: Tue Nov 23, 2004 5:45 pm   Post subject: 3D in turing??

Yah, I have a very general question about 3D graphics in turing. OK, all I want to knwo if how I would render 3D stuff in turing. I know there are many different ways and any of them would be helpful. And don't tell me it can't de done becasue I've seen it b4. Any and all sugestions are good. I've been messing around with drawing a cube using Draw.Line and a lot of math to get it to rotate but I'm sure and would hope that there is an easyer way to do it.

There might be a post already about this so sry but I was unable to find it so if there is just link me plz. Thanks
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Tue Nov 23, 2004 5:55 pm   Post subject: (No subject)

No, it's really not possible. Go make your Zelda clone.


(Haha, kidding. Seriously, go make the game).

Anyways...
An easy way to get 3D points on a 2D screen is shown here.
Tony




PostPosted: Tue Nov 23, 2004 7:28 pm   Post subject: (No subject)

besides, if you've seen it done, just look over the source code - namely their draw function to see how exactly 3D image is being rendered.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jonny Tight Lips




PostPosted: Tue Nov 23, 2004 7:52 pm   Post subject: (No subject)

Well, I saw it done by Dan. SO Dan if you would please post your code for that 3D space game you made it would be nice. ty
Cervantes




PostPosted: Tue Nov 23, 2004 8:09 pm   Post subject: (No subject)

Or you could just go to the Best of the Turing Submissions and scroll down a little bit until you get to the link to the Engines. Homer's and Zylum's are both listed there.

EDIT: I guess I should mention this, just in case. You can also use the Posted Image, might have been reduced in size. Click Image to view fullscreen. function.
Jonny Tight Lips




PostPosted: Tue Nov 23, 2004 8:10 pm   Post subject: (No subject)

Also, Coutsos I need a lil help understanding that site you linked.
This is the code they give at the end of the page.
code:
procedure 3Dto2D (x, y, z, pan, centre, position)

 

x = x + position.x

y = y + position.y

z = z + position.z

 

new.x = x*cos(pan.x) - z*sin(pan.x)

new.z = x*sin(pan.x) + z*cos(pan.x)

new.y = y*cos(pan.y) - new.z*sin(pan.y)

z = new.y*cos(pan.y) - new.z*sin(pan.y)

x = new.x*cos(pan.z) - new.y*sin(pan.z)

y = new.x*sin(pan.z) + new.y*cos(pan.z)

 

if z > 0 then

    screen.x = x / z * zoom + centre.x

    screen.y = y / z * zoom + centre.y

end if


yah well here are my questions.
1) how can they have pan.x? Is that one var or is it some combination of the 2?
2) What would be the point of my point after all of these steps? x,y?
3) What is the different between screen.x and just x
4) What is the variable pan for? Its for paning yes but if it = 1 what would that mean?
5) What programing language is this meant for?
Mazer




PostPosted: Tue Nov 23, 2004 8:51 pm   Post subject: (No subject)

OK, how about this: ignore pan. In fact, why don't you go ahead and ignore the whole thing. The point of that was this:
code:

var pointx, pointy, pointz : int
% give the above variables some value, I don't care

drawdot(pointx, pointy, 12) % uh-oh, the drawdot() command only takes an x and y coordinate!

% if only we had a way to fake depth!
% LIGHTBULB! Let's divide the x and y coordinates by the z value! Just because!

drawdot( round(pointx/pointz), round(pointy/pointz), 12)

% one small problem... now everything is over in the bottom left corner...
% so let's try this:

drawdot( maxx div 2 + round(pointx/pointz), maxy div 2 + round(pointy/pointz), 12)


Really, that was the main thing.
Jonny Tight Lips




PostPosted: Tue Nov 23, 2004 9:07 pm   Post subject: (No subject)

ok.... thas easy.
Wow that site mad everything so complicated with the sin and cos and AHHHHHHHHHHHHhhhhhhhhhhhhhhhhhhhhhh
Thanx for the help
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Tue Nov 23, 2004 9:12 pm   Post subject: (No subject)

You'll need cos and sin for rotating things. Check out rotation matrices.
Jonny Tight Lips




PostPosted: Tue Nov 23, 2004 9:43 pm   Post subject: (No subject)

Yay I want to rotate a cube. So where would I go to find these Matrixes you speek of? And how would I use them?





Is there a 3d equation??
like for example if I have a cube and I want it to rotate, is there some equations that will tell me that the points are supposed to be?

Also those 3d engines are great but where can I get the source code for them and not just the exe
Dan




PostPosted: Wed Nov 24, 2004 2:23 pm   Post subject: (No subject)

Jonny Tight Lips wrote:
Well, I saw it done by Dan. SO Dan if you would please post your code for that 3D space game you made it would be nice. ty


I made that 3D engion for C++ and not turing.......if u are looking for one in turing, there is the sorce code for them posts some where in the turing sections. try using the sreach thing.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
rizzix




PostPosted: Wed Nov 24, 2004 3:34 pm   Post subject: (No subject)

i can never understand these sites, for ex the one Mazer Twisted Evil pointed out.

#1:
Quote:
screen.x = x / z * zoom
screen.y = y / z * zoom
dosen't make sense. Razz

ha! dividing by z will NOT give you the 3D-normalized-perspective-projection of any point onto your screen
Mazer




PostPosted: Wed Nov 24, 2004 8:13 pm   Post subject: (No subject)

Why not? Perhaps you're doing something wrong? don't forget to add half the screen width and half the screen height so that the origin is at the middle of the window.
Dividing by z:
I'm sure you know that z represents the depth of the point. For our purposes, a greater z value means a greater depth and therefore, a point that is further of the camera. Which kinda makes sense because dividing x by a greater number will give you a smaller result. Right?
Let z = 2, x = 6
x / z = 3. OK.

Now let z = 8, x = 6
x / z = 0.75. Quite a bit smaller, right? Just like objects further away from your viewpoint appear smaller.

Does that make sense now?
Jonny Tight Lips




PostPosted: Wed Nov 24, 2004 9:41 pm   Post subject: (No subject)

Ok, but dividing by z will give you a one point perspective. So how would I make that into 2 point perspective so that I can draw a cube with it?
Mazer




PostPosted: Wed Nov 24, 2004 10:11 pm   Post subject: (No subject)

I'm not sure what you mean. Try drawing a cube with this. It'll be hard to visualise, but just pick 8 points and draw them. Have a variable for the angle, and for each point do this:
pointz := round (15 * sind(angle))
pointx := round (15 * cosd(angle))

The 15 is just a scalar because sin and cos will give you small values (between -1 and 1). You can change the 15 to whatever you want so you can see the points better.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 23 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: