Feature Proposal: Spectator Camera Mode

Feature Proposal: Spectator Camera Mode

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

jnnnnn
Posts: 16
Joined: 25 Oct 2006, 11:14

Feature Proposal: Spectator Camera Mode

Post by jnnnnn »

I have been experimenting with the TASpring code and would like to implement a feature.

I thought it was best if I asked first, for suggestions.

Here is my proposal:

Spring Cinematic Camera Mode

Aim: Create a new spectator-only camera mode that automatically follows the most interesting parts of a Spring game.

Purpose:
- To be able to use Spring as a screensaver (in conjunction with global AIs and an auto-restart feature when games end). This could be fun for eg. PC shops which often have boring screensavers running, or swapmeets where vendors wish to demonstrate the power of computers.
- To make it easier for spectators to watch replays / games
- because it would be cool

Design:
Stage 1: Create a new map mode similar to radar/metal views that indicates how interesting areas are.
Stage 2: Implement a camera mode that automatically moves between areas of high interest.

Ideas for stage 1:
- break map into segments
- interest++ if change in health (small bonus if increasing)
- interest++ if moving units (bonus if weaponised) * total health
- interest++ if opposing teams are in close proximity (attempt to predict battles before they happen
- balance factors for each
- balance based on total health of units (based on the assumption that more interesting units have more health)
- interest decays over time (keep 3 calculations in a queue)?
- recalculate only every ten seconds to keep cpu usage down

Ideas for stage 2:
- move camera to points of interest
- rotate camera around points of interest
- looking at an area reduces its interest for a certain amount of time

Implementation plan:
1.1: New map mode (all constant value)
1.2: Map mode displays total possible health for each sector (ignores current health)
1.3: Design decent class structure for next stages
1.4: Moving Units give bonus to interest value for sector
1.5: Opposing teams in close proximity give bonus to interest value for sector
1.6: time factor - Interest accumulates for a certain amount of time and is then discarded
2.1: camera position adjusted automatically (rotation/zoom unchanged, similar to overview mode repositioning)
2.2: looking at a sector reduces its interest
2.3: camera rotates around areas of interest (stays focussed on one point and pans around it to observe from all angles)
2.4: camera transitions smoothly between areas of interest
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Eek. That sounds an awfully lot like a fairly intensive AI running in the background.

I don't mind the idea per se, but for goodness sakes, it must not run by default and should require some specific command-line command to start. That's all I ask. It's a good idea to increase interest in Spring, etc., and could even be expanded- "greatest hits of my recent replays", etc.... but if it runs without being asked explicitly, it'll suck up CPU in NanoBlobs so fast it'll melt people's poor processors ;)
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Sounds good, but a few bugs ive already spotted:


Say you have two areas of interest, one at 100 and the other at 110. Naturally, interest centers around the 110 area, although its interest quickly goes down as its being veiwed. When interest reaches 100, the program makes a random decision between the two scenes, and switches between them. and then it keeps switching, backwards and forwards, not settling anywhere because of the similar scores.

To solve this, you could add in some hysterisis on the scoring calculations, so that the camera doesnt switch till the score is considerably lower than other scores around it.


When creating things like fusion farms, quite a large amount of health would be centered around one spot. This could really skew the calculations, especially if armys are still at that specific moment. As they have such large health, and nothing is moving, interest would center around the fusions, which are really, REALLY boring to watch...

Dunno how you could fix this, besides carefull weighting of the values as to favor units with weapons more than units without weapons. Perhaps if nothing is really moving or firing, the camera could just scroll around the map, showing off the scenery?


Someone fires a nuke at the enemy. As the nuke is not a unit, your current scripts would not detect it, therefore the camera would not snap to the location of the hit untill AFTER the nuke explodes, damaging everything and setting off the health lost alarm.

To fix this, you could add another watch to the code, to see if weapons are fired, and work out where the weapon will hit, watching there if nothing else is going on.
User avatar
diggz2k
Posts: 208
Joined: 04 Mar 2005, 06:34

Post by diggz2k »

maybe also have a user operated mode so you could press spacebar to switch between interest areas. So when you are watching and the ai is watching something not interesting to you or if it moved away from somewhere you were still watching you could take over.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

I imagine this will be a non-issue cpu-wise since only parties running this camera will need to perform calculations.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

- break map into segments
- interest++ if change in health (small bonus if increasing)
- interest++ if moving units (bonus if weaponised) * total health
- interest++ if opposing teams are in close proximity (attempt to predict battles before they happen
- balance factors for each
- balance based on total health of units (based on the assumption that more interesting units have more health)
- interest decays over time (keep 3 calculations in a queue)?
- recalculate only every ten seconds to keep cpu usage down

I would simplify it to the following:
  • Break map into segments

    Sum metal costs and total health of units per segment. Store this sum, as say sum1[].

    Sum metal costs and total health per segment again, call it sum2. Subtract it out from the previous, sum1[], and divide this result by sum2[]+sum1[].

    The biggest percentage change should receive the current focus, but don't switch focus until the current focus has gone on for at least 8 seconds or so.

    Rinse and repeat.
There's only 1 special case you will have to check for - nukes.and you could probably run that scan only once something capable of building a nuke pops up, and then, still only check every ten seconds, following the nuke if it does fire.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

aha, why didnt I think of doing that!

*quickly goes off todo AI stuff*
jnnnnn
Posts: 16
Joined: 25 Oct 2006, 11:14

Post by jnnnnn »

Thanks everyone for your comments.

Argh: It won't run by default. I was planning to have it recalculate areas of interest every 5sec. Hopefully it would not be a particularly intensive calculation anyway, apart from possibly detecting units that are close to opposition units.

Maelestrom:
Hystersis sounds good. My first attempt won't include time-based stuff, but that hysteresis thing definitely sounds like a good idea. Also, in most battles, I expect the situation would change before the camera had switched back and forth too many times, although I suppose even one switch back would be weird.

I'm not going to worry about nukes for now.
Cool idea for later (maybe for nukes as well): I was considering a sort of Matrix effect where occasionally when a big gun is fired (say a Bertha), the camera follows the projectile until it crashes and then zooms out to watch the damage.

I'm going to bias the weighting pretty heavily towards units with weapons, to the point of ignoring units without them. Partly because I don't want the camera to care if there are two metal makers next to each other - "interesting" ~~ "fighting" for this little feature.

diggz2k:
I like that idea! Switching on demand would be cool, and good for debugging initially. Thanks!

(Not forgetting the eventual aim of being able to enjoy watching it unattended).

Dragon45:
That sounds nice and simple :) Perhaps I'll try that first.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post by Forboding Angel »

if you implement this then you will become my bff. 8)
Lemm1w1nkz
Posts: 16
Joined: 26 Jun 2006, 21:07

Post by Lemm1w1nkz »

coolest screen saver ever, I can't wait for this.

good luck
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Forboding Angel wrote:if you implement this then you will become my bff. 8)
Boyfriend's friend?
Lord JoNil
Posts: 47
Joined: 28 Dec 2005, 03:20

Post by Lord JoNil »

Good Luck. If you succeed this will be really cool. 8)
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post by Forboding Angel »

rattle wrote:
Forboding Angel wrote:if you implement this then you will become my bff. 8)
Boyfriend's friend?
Appearently you never watch south park.

Best friend forever.
jnnnnn
Posts: 16
Joined: 25 Oct 2006, 11:14

Post by jnnnnn »

It's starting to work!

Image

(Screenshot at Stage 1.2 of the Interest map drawing mode. The red square represents the most interesting square; the whiter squares show more interest. At the moment all it's doing is summing health. )
Last edited by jnnnnn on 03 Nov 2006, 07:46, edited 2 times in total.
User avatar
Decimator
Posts: 1118
Joined: 24 Jul 2005, 04:15

Post by Decimator »

Try http://www.photobucket.com it will let you link directly to images.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Forboding Angel wrote:
rattle wrote:
Forboding Angel wrote:if you implement this then you will become my bff. 8)
Boyfriend's friend?
Appearently you never watch south park.

Best friend forever.
I don't watch it indeed. :)
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Oh nice work, already this far, its looking good!

With interest maps that low res, what happens if you have a largish army of small units that cover 2+ squares? The interest points will be spread out over a larger area, so the area wont appear as interesting, even though it has a huge mass of units, just not concentrated.

Dunno how to solve this, besides increasing the resolution of the interest map, but you still potentially have the same problem, just at a lower scale.

Or maybe take say a 3x3 block of interest blocks, add up the interest in them, and use that to define where is good to look at? These larger 3x3 blocks would over lap, so you wouldnt get the same problem, and i doubt you would get armies larger than 3x3 interest blocks big.
Arco
Posts: 75
Joined: 17 Jun 2006, 16:28

Post by Arco »

Maelstrom wrote:Dunno how to solve this, besides increasing the resolution of the interest map, but you still potentially have the same problem, just at a lower scale.
You could have overlapping interest blocks. (You could think of it as one layer of tiled squares, and a second layer of tiled squares offset by half the square length in each dimension.) So every unit is actually counted twice, but it prevents "border separation" issues since a mass will more smoothly transfer between blocks. Of course, you could really go nuts and have many simultaneous pseudo-random tesselations, virtually guaranteeing smooth transitions between interest zones.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

Just create a number of tesselations based on some constant value that you import via an external text file or something (of course for now just set it a constant in the code). That way the user can modify it to suit their hardware.
jnnnnn
Posts: 16
Joined: 25 Oct 2006, 11:14

Post by jnnnnn »

Here's the 1.2 patch.

To try it, press Ctrl+Shift+i to enable the interest mode drawing.

There is also a Cinematic camera mode that will follow the most interesting square if the mouse is at the right of the screen.

Code is probably awful; I've never tried serious C++ coding before.

At the moment, "interest" is worked out as "what is the second-greatest total health of an ally team group in this square?". This means that squares containing only one ally-team are not interesting. It's just a start.

Patch file at http://www.cs.mu.oz.au/~jnnewn/spring/S ... ge1.3.diff .
More readable version at http://www.cs.mu.oz.au/~jnnewn/spring/S ... ge1.3.html .
Post Reply

Return to “Engine”