"LW Item Info 2"
Availability: LightWave 6.0
Component: Layout
The item info global returns functions for traversing a list of the items in a scene
and for getting information about any one of them. The information available through this
global is common to all item types. Information specific to certain item types is provided
through separate global functions.
This information is read-only, and in general, it doesn't account for the effects of
plug-ins.
Global Call
LWItemInfo *iteminfo;
iteminfo = global( "LW Item Info 2", GFUSE_TRANSIENT );
The global function returns a pointer to an LWItemInfo.
typedef struct st_LWItemInfo {
LWItemID (*first) (LWItemType, LWItemID);
LWItemID (*next) (LWItemID);
LWItemID (*firstChild) (LWItemID parent);
LWItemID (*nextChild) (LWItemID parent, LWItemID prevChild);
LWItemID (*parent) (LWItemID);
LWItemID (*target) (LWItemID);
LWItemID (*goal) (LWItemID);
LWItemType (*type) (LWItemID);
const char * (*name) (LWItemID);
void (*param) (LWItemID, LWItemParam, LWTime,
LWDVector vector);
unsigned int (*limits) (LWItemID, LWItemParam,
LWDVector min, LWDVector max);
const char * (*getTag) (LWItemID, int);
void (*setTag) (LWItemID, int, const char *);
} LWItemInfo;
- id = first( itemtype, bone_object )
- Returns the ID of the first item of a given type, or LWITEM_NULL if there are
no items of this type in the scene. Valid item types are
LWI_OBJECT
LWI_LIGHT
LWI_CAMERA
LWI_BONE
If itemtype is LWI_BONE, the second argument is the ID of the boned
object. Otherwise it should be LWITEM_NULL.
- id = next( item )
- Returns the next item of the same type as the item argument. If there are no
more, this returns LWITEM_NULL.
id = firstChild( parent )
- Returns the first child item of the parent item, or LWITEM_NULL if the parent
item has no children.
id = nextChild( parent, child )
- Returns the next child item given a parent item and the previous child, or LWITEM_NULL
if there are no more children.
id = parent( item )
- Returns the item's parent, if any, or LWITEM_NULL.
id = target( item )
- Returns the item's target, if any, or LWITEM_NULL.
id = goal( item )
- Returns the item's goal, if any, or LWITEM_NULL.
itemtype = type( item )
- Returns the type of an item.
itemname = name( item )
- Returns the name of the item as it appears to the user.
param( item, param, time, vector )
- Returns vector parameters associated with an item. The param argument
identifies which parameter vector you want. The parameters are
LWIP_POSITION
- The keyframed position before parenting. Equivalently, if the item is parented,
this is its position relative to its parent.
- LWIP_W_POSITION
- The keyframed position in world coordinates (after parenting).
- LWIP_ROTATION
- The keyframed rotation, in radians (relative to its parent's rotation).
- LWIP_SCALING
- The keyframed scale factors (relative to the parent's scale).
- LWIP_PIVOT
- The item's pivot point, in its own coordinates. This is the origin for rotations.
- LWIP_RIGHT
- LWIP_UP
- LWIP_FORWARD
- +X, +Y and +Z direction vectors for the item, in world coordinates. Together they form
the item's rotation and scale transformation matrix. Since they include scaling, these
vectors aren't normalized.
- LWIP_W_RIGHT
- LWIP_W_UP
- LWIP_W_FORWARD
- +X, +Y and +Z direction vectors for the world, in item coordinates. In other words,
these are the inverse of the previous parameters.
The value is written to the vector array for the given time.
- channels = limits( item, param, minvec, maxvec )
- Get upper and lower bounds on vector parameters. These may be limits set by the user on
joint angles or ranges of movement. The function returns an integer containing bit flags
that indicate which of the three vector components contain limits. The symbols for these
bits are
LWVECF_0
LWVECF_1
LWVECF_2
If the bit is set, then the corresponding element of the vector array contains a valid
limit. If the bit is 0, the channel is unbounded.
Example
This code fragment traverses the object list, collecting names and some parameters.
#include <lwserver.h>
#include <lwrender.h>
LWItemInfo *iteminfo;
LWItemID id;
char *name;
LWTime t = 3.0; /* seconds */
LWDVector rt, up, fd;
iteminfo = global( "LW Item Info 2", GFUSE_TRANSIENT );
if ( iteminfo ) {
id = iteminfo->first( LWI_OBJECT, NULL );
while ( id ) {
name = iteminfo->name( id );
iteminfo->param( id, LWIP_RIGHT, t, rt );
iteminfo->param( id, LWIP_UP, t, up );
iteminfo->param( id, LWIP_FORWARD, t, fd );
if ( rt[ 0 ] > 0.0 ) { ...
id = iteminfo->next( id );
}
}
|