Backdrop Info Camera Info Globals Table of Contents

Bone Info

Availability  LightWave® 6.0
Component  Layout
Headerlwrender.h

The bone info global returns functions for getting bone-specific information about any of the bones in a scene. Use the item info global to get the bone list and for generic item information. The data returned by these functions is read-only, but you can use commands to set many of the parameters.

Global Call

   LWBoneInfo *boneinfo;
   boneinfo = global( LWBONEINFO_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWBoneInfo.

   typedef struct st_LWBoneInfo {
      unsigned int (*flags)     (LWItemID);
      void         (*restParam) (LWItemID, LWItemParam, LWDVector vec);
      double       (*restLength)(LWItemID);
      void         (*limits)    (LWItemID, double *inner, double *outer);
      const char * (*weightMap) (LWItemID);
      double       (*strength)  (LWItemID);
      int          (*falloff)   (LWItemID);
      void         (*jointComp) (LWItemID, double *self, double *parent);
      void         (*muscleFlex)(LWItemID, double *self, double *parent);
      void         (*type)      (LWItemID);
      double       (*twist)     (LWItemID);
      int          (*transform) (LWItemID, int transform, int relativeto,
                                 LWFMatrix3 m, LWFVector pos, LWFVector end);
      void         (*muscleBulge)      (LWItemID, double *self, double *parent);
      void         (*muscleBulgeMap)   (LWItemID, LWTextureID *self, LWTextureID *parent);
      void         (*displacementMap)  (LWItemID, LWTextureID *self, LWTextureID *parent);
   } LWBoneInfo;
boneflags = flags( bone )
Returns a set of flag bits combined using bitwise-or. The flags are

LWBONEF_ACTIVE
The bone is active.
LWBONEF_LIMITED_RANGE
The bone has a limited range.
LWBONEF_SCALE_STRENGTH
The strength of the bone is scaled by the rest length.
LWBONEF_WEIGHT_MAP_ONLY
Deformation will be based solely on the weight map.
LWBONEF_WEIGHT_NORM
The weight normalization option is turned on. The relative strength of each weight map value is scaled so that the total for all values is 1.0.
LWBONEF_JOINT_COMP
LWBONEF_JOINT_COMP_PAR
Joint compensation is enabled for the bone. This can also account for the rotation of the bone's parent.
LWBONEF_MUSCLE_FLEX
LWBONEF_MUSCLE_FLEX_PAR
Muscle flexing is enabled for the bone. Like joint compensation, this is a volume preserving adjustment to the deformation caused by the bone and can include the effect of the bone's parent.

restParam( bone, param_type, vector )
Gets vector parameters for the rest position of a given bone. Parameters of the animated bone can be read from the normal item info functions. See the item info parameter list for the values that can be passed in the param_type argument.

length = restLength( bone )
Returns the rest length of the bone.

limits( bone, inner_limit, outer_limit )
For limited range bones, this gets the inner and outer limit radii for the bone.

name = weightMap( bone )
Returns the name of the weight map for the bone. The weight map is a vertex map of type LWVMAP_WGHT. The object info and scene objects globals provide functions for reading the values in a vmap.

bone_strength = strength( bone )
Returns the bone strength setting.

type = falloff( bone )
Returns the falloff as an index into an options list. In general, the falloff function is the distance raised to the power -2type. A type of 0 is inverse distance, 1 is inverse distance squared, 2 is inverse distance to the fourth power, and so on.

jointComp( bone, self, parent )
Fills in self and parent with the joint compensation amount.

muscleFlex( bone, self, parent )
Fills in self and parent with the muscle flexing amount.

type = type( bone )
Returns the type of the bone. The type is one of:
LWBONETYPE_ZAXIS
LWBONETYPE_JOINT

twist = twist( bone )
Returns the twist value for the bone.

res = transform( bone, transform, relativeto, m, pos, end )
Obtains the transform or coordinate system of the bone. These transforms are used to determine how the bone deforms the mesh. A transform consists of a matrix defining the coordinate system of the bone, the starting position of a bone, and the position where the bone terminates. The bone coordinate system can be different from the bone's item coordinate system. There are several coordinate systems that can be obtained:
LWBONETRANS_REST
The bone's rest coordinate system.
LWBONETRANS_FINAL
The bone's final coordinate system.
It is the change between rest and final that defines the deformation that a bone applies to a mesh. The coordinate system can be obtained relative to one of:
LWBONETRANS_OBJECT
Relative to the mesh object the bone is in.
LWBONETRANS_PARENT
Relative to the parent of the bone.
LWBONETRANS_WORLD
Relative to the world.
The function returns 1 if the transform could be obtained, 0 otherwise.

muscleBulge( bone, self, parent )
Fills in self and parent with the muscle bulge amounts.

muscleBulgeMap( bone, self, parent )
Fills in self and parent with the muscle bulge textures, if any.

displacementMap( bone, self, parent )
Fills in self and parent with the bone displacement textures, if any.

Example

This code fragment collects information about the bones in the scene.

   #include <lwserver.h>
   #include <lwrender.h>

   LWItemInfo *iteminfo;
   LWBoneInfo *boneinfo;
   LWItemID object, bone;
   unsigned int flags;
   LWDVector pos;
   double restlen;

   iteminfo = global( LWITEMINFO_GLOBAL, GFUSE_TRANSIENT );
   boneinfo = global( LWBONEINFO_GLOBAL, GFUSE_TRANSIENT );
   if ( !iteminfo || !boneinfo ) return AFUNC_BADGLOBAL;

   object = iteminfo->first( LWI_OBJECT, NULL );
   while ( object ) {
      bone = iteminfo->first( LWI_BONE, object );
      while ( bone ) {
         flags = boneinfo->flags( bone );
         boneinfo->restParam( bone, LWIP_POSITION, pos );
         restlen = boneinfo->restLength( bone );
         ...

         bone = iteminfo->next( bone );
      }
      object = iteminfo->next( object );
   }