CCG/Modelling: Animation Events

From TrainzOnline
< CCG(Redirected from Modelling: Animation Events)
Jump to: navigation, search

Contents

Animation Events

Sounds events and generic events can be linked to an animation key-frame to give great control over sound and script timing for industry and scenery assets.

When an animation file (.kin file) is exported from 3DSMmax (or GMax), the exporter will make a query for an event file. Tick the box and you will be asked to browse to the event file.

CCG exporter animation window.jpg

The event information is added to the contents of the new animation file.

The Event File

(filename.evt)

Format: FrameNum EventType EventName.

The event file consists of a list of events and is set up as a simple text file. Each event consists of the frame number, followed by the event type (Sound_Event or Generic_Event), then the event name. Sound events are generally referenced as a trigger within the asset's config.txt file (or through script). All events start on a new line (should there be more than one)

Sound and Generic Events:

A Sound_Event tells Trainz when to play a sound, relative to an animation keyframe.
A Generic_Event is an animation keyframe reference for script timing and control.


Example 1: Lumbermill

The animation in the max file is set up over 1000 frames.

We want a single sound to play on frame 760 as a log runs through the mill on the conveyor. When exporting the kin animation we are queried for an event file.

Check the Query for Event File box and browse for the lumbermill.evt file. This file has been prepared earlier and is as follows.

lumbermill.evt

760 Sound_Event logcut
999 Generic_Event animstop

An excerpt from the Lumbermill config.txt file (note the trigger) :

soundscript
  {
     log_cut
         {
           trigger logcut
           attachment a.sawsound
           nostartdelay 1
           repeat-delay 1
           distance 10,400
           sound
             {
               0   log_cutting.wav
             }
         }
  }

Note: For script reference please refer to Scripting


Example 2: Looping sounds:

Not only can we control when a single sound plays but we can also control the start and the stop of a looping sound by adding another Sound_Event with a / before the relevant name. In the example below the sound starts on frame 370 and ends on 589.

looping.evt

   370 Sound_Event reverse
   589 Sound_Event /reverse

config.txt entries :-

soundscript
  {
    backup
      {
        attachment a.sound
        trigger reverse
        repeat-delay 0
        distance 5,100
        sound
          {
           0   warning.wav
          }
      }
  }



Important Note: The Max file in Example 1 has 1000 frames:

One thing to note is that although the Max file states the frames are from 0 - 1000 frames, we must remember that frame 999 is the last one. On a looping time scale, frame 1000 is the same time as frame 1.
Therefore, the Generic-Event at the end of the animation is thus:
 999 Generic_Event animstop


Previous Page . . . . Next Page

Return to CCG Index

Content Creator's Guide

Personal tools