Centering model at origin

Started by beyhude, February 26, 2008, 20:32:45

Previous topic - Next topic

beyhude

Hi everyone,

I have a vehicle and when I rotate it, it doesn't rotate at the origin.  I checked some forum posts but it didn't help (glTranslatef(-x,-y,-z) before and normal after the render...).

My code:

GL11.glPushMatrix();
		{
			GL11.glTranslatef(x, y, z);
			GL11.glRotatef(90, 1, 0, 0);

			GL11.glRotatef(radius-90, 0, 1, 0);

			GL11.glTranslatef(-x, -y, -z); 

			head.render();

		}
		GL11.glPopMatrix();


And I must also say that the texture of the models I downloaded from Turbo Squid (.3DS) didn't load, just a color. GL11.glEnable(GL11.GL_TEXTURE_2D); is done.

Thanks by advance.

elias4444

SO much of this depends on how you're loading the model and how the model is formatted, that it makes your question almost impossible to answer.

Personally, I track the highest and lowest vertices for each axis upon loading the model, and then, once finished, I shift each vertex coordinate to position the whole model around a central origin. Of course, in my loader I also add the option to not center the model, because you don't always want to do that.

=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

beyhude