View Full Version : Xpresso Loop

03 March 2006, 05:33 AM
I am trying to put together an expression to make an object loop.

For example, loop the rotation of a cube.

I know this can be done through simple keyframe animation and set the loop range. However, I would like to be able to do the following.

I would like to connect the "loop" expression to a user data where I can control the speed of the loop. I have managed to make this happen. The problem is I can't get it to stop completely. I understand why I won't stop, but am stumped on how to get it to stop.

Here is brief description how I have it set up:
I have a Time node going into a Range Mapper into the rotation of my cube. I then have float slider connected to another Range Mapper that controls the Input Upper of the first Range Mapper.

This allows me to speed up and slow down the loop, by shortening the amount frames it takes to rotate 360. I can only get it to slow way down, but never stop.

Is there a better way to acheive this through Xpresso?

Thanks for the help in advance.

03 March 2006, 08:15 AM
Use the Range Mapper spline to control the rotation. Looping is achieved by enabling the node's Modulo option.

03 March 2006, 02:01 AM
I composed the RPM and BPM nodes exactly for this purpose
they do Rotations or Beats per minute

dl them here
rpm_bpm_nodes (

03 March 2006, 06:37 PM
Base80, thanks for the files. Your website has been a great resource.

However, I am having a problem slowing the rotations to a stop. It loops great, but then when I animate the RPM down to 0 the cube rotates extremely fast just before it stops. It looks like the cube is unwinding all of the rotation it has just done.

Here is the scene file:

Spinning Cube (

Any thoughts?

03 March 2006, 01:58 PM
well actually the node spins backward when you want to decelerate.
It is because I am an amateur.
You will have to use an other method unfortunately

03 March 2006, 02:02 PM
If you use a direct relation (multiplication depending on time) animating the speed of rotation will not work. If you use an increment it does. A setup like that can not be scrubbed in the editor though, it can only work when animating from start to end in one go without extra refreshes inbetween.

03 March 2006, 03:14 PM
Kinda cheeky jumping in here but I just found MAXON's Infinate Rotation C.O.F.F.E.E. expression. Using it I reproduced your file and it's now working. :thumbsup:

Since I really don't know C.O.F.F.E.E. I can't figure out how to get a User Data added to the expression to control the speed that way (var the_Speed = 3.130; ). Perhaps Bjorn, Darter or Base80 could solve that. :)

03 March 2006, 10:59 PM

Thanks for the input, your expression is a handy thing to keep my library.

I am not quite sure what you mean. Xpresso is not my strength, by a long shot, I just know enough to get by. Would you mind explaining the increment method a little more in detail?

This does solve the problem. However, I know absolutely nothing about coffee. So oustide animating the enable/disable function I would not be able to adjust. For example, how would I animate the speed. And to be picky, how would I ease a start and stop?

Thanks again for the help.


03 March 2006, 01:26 AM
Hi Jamie,
First off, I don't know how to do easing. F-Curves would do it but since the C.O.F.F.E.E. isn't keyframed animation that wouldn't work. I'm sure there's a C.O.F.F.E.E. solution to easing but I'm too new with it to know how.

Getting into it and changing the speed is easy.
1-Double click on the C.O.F.F.E.E. tag in the OM.
2-You'll then see the editor open and be presented with the code. It's short but the stuff we're concerned with is here:

// "the_Rotation" is the amount of rotation
// added to the object every second. The vector
// is specified in HPB angles and the components
// are described as radians ( PI = 180° ).

var the_Rotation = vector ( 0, 1, 0 );

// "the_Speed" is the speed of the rotation.
// It's value is multiplied times the current
// time yielding a temporal scale of the
// function.

var the_Speed = 3.130;

The second 'var' you see (first in the bit I copied shown above) is what controls which axis direction the object rotates on (H, P, B). Notice I put '1' in the 'P' angle.

The third 'var' (second in the bit I copied shown above) is the speed of rotation. I played with it a bit to get it to stop when I wanted it to.

3-When you're finished making changes to the expression, click 'Execute.'
4-Close the C.O.F.F.E.E. window and hit play.

03 March 2006, 05:49 PM
Thanks for the explanation. This helps a lot.

My next question would be, how do I animate these values?
For example, I want is to start a 3.1 and 30 frames later I want it to speed up to 6.2.

03 March 2006, 07:09 PM
I won't be at my C4d machine for another 8 hours :sad: but I'll have a look then. I don't remember how to solve this but there should be a way.

I would imagine it's possible to write some code that would make that 'the_Speed' variable into some keyfameable user data.


CGTalk Moderation
03 March 2006, 07:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.