Table of Contents

Scripting with StateAnimator

This page describes how 3D model assets can be manipulated via Doomsday Script.

Introduction

The objects involved in 3D model rendering are:

StateAnimator supports scripting via the following:

StateAnimator variables

StateAnimator is the central object for model scripting purposes.

The StateAnimator variables automatically available in timeline scripts are:

Variable Description
ID Text string with the asset identifier (e.g., “model.thing.possessed”).
__asset__ Asset metadata, providing read access to the animation and render blocks, and any other data specified inside the asset block. Changing these values has no effect on already initialized objects, because the definitions are only checked when the model is first being prepared for an object.
__thing__ Map object being animated (when the asset is a model.thing.*).
__player__ Player whose weapon is being animated (when the asset is model.weapon.*).
material Material to use when drawing, unless a rendering pass specifies another one.
notifiedStates Name of the mobj state, or an array of mobj state names, that cause state change notification callbacks to be made to the onStateChange method.
(shader variable) Shader variables declared in the render block (e.g., uEmission above).
(pass).(variable) Shader variables declared in rendering passes (e.g., body.uEmission).
(pass).enabled Other pass variables in the pass records (e.g., body.enabled).
(pass).material Material to use when drawing a rendering pass (if declared in the definition).

StateAnimator methods

Objects of the Render.StateAnimator class have the following methods.

playingSequences ( )

startSequence ( sequence : Text, priority : Number, looping, node : Text = “” )

startTimeline ( name : Text )

stopTimeline ( name : Text )

thing ( )

Returns a World.Thing representing the mobj that the animator belongs to.

Asset callbacks

StateAnimator will call methods defined in the model asset when certain events occur.

onInit ( animator : Render.StateAnimator )

onDamage ( animator : Render.StateAnimator, points : Number, inflictor : World.Thing )

onStateChange ( animator : Render.StateAnimator, state : Text )

This is only called if the state is in the animator's notifiedStates variable. For example, in the model definition, one could use:

notifiedStates <DEADARTI1, DORMANTARTI1>

Examples