Camera widget request

Camera widget request

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Camera widget request

Post 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?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Camera widget request

Post by knorke »

User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Camera widget request

Post 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?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Camera widget request

Post 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)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Camera widget request

Post 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
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Camera widget request

Post 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
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Camera widget request

Post by AF »

>_< fail, why did I have matrices in my head

So how would I obtain the Fov?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Camera widget request

Post by knorke »

are you baked?
http://springrts.com/wiki/Lua_UnsyncedRead#Camera
Spring.GetCameraFOV
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Camera widget request

Post by AF »

Still cooking
Post Reply

Return to “Lua Scripts”