ent_bonehandle(ENTITY*,STRING* name,var index)
ent_boneparent(ENTITY*,STRING* name,var index)
Finds the handle and optionally the name of a bone (ent_bonehandle, A7.81) or of the 'parent' bone to which a bone with the given index number is attached (ent_boneparent, A7.10).
Parameters:
ENTITY* |
Entity pointer
|
name |
Name
of the bone (STRING* or char*), either input to or output from the function, or NULL. |
index |
Index number of the bone, or 0
when STRING* contains the bone name or handle. |
Returns:
Handle of the bone resp. bone parent (0 if the bone has no parent).
Modifies:
name
(set to the name of the bone resp. parent bone when both name and index are nonzero) .
Remarks:
- Entity scene and bone names must consist of at least 3 characters.
-
If name and index are both given, index is used to find the bone and name is set to the name of the
bone resp. of the parent bone.
- The index number is the number of
a bone within the skeleton
, starting with 1. By calling the ent_boneparent function in a loop over the index number from 1 to ent_bones(), the structure of the whole skeleton can be determined.
-
A bone handle is a long variable that contains the number of the bone, starting with 1. All bone functions also accept a handle instead of a name; using handles is faster. An index number can be converted to a bone handle by casting it to long, f.i. long handle = (long)index. A bone handle can be converted to an index number by casting it to var, f.i. var index = (var)handle.
Speed:
Fast
Example (lite-C):
// return the handle of the first child bone of a bone with a given index
long ent_bonechild(ENTITY* ent,var index)
{
var i;
for (i=1; i<=ent_bones(ent); i++)
if (index == ent_boneparent(ent,NULL,i))
return (long)i;
return 0; // no child found
}
// get the name of the parent bone when a child index is given.
STRING* parent_name = "";
ent_setboneparent(ent,parent_name,child_index); // retrieve the parant name from the child index.
// get the name of the parent bone when a child name is given.
STRING* child_name = "foot_left";
long handle = ent_setboneparent(ent,child_name,0); // return a handle to the parent bone
ent_setbonehandle(ent,parent_name,(var)handle); // retrieve the parant name from the parent handle.
See also:
vec_for_bone, ent_bonename, ent_bones
► latest
version online