🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

d3dim!!! Did I miss something?

Started by
2 comments, last by meganova75 24 years, 7 months ago
I would recommend the book Computer Graphics - Principles and Practice by Foley, van Dam, Feiner and Hughes, published by Addison Wesley. It has a section entitled Viewing in 3D which sounds like what you want. It covers a great number of other topics.

That's where I learned. I'm sure there are alternative resources on the web though.

Advertisement
Try the OpenGL Programming Guide also called the red book. You can read it for free over the internet. Well, as far as 3D transformations go, either explicitly create a 4x4 matrix and fill it with numbers, or use an api function where you give the rotation angle in radians or degrees, and the axis that you want to rotate the point around. Basically, all of your vertices are multiplied by the matrix and are displayed on the screen.
In OpenGL:

glPushMatrix();
glBegin(GL_TRIANGLES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(2.0f, 2.0f, 0.0f);
glVertex3f(4.0f, 0.0f, 0.0f);
glEnd();
glPopMatrix();

This creates a triangle with lower left corner in the middle of the screen which is x=y=z=0. In OpenGL you have a matrix stack, that contains a 4x4 matrix and is called the current matrix. When you call the glPushMatrix() you make a copy of the matrix that's on the first level of the stack and it will be written to the second level of the stack and becomes the current matrix. Let's say I am creating a 3D cube, so I write a code that draws one face of the cube. Then copy the current matrix to second level, since the first level matrix already contains values that specify your view and projection. I rotate the new quad face with glRotatef(90.0f, 0.0f, 1.0f, 0.0f) around y-axis (that's the 1.0f that I tell OpenGL to rotate the face counter clockwise) then I use glTranslatef(-2.0f, 0.0f, 0.0f) to move the rotated face 2 feet to the left(negative x-axis). The rotation occured around one fixed world coordinate system with its center at x=y=z=0. So the order of operation would be:
1) glPushMatrix()
2) do glTranslate*() call
3) do glRotate*() call
4) glBegin()
.... glVertex*() stuff
5) glEnd()
6) glPopMatrix()

Next
1) do same
2) go 2 feet to the right i.e. positive x-axis
3) rotate -90 deg clockwise
4) draw second face
5) same
6) same

OpenGL will issue glRotate* and glTranslate* in reverse, so the matrices are generated by OpenGL first, i.e. rotation happens first then movement along negative x axis is second. The current matrix contains view and projection values, so you don't want to change this, therefore issue glPushMatrix() to make a copy, then OpenGL creates a translation matrix which is left multiplied by current matrix, then OpenGL creates rotation matrix which is also left multiplied by now view, projection, translate matrix, then your matrix becomes a convoulted mess with view, projection, translation, and rotation values all multiplied together, and after that your vertices are multiplied by this current 2nd level matrix. After translated and rotated vertices of the first face are send to the card, then the 2nd level matrix is destroyed by OpenGL and you remain again at center x=0, y=0, z=0, and current matrix stack contains view and projection values only. Then second face is drawn and you're back to center again. You can also draw 3D cube without rotation or translation and without glPushMatrix and glPopMatrix, but that way you have to really draw the cube in 3D with different values for each vertex, since each face is oriented differently in 3D scene, instead here I drew only one face and moved it and rotated it to position(I am reusing the same vertices for the next three faces). To recap, under OpenGL you tell the api what primitive you want to draw with glBegin(GL_TRIANGLES), then you specify the right amount of vertices, in this case 3 since it's a triangle, then use glEnd() to tell the api that you're done specifying vertices, then you call glFlush() to send data to the video card, and then you swap the back buffer where your triangle is rendered to the front buffer which the video card scans and sends output to your monitor. Hope this will help you. Good luck



direct3d im forces you (well...me) to use a "geometery pipeline". The documentation explains the pipeline as if I were supposed already be familiar with one. Well, I'm not. I understand the "mathematics" I just can't grasp the concepts of translating coordinates from one "space" to another. I've come to the conclusion that I am missing some necessary foundation. I mean the key to learning HOW something works is understanding WHY it works.

1.Is there a way to get around having to implement my own rendering pipeline? (I ask this because I saw a complete source that did
nothing of the sort)

2.If not, can you point out a great resource for CONCEPTUAL 3d graphics. (I DON'T NEED ANOTHER MATH BOOK).

thanks.

------------------

If you are having problems understanding transforming to different spaces in 3D, you might be better of learning how it works in 2D first its much easyier to understand. Ive got some docs somewhere covering this sort of thing, if you get stuck mail me and ill see if i can help Steve_sm98@yahoo.co.uk

This topic is closed to new replies.

Advertisement