I have the Camera Control on the AI side pretty much designed now and the basic mechanism tested.
Below is a screen shot of the Plot Line Editor showing a series of Plot Lines I put together some time back for automating Change Of Guards.
Essentially, the ambient AI routines I wrote for the Village includes four Wall Guards that patrol the fortified walls enclosing the village. Each is
assigned to one of the four sides and patrols that wall walking forwards and backwards stopping at waypoints along the walls and turning to survey the
countryside before continuing their patrol. This continues unabated until, randomly triggered within a time range, a replacement guard is despatched
from the guard house to replace one of the patrolling guards (again randomly chosen).
The Plot Line shown here controls this Change Of Guard and the Guards chosen are only known at run time as they are randomly chosen from available guards
that fit the Roles. The Plot Lines define how the currently Patrolling Guard returns to his start position and awaits the replacement guard who walks
from the guard house to meet him. Upon arriving within a given distance he stops and both guards turn to face each other and a hand over conversation
takes place between them controlled by speech Actions on the time line. Once complete, they swap places and the original patrolling guard exits and
returns to the guard house leaving the new guard to continue the patrol duties.
When integrating camera control I needed to deal with situations where the camera position and its target would be known at design time (such as set cut
scenes within the game) but also deal with these more dynamic situations when the ambient system chooses the actors at run time to fit the predefined
roles and I have no way of knowing beforehand which actors or which of the four possible locations will be used during any instance of this activity.
I've achieved this by adding a virtual Camera Agent that can be added to the Plot Lines and a series of Camera Actions that can be added within the Plot
Lines to sync in with the defined actions for actors in the scene. Dynamic construction of the target and camera position is achieved by passing the
target Actor (say the replacement Guard in this example) as a parameter to the Action and having the Action script determine that the parameter passed
is an agent type and find the closest camera waypoint to this actor. Both bits of information can then be passed to the game engine to invoke the
positioning of the camera and the target direction by virtue of the target actor.
Conversely, where the design is known at design time my mechanism allows for a Camera Config object to be added as a prop and passed to the Action.
The action will then identify this and extract the camera position and target directly from the config object and pass these to the game engine. These
can be explicitly stated or again point to waypoints/actors.
An extract from my debug output to my engine log file shows the results of the dynamic parameter passing as processed by the Camera Action script @
22:27:46 ... approx. 4 minutes into the simulation:
Code:
22:23:28 info: createEntityFromEKIMessage: Creating NPC: ShetlandPony1
22:23:28 info: animationManager::registerModelName: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: Buck for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: GrazeA for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: GrazeB for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: IdleA for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: IdleB for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: Run for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: Trot for Model: ShetlandPony
22:23:28 info: animationManager::addModelAnimation: Walk for Model: ShetlandPony
22:23:28 info: npc::setupSound: Created sound neigh1 for model: Shetland Pony1
22:23:28 info: npc::memoryAddressChanged: NPC recreated in memory for model: Shetland Pony1
22:27:46 info: CameraDirector: Action: CameraStaticFollow_onStart
22:27:46 info: CameraDirector: CameraStaticFollow_onStart: Passed Direct object is Guard8 of Object Type: NPCWithPatrol
22:27:46 info: CameraDirector: Closest camera to target: Guard8 is: camera_WP1
22:28:12 : shutting down EKI One engine...
22:28:12 : - resetting state
22:28:12 : - unregistering singletons
22:28:12 : EKI One engine shut down successfully
log file evaluation, 0 error(s) occurred.
, log file closed.
The Camera Action script (which ever is chosen) then simply raises a Camera_Control event and passes the Type, Position and Target Position to the
game engine to handle.
The game engine side is the next to be coded but will have to wait till I come back from holiday in three weeks time. I'm pleased with the progress
so far though!