Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bluemoon

Self written translations and rotations ?

This topic is 5677 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi to all. This is my first post at this Forum: I am currently writing my own little 3D-Engine and came to the conclusion that their is no use for OpenGL functions like gltranslatef and glrotatef. Instead I need to write those functions by myself since i need to write them by myself in order to know the Position of every Vertice or I would not be able to do Collisioin Detection etc. , because i wouldn''t know the position of each Vertex. To check my thoughts I searched the Quake III source code and could not find any gltranslatef or glrotatef calls. Now my question: Am I thinking in the right way, or is this completely wrong ?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Well, for each object (or component thereof) you need to store its orientation somehow, e.g., yaw/pitch/roll, spherical rotation angles (theta/phi/roll), axis/angle, quaternion, rotation matrix, as well as its "position", i.e., translation from local coords to world coords. Then for OpenGL rendering, you need to set the modelview matrix to the proper transformation for the current position and orientation of the object. You can do this with glTranslate and glRotate or you can directly compute the transformation matrix yourself and use glLoadMatrix.

Share this post


Link to post
Share on other sites
Vertex-based collision routines are more or less useless for realtime games, since they''re way too slow. the Quake engine probably doesn''t use those calls since it handles its own matrix calculations. And you can still transform vertices yourself through the generated model/view matrix if you want.

It sounds like you don''t really understand what exactly the glRotate/glTranslate calls do. I suggest you read up on matrix math and homogenous coordinates before trying to reinvent the wheel.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
At first...thanks for your answers.

@sneftel: You are right in the way that I really should read a little bit more about Matrices and so on...but, my problem aren''t really the Matrices or the way they work.

My Problem is that i do not understand the conncetion between the glrotate/gltranslate commands of OpenGL and the Vertex Coordinates that I am using to define the Position of the object.

Maybe, somehow, I am thinking in a wrong direction but lets try to explain it like this:

- Lets say their are two Triangles
- Each of them has 3 vertices (of course)...(lets just forget
about roll, pitch etc. for now)
- now i want to move the two Triangles (somehow)
- you could use GLTranslate now [lets say: gltranslatef(0,0,-3)]
=> now the Matrix of each Vertex is changed and the object is
drawn 3 units further away from the screen

- NOW: I want to know if the two Triangles intersect:
=> so i now i need the Positions of the Triangles (for
calculating the bounding sphere or whatever)
- How do i know the Vertex Coordinates now ? - since I translated
the Vertices with an OpenGL procedure

Share this post


Link to post
Share on other sites
quote:
Original post by bluemoon
- you could use GLTranslate now [lets say: gltranslatef(0,0,-3)]
=> now the Matrix of each Vertex is changed and the object is
drawn 3 units further away from the screen

glTranslatef doesn''t change the "matrix for each vertex", it manipulates the modelview matrix at the top of the matrix stack. Successive glVertex commands (and a few other GL commands, mostly rendering) are then affected by that matrix.

Time to read up about OpenGL''s rendering philosophy.

Share this post


Link to post
Share on other sites
*scratches head*

How can you look through the Q3 source when all that''s available is the mod source? I think the way Q3 is setup, all of the rendering calls are in the engine (so you wouldn''t know if or when they''re called, would you?).

I think if you grep the GPL''d Q2 engine source, you''ll see both functions used like you''d expect, but I can''t say for sure.

Share this post


Link to post
Share on other sites
I see, my problem is more that I have problems expressing what I mean :-(
(for example: I know that gltranslate changes the Modelview Matrix)

But the reply of the "Anonymous Poster" (first reply) actually solves my Problem.

Especially the last sentence he wrote...
So if use glrotatef (like he wrote) and lets say now I want to read the current Matrix (for example if I want to know how the object is currently rotated) I could just use glgetfloatv ... would that be right ?

[edited by - bluemoon on December 4, 2002 9:10:45 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!