PDA

View Full Version : Parenting Question



TyVole
11-22-2003, 06:03 AM
I'm trying to parent a null to a bone. But I can't seem to figure out how to call the ParentItem function correctly.

If I parent the null with a top-level object (such as ParentItem("MyObject:Skelegons"), it works -- but I can't figure out the syntax to parent it to something lower in the hierarchy.

For example, if I write ParentItem("MyObject:Skelegons.Hips"), I get an error. I also get an error with ParentItem("Hips").

Anyone have any suggestions?

Thanks.

faulknermano
11-22-2003, 08:10 PM
Originally posted by TyVole
I'm trying to parent a null to a bone. But I can't seem to figure out how to call the ParentItem function correctly.

If I parent the null with a top-level object (such as ParentItem("MyObject:Skelegons"), it works -- but I can't figure out the syntax to parent it to something lower in the hierarchy.

For example, if I write ParentItem("MyObject:Skelegons.Hips"), I get an error. I also get an error with ParentItem("Hips").

Anyone have any suggestions?

Thanks.

you cant parent a parent to a children instantly. you have to de-parent it first and then parent it.

TyVole
11-22-2003, 08:39 PM
I'm sorry, but I think you've misunderstood me.

I've added a null and want to make it a child of the hip bone, which is a child of the Skelegon layer of my object, as follows:

AddNull("MyNull");
ParentItem("Hips");

But I receive an error stating that Hips is not an object. The following, though, is okay:

AddNull("MyNull");
ParentItem("MyObject:Skelegons");

What I need is how to define the Hips bone within the ParentItem function so that LightWave understands it. I've tried ParentItem("Hips"), ParentItem("MyObject:Skelegons.Hips"), ParentItem("MyObject:Skelegons:Hips"), and many others without success.

Thanks.

faulknermano
11-25-2003, 06:57 AM
hmm. without seeing your scene i can only guess what to do from here.

if you can somehow get the Mesh Object Agent of your "Hips" item, by either traversing the mesh it is on and locating it via name checking, it would then be a simple matter of recording its id and then feeding that id to ParentItem():

[code]

myMesh = Mesh("myObject");
b = myMesh.bone();
found = false;
while(b)
{
if(b.name == "Hips")
{
hipsID = b.id;
found = true;
break;
}
else
b = b.next();
}
if(found == false)
warn("could not find hips");

SelectItem("myNull");
ParentItem(hipsID);
}

cant test it.. but hopefully it gets you there somehow.

TyVole
11-25-2003, 09:00 PM
Thank you.

kevman3d
12-07-2003, 02:34 AM
Just to follow up on that...

There is a bug in LScript that didn't properly resolve the bone from name reference. It was fixed in 7.5c (ie. should work)

However faulknermano's loop through the bones should work for all versions of LW.