Monday 14 April 2014

Lesson 9: Multiple animations (part 1)

Up to now, all the animations we have created have been simple, one-step animations: the window swings open or close. But some of the more impressive effects are multiple animations and there are two sorts: simultaneous and sequential.

Simultaneous animations

Animations where two or more changes occur at the same time are easy to create. All that is necessary is to add the different effects in the same onClick (or other) area, separated by semicolons, e.g.

ANIMATE("X",0,50); ANIMATE("Y",0,100)

The order is irrelevant as they start together. (They may end at different times depending on which type of animation you use.)

As an example, we shall create a pair of double doors which open simultaneously. So create a door with a cutaway corner (see image below) and make it into a component. Duplicate it and flip the copy along the red axis so that the axes are on the outside (this is where the cutaway shape comes in useful). Then make the two doors into a component ("DC5"). It should look something like this:

 
To open the doors, we add an onClick to the DC5 component to animate them. How do you know which of the two sub-components is which? Well, if you add the X attribute to both doors, you will see that one has a X position of 0 (the left) while the other has a value twice the width of the door. You can also look at the RotX of both which will show 0 and -180.

The problem with the model at the moment is that we have used two copies of the door component; consequently  they both have the same name. If we rename one, they both get renamed. If we animate the RotX, SketchUp can get confused as to which we are referring to. We could have used groups which would be separate but, because the doors are identical, it is better to use components.

To get around the problem, we can create two custom attributes in the top level "DC5" to hold the angles for both doors: LeftAngle and RightAngle. We enter 0 into the first and -180 into the second, then link the RotZ of each door to its appropriate value.

=DC5!LeftAngle
and

=DC5!RightAngle

If we now enter different values into LeftAngle and RightAngle, we should see the doors adjust their angle.

Finally, we enter the two animations into the onClick box of "DC5", separated by a semicolon. The first changes LeftAngle, the second changes RightAngle. If we click the doors with the Interact tool, the doors should open and close together.

If your component isn't working, check it against these formulas:



The model, DC5, is available on 3D Warehouse at
https://3dwarehouse.sketchup.com/model.html?id=u2ba92957-10fd-48bf-b004-9d9d4219e20e

In the next lesson, we will look at how to create sequential animations where they do not occur at the same time.

No comments:

Post a Comment