Sunday 18 July 2010

Page Turn in Cinema4D controlled with Xpresso

This is a problem I was presented with this week. A small animation to show a page turn for a virtual book. The actual final piece has gone into an after effects project and composited for use in a flash portion of a website. Unfortunately I cant show the final versions because its for a client and yet to be launched. Here is an example of what I have created:

[vimeo width="590" height="332"]http://www.vimeo.com/13310306[/vimeo]

There are a few way to achieve this really. One would be to use the cloth tag in cinema and animate the gravity and maybe a bit of wind to get the page to turn. I also played around with a joint structure and weighting a high poly plane to create a more controllable effect. I found this post and video on Nick Cambell's Greyscale gorilla very good while I explored joints, not to mention how well Mike Senften explains xpresso. It was this insight into xpresso that really gave me the confidence to set out on my own little scripting mission. Yes I could of rigged the pages and animated them manually, but that's far to easy. So about creating the scene and creating my first xpresso script from scratch. The scene is just some polygon planes and two bend modifiers. One controls the page uniform bend and the other creates the corner deformation. The bend value is controlled my a user input field called "bend". Now this is where I started to get creative with a bit of simple maths (really very very simple, but I'm still proud). Essentially I had to create a ratio between the two bend modifiers because bending one to 80% was just too much for the other. So using a maths node and the divide function I took the bend value and divided it by a figure generated by a formula node. This way I can change the ratio in the formula node to effect the difference in bend's at any time. The other part of the script is controlling the rotation and position of the page as it turns. A user data field gives me the amount of rotation for each page, a straight forward link. To make the pages look as if they are stacking as they turn I needed to raise them slightly though the turn. Using the rotation value I can use a range mapper node to re-map this data into a change in the Y global position. Voila, a page turn with only 2 values to keyframe. Some tweaking was required depending on how many pages need turning as the Y range need's to be fiddled.

[caption id="attachment_214" align="aligncenter" width="590" caption="Bend Modifiers of page flip"]Page Flip[/caption]

For a first real venture into Xpresso I really quite enjoyed it. It is a very simple scripting method and is designed so non programmers like myself and make stuff work, and I know a seasoned c4d'er will think this is a little trivial. I did find it very similar to pflow in 3ds max with the whole plug in nodes network and I am sure as I venture into thinking particles I will find many more similarities.

[caption id="attachment_213" align="aligncenter" width="590" caption="the nodes"]My First Xspresso[/caption]

More Xpresso learning soon I hope.

1 comment:

  1. Thanks Thomas for that great tutorial!
    Is there any way you could share the c4d file so I do not have to do it all again?

    ReplyDelete