# Displaying 3D object in Ortho

## Recommended Posts

starfleetrp    127
I have been trying to do this, however it seems that If I try to draw any object with a Z axis, it just wont display. (Ive been using cubes for testing) I want to do this so I can load 3D models into my Ortho Scene, and have them rotate. I am using this code to make it ortho, however i'm not even sure if its the right way to go about it.
void glEnable2D()
{
int vPort[4];

glGetIntegerv(GL_VIEWPORT, vPort);

glMatrixMode(GL_PROJECTION);
glPushMatrix();

glOrtho(0, vPort[2], 0, vPort[3], -.001, 1000);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
}

void glDisable2D()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}


##### Share on other sites
NickGravelyn    855
The problem is (possibly) your glOrtho call. The last two parameters specify the smallest and largest z value that are rendered. Try using glOrtho(0, vPort[2], 0 vPort[3], -1000, 1000) and see if that works.

##### Share on other sites
starfleetrp    127
I am now also wondering if there is a way to rotate a quad on the y axis (so it appears to become shorter/like a gun barel at 45 degrees would look like from the air.) since the Z axis sets its direction.

Also, is there a way to make it so you see a 3D model as if from a birds eye view, but not right on top. So you might see 3/4 of its top and maybe 1/4 of its side thats facing the monitor (front back, side etc). Would this be just as simple as roating the object? However I dont think this will work because once you set its direction, wont it be all messed up? I am not sure if this is exactly clear, however if its not I will try and clarify the best that I can.

##### Share on other sites
Kalidor    1087
Quote:
 Original post by starfleetrpI am now also wondering if there is a way to rotate a quad on the y axis (so it appears to become shorter/like a gun barel at 45 degrees would look like from the air.) since the Z axis sets its direction.
glRotate*

The y-axis is the vector (0,1,0).
Quote:
 Original post by starfleetrpAlso, is there a way to make it so you see a 3D model as if from a birds eye view, but not right on top. So you might see 3/4 of its top and maybe 1/4 of its side thats facing the monitor (front back, side etc). Would this be just as simple as roating the object? However I dont think this will work because once you set its direction, wont it be all messed up? I am not sure if this is exactly clear, however if its not I will try and clarify the best that I can.
Just position the "camera" so that it looks at the object from above and to the side (one way to do that is with gluLookAt). If you're just looking at one object than you could get the same effect by just rotating that object.

How would setting its direction mess it up?

##### Share on other sites
starfleetrp    127
When I try to set the Quad with a Y axis of even (1 as angle) it just disappears, I have no idea why. Sorry that I wasnt clearer, I skipped a scentence.

Hmm, the camera, I thought I tried that and it didnt work... Ill try it again! Thanks for your help. So id move it back(z) maybe 10.0f and up(y) 40.0f as an example?

##### Share on other sites
dawidjoubert    161
I think your dissapearance issue has to do with the fact that your pivotal point for rotation is not the center of the quad.

If you now rotate it by 1 degree the center of the quad will move.

The way to remedy this is to use gltranslate, try the following code
glPushMatrix(); // save the matrixglTranslatef(x,y,z);glScalef(sizex,sizey,sizez);glBegin(GL_QUADS); glVertex3f(-1,-1,0); glVertex3f(1,-1,0); glVertex3f(1,1,0); glVertex3f(-1,1,0);glEnd();glPopMatrix();//Restore the matrix

##### Share on other sites
starfleetrp    127
Ah, that would be the problem, however since I have an image on the quad, whos center point of rotation should be at one end not the middle, how would I be able to fix this so it will still rotate?