Globals: Channel Info

LightWave

Camera Info Color Picker Globals Table of Contents

Channel Info

Availability  LightWave 6.0
Component  Layout, Modeler
Header  lwenvel.h

A channel is an animation parameter that varies as a function of time. In contrast to envelopes, which are arrays of keys, channels may include the effects of other plug-ins and calculations. The channel info global gives you access to Layout's list of grouped channels. A channel's underlying envelope data may also be read (see the Animation Envelopes page for more information).

Global Call

   LWChannelInfo *chaninfo;
   chaninfo = global( LWCHANNELINFO_GLOBAL, GFUSE_TRANSIENT );

The global call returns a pointer to an LWChannelInfo.

   typedef struct st_LWChannelInfo {
      LWChanGroupID (*nextGroup)       (LWChanGroupID parent,
                                          LWChanGroupID group);
      LWChannelID   (*nextChannel)     (LWChanGroupID, LWChannelID);
      const char *  (*groupName)       (LWChanGroupID); 
      const char *  (*channelName)     (LWChannelID); 
      LWChanGroupID (*groupParent)     (LWChanGroupID); 
      LWChanGroupID (*channelParent)   (LWChannelID); 
      int           (*channelType)     (LWChannelID); 
      double        (*channelEvaluate) (LWChannelID, LWTime); 
      const LWEnvelopeID (*channelEnvelope) (LWChannelID); 
      int           (*setChannelEvent) (LWChannelID,
                                          LWChanEventFunc, void *); 
      const char *  (*server)          (LWChannelID, const char *class,
                                          int index);
      unsigned int  (*serverFlags)     (LWChannelID, const char *class,
                                          int index );
      LWInstance    (*serverInstance)  (LWChannelID, const char *class,
                                          int index );
      int           (*serverApply)     (LWChannelID, const char *class,
                                          const char *name, int flags );
      void          (*serverRemove)    (LWChannelID, const char *class,
                                          const char *name, LWInstance);
   } LWChannelInfo;
group = nextGroup( parent_group, prev_group )
Returns the next channel group in the group list. If the parent is NULL, this returns groups from the root of the channel tree, and if the previous group is NULL, it returns the first group.

channel = nextChannel( group, prev_channel )
Returns the next channel in the group. If the previous channel is NULL, this returns the first channel in the group.

gname = groupName( group )
Returns the name of the channel group.

cname = channelName( channel )
Returns the name of the channel.

parent = groupParent( group )
Returns the parent group of a channel group.

parent = channelParent( channel )
Returns the group a channel belongs to.

type = channelType( channel )
Returns the value type of the channel, which determines how the value is interpreted and displayed to the user. It can be one of the following.
LWET_FLOAT
LWET_DISTANCE
LWET_PERCENT
LWET_ANGLE
value = channelEvaluate( channel, time )
Returns the value of the channel at the specified time.

envelope = channelEnvelope( channel )
Returns the underlying envelope for a channel. The envelope can be examined and modified using the Animation Envelopes global.

result = setChannelEvent( channel, event_func, data )
Set a callback for a channel. Whenever the channel's underlying envelope is modified, your event_func function will be called with data as its first argument. The result is true (non-zero) if the function succeeds and false (0) if it fails. The callback receives the same event codes as the envelope global's setEnvEvent function, plus LWCEVNT_VALUE.

servname = server( channel, class, index )
Returns the name of a plug-in applied to the channel. The class argument is the class string, which will often be LWCHANNEL_HCLASS but may be others. The index specifies the "slot," or position in the server list, and counts from 1.

flags = serverFlags( channel, class, index )
Returns flags for the plug-in applied to the channel. This is the channel-specific version of the Item Info serverFlags function.

instance = serverInstance( channel, class, index )
Returns an opaque pointer to the plug-in's instance data. This is the LWInstance created and used by the plug-in's LWInstanceFuncs callbacks.

index = serverApply( channel, class, name, flags )
Apply the plug-in to the channel. Returns the server list index, or 0 if it fails. The name is the server name, the string in the name field of the plug-in's ServerRecord. The flags can be any combination of those returned by serverFlags.

serverRemove( channel, class, name, instance )
Remove the plug-in from the channel. The instance is the pointer returned by serverInstance.

History

In LightWave 7.0, the service name for this global was incremented from "Channel Info" to "Channel Info 2", and the serverFlags, serverInstance, serverApply and serverRemove functions were added, along with the LWCEVNT_VALUE event code.

Example

The find_channels function finds all of the channels belonging to a group and prints the name and type of each channel. It calls itself recursively to examine the subgroups of the parent group.

   #include <lwserver.h>
   #include <lwenvel.h>

   static void find_channels( LWChannelInfo *chinfo,
      LWChanGroupID parent, int indent )
   {
      LWChanGroupID group;
      LWChannelID chan;

      group = chinfo->nextGroup( parent, NULL );
      while ( group ) {
         printf( "%*s(G) \"%s\"\n", indent, " ",
            chinfo->groupName( group ));
         find_channels( chinfo, group, indent + 2 );
         chan = chinfo->nextChannel( group, NULL );
         while ( chan ) {
            printf( "%*s(C) \"%s\" type %d\n", indent + 2, " ",
               chinfo->channelName( chan ),
               chinfo->channelType( chan ));
            chan = chinfo->nextChannel( group, chan );
         }
         group = chinfo->nextGroup( parent, group );
      }
   }