This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
assets:scripting_with_stateanimator [2017-06-18 14:53] – [Introduction] skyjake | assets:scripting_with_stateanimator [2019-11-17 19:52] (current) – [StateAnimator methods] skyjake | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Scripting with StateAnimator ====== | ||
+ | |||
+ | This page describes how [[model|3D model assets]] can be manipulated via Doomsday Script. | ||
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | The objects involved in 3D model rendering are: | ||
+ | |||
+ | * **A map object.** Any mobj in the map can be represented by a 3D model. | ||
+ | * **3D model asset.** An asset definition in the Info file of a package. Specifies the model file path, materials, rendering parameters, animation triggers, and any custom script functions. | ||
+ | * **StateAnimator.** Each mobj has its own animator instance. This allows many objects to share the same 3D model asset but each still have their unique animation state. When a StateAnimator is created, its initial state is set up as defined in the model asset. | ||
+ | * **ModelLoader.** The model loader ensures that the 3D model asset is in memory when it is needed. It also reads the asset definitions and passes on the information to the mobj when it is being initialized. | ||
+ | |||
+ | StateAnimator supports scripting via the following: | ||
+ | |||
+ | * In the package Info file, one can append a '' | ||
+ | script { | ||
+ | record model.thing.misc3 () | ||
+ | def onStateChange (animator, state) | ||
+ | print "State changed:", | ||
+ | animator.startTimeline(" | ||
+ | end | ||
+ | end | ||
+ | }</ | ||
+ | * The package can optionally have a file called ''< | ||
+ | def onStateChange (animator, state) | ||
+ | print "State changed:", | ||
+ | animator.startTimeline(" | ||
+ | end | ||
+ | end</ | ||
+ | * The model asset' | ||
+ | * Any state sequence trigger defined in the model asset can have an embedded [[model# | ||
+ | ===== StateAnimator variables ===== | ||
+ | |||
+ | StateAnimator is the central object for model scripting purposes. | ||
+ | |||
+ | The StateAnimator variables automatically available in timeline scripts are: | ||
+ | |||
+ | ^ Variable^ Description | | ||
+ | | '' | ||
+ | | ''< | ||
+ | | ''< | ||
+ | | ''< | ||
+ | | '' | ||
+ | | '' | ||
+ | | (shader variable)| Shader variables declared in the '' | ||
+ | | (pass).(variable)| Shader variables declared in rendering passes (e.g., '' | ||
+ | | (pass).'' | ||
+ | | (pass).'' | ||
+ | |||
+ | |||
+ | ===== StateAnimator methods ===== | ||
+ | |||
+ | Objects of the Render.StateAnimator class have the following methods. | ||
+ | |||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | |||
+ | # | ||
+ | |||
+ | # | ||
+ | |||
+ | 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. | ||
+ | |||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | This is only called if the state is in the animator' | ||
+ | < | ||
+ | notifiedStates < | ||
+ | </ | ||
+ | |||
+ | ===== Examples ===== | ||
+ | |||
+ | |||
+ | |||