advanced animation techniques part ii by demetrios halazonetis

28
Advanced Animation Advanced Animation Techniques Techniques Part II Part II by Demetrios Halazonetis www.dhal.com

Upload: gabriella-dickerson

Post on 22-Dec-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Advanced Animation Techniques Part II by Demetrios Halazonetis

Advanced Animation TechniquesAdvanced Animation TechniquesPart IIPart II

by Demetrios Halazonetis

www.dhal.com

Page 2: Advanced Animation Techniques Part II by Demetrios Halazonetis

Using Macros for AnimationUsing Macros for Animation

• First create the object you wish to move.First create the object you wish to move.

• Then write a macro that moves the object.Then write a macro that moves the object.

• Add a custom action button on the slide.Add a custom action button on the slide.

• Then set the Action Settings of the button to Then set the Action Settings of the button to trigger the macro.trigger the macro.

Page 3: Advanced Animation Techniques Part II by Demetrios Halazonetis

Create the objectCreate the object

• This is the easy part.This is the easy part.

• The object can be a simple object or a group The object can be a simple object or a group of objects.of objects.

• The next slide (Slide 4) has the object The next slide (Slide 4) has the object (mandible plus teeth, in a group). It also has (mandible plus teeth, in a group). It also has other things on it, which will be explained other things on it, which will be explained later.later.

Page 4: Advanced Animation Techniques Part II by Demetrios Halazonetis

RotateRotate

RotateResetRotateReset

MoveMove

ResetAllResetAll

Rotate AnimationRotate Animation

Rotate CondyleRotate Condyle

Page 5: Advanced Animation Techniques Part II by Demetrios Halazonetis

Writing a macro (good luck)Writing a macro (good luck)

• NOTE: The following is a step-by-step NOTE: The following is a step-by-step guide. However, the macros are already guide. However, the macros are already present in this file, so you should not follow present in this file, so you should not follow these steps, unless you do it in a new these steps, unless you do it in a new PowerPoint presentation, which does not PowerPoint presentation, which does not contain any macros.contain any macros.

Page 6: Advanced Animation Techniques Part II by Demetrios Halazonetis

Writing a macro (assuming no Writing a macro (assuming no macros are already present)macros are already present)

• Open the Visual Basic Editor: Open the Visual Basic Editor: Tools>Macro>Visual Basic EditorTools>Macro>Visual Basic Editor

• In the Project box, select the VBProject and In the Project box, select the VBProject and then select Insert>Module from the menu. then select Insert>Module from the menu. The code window opens. If not, double-The code window opens. If not, double-click on the newly created module click on the newly created module (Module1).(Module1).

Page 7: Advanced Animation Techniques Part II by Demetrios Halazonetis

Writing a macro…Writing a macro…

• Position the mouse cursor in the code area Position the mouse cursor in the code area (the large window on the right) and select (the large window on the right) and select Insert>Procedure. Type “SimpleRotate” and Insert>Procedure. Type “SimpleRotate” and make sure Sub and Public are selected. make sure Sub and Public are selected. Click OK.Click OK.

• In the code box, complete the procedure so In the code box, complete the procedure so it looks like the following: (next slide)it looks like the following: (next slide)

Page 8: Advanced Animation Techniques Part II by Demetrios Halazonetis

A simple procedure:A simple procedure:

Public Sub Public Sub SimpleRotateSimpleRotate()()

Dim Dim aSlideaSlide As Slide, aShape As Shape As Slide, aShape As Shape

Set Set aSlideaSlide = ActivePresentation.Slides(4) = ActivePresentation.Slides(4)

Set aShape = Set aShape = aSlideaSlide.Shapes(1).Shapes(1)

aShape.Rotation = aShape.Rotation + 3aShape.Rotation = aShape.Rotation + 3

End SubEnd Sub

Page 9: Advanced Animation Techniques Part II by Demetrios Halazonetis

Writing a macro…Writing a macro…

• This procedure rotates the first shape This procedure rotates the first shape (object) on Slide #4 by 3 degrees.(object) on Slide #4 by 3 degrees.

• To see it in action we need to ‘attach’ it to To see it in action we need to ‘attach’ it to an action object. (next slide)an action object. (next slide)

Page 10: Advanced Animation Techniques Part II by Demetrios Halazonetis

Create an action buttonCreate an action button

• Slide 4 has an action button ‘Rotate’. This Slide 4 has an action button ‘Rotate’. This was created by selecting: Slide Show > was created by selecting: Slide Show > Action Buttons > CustomAction Buttons > Custom

• Then drag the mouse on the slide to create Then drag the mouse on the slide to create the button.the button.

Page 11: Advanced Animation Techniques Part II by Demetrios Halazonetis

Create an action button…Create an action button…

• As soon as the button is created, the Action As soon as the button is created, the Action Settings dialog box opens.Settings dialog box opens.

• Select the Run Macro option and pick the Select the Run Macro option and pick the SimpleRotate macro from the list box. SimpleRotate macro from the list box.

• The text on the button was entered after The text on the button was entered after right-clicking the button and selecting Add right-clicking the button and selecting Add Text from the pop-up menu.Text from the pop-up menu.

Page 12: Advanced Animation Techniques Part II by Demetrios Halazonetis

Now test it!Now test it!

• Go to slide #4.Go to slide #4.

• Click the Slide Show icon on the lower left Click the Slide Show icon on the lower left of your screen.of your screen.

• Use your mouse to click the Rotate button. Use your mouse to click the Rotate button. The mandible and teeth should rotate each The mandible and teeth should rotate each time the button is pressed.time the button is pressed.

Page 13: Advanced Animation Techniques Part II by Demetrios Halazonetis

ProblemsProblems

• How do we translate?How do we translate?

• How do we return the mandible to the How do we return the mandible to the original position?original position?

Page 14: Advanced Animation Techniques Part II by Demetrios Halazonetis

More difficult problemsMore difficult problems

• Rotation is around the center of the Rotation is around the center of the mandible. How do we rotate around the mandible. How do we rotate around the condyle?condyle?

• If we have more shapes on the slide, how If we have more shapes on the slide, how do we specify (in the macro) which shape do we specify (in the macro) which shape will move?will move?

Page 15: Advanced Animation Techniques Part II by Demetrios Halazonetis

Some info to solve the problemsSome info to solve the problems

• Slides have a coordinate system from 0,0 at the Slides have a coordinate system from 0,0 at the upper left corner, to 720,540 at the lower right. upper left corner, to 720,540 at the lower right. These coordinates hold for On-screen Show These coordinates hold for On-screen Show (File>Page Setup…).(File>Page Setup…).

• Macros permanently alter the placement of Macros permanently alter the placement of objects. Therefore, we require a macro to return objects. Therefore, we require a macro to return the object to the original position. Else, use the the object to the original position. Else, use the Undo command (Edit>Undo) immediately after Undo command (Edit>Undo) immediately after running the macro.running the macro.

Page 16: Advanced Animation Techniques Part II by Demetrios Halazonetis

More helpMore help

• An example of an undo macro for the An example of an undo macro for the SimpleRotate macro can be found in this file. It is SimpleRotate macro can be found in this file. It is the SimpleRotateReset macro. The main command the SimpleRotateReset macro. The main command is this:is this:

• aShape.Rotation = 0aShape.Rotation = 0• The RotateReset button on Slide #4 activates this The RotateReset button on Slide #4 activates this

macro. So after using the Rotate button, click the macro. So after using the Rotate button, click the RotateReset button to return the mandible to the RotateReset button to return the mandible to the original position.original position.

Page 17: Advanced Animation Techniques Part II by Demetrios Halazonetis

Translating objectsTranslating objects

• An example of a macro for translating An example of a macro for translating objects is the SimpleMoveRightDown. Use objects is the SimpleMoveRightDown. Use the Move button on Slide #4 to activate it.the Move button on Slide #4 to activate it.

• The SimpleResetAll macro resets the The SimpleResetAll macro resets the mandible to its original position.mandible to its original position.

Page 18: Advanced Animation Techniques Part II by Demetrios Halazonetis

Animating movementAnimating movement

• You can create continuous animation by You can create continuous animation by repeating movements many times. The repeating movements many times. The SimpleRotateAnimation demonstrates this. SimpleRotateAnimation demonstrates this. The main code is this:The main code is this:

• For n = 1 To 10For n = 1 To 10• aShape.Rotation = aShape.Rotation + 3aShape.Rotation = aShape.Rotation + 3• DoEventsDoEvents• NextNext

Page 19: Advanced Animation Techniques Part II by Demetrios Halazonetis

Animating movement…Animating movement…

• We see that the heart of the code is the We see that the heart of the code is the same as the SimpleRotate macro. It is just same as the SimpleRotate macro. It is just repeated 10 times.repeated 10 times.

• The DoEvents command allows PowerPoint The DoEvents command allows PowerPoint to redraw the slide after each rotation, so to redraw the slide after each rotation, so that a continuous motion is perceived.that a continuous motion is perceived.

Page 20: Advanced Animation Techniques Part II by Demetrios Halazonetis

Specifying the slide in the macroSpecifying the slide in the macro

• Slides in PowerPoint are held in a list. To Slides in PowerPoint are held in a list. To specify e.g. slide #4, use a command such as this specify e.g. slide #4, use a command such as this ::

• Set aSlide = ActivePresentation.Slides(4)Set aSlide = ActivePresentation.Slides(4)

• If you know the name of the slide you can also If you know the name of the slide you can also use this syntax:use this syntax:

• Set aSlide = ActivePresentation.Slides(“Mouth”)Set aSlide = ActivePresentation.Slides(“Mouth”)

Page 21: Advanced Animation Techniques Part II by Demetrios Halazonetis

Specifying the object in the Specifying the object in the macromacro

• Objects in PowerPoint are held in a Objects in PowerPoint are held in a ‘Shapes’ list. To specify the desired object ‘Shapes’ list. To specify the desired object (e.g. shape #1 in slide: aSlide) use a (e.g. shape #1 in slide: aSlide) use a command such as this:command such as this:

• Set aShape = aSlide.Shapes(1) Set aShape = aSlide.Shapes(1) • If you know the name of the object you can If you know the name of the object you can

also use this syntax:also use this syntax:• Set aShape = aSlide.Shapes(“tooth”)Set aShape = aSlide.Shapes(“tooth”)

Page 22: Advanced Animation Techniques Part II by Demetrios Halazonetis

Rotating around any pointRotating around any point

• To rotate an object around any point, use the To rotate an object around any point, use the RotateAround macro that is included in this file. RotateAround macro that is included in this file. You should include it in your own macros like You should include it in your own macros like this:this:

• RotateAround aSlide.Shapes(1), 3, 190, 140RotateAround aSlide.Shapes(1), 3, 190, 140• (see the RotateCondyle macro and try the Rotate (see the RotateCondyle macro and try the Rotate

Condyle button on Slide #4. Remember to use the Condyle button on Slide #4. Remember to use the ResetAll button to return the mandible to the ResetAll button to return the mandible to the original position)original position)

Page 23: Advanced Animation Techniques Part II by Demetrios Halazonetis

Helper fileHelper file

• PowerPoint does not have an easy way to rename PowerPoint does not have an easy way to rename objects or slides, or to figure out the coordinates of objects or slides, or to figure out the coordinates of objects on a slide.objects on a slide.

• You can use the ShowShapes.ppt file to help you do You can use the ShowShapes.ppt file to help you do this. Open the file in PowerPoint and then run the this. Open the file in PowerPoint and then run the ShowSlideObjects macro (with your .ppt file open at ShowSlideObjects macro (with your .ppt file open at the same time). A dialog box will open, which the same time). A dialog box will open, which shows all shapes on the current slide. You can shows all shapes on the current slide. You can rename the slide or the shapes on it. You can also rename the slide or the shapes on it. You can also see their Top, Left and Rotation properties so that see their Top, Left and Rotation properties so that you can write macros easier. you can write macros easier.

Page 24: Advanced Animation Techniques Part II by Demetrios Halazonetis

Reset

Example 1: Eruption and ankylosisExample 1: Eruption and ankylosis

Click the teeth on the left, then the teeth on the right.Click the teeth on the left, then the teeth on the right.

Click Reset to return them to the initial position.Click Reset to return them to the initial position.

Page 25: Advanced Animation Techniques Part II by Demetrios Halazonetis

Example 2: Opening and closingExample 2: Opening and closing

OpenOpen

CloseClose

Page 26: Advanced Animation Techniques Part II by Demetrios Halazonetis

Example 3: TorqueExample 3: Torque

Torque wireTorque wire Insert wireInsert wire Torque is expressedTorque is expressed ResetReset

Click on the buttons in turn:Click on the buttons in turn:

Page 27: Advanced Animation Techniques Part II by Demetrios Halazonetis

Example 4: Activate T loopExample 4: Activate T loop

ActivateActivate ResetReset Note: the template curves could be drawn with Note: the template curves could be drawn with No Line, and would be invisible.No Line, and would be invisible.

Page 28: Advanced Animation Techniques Part II by Demetrios Halazonetis

Good luck!Good luck!

• If you need help:If you need help:– www.dhal.comwww.dhal.com