Texture Editor

Availability LightWave 6.0 | Component Layout, Modeler | Header lwtxtred.h

This global provides access to a user interface for editing textures. If you use XPanels with vparms that can be textured, the interaction with the texture editor is handled for you, and you don't need this global. But if your interface is built with classic Panels or OS-specific elements, you can use this global to provide your users with the standard texture interface.

Global Call

   LWTxtrEdFuncs *txedf;
   txedf = global( LWTXTREDFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWTxtrEdFuncs.

   typedef struct st_LWTxtrEdFuncs {
      LWTECltID   (*subscribe)   (char *title, int flags, void *userData,
                                   LW_TxtrRemoveFunc *,
                                   LW_TxtrAutoSizeFunc *,
                                   LW_TxtrEventFunc *);
      void        (*unsubscribe) (LWTECltID);
      void        (*open)        (LWTECltID, LWTextureID, char *title);
      void        (*setTexture)  (LWTECltID, LWTextureID, char *title);
      void        (*setPosition) (LWTECltID, int, int);
      void        (*close)       (LWTECltID);
      int         (*isOpen)      (LWTECltID);
      int         (*refresh)     (LWTECltID);
      LWTLayerID  (*currentLayer)(LWTECltID);
      int         (*selectAdd)   (LWTECltID, LWTextureID);
      int         (*selectRem)   (LWTECltID, LWTextureID);
      int         (*selectClr)   (LWTECltID);
      LWTextureID (*selectFirst) (LWTECltID);
      LWTextureID (*selectNext)  (LWTECltID, LWTextureID);
      void        (*setGradientAutoSize)(LWTECltID,
                                   LW_GradAutoSizeFunc *);
   } LWTxtrEdFuncs;
client = subscribe( title, flags, data, txremove, txautosz, txevent )
Returns an identifier that plug-ins use in later calls to the texture editor functions. The callbacks are optional and are called when the user removes or autosizes a texture, or does anything with it in the editor. The data argument is passed to these callbacks; its contents are up to you, and it can be NULL. The flags determine what the user can do in the editor and can be one or more of the following.
TEF_USEBTN
Add use/remove buttons at the bottom of the pane.
TEF_OPACITY
Add layer opacity settings.
TEF_BLEND
Add blend options to the layer global settings.
TEF_TYPE
Add layer type control on the top of the pane.
TEF_LAYERS
Add layer list pane on the left side of the pane.
TEF_ALL
All of the above flags. This is the standard configuration for the texture editor.
unsubscribe( client )
Free resources allocated by subscribe. This call invalidates the client ID. You'll need to call subscribe again before calling the texture editor functions.
open( client, texture, title )
Open the texture editor window.
setTexture( client, texture, title )
Initialize the texture editor with the texture to be edited.
setPosition( client, x, y )
Move the editor window. The coordinates are for the upper left corner of the window.
close( client )
Close the texture editor window.
isopen = isOpen( client )
True if the editor window is currently open.
result = refresh( client )
Redraw the editor window.
tlayer = currentLayer( client )
Returns the texture layer currently being edited.
ok = selectAdd( client, texture )
ok = selectRem( client, texture )
ok = selectClr( client )
Add a texture to a multiselection, remove a texture from a multiselection, or clear the selection list.
texture = selectFirst( client )
next = selectNext( client, texture )
Enumerate the selected textures.
setGradientAutoSize( client, gsizecb )
Set a callback for autosize requests from gradient texture layers.

Callbacks

The callbacks passed to subscribe and setGradientAutoSize allow you to react to user actions in the editor.

   typedef void LW_TxtrRemoveFunc (LWTextureID, void *userData);
   typedef int  LW_TxtrAutoSizeFunc (LWTextureID, void *userData,
      double bbox[3][2]);
   typedef int  LW_GradAutoSizeFunc (LWTxtrParamDesc *param,
      int paramNb, void *userData);
   typedef int  LW_TxtrEventFunc (LWTextureID, void *userData,
      int eventCode);

The remove callback is called when a texture is removed. The texture autosize callback is called when the user has requested that the texture size be set automatically. The bounding box array should be set to the default size of the texture. The gradient autosize callback is called for automatic sizing of gradient layers. The size should be set in the parameter description. See the Texture Functions global for a description of the LWTxtrParamDesc structure.

The event callback is called when the texture settings are modified by the user. This gives you a chance to update thumbnails or other aspects of your interface that depend on the texture settings. The event code can be one of the following.

TXEV_ALTER
A texture setting has changed.
TXEV_TRACK
A texture setting is being changed (a slider is being manipulated, for example).
TXEV_DELETE
A texture layer has been deleted.

Example

The txchan and atmosphere samples use Texture Editor functions.