PDA

View Full Version : Skeleton Maker?



MonroePoteet
05-11-2005, 01:53 PM
Under LW V5.5 I used the "Skeleton Maker" plug-in to do the grunt work of setting up IK chains, creating and positioning the goal object, setting the bone hierarchy limits/controllers to "Inverse Kinematics" and assigning the end-bone's Goal Object. I'm now on V8.2, and I know Convert Skelegons can be used to draw in the IK chain in Modeler, but is there a newer, improved method of doing the other mechanics of IK setup?

Thanks,
mTp

MonroePoteet
05-12-2005, 08:31 PM
@warnings
@version 2.4
@script generic

// SetupIK.ls
//
// Author:
//
// Monroe Poteet
//
// Description:
//
// This Lightwave LScript does the grunt work
// of setting up one or more IK bone chains for
// an object. Each bone for the object is set
// to have Heading, Pitch, and Bank as IK, and
// a Goal Null is created for each leaf bone.
//
// The created Goal Nulls are placed at the same
// position and rotation as the leaf bone to which
// they are assigned. Their names are <object>_IKGoal,
// with the corresponding numeric suffix if more
// than one Goal is created. For example, if the
// object is XYZ and there are two bone chains,
// the Goals will be XYZ_IKGoal (1) and (2).
//
// Usage:
// Either create Skelegons or manually create
// the bone chains. Select the Object (not the
// bones) to be set up. Invoke the LScript and
// select desired options.
//

// Define options variables
//
// Apparently we can't pass "by-reference" parameters
// to LScript functions, so define them globally.

bSkelegons = true;
bRestBones = true;
bFullTimeIK = true;
bMatchGoalOrientation = true;
bKeepGoalWithinReach = true;

// The main Generic class function

generic
{
// Create a mesh object for the currently selected item

hMesh = Mesh(0);
if (hMesh == nil)
{
info("Please select the Object for IK Setup");
return;
}

sName = hMesh.name; // get raw name

// Get the options from the user

if (!GetOptions(sName))
{
return;
}

// Convert Skelegons to Bones, if requested

if (bSkelegons)
{
SkelegonsToBones();
}

// Construct the Null name. Note that if we have
// multiple IK chains, they'll inherit the numeric
// suffix (e.g. (1), (2), etc.)

sNullName = sName + "_IKGoal";

// Walk the bone chain, setting each of them to
// have Inverse Kinematics as Heading, Pitch
// and Bank controllers. Note that in the CmdList
// in Layout, it shows "IK" as a value of three,
// so it appears that there it is zero-based,
// whereas here it is one-based.
//
// Also, record the rest position of each bone.

hBone = hMesh.bone(); // get first bone
if (hBone == nil)
{
info("No Bones to Process");
return;
}

while (hBone)
{
// Capture this bone for setting up Goals later

hLastBone = hBone;

// select the bone to allow Cmd operation

hBone.select();

HController(4); // one-based in LScript?
PController(4); // one-based in LScript?
BController(4); // one-based in LScript?

if (bRestBones)
{
RecordRestPosition();
}

// on to the next bone in the list, or off the end

hBone = hBone.next();

// To support multiple bone chains in an object,
// we check here to see if the next bone either
// doesn't exist (ran off the end of the chain)
// or has an object (i.e. not a bone) as its parent.
// If so, then the LastBone (captured above) needs
// to have a Goal created for it

if (hBone)
{
// next bone exists, see if it's parent is a bone

hParent = hBone.parent; // no parens?
if (!hParent.isBone())
{
hGoalNull = SetupGoal(hLastBone,sNullName);
}
}
else
{
// next bone doesn't exist, set up the last one

hGoalNull = SetupGoal(hLastBone,sNullName);
}
}

// and set up to the last IK Goal created for action!

hGoalNull.select();
}


SetupGoal: hLastBone,sNullName
{
// set up the IK goal at the same position and
// rotation as the last bone
//
// Note that setting up a parent object doesn't
// appear to be supported in LScript. Otherwise,
// it'd be nice to automatically parent the new
// Goal Null to the mesh object and subtract out
// the mesh object's position.

vBonePosition = hLastBone.getWorldPosition(0);
vBoneRotation = hLastBone.getWorldRotation(0);

AddNull(sNullName);
hGoalNull = Mesh(0); // get handle to Goal Null

// copy the first six channels from the last bone to
// the null. These are X,Y,Z position and H,P,B rotation.

hChannel = hGoalNull.firstChannel(); // Xposition;
hChannel.createKey(0,vBonePosition.x);

hChannel = hGoalNull.nextChannel();
hChannel.createKey(0,vBonePosition.y);

hChannel = hGoalNull.nextChannel();
hChannel.createKey(0,vBonePosition.z);

hChannel = hGoalNull.nextChannel();
hChannel.createKey(0,vBoneRotation.x);

hChannel = hGoalNull.nextChannel();
hChannel.createKey(0,vBoneRotation.y);

hChannel = hGoalNull.nextChannel();
hChannel.createKey(0,vBoneRotation.z);

// set up the goal object and full-time IK on the last
// bone in the chain

hLastBone.select();

GoalItem(hGoalNull.id);

if (bFullTimeIK)
{
FullTimeIK();
}

if (bMatchGoalOrientation)
{
MatchGoalOrientation();
}

if (bKeepGoalWithinReach)
{
KeepGoalWithinReach();
}

return(hGoalNull);
}

GetOptions: sObjectName
{
nColumn = 35;
nRow = 5;
nRowIncr = 25;

// Set up the panel controls

reqbegin("Setup IK Chain for " + sObjectName);

c0 = ctlcheckbox("Convert Skelegons",bSkelegons);
ctlposition(c0, nColumn, nRow);
nRow += nRowIncr;

c1 = ctlcheckbox("Rest Bones",bRestBones);
ctlposition(c1, nColumn, nRow);
nRow += nRowIncr;

c2 = ctlcheckbox("Full Time IK",bFullTimeIK);
ctlposition(c2, nColumn, nRow);
nRow += nRowIncr;

c3 = ctlcheckbox("Match Goal Orientation",bMatchGoalOrientation);
ctlposition(c3, nColumn, nRow);
nRow += nRowIncr;

c4 = ctlcheckbox("Keep Goal Within Reach",bKeepGoalWithinReach);
ctlposition(c4, nColumn, nRow);
nRow += nRowIncr;

// Operate the panel, returning if they Cancel

if (!reqpost())
{
return(false);
}

// Retrieve the values from the controls into the
// global variables

bSkelegons = getvalue(c0);
bRestBones = getvalue(c1);
bFullTimeIK = getvalue(c2);
bMatchGoalOrientation = getvalue(c3);
bKeepGoalWithinReach = getvalue(c4);

reqend(); // done with the panel
}

cgbloke2004
05-12-2005, 08:43 PM
LOL!!!! hehe..

anyway.. i found this very useful - you need to rig the fingers yourself, but overall its very decent.
ive been using it on alot of things [not quadrapeds though..] and its good for very quick posable setups.

http://www.animationsnippets.com/plugins/index.html
http://www.animationsnippets.com/downloads/simplerigger.zip

Based on the skelegons of an object, this plug-in creates a medium-complex rig. Contains plug-in, description, sample object files
one of the best, simplest and fastest auto-rigs thats also free, out there..

[all you have to do is add the plugin, load the skelegon object, adjust it to fit your model [which would be in the background layer], copy/cut n paste the skelegons into your object and save it, load it into lightwave [layout] and run the simplerigger plugin - and hey presto! a rigged character is born!]

Newtek ought to bundle it with LW to give LW a headstart for those wanting LW to do character stuff - most apps out there appear to have native auto-riggers, LW, afaik has never had one.

as a starter, i think something like this is pretty good.
[but if you want to learn, theres no better way than from scratch with the multitude of tutorials out there..]

hth

MonroePoteet
05-13-2005, 12:25 PM
Thanks for the pointers, I'll give it a try. Knowing the key word "autorigger" will certainly help my searches.

I've done quite a bit of manual rigging, which is why I was looking for the plug-in. Once I've done 10-20 similar bone traversal to set everything to "IK", creating / placing / setting goal objects, setting up limits / stiffness etc., I start thinking "automation".

Thanks again,
mTp

cgbloke2004
05-13-2005, 12:39 PM
you and me both.
i went on the hunt for something quick and dirty a while ago and found a few things, but the most relaible seemed to be simplerigger above.

i'd seen one or two others based on the same principles with differences in how the legs were setup, but since i was after a generic setup that would work quickly everytime, this one seemed to fit the bill.

hth