Camera pos/dir + rot == right RTS view

Started by
9 comments, last by haegarr 18 years, 1 month ago
Hello, I'm sorry, I've figured out that i posted in the wrong section, so I post again here(sorry again for my dumbness). Here's the deal: I want to set camera and everything right so that i get my look on a trapezium, as in classic RTS(ie "Age of Mythology"); I don't know what to do, I've tryed many ways but the answer is prolly too easy for me to be got :S I'd be grateful if you can try at least to understand what I'm explaining :P a noOb.
I'm happy to be your BacKdoOrMaaan
Advertisement
It's all about manipulatin your camera. In a RTS usually you have a top-down view with a slight inclination. Once you have a working camera adjusting the position is a child`s play.

My project`s facebook page is “DreamLand Page”

Hmm.. Are you looking for an isometric camera, perhaps? (I think that trapezium might == the familiar flattened diamond shape of yore.) If so, try googling for isometric and parallel projections; it's very possible to implement these in a modern 3D pipeline, and the results can be interesting.
I don't want isometric(thanks anyway).
I can't understand how to manipulate my camera to make its view field a trapezium: this way I mean to see no perspective distorsions on the terrain(ie)
I'm happy to be your BacKdoOrMaaan
Quote:Original post by ForestMaster
I don't want isometric(thanks anyway).
I can't understand how to manipulate my camera to make its view field a trapezium: this way I mean to see no perspective distorsions on the terrain(ie)


You can use an orthogonal projection to eliminate perspective distortion. As for acheiving a view of a trapezium-shaped region of terrain, you would probably want your camera at a small offset from a straight-down view angle.

- Mike
Quote:Original post by doctorsixstring

You can use an orthogonal projection to eliminate perspective distortion. As for acheiving a view of a trapezium-shaped region of terrain, you would probably want your camera at a small offset from a straight-down view angle.

- Mike


Sorry for my noobshitness but.. How do I achieve the camera offset from a straight-down view angle? :S
I'm happy to be your BacKdoOrMaaan
An orthogonal projection has a rectangular box as view volume. If such a box cuts a plane (as the simplest ground) a rectangle is yielded regardless of the inclination angle (as long as the front/back of the box are not cut). You will need to use a perspective projection if an actual trapezium should be yielded.

Your camera should have an own co-ordinate frame (that is a combination of a position and an orientation in your case) that defines the camera inside the world. Use a translation to move the camera upwards by an amount, and a rotation around the x axis for inclination. A 90° rotation will yield in a straight down look, so you may use a e.g. 75° rotation if you want a nearly straight down look.
Quote:Original post by haegarr
Your camera should have an own co-ordinate frame (that is a combination of a position and an orientation in your case) that defines the camera inside the world. Use a translation to move the camera upwards by an amount, and a rotation around the x axis for inclination. A 90° rotation will yield in a straight down look, so you may use a e.g. 75° rotation if you want a nearly straight down look.


Thanks a lot, yes I have my own camera class ready to fire
So:(OGL)
camera.look();glRotatef(75,1,0,0);/*DrawAnythingYouWant*/


Am I on the right track?
I'm happy to be your BacKdoOrMaaan
Quote:Original post by ForestMaster
Am I on the right track?

In principal yes, but the stuff around the glRotate may have an influence. Be aware of the following (sorry, but here comes a bunch of theory):

(1) If camera.look() changes the heading of the camera (say it rotates around the cardinal y axis) then using glRotate(angle,1,0,0) may suffer. Perhaps you want to rotate around the _local_ x axis for camera inclination.

(2) The camera is given in global space. Rendering models (like the ground) appears also in global space. However, what you want to see on your monitor is in _view_ space. To reach this, you have to set-up the VIEW portion of the MODELVIEW matrix in OGL (you already know this, right?) Since one comes from VIEW space to global space by applying the camera's transformation, but wants the transformation vice-versa (from global to VIEW space), the VIEW transformation is just the inverse of the camera transformation. So I assume you have (regardless of point (1) here) do a
glRotate(-75°,1,0,0)
what is the said inverse. Please check this.
Quote:Original post by haegarr
(1) If camera.look() changes the heading of the camera (say it rotates around the cardinal y axis) then using glRotate(angle,1,0,0) may suffer. Perhaps you want to rotate around the _local_ x axis for camera inclination.


camera.look() simply uses gluLookAt passing the position, view and up vectors of the camera. I still don't well understand Where to place the rotation /_\
I'm happy to be your BacKdoOrMaaan

This topic is closed to new replies.

Advertisement