Item InfoAvailability LightWave 6.0 Component LayoutHeader lwrender.h 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. Global Call LWItemInfo *iteminfo; iteminfo = global( LWITEMINFO_GLOBAL, 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); unsigned int (*limits) (LWItemID, LWItemParam, LWDVector min, LWDVector max); const char * (*getTag) (LWItemID, int); void (*setTag) (LWItemID, int, const char *); LWChanGroupID (*chanGroup) (LWItemID); const char * (*server) (LWItemID, const char *, int); unsigned int (*serverFlags) (LWItemID, const char *, int); void (*controller) (LWItemID, LWItemParam, int type[3]); unsigned int (*flags) (LWItemID); LWTime (*lookAhead) (LWItemID); double (*goalStrength)(LWItemID); void (*stiffness) (LWItemID, LWItemParam, LWDVector); unsigned int (*axisLocks) (LWItemID, LWItemParam); } LWItemInfo;
LWI_OBJECT LWI_LIGHT LWI_CAMERA LWI_BONEIf itemtype is LWI_BONE, the second argument is the ID of the boned object. Otherwise it should be LWITEM_NULL. id = firstChild( parent ) id = nextChild( parent, child ) id = parent( item ) id = target( item ) id = goal( item ) itemtype = type( item ) itemname = name( item ) param( item, param_type, time, vector ) LWIP_POSITION LWIP_PIVOT_ROT LWIP_UP LWIP_FORWARD LWIP_W_UP LWIP_W_FORWARD LWVECF_0 LWVECF_1 LWVECF_2If 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. setTag( item, tagnum, tag ) changroup = chanGroup( item ) servname = server( item, class, index ) flags = serverFlags( item, class, index ) LWSRVF_DISABLED LWSRVF_HIDDEN LWMOTCTL_KEYFRAMES LWMOTCTL_TARGETING LWMOTCTL_ALIGN_TO_PATH LWMOTCTL_IK LWITEMF_ACTIVE LWITEMF_UNAFFECT_BY_IK LWITEMF_FULLTIME_IK LWITEMF_GOAL_ORIENT LWITEMF_REACH_GOAL strength = goalStrength( item ) stiffness( item, param_type, vector ) History LightWave 7.5 added the axisLocks function, but LWITEMINFO_GLOBAL was not incremented. If you ask for "LW Item Info 3", use the Product Info global to determine whether you're running in LightWave 7.0 or later before attempting to call these functions. 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( LWITEMINFO_GLOBAL, 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 ); } }The vectors returned by the param function can be used to transform points between item and world coordinates. In the following fragments, p is the position of a point in item coordinates and q is the same point's position in world coordinates: LWDVector p, q, rt, up, fd, wrt, wup, wfd, wpos, piv; LWItemID id; ... iteminfo->param( id, LWIP_RIGHT, t, rt ); iteminfo->param( id, LWIP_UP, t, up ); iteminfo->param( id, LWIP_FORWARD, t, fd ); iteminfo->param( id, LWIP_W_POSITION, t, wpos ); iteminfo->param( id, LWIP_PIVOT, t, piv );To convert from item to world coordinates, subtract the pivot position (to move the rotation origin to the world origin), multiply by the matrix formed from the direction vectors, and offset the result by the world position of the item. for ( i = 0; i < 3; i++ ) q[ i ] = ( p[ 0 ] - piv[ 0 ] ) * rt[ i ] + ( p[ 1 ] - piv[ 1 ] ) * up[ i ] + ( p[ 2 ] - piv[ 2 ] ) * fd[ i ] + wpos[ i ];To transform from world to item coordinates, just apply the same procedure in reverse, using the inverse direction vectors. iteminfo->param( id, LWIP_W_RIGHT, t, wrt ); iteminfo->param( id, LWIP_W_UP, t, wup ); iteminfo->param( id, LWIP_W_FORWARD, t, wfd ); for ( i = 0; i < 3; i++ ) p[ i ] = ( q[ 0 ] - wpos[ 0 ] ) * wrt[ i ] + ( q[ 1 ] - wpos[ 1 ] ) * wup[ i ] + ( q[ 2 ] - wpos[ 2 ] ) * wfd[ i ] + piv[ i ]; |