Sign in to follow this  
Toji

Strict Camera Positioning

Recommended Posts

Toji    535
Discalimer: This is more of a mental exercise than anything else, so feel free to throw out just about anything ^_^ I was thinking the other day of how one might make a camera for a 3D "Smash TV" type multiplayer shooter. I sketched out a few quick diagrams to see how you might do it, but from my inital look at the problem, it would seem that you don't have enough information to solve this. I was wondering if anyone had any insight for me. Camera rules: The theoreical game is played from a top-down or 45 degree angle view, and aim is determined by a free-moving cursor that is independant of your charecters movement. Because of this, it would be desirable if your view always showed you the same amount of the playing field both above your charecter and below him. Additionally, we want the player to be able to adjust the camera to the view that they like best BUT we don't want certain angles to give an advantage ove others. Once again, we need to keep the same veiwable distance before and after the player. The way I see it, there are two styles of camera control that would fit these requirements. Either: A) The user controls the distance of the camera from their avatar, and the game calculates the angle of the camera based on that or B) The user specifies the angle of the camera and the game then calculates it's distance from the player. These two approaches graph something like this: in both diagrams f represents the Field of View and v is the desired visible distance before and after the player (therefor 2v is the total viewable distance.) In "A" d represents the desired distance of the camera from the player, and therefore the goal is to solve for the unknown angle shown by "?". In "B", d represents the angle of the camera to the floor, and so the goal is to solve for the distance from camera to player shown as "?" Right off the bat, it would seem that these are unsolvable with the variables given, so we may need to add some extra parameters to the system or calculate based off of a different variable. (For example, perhapse we could instead let hte player control the distance of the camera from the floor, not the player. That would give us a nice right-triangle ^_^) Anyone have any comments/guesses/pointers?

Share this post


Link to post
Share on other sites
PaulEdwards    218
Here's what I think.

If we're using a standard perspective projection matrix, this is impossible unless the camera is directly above the player (since the far side of the player will always be longer than the near side).

So we'd have to change the projection matrix.
If we do this though, we can place the camera anywhere we want, and still make this work. That means that the angle ? does not depend on d, we can change d and ? and still make this work (in the 2d example this is actually polar coordinates for the camera position).

So, to help build a new projection matrix, we'll need to know the two angles that sum up to angle f in your diagram. But choosing a ? and a d give us enough information to solve everything inside the triangles (since the floor length is v). This includes the two parts to f.

Now it's just a matter of fitting this information in to a projection matrix.

Share this post


Link to post
Share on other sites
Toji    535
Quote:
If we're using a standard perspective projection matrix, this is impossible unless the camera is directly above the player (since the far side of the player will always be longer than the near side).


Hm... I'm not sure what you mean by this. I guess I should point out that the player does not have to be centered on the screen, you simply need to be able to see an equal amount before and after him. At low angles this would move the player closer to the top of the screen, but if you were to limit the angle to a certain range the effect shouldn't be too severe.

Creating an alternate projection matrix IS an interesting solution, though. I think I'll have to fiddle around with that a bit in the future...

Share this post


Link to post
Share on other sites
PaulEdwards    218
What I meant is that with a typical perspective projection matrix, the two parts to the angle f will be equal (where d is heading straight at what you're looking at). So if those two angles are equal then you can see intuitively that the far triangle will have a longer "ground line" than the near triangle. Mathematically, knowing d, knowing f/2 and knowing that the far left angle is less than the far right angle (in your diagram), we can use the sine law to show that the length of the far ground line will be greater than the near ground line, unless of course the camera is directly overhead. Man you really do need pictures for this don't you?

But you mentioned not making the effect too severe, that could be a bit different, and then I *think* that if you chose the minimum length difference between the two sides that you're willing to accept (and realize that the line d bisects angle f) that the angle ? should be solvable.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this