Page 1 of 1

Camera widget request

Posted: 07 Mar 2011, 12:24
by AF
I'm experimenting offline with some things, and need a good way of demonstrating them.

My idea was to have a widget that focused on the average location of a players base, and zoomed in and out as the units moved, keeping every unit that the team owns on screen at any time if possible.

I'd then make videos using this and use them to make shiny things =) Anybody want to help?

Re: Camera widget request

Posted: 07 Mar 2011, 18:24
by knorke

Re: Camera widget request

Posted: 07 Mar 2011, 18:30
by AF
That's not what I need, that shows important events happening. I want to show all events happening on the screen at once for a team. If they cant be fitted on screen, zoom out and adjust position until they can.

I can figure out the place the camera should be looking at, but how do I make it pull out so that everything that team owns is on screen at once?

Re: Camera widget request

Posted: 07 Mar 2011, 18:34
by knorke
AF wrote:I can figure out the place the camera should be looking at, but how do I make it pull out so that everything that team owns is on screen at once?
well easiest way is probally to make the camera into a straight down view so that the viewable area is an rectangle. Then find the units most north,south,west,east and use them to get the corners of the rectangle. Then move camera into middle of rectangle and adjust height based on FOV. (as FOV can not be changed at runtime)

Re: Camera widget request

Posted: 07 Mar 2011, 20:15
by AF
That last part is what I have issues with. I know how to calculate what needs to be in view, Mapwise. I don't know how to calculate the height necessary to show that rectangular region given a camera orientation or straight down

Re: Camera widget request

Posted: 07 Mar 2011, 21:12
by knorke
for straight down it might just be trig., triangle like this:

Code: Select all

     O    ^
    / \   | H
   /   \  |
  <--X--> v 
###########
O = camera
### = ground
/\ = view cone
angle at top is cameras FOV
H = camera height
X = length of area you want to show

Re: Camera widget request

Posted: 07 Mar 2011, 21:32
by AF
>_< fail, why did I have matrices in my head

So how would I obtain the Fov?

Re: Camera widget request

Posted: 07 Mar 2011, 21:51
by knorke
are you baked?
http://springrts.com/wiki/Lua_UnsyncedRead#Camera
Spring.GetCameraFOV

Re: Camera widget request

Posted: 08 Mar 2011, 14:06
by AF
Still cooking