Globals: Scene Objects

LightWave

LW Scene Info 2 Shelf Functions Globals Table of Contents

Scene Objects

Availability  LightWave 6.0
Component  Layout, Modeler
Header  lwmeshes.h

The scene objects global gives plug-ins access to the internal representation of each object file loaded into the current scene in Layout or the object database in Modeler. Functions are provided for reading object geometry and the vertex map list.

Although vertex maps are stored in object files, LightWave's internal vmap list isn't object-specific, and this has several consequences. If a vmap of the same name and type is stored in two different object files, LightWave creates a single entry in the vmap list when both files are loaded. The vmap is shared by the two objects. If both objects are then removed, the vmap is not removed from the list. And the only way to determine whether a vmap affects a given object is to test all of its vertices, using the Mesh Info pntVGet function, to see whether any of them is mapped.

Global Call

   LWObjectFuncs *objfunc;
   objfunc = global( LWOBJECTFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWObjectFuncs.

   typedef struct st_LWObjectFuncs {
      int          (*numObjects)  (void);
      const char * (*filename)    (int obj);
      int          (*maxLayers)   (int obj);
      int          (*layerExists) (int obj, int lnum);
      void         (*pivotPoint)  (int obj, int lnum, LWFVector pos);
      LWMeshInfo * (*layerMesh)   (int obj, int lnum);
      int          (*numVMaps)    (LWID);
      const char * (*vmapName)    (LWID, int index);
      int          (*vmapDim)     (LWID, int index);
      LWID         (*vmapType)    (int index);
      const char * (*layerName)   (int obj, int lnum);
      int          (*layerVis)    (int obj, int lnum);
      const char * (*userName)    (int obj);
      const char * (*refName)     (int obj);
   } LWObjectFuncs;
count = numObjects()
Returns a count of the number of objects in the object database. This is the number of unique object files that have been loaded, which in general will be different from the number of animateable object items (clones and null objects, for example, aren't counted).

name = filename( object_index )
Returns the filename for the object. Objects in the database are indexed by integers ranging from 0 to count - 1. Except during rendering, the index associated with a given object can change at any time as objects are added to or removed from the object database by the user.

maxlayer = maxLayers( object_index )
Returns a value one greater than the highest indexed, existing layer for the object. This is just the layer count if all layers with indexes between 0 and maxlayer - 1 exist.

exists = layerExists( object_index, layer_index )
True if the layer exists.

pivotPoint( object_index, layer_index, pos )
Get the pivot point for the object layer.

mesh = layerMesh( object_index, layer_index )
Returns a mesh info structure for the object layer. These are described on the Mesh Info page. For object layers with subpatches, the mesh returned by this function does not include geometry that would be created by subdivision unless the subpatches have been frozen.

vmap_count = numVMaps( vmtype );
Returns a count of the number of vertex maps of a given type, or the total of all types in the scene if vmtype is 0. Vmap type codes are an extensible set of four-character identifiers. The lwmeshes.h header defines some of the common vmap IDs.

LWVMAP_PICK - selection set
LWVMAP_WGHT - weight map
LWVMAP_MNVW - SubPatch weight map
LWVMAP_TXUV - texture UV coordinates
LWVMAP_MORF - relative vertex displacement
LWVMAP_SPOT - absolute vertex displacement

vmap_name = vmapName( vmtype, vmindex );
Returns the name of a vmap. The index ranges from 0 to vmap_count - 1.

dimensions = vmapDim( vmtype, vmindex );
Returns the number of dimensions, or values per vertex, of a vmap. Vmaps are typically 2D or 3D (two or three coordinate values per vertex), but they can have any number of dimensions, including 0.

vmtype = vmapType( vmindex )
Returns the LWID for the vmap. Call numVMaps with a vmtype of 0 to find the upper bound on vmindex.

lname = layerName( objnum, lnum )
Returns the name assigned to the layer, or NULL if the layer is unnamed.

isvis = layerVis( objnum, lnum )
Returns a boolean indicating whether the layer is marked as visible.
 
name = userName( object_index )
Returns the name of the object as seen by the user. This is typically the base filename without the path or extension, or "Unnamed N" for unsaved objects. These are not guaranteed to be unique.
 
name = refName( object_index )
Returns an internal reference name for this object. The reference name is guaranteed to be unique and unchanging for the lifetime of the object. This is useful in Modeler as an argument to commands requiring a filename, since some objects in Modeler may not have been saved yet and therefore have no filename.

Example

The inertia sample uses this global to display a list of vertex maps to the user. The vmap values are used in the displacement evaluation to scale the lag.