Help me!

Started by
6 comments, last by xDS4Lx 21 years, 7 months ago
Hey, im new to GL but been doing win32 and c++ for 8 years. Im having problems trying to learn gl. 1st ? is when I call glVertex* do the params mean im drawing x,y,z away from the origin? or where ever i moved the camer to look at by calling glTranslate*?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
Advertisement
Both. Vertex positions are relative to the origin of the current coordinate system.

[twitter]warrenm[/twitter]

Can you explain more please?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
If you have not called glTranslate at all, and you do the following...

glVertex3f(0.0f, 1.0f, 3.0f);

You will get 1 point at 0, 1, 3 (x, y, z)

But, say you called glTraslatef(0.0f, 1.0f, 2.0f);

Then you do the same function

glVertex3f(0.0f, 1.0f, 3.0f);

Then, with respect to the world origin, you have a point at (0.0f, 2.0f, 5.0f);

So, when you translate, it basically moves everything, but the origin stays the same.

PS - I may not be totally correct in this, so if anyone (ZE ) knows that I uffed it up, flame me


"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan [TheBlackJester ]
[Wildfire Studios ]

[edited by - TheBlackJester on August 31, 2002 12:10:14 AM]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

Bah, I try hard not to flame.

Your code was perfect, but then you said, "when you translate, it basically moves everything, but the origin stays the same." That''s effectively what happens, but the way it''s most often explained is that glTranslateX really does move the origin (place to where all vertices are relative). When you understand what the origin represents, it''s easier to visualize how things fit together. Nice explanation overall though. I''m probably too pedantic

Peace,
ZE.


//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

/me would just like to mention that the reason it matters that you are "moving the origin" is that rotations are always performed around the origin.

Therefore if you translate (0,0,10), 10 units back into the screen, then rotate 180 degrees around the y axis, the new position for the object will be (0,0,-10), facing the opposite direction as before.

If you rotate 180 degrees around y axis first, then translate (0,0,10), the object will be at (0,0,10), but also facing the opposite direction. Understand all that? This is one of the most asked question, imho, the order of translation & rotation.

500, 500, 500 error
The way I understand it, calling glTranslate is like moving the ''cursor''. Everything new you draw is placed relatively to this cursor. The same happens with glRotate - the coordinate system is rotated.
Hope that was understandable

____________
"Reality is merely an illusion, albeit a very persistent one." (Albert Einstein)

My Homepage
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
quote:Original post by Neosmyle
/me would just like to mention that the reason it matters that you are "moving the origin" is that rotations are always performed around the origin.



Half correct I believe.

I have to conclude that, in essence, there are two origins. One that changes with glTranslate, and one that doesn't.

For instance, if you draw a point at say (0, 0, 0) and traslate -5 on the z axis, you'll get your point at (0, 0, -5)

Therefore moving the origin (or 0, 0, 0) to (0, 0, -5)

But, if you then called glRotate(degree, 1.0f, 0.0f, 0.0f);

You'll get your point rotating around the "real" origin with a radius of 5.

So actually in respect to rotations, the "real" origin does not move with glTranslate.

Once again, I'm pretty sure thats right, but if not I'm open to correction


[edited by - TheBlackJester on September 1, 2002 3:08:33 PM]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

This topic is closed to new replies.

Advertisement