Wednesday, February 27, 2013

Skydome rotation

Here's how to constrain the skydome rotation to the camera:
  1. Create a group for the skydome (skydome_GRP)
  2. Parent constrain skydome_GRP to the layout camera (driver: camera, driven: skydome_GRP), maintaining offset and ONLY constraining translation values
  3. Open the expression editor and create a new expression (skyRot)
  4. Enter these expressions (<skydome> is the name of the sky GEOMETRY, not group and <camera> is the full name of the layout camera):
int $ct = `currentTime -q`;
float $rx = `getAttr -time $ct <camera>.rotateX` - `getAttr -time 1 <camera>.rotateX`;
float $ry = `getAttr -time $ct <camera>.rotateY` - `getAttr -time 1 <camera>.rotateY`;
float $rz = `getAttr -time $ct <camera>.rotateZ` - `getAttr -time 1 <camera>.rotateZ`;
float $deg = 0.8;
<skydome>.rotateX = $deg * $rx;
<skydome>.rotateY = $deg * $ry;
<skydome>.rotateZ = $deg * $rz;
Hit create expression and you're done!

No comments:

Post a Comment