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

Username:   Password: 
 RegisterRegister   
 Where can I go to learn about 3D programming?
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Raknarg




PostPosted: Thu Dec 01, 2011 3:16 pm   Post subject: Where can I go to learn about 3D programming?

Hey, I was wondering if anyone knows somewhere that I could find tutorials on programming in 3D? I'm sure I could find one eventually, but I was wondering if anyone already knew one already...
Preferably I'd like to work with turing, as that's all I can really do so far, but even if it's for another language, as long as i can learn the concept, the syntax shouldn't be too hard
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Dec 01, 2011 3:40 pm   Post subject: RE:Where can I go to learn about 3D programming?

In general, the most basic unit in 3D graphics is the triangle. In most 3D games and and many 3D modelling suites (excepting CAD suites), everything is modeled as a lot of triangles. The more triangles, the more you can approximate complicated shapes, so the more accurate your model becomes.

Triangles have 3 points and 3 edges. Since triangles tend to share points, it is typically common to have two arrays:
1: Points array. (x,y,z) for each point.
2: Faces array. (i,j,k) indexes referring to entries in the Points array.

You'll want to start with what's called a wireframe - just lines, no faces drawn. The most straightforward way is to store the (x,y,z) coordinates of points and the indices of the points (i,j) for each line. Then, on each frame, project* each point onto the screen and draw the line between points that are connected. Start with a single triangle:

Points, assuming x is right, y is up, z is depth:
(0,0,0)
(0,1,0)
(1,0,0)
Lines:
0,1
1,2
2,3

Once you've got a triangle, try a more complicated shape -- a cube or a real model.

Then, you can start drawing faces. You need to draw faces carefully, or else rear faces will overlap front faces incorrectly. Draw them with basic colours first, then look up Lambertian reflectance and try that.

Unfortunately, this is a process that is usually done mostly on the graphics card, by dedicated processing units. Turing, on the other hand, is on a generalized processing unit (CPU) and is incredibly slow. This means you won't really be able to draw anything complicated -- a small model of perhaps 1000 triangles is likely to push you to the limits of Turing. Turing currently lacks any interface to the graphics card (OpenGL or DirectDraw), so you can't use those tools either.

Once you're ready to move past Turing (which will involve a learning period as you pick up a new language), you should pick up a book on game engine programming, OpenGL, or DirectX. The topic is so deep and so complicated that it's difficult to address meaningfully in anything short of a 1000-page manual.

* The process of projecting points onto the viewscreen can get a little more complicated mathematically. The easiest way is to choose the "orthogonal projection", which means that you can just draw the point (x,y,z) at (x,y) -- drop the Z coordinate entirely. A more realistic projection is called "perspective projection", but it requires a bit of mathematics to understand properly.
Raknarg




PostPosted: Thu Dec 01, 2011 5:32 pm   Post subject: RE:Where can I go to learn about 3D programming?

So how would the depth coordinate relate to the x and y coordinates? Obviously you can't draw anything with a z coordinate, so how do you implement z into it?

And yeah, I know Turing is bad, but I'm not looking to make a big game or someting, I just to understand the concept, which I know works fine in turing. You have to understand the easy stuff before you can do it on anything else, and seeing as Turing is a simple language, that should make it that much simpler to learn.
mirhagk




PostPosted: Thu Dec 01, 2011 5:34 pm   Post subject: RE:Where can I go to learn about 3D programming?

A language that allows very easy use of 3D is C# with XNA. You can learn how to use points, projections, matrices and everything, without having to go into the dirty work of multiplying matrices, or actually developing a projection matrix. I'd suggest looking into that, and there are tons of tutorials for 3d in XNA.
Raknarg




PostPosted: Thu Dec 01, 2011 5:36 pm   Post subject: RE:Where can I go to learn about 3D programming?

Wouldn't I learn more by creating my own projection matrix?
mirhagk




PostPosted: Thu Dec 01, 2011 5:38 pm   Post subject: RE:Where can I go to learn about 3D programming?

Yes, but the point is that you can ease into it, and not get overwhelmed by everything all at once. Do you know what a projection matrix is? How about a matrix? or Vectors? 3D matrices is university math, and projection matrices are like 2nd year university I think. Feel free to try to do it, but I'd suggest easing into it so you don't get overwhelmed (which is the reason you learned Turing instead of MASM)
Raknarg




PostPosted: Thu Dec 01, 2011 5:41 pm   Post subject: RE:Where can I go to learn about 3D programming?

Lol the only reason I learned turing is thats cause thats where everyone else was at... I think if I tried I might be able to do it, but we'll see. Thanks for the information
Tony




PostPosted: Thu Dec 01, 2011 5:41 pm   Post subject: RE:Where can I go to learn about 3D programming?

"very easy" is Unity, which could be drag-and-drop of putting together 3D games. It matters as to what you are trying to do. If you want to skip learning all the basics -- sure, go use tools with higher levels of abstraction.

If you actually want to learn the basics and implement your own tools (or at least understand how such would work) -- http://en.wikipedia.org/wiki/3D_projection
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Thu Dec 01, 2011 5:51 pm   Post subject: RE:Where can I go to learn about 3D programming?

Yes Tony, obviously it's more abstracted, and obviously a drag and drop engine like unity would be easier, but XNA will let you do literally everything on your own. So you can start out by creating some points and drawing/rotating them or whatever. Then you can learn how to draw those points yourself by making a shader. Or learn how matrices work by multiplying them together yourself, or learn how projections work by creating one yourself. That way you can learn every single concept, the same as if you were doing it by hand in turing, except you don;t have to worry about being overwhelmed.

Most students get to a point where they want to learn 3D, and then they find some stuff, read it, and half understand it. Then they fumble through making their own program to do it, and end up either getting nothing onscreen, or getting complete garbage onscreen. Just trying to help him ease into learning 3D, as it's not really something you can learn in a day.
Raknarg




PostPosted: Thu Dec 01, 2011 6:46 pm   Post subject: RE:Where can I go to learn about 3D programming?

Of course it isnt, but i'm prepared to take the time to learn it. Thanks for the suggestions. anything ewlse I should know?
mirhagk




PostPosted: Thu Dec 01, 2011 10:15 pm   Post subject: RE:Where can I go to learn about 3D programming?

Depends on whether your starting out easy and going in deeper, or just jumping straight in. If your jumping straight in there is a LOT you need to know. If your starting out easy, XNA is pretty self-explanatory and there are lots of tutorials out there. Make sure you learn how to draw primitives though, and not models (models are TOO easy).

If your learning XNA you should get familiar with C#, and if your learning it from the very basics, you need to learn C++ or something similar. You will not accomplish very much with Turing, sorry.
Raknarg




PostPosted: Fri Dec 02, 2011 6:18 pm   Post subject: RE:Where can I go to learn about 3D programming?

I know I won't but I thought it would be a good place to begin. See, I know from someone else who learned about 3D that simple things can be done with turing, and thats where I wanted to start out.
DemonWasp




PostPosted: Fri Dec 02, 2011 6:27 pm   Post subject: Re: RE:Where can I go to learn about 3D programming?

Raknarg @ Thu Dec 01, 2011 5:32 pm wrote:
[...] how do you implement z into it?


You don't, at first. Your brain can do a surprising amount of work to figure out where things are (especially if your model rotates) on their own. A perspective projection gives a lot of hints based on Z coordinate (things smaller in the distance), and adding faces gives essentially full information (things in front of other things). You could probably fake something with "fog" (things further away are lighter), but that might be a little slow in Turing.
mirhagk




PostPosted: Fri Dec 02, 2011 6:36 pm   Post subject: RE:Where can I go to learn about 3D programming?

I guess yeah you could simply have 3d points rotate with a rotation matrix, or even just figuring it out with trig. Like DemonWasp said, once the local coordinates are transformed into screen coordinates (rotated and so forth) then all you really need to do is draw the x and y, and you can use the z for which ones are on top, and possibly scaling it down if it's farther away (although once faces are in, an orthogonal projection should work okay so long as you aren't rendering entire scenes)
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: