3D in Ortho

I'm trying to draw some 3D objects so that regardless of their position on screen, they always have the same perspective.

I tried pulling the camera waaaay far back and narrowing the FOV to a very narrow field but that didn't work and at that distance, even with the far clipping plane set far back enough, there occurred some z-fighting between the front and back of the objects.

The only other thing I can think of is drawing the 3D objects to an orthographic perspective, so that there will be no dimension other than the way the objects are oriented. I can scale them to represent zoom, if needed.

I'm not sure what else there is to do to set this up. I presume we'll need lighting and depth testing turned on as you would with any other 3D objects, so that it draws correctly so I'm turning those on before drawing the 3D and back off before the 2D.

I removed the camera and any camera transformations and repositioned the objects at the origin so that I can see them as a start. They draw right up close on the screen when I set the projection to perspective. Now, when I set the orthographic mode, I see the background and nothing else. It's not behind the background because when I turn off the background draw call, it's just the clear color.

bmantzey Wrote:I'm not sure what else there is to do to set this up. I presume we'll need lighting and depth testing turned on as you would with any other 3D objects, so that it draws correctly so I'm turning those on before drawing the 3D and back off before the 2D.

There shouldn't need to be any difference other than the way you set up your projection matrix. I can't see anything obviously wrong from what you posted, so I'd be resorting to more basic troubleshooting. If you draw a quad facing the viewer at the origin, can you see it? If so, there's probably something wrong with how/where you're drawing your object(s). Since you're drawing them at the origin, maybe you're only seeing the inside of the objects and their backfaces are getting culled?

Strange, I still can't see anything obviously wrong. One thing it might be is that your ortho projection has {0, 0} in the upper left corner, which may not center your objects where you expect them to be. It's also possible that 320 x 480 is large enough that your objects are too small to see, depending on how large they are themselves. Maybe try glOrthof(-((float) width / (float) height), ((float) width / (float) height), -1.0f, 1.0f, -1.0f, 100.0f)?

No luck with that. I even tried making the view bigger, scaling the models both ways, implementing a variable scale that goes up and down from 0.0 to 2.0...

It draws just as you would expect in the perspective.

I even put the 3D draw calls in with the 2D stuff just to see if it would work. newp

The thing that really makes this painful is it was working last night and I went to change some stuff and ended up losing what I did. I don't have a backup either. I remember doing nothing special to it and it worked right away. I merely changed the projection to ortho instead of projection.

Update:

Okay, I'm not sure why or how but I rotated 90 degrees it and then translated it a little bit and now it's right there laughing in my face. Ugh!

Update:

I'm not sure what's happening now. It's drawing but I realized that what it's drawing to is actually the projection identity matrix. Upon "fixing" it so that it's supposedly drawing to the orthographic perspective, it breaks.

Update:

It makes sense now. You were right. I scaled my model 300 times and it appeared down in the lower left corner. Yay!

(I'm using iPhone with landscape orientation, so it would be top left if I was holding it right side up.)