Record Animation Segments
While the Coaster Tutorial and the default template provides a quick an easy way to get your ride setup and running, it has it's limitations. Not all coasters will be single circuit, one lap rides with a stop in the station. Sometimes you want to make it move non-linearly by rolling back or move through a track switch.
This tutorial will teach you how to best use the KeyframeRecorder
, TriggerRecorder
, and AnimationRecorder
in order to generate more complex animations.
Goal
- Learn how to manipulate
KeyframeRecorder
,TriggerRecorder
, andAnimationRecorder
to create animations.
Requirements
- Know the basics of how to use
KeyframeRecorder
andAnimationRecorder
to create animations via the Coaster Tutorial - Know how to use any of the various simulator modules
Documentation Links
Overview of Creating Animations
The two building blocks of an Animation (for RTRF) are Keyframes
and TriggerInfo
. The classes that hold these are KeyframeRecorder
and TriggerRecorder
, respectively.
If you have taken a Computer Science data structures class or have experience in other programming languages, you should think of them like wrappers around arrays (see JavaScript Array).
In KeyframeRecorder
order position matters since each keyframe needs to be played sequentially. Thus it's methods emphasize this to maintain order. push
and append
will both add their respective data to the end of the KeyframeRecorder
while appendToBeginning
will add to the start. (Yes these names were taken from the JavaScript Array implementation)
TriggerRecorder
, on the other hand, while it uses an array structure internally, order does not matter as much. The names add
and combine
do not specify where in the recorder it will be added. This is because, when exporting, triggers will be re-ordered based on time position.
TriggerRecorder
's methods will change as will make it easier to remove triggers if their index can be obtained.
AnimationRecorder
is a helper class useful in helping create and export animations. It handles exporting for you. More on this in the section below.
KeyframeRecorder
First, we will review KeyframeRecorder
and a few important methods. If you are coming from the Coaster Tutorial, then KeyframeRecorder
should still feel very foreign to you as the template did most of the work.
:push()
adds a Keyframe to the end KeyframeRecorder. :append()
clones and adds the Keyframes from one KeyframeRecorder to the end of itself.
push
allows you to manually add individual keyframes to yourKeyframeRecorder
- Importance of adding startKeyframe
getLast
andgetLastPosition
methods
- Importance of adding startKeyframe
append
is important because- simulations return a
KeyframeRecorder
- simulations return a
Recording segments
Getting data from last segment
KeyframeRecorder
Some review?
- KeyframeRecorder
- Holds keyframes
- What do the simulator modules do?
- Simulate some thing and output a
KeyframeRecorder
- Simulate some thing and output a
- KeyframeRecorder
KeyframeRecorder:push()
adds aKeyframe
to aKeyframeRecorder
.KeyframeRecorder:append()
adds the keyframes of another KeyframeRecorder to a KeyframeRecorder.- Basically it's like combining two tables.
Pattern for recording simulation segments is to take the KeyframeRecorder returned by the simulation
Pattern for changing track, etc.
AnimationRecorder
AnimationRecorder
Allows you to keep scope separate for all the segments.
- Why is this good?
- Reuse variable names
- Naming is hard!
- Make sure we are using the correct values and overwrite some other ones
- Organization
- Overall, reduces the amount of things we need to keep track of.
- Reuse variable names
- Why is this good?
recordSegment()
- Takes a function with 4 arguments
- keyframeRecorder
- triggerRecorder
- mainKeyframeRecorder
- mainTriggerRecorder
- Takes a function with 4 arguments
Pattern is usually to have each segment handle for a given start and end position of a ride.
- Examples:
- Station to Station
- Station to Pre Launch Hold and Pre Launch Hold to Station
- Drop Track, Turntable, Elevator Lift, etc. segment
- Examples:
When would you want to use :recordAndExportSegment()?
- Recording separate animations for drop tracks, elevator lifts, etc.
- These are objects that move with the train.
- We want to be able to sync these with the train, thus we want to clone the data and just change the track.
- We will explain more in their specific tutorials.
show an example how you would record these animations
Full Code