(Page 2 of 2 pages for this article  <  1 2)

Sunday, March 07, 2010

Filed under: Post ProductionVisual Effects

Deeper Modes of Expression, Part 3: Deeper Into Arrays

Chris Meyer | 03/07

How to translate values between parameters that have different dimensions.

Measuring Tape

After Effects provides a pair of “length” expression methods which can measure either the distance between a Position value and the position 0,0 (or in the case of 3D, 0,0,0), or the distance between two different Position values. Oldtimers who remember the Motion Math “span” script may start to imagine some uses for this method.

We tend to use the form length(pos1,pos2). In the lefthand image below, we used it to tell us how far the spaceman is from the wireframe planet he is swinging by – even when the position of both are changing, and even if they are in 3D. To display the result onscreen, we applied the following to the value of Text > Numbers:

pos_1 = thisComp.layer(“spaceman”).position;

pos_2 = thisComp.layer(“globe”).position;

length(pos_1,pos_2)

(You can also apply this expression to the Source Text parameter of a text layer. It can get a bit messy, as you get all of the internal digits to the right of the decimal point. We will discuss using expressions with text in a later installement.)

We wrote this as a three-line expression for the sake of clarity. You could write this in one line, using the pick whip to help you fill in the values between the brackets rather than typing it by hand.

In these two examples, we used the Numbers effect and the expression length(pos1,pos2) to help measure the distance between 2D or 3D objects. Spaceman courtesy Classic PIO/Nostalgic Memorabilia.

Constant Size

To keep a layer’s apparent size constant at varying distances from a 3D camera, apply the following expression to its Scale:

distance = length(sub(position, thisComp.activeCamera.position));

scale * (distance / thisComp.activeCamera.zoom)

 

Here’s Looking At You

Whereas the length expressions measure the distance between two points, the “look at” expression finds the angle between two points. You might already be familiar with the ability to have a layer, light, or camera auto orient along its path, or to have a layer auto orient toward a camera; the look at expression allows one layer to auto orient toward another layer.

For the lookAt expression to work, it must be applied to the Orientation property of a layer that has its 3D Layer switch enabled. To apply it, expose Position and Orientation for the layer you want to apply it to, Position for the layer you want to look at, and follow these steps:

  1. Enable expressions for the Orientation property of the layer doing the looking.
  2. Type lookAt
  3. Drag its pick whip to the Position property of the layer you want to look at.
  4. Type a comma, and either drag the pick whip to this layer’s Position, or just type position
  5. Type ) and press Enter.

(By the way, if you use the expression language menu to help write a “look at” expression, note that it has the Position properties backward: It says lookAt(fromPoint, atPoint), but this will make the back of the layer face toward the layer of interest.)

Depending on how your layer was designed, you may find it is facing - rather than pointiong at - the other layer. You can fix this by scrubbing the X, Y, or Z Rotation values as needed to reorient the layer to point as desired. In the example below, we set the arrow’s Y Rotation to 90 degrees to get it to point in the right direction.

The normal lookAt expression causes a layer to face – rather than point at – another layer. To reorient a layer, scrub its Rotation properties; + or –90 degrees for one of these will fix your problem.

Next Installment: Space Conversions

That was a lot to chew on. But if you made it past the theory on page to the useful length and lookAt expression methods above, now you have a couple more handy tools in your pocket.

In the next installment, we’ll tackle the tricky subject of how to translate between a composition’s “world” space and a layer’s “local” space, or between 2D and 3D dimensions. Until then…

The content contained in Creating Motion Graphics with After Effects - as well as the CMG Blogs and CMG Keyframes posts on ProVideoCoalition - are copyright Crish Design, except where otherwise attributed.

 

(Page 2 of 2 pages for this article  <  1 2)

               



You must be registered to comment. This is an effort to reduce spam. Please REGISTER HERE.

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:




After Effects Apprentice Free Video: Exploring Shape Effects
After Effects Apprentice Free Video: Drawing Parametric Shapes
After Effects Apprentice Free Video: The Puppet Starch Tool
After Effects Apprentice Free Video: Eraser Tool Modes
After Effects Apprentice Free Video: Tracking with mochaAE
After Effects Apprentice Free Video: Performing a Motion Track
After Effects Apprentice Free Video: Creating 3D Objects using Adobe Repoussé
After Effects Apprentice Free Video: Understanding Axis Modes
Using After Effects as an Advanced Titler for Premiere Pro
After Effects Apprentice Free Video: Creating an Orbit Camera Rig
CMG Hidden Gems: Chapter 45 – What’s Your Preference?
CMG Hidden Gems: Chapter 44 – Prerendering and Proxies
CMG Hidden Gems: Chapter 43 – Advanced Rendering
CMG Hidden Gems: Chapter 42 – Render Queue
CMG Hidden Gems: Chapter 41 – Video Issues
CMG Hidden Gems: Chapter 40B – 3D Channel Effects
CMG Hidden Gems: Chapter 40 – Integrating with 3D Applications
CMG Hidden Gems: Chapter 39 – Integration 101
After Effects Apprentice Free Video: Multiple Playback Speeds
CMG Hidden Gems: Chapter 38 – Import and Interpret
CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters
CMG Hidden Gems: Chapter 37 – Expressions
CMG Hidden Gems: Chapter 36B – Audio Effects
CMG Hidden Gems: Chapter 36 – Working With Audio
Upgrading to After Effects CS5.5?
CMG Hidden Gems: Chapter 35 – The Puppet Tools
After Effects Apprentice Free Video: The Wiggle Expression
CMG Hidden Gems: Chapter 34 – Roto Brush
CMG Hidden Gems: Chapter 33 – Paint and Clone
After Effects Apprentice Free Video: What Could Go Wrong?







Expression Shorts - Numerical Readout

David Torno | 02/05

Create numerical readouts for use in HUD style graphics.

image

With this Expression, I will show you how to feed numerical property information…

After Effects Apprentice Free Video: Drawing Parametric Shapes

Chris and Trish Meyer | 01/27

The same tools you’ve used to create masks can also be used to create Shape Layers - with far more options than you might have imagined.

As we mentioned awhile back, we’ve been busy the past year and a half creating an extensive, multi-course video training…

CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters

Chris and Trish Meyer | 09/02

This time, a collection of resources on expressions and scripting - including a PDF of Bonus Chapter 37C on scripting.

We’re going through our book Creating Motion Graphics with After Effects 5th Edition (CMG5) and pulling out a few “hidden gems” from…

CMG Hidden Gems: Chapter 37 – Expressions

Chris and Trish Meyer | 08/27

Another selection of “hidden gems” (and essential advice), this time from Chapter 37 of Creating Motion Graphics with After Effects.

We’re going through our book Creating Motion Graphics with After Effects 5th Edition (CMG5) and pulling out a few “hidden gems” from…

To be considered for listing, contact pr (at) provideocoalition (dot) com


Copyright © 2011, HD Expo, LLC a division of Diversified Business Communications. DBA Createasphere

All rights reserved. HD EXPO, High Def EXPO, Createasphere, E-Tech, Entertainment Technology Exposition, 3D Production Workshop, VariCamp, P2 Camp, ColorCamp 101, and Lighting, Filters & Gels for HD are all trademarks of HD Expo, LLC.

Terms of Use  |  Privacy Policy

Check PageRank