Skip to main content
gamedev.net
🔒 Locked

Projection Matrix setup

Started by davsimp Jan 8, 2007 at 5:58 PM 4 replies 650+ views
Original Post
davsimp
davsimp
Hi, I'm trying to setup my projection matrix right, and I'm having some problems. Basically what I'd like is an ortho projection that could support rotation in the same way as a projective matrix. I want to be able to rotate my object in x/y/z, but not have a perspective effect change on them as I translate them around the screen. If I have rotated an object by 90 degrees in the Y axis, I would expect it to stay as a thing sliver anywhere I move it on the screen with a translate. As I move it to the left or right (with a 90 degree rotation), the object starts to look a bit like a 45 degree rotation at 0,0 translation. My FOV passed to gluPerspective is 22. If I set the fov to a very small value (0.5), then there isn't distortion as I move the object, but the rotation effect looks very 2D (as you might expect). Is there anyway to achieve what I want (no projection distortion as I move translation, but a nice perspective effect when rotating) ? Thank you all very much!
Basiror
Basiror
maybe a little sketch would help us to understand you


What exactly hinders you to use a plain orthogonal projection?

http://www.8ung.at/basiror/theironcross.html
davsimp
davsimp
I have uploaded 3 images demonstrating what I'm looking for. The FOV to gluPerspective is 22 in all of them.

1) Translation 0,0 rotation Y 0

Image 1

2) Translation 0,0 rotation Y 45 degrees

Image 2

3) Translation -0.8,0 rotation Y 45 degrees

Image 3

Basically I want to be able to have image 3 have the same rotation look as image 2. As you can see, image 3 is more stretched out as it gets away from 0,0.

Can I maintain the rotation look of image 2 but be able to translate it anywhere on the screen without it "distorting" ?
stevenmarky
stevenmarky
I don't know if there is a matrix that will do what you want to achieve (I suspect not because the effect you want is dependant on the position of the 'center' of the object, which is lost after a world transform) but I know you could do it by rendering to texture.

Just wondering, are you aware that your scene will look very strange if there are several objects close together, points that should meet won't (imagine two cubes next to each other, the far sides won't touch).

Edit: Just had an idea. Try doing a perspective transform before your world transform (instead of the other way round).

[Edited by - stevenmarky on January 9, 2007 6:12:16 AM]
davsimp
davsimp
Do I have to use a vertex shader to try this out, or is there a way to do this with the fixed function pipeline?
arudson
arudson
It sounds like you're describing a paradox. In order to have any kind of perspective, you need a "vanishing point", towards which objects in the distance are warped/skewed. Eg. looking down a long road, it appears as though the road's edges will eventually meet at a point. What you're asking for is basically a local vanishing point for each object, regardless of where it is rendered on the screen.

I don't think there's any "standard" way of doing this, so you'd probably have to come up with a clever way of doing it yourself. Maybe by moving the viewport around or something. The center of the viewport is your vanishing point, so when you move that to the appropriate 2D location on the screen, and perform a perspective correct render of the object at world 0,0,0 it will effectively have it's own vanishing point, and do roughly what you're describing.

HTH.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.