Archived

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

Gammastrahler

use glTranslate for each primitive?

Recommended Posts

hello again, for my ego-shooter engine, i currently use one call to glTranslate() to move through my 3d-world. this is pretty simple, but on the other side, i need to specify the absolute coordinates for every polygon in 3d space which can be annoying... since i need to readjust 10 times in many cases..... but i wan´t to rewrite my engine so that every polygon hold a x,y,z val for position and only the dimensions in relative units. this would mean that i have to call glTranslate() for every polygon. but i think it could slow down the game, because the matrix would be recalculated for every poly each frame.... any idea? thanks & greets gammastrahler

Share this post


Link to post
Share on other sites
quote:
Original post by Gammastrahler
but i wan´t to rewrite my engine so that every polygon hold a x,y,z val for position and only the dimensions in relative units. this would mean that i have to call glTranslate() for every polygon.


You are talking about polygons. Do you not use models?
It seems like you are moving by using glTranslate and that can also be little confusing.

Some pseudo code for the standard way:

glLoadIdentity();
gluLookAt(...); // move here
for(allModels) {
glPushMatrix();
translateAndRotateModelToTheProperPlace(...);
drawModel(...);
glPopMatrix();
}



Share this post


Link to post
Share on other sites
@obelix:

no, i´m currently using no models, all polygons i use are coded coordinate by coordinate in c++.

the pseudo-code you stated is exactly what i mean, but as i said, you must translate and rotate for each model or poly, and i think that would slow down the engine, does it?

thanks
gammastrahler!

Share this post


Link to post
Share on other sites
Yes, it would slow down the engine if you called it for each polygon. A model has many polygons so it does not make any difference. You can always write a function that transform your new format to absolute vertex coordinates. I think that you should write a editor before you get mad by hardcoding everything.
Perhaps can a editor made for another game like Quake be used?

Share this post


Link to post
Share on other sites