Skip navigation

Monthly Archives: August 2015

To Bind a hand-held weapon to a mesh (when the mesh is a single mesh as UE4 requires) keep the bones SEPARATE (unparented) when you first bind, then parent the bones together AFTER mesh bind. This prevents mesh pieces from different weapons from receiving influence from bones intended for different meshes.

binding-weapons

Advertisements

I found this problem coming up after I:

* Had a mesh that I wanted to adjust
* Detached skin & adjusted the mesh by moving faces
* MOVED/ROTATED A CONTROLLER which had Orient Constraints & Point Constraints on a bone for the mesh
* Tried to re-bind the bones & skin, which caused the error

The solution was: Delete the moved controller, then delete any IK handles upstream of the moved controller (maybe even all of them).

When creating an animation of a cloth for example, you may like to take a snapshot of one frame and save it into the mesh.

To do that you use Animate / Create Animation Snapshot. …

The settings that work for cloth are:

Start Time: Whatever
End Time: Whatever
Increment: any

Update: FAST (update only when keyframes change)

If you use On Demand or Slow Updates, the animation snapshot won’t work for cloth

animation snapshot

All objects in Maya are actually accessible by string.

So when you type

$var = `select -r objectName1`;

Maya will select that object in the viewport.

But $var doesn’t contain anything but a string! It just contains the string name for the current selection.

To iterate in maya, you need to use the polyEvaluate function, which retrieves things like the NUMBER of faces or vertices a polygon has.

Access of individual members of the polygon is by string:

Vertices: polyName.vtx[index]
Faces: polyName.f[index]
UV’s: polyName.map[index]

It turns out that the .vtx, .f, and .map are NOT objects. They don’t have a .size() member or anything, they’re just “string addresses”. When you address polyName.f[0], that’s the first face in the mesh. You have to pass the string address to a function to use it though.

Gotchas:

Declaring arrays with a leading 0 doesn’t work.

Move to origin:

// Zero transformation on manipulator (world space).
move -rpr 0 0 0
// Freeze transformations afterward to park manipulator @ origin
// Zero the transformation on object (local space)
string $objects[] = `ls -sl`;
$obj = $objects[0];

setAttr( $obj + ".translateX" ) 0.0;
setAttr( $obj + ".translateY" ) 0.0;
setAttr( $obj + ".translateZ" ) 0.0;

setAttr( $obj + ".rotateX" ) 0.0;
setAttr( $obj + ".rotateY" ) 0.0;
setAttr( $obj + ".rotateZ" ) 0.0;
// CLEAR KEYFRAMES
int $maxTime = `playbackOptions -q -max`;
for( $i = 0; $i <= $maxTime; $i++ )
{
  currentTime $i;
  timeSliderClearKey;
}
// left leg / right leg copy.
// use: select src controller, dst controller then
// run the script.
proc copyKeyframes( string $o1, string $o2, int $kf1, int $kf2, int $maxTime )
{
  // TRANSLATION
  copyKey -time $kf1 -attribute translate $o1;
  pasteKey -time $kf2 -attribute translate $o2;
  // if the dst frame is frame 0, also copy into end frame
  if( $kf2 == 0 ) { pasteKey -time $maxTime -attribute translate $o2; }
  
  // ROTATION
  copyKey -time $kf1 -attribute rotate $o1;
  pasteKey -time $kf2 -attribute rotate $o2;
  // if the dst frame is frame 0, also copy into end frame
  if( $kf2 == 0 ) { pasteKey -time $maxTime -attribute rotate $o2; }
}

int $maxTime = `playbackOptions -q -max`;
string $objects[] = `ls -sl`;
$o1 = $objects[0];
$o2 = $objects[1];
int $kf = 0;
while( $kf <= $maxTime )
{
  $kf = `findKeyframe -time $kf -which next $o1`;
  $kf2 = ($kf + $maxTime/2) % $maxTime;
  print $kf;
  print " ";
  print $kf2;
  print "\n";
  copyKeyframes( $o1, $o2, $kf, $kf2, $maxTime );
  $kf++;
}