Skip to content

Commit 8f73fd8

Browse files
authored
Merge pull request #30 from bmwcarit/update-docs-to-v1
Update docs to v1.0
2 parents 5280ce6 + 707bfa2 commit 8f73fd8

31 files changed

+22392
-131653
lines changed

advanced/animations/README.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,39 @@ Furthermore, the scene graph now contains a Node which also has an animation obj
7272

7373
![](./docs/scene_graph.png)
7474

75-
The animation is statically assigned to the node and its outputs are linked to the node transformation properties. Looking
76-
at the Animation properties, you will see the animation channels alongside the state of the animation object and its current
77-
output values:
75+
The animation is statically assigned to the node and its outputs are linked to the node transformation properties.
76+
You can experiment with the `progress` input of the animation object to see the animation in different phases/states:
7877

7978
![](./docs/animation.png)
8079

81-
You can set the "play", "loop" and "rewind on pause" properties or link them to scripts to control the state of the animation.
82-
This works exactly as with other scripts, see the [section on linking Lua properties in the Monkey example](../../basics/monkey/README.md#Lua-Scripting) for details.
80+
If you want to preview the animation in the Composer, you can create a `Timer` object (in the Resources View) and link
81+
it to a control script which translates timer ticks to a normalized [0, 1] value which is linked to the animation `Progress` input.
8382

84-
## How to control time
83+
Your script can look like this:
8584

86-
Currently there is no direct way to control the time progression of animations with Lua. We are addressing this
87-
in the logic engine and will update this tutorial after we have a solution. In Ramses Composer 0.11.0, the time is
88-
automatically passed to all animation objects in a strictly progressing fashion, and scripts are only allowed to set
89-
the state of an animation - running, paused, stopped, and rewind.
85+
```lua
86+
87+
function interface(IN,OUT)
88+
IN.ticker = Type:Int64()
89+
OUT.animationProgress = Type:Float()
90+
end
91+
92+
function run(IN,OUT)
93+
-- Total duration of the animation in seconds
94+
local durationInSeconds = 3
95+
-- How many microseconds are needed to fill the progress from 0 -> 1
96+
local normalizeFactor = 1000000 * durationInSeconds
97+
-- Convert timer ticks to progress and normalizing to [0, 1]
98+
local progress = (IN.ticker % normalizeFactor) / normalizeFactor
99+
OUT.animationProgress = progress
100+
end
101+
102+
```
103+
104+
Now you can link the script's animationProgress output to the Animation's `Progress` input.
105+
This works exactly as with other scripts, see the
106+
[section on linking Lua properties in the Monkey example](../../basics/monkey/README.md#Lua-Scripting)
107+
for details.
108+
109+
You can do any transformation - you can stop at a given point, reverse the animation, or rewind to a given point.
110+
you have the full freedom of Lua to define the logic to translate the time ticks to animation state/progress.

0 commit comments

Comments
 (0)