Multithreading Utilities Object Info Globals Table of Contents

Node Editor

Availability  LightWave® 9.0
Component  Layout,Modeler
Header  lwnodeeditor.h

This global provides access to a user interface for editing nodes.

Global Call

   LWNodeEditorFuncs *nodeedf;
   nodeedf = global( LWNODEEDITORFUNCS_GLOBAL, GFUSE_TRANSIENT );

Root Node Functions

 typedef struct LWRootNode_t {
 NodePreviewType  previewType;
 LWError          (*init)( NodeEditorID, int );
 LWError          (*newTime)( NodeEditorID, LWFrame, LWTime );
 void             (*cleanup)( NodeEditorID );
 LWXPanelID       (*panel)( NodeEditorID ); 
 LWError          (*options)( NodeEditorID );
 void             (*preview)( NodeEditorID, LWNodalAccess*, LWDVector );
 void             (*customPreview)( NodeEditorID, int, int );
 } LWRootNode;

The root node, is the destination node that all the other nodes connect to.
The client needs to evaluate the inputs, and handle the implementation for whatever class it is used with.

init( editor , mode )
Init for the root node. For initializing render data for the root node.
newTime( editor, frame, time )
Newtime for the root node.
cleanup( editor )
Cleanup for the root node.
panel( editor )
Embedded xpanel, for the “Node Properties” panel.
options( editor )
Options is called when no xpanel is defined for the root node.
preview( editor, access, color )
Preview function to draw the preview sphere for the root node. The color is the resulting pixel color which the client should fill in. The color will be scaled and clamped into [0, 255] range internally.
customPreview( editor, width, height )
Custom preview function, for doing custom previews for the root node.
Input Node Functions

 typedef struct LWInputNode_t {
 LWError          (*init)( NodeEditorID, int );
 LWError          (*newTime)( NodeEditorID, LWFrame, LWTime );
 void             (*cleanup)( NodeEditorID );
 void             (*evaluate)( NodeEditorID, LWNodalAccess*, NodeOutputID, NodeValue );
 LWXPanelID       (*panel)( NodeEditorID ); 
 LWError          (*options)( NodeEditorID );
 void             (*preview)( NodeEditorID, LWNodalAccess*, LWDVector );
 } LWInputNode;

The input node, is the input node which provides evaluation data from outside the Node Editor.
The client needs to evaluate the node with the custom evaluation function.

init( editor , mode )
Init for the input node. For initializing render data for the input node.
newTime( editor, frame, time )
Newtime for the input node.
cleanup( editor )
Cleanup for the input node.
evaluate( editor, access, outputID, outvalue )
The custom evaluation function for the input node.
panel( editor )
Embedded xpanel, for the “Node Properties” panel.
options( editor )
Options is called when no xpanel is defined for the input node.
preview( editor, access, color )
Preview function to draw the preview sphere for the input node. The color is the resulting pixel color which the client should fill in. The color will be scaled and clamped into [0, 255] range internally.

Node Editor Functions

 typedef struct st_LWNodeEditorFuncs {
 NodeEditorID       (*create)( const char*, const char*, LWRootNode*, LWInputNode*, void* );
 void               (*destroy)( NodeEditorID );
 void               (*rename)( const char*, NodeEditorID ); 
 void               (*setUpdateFunc)( NodeEditorID,  nodeEditorUpdateFunc* );
 LWError            (*copy)( NodeEditorID, NodeEditorID );
 LWError            (*save)( NodeEditorID, const LWSaveState* );
 LWError            (*load)( NodeEditorID, const LWLoadState* );
 LWError            (*init)( NodeEditorID, int );
 LWError            (*newTime)( NodeEditorID, LWFrame, LWTime );
 void               (*cleanup)( NodeEditorID );
 NodeInputID        (*addInput)( NodeEditorID, ConnectionType,  const char*, NodeInputEvent* );
 void               (*remInput)( NodeEditorID, NodeInputID );
 NodeOutputID       (*addOutput)( NodeEditorID, ConnectionType,  const char* );
 void               (*remOutput)( NodeEditorID, NodeOutputID );
 void               (*setEnvGroup)( NodeEditorID, LWChanGroupID );
 void               (*setAutosize)( NodeEditorID, nodeAutoSizeFunc* );
 void               (*setUserData)( NodeEditorID, void* );
 void               *(*getUserData)( NodeEditorID );
 int                (*numberOfNodes)( NodeEditorID );
 NodeInputID        (*getInputByName)( NodeEditorID, const char* );
 NodeInputID        (*getInputByIndex)( NodeEditorID, int );
 unsigned short int (*getState)( NodeEditorID );
 void               (*setState)( NodeEditorID, unsigned short int );
 int                (*OpenNodeEditor)( NodeEditorID );
 int                (*isOpenNodeEditor)( NodeEditorID );
 NodeID             (*getRootNodeID)( NodeEditorID );
 NodeID             (*getInputNodeID)( NodeEditorID );
 NodeEditorID       (*getEditorID)( NodeID );
 LWError            (*connect)( NodeOutputID, NodeInputID ); (rev.11+)
 NodeID             (*addNode)( NodeEditorID, const char* );
 void               (*destroyNode)( NodeID );
 void               (*setXY)( NodeID, int, int );
 void               (*setContext)( NodeEditorID, const char* );
 const char*        (*getContext)( NodeEditorID );
 const LWItemID*    (*usedItems)( NodeEditorID );
} LWNodeEditorFuncs;

The node editor functions.

create( rootname, paneltitle, rootnodefuncs, inputnodefuncs, userdata )
Create a node editor ID.
destroy( editor )
Destroy a node editor ID.
rename( newname, editor )
Rename the editor. It is essentially the title for the editor window.
setUpdateFunc( editor, UpdateFunc )
Set the update function for the editor.
copy( to, from )
Copy the node editor data.
save( editor, SaveState )
Save the node editor data.
load( editor, LoadState )
Load the node editor data.
init( editor, mode )
Init needs to be called when rendering is being initialized.
This function calls Init for all the nodes in the editor.
newTime( editor, frame, time )
This function calls newTime for all the nodes in the editor.
cleanup( editor )
This function calls cleanup for all the nodes in the editor.
Must be called after evaluation is done, if Init was called.
addInput( editor, ConnectionType, name, InputEvent )
Add an input to the root node.
remInput( editor, input )
Remove an input from the root node.
addOutput( editor, ConnectionType, name )
Add an output to the input node.
remOutput( editor, output )
Remove an output from the input node.
setEnvGroup( editor, ChanGroupID )
Set the envelope group for the editor. All node envelope groups are parented into this group.
setAutosize( editor, AutoSizeFunc )
Set the autosize function for the editor.
setUserData( editor, userdata )
Set the userdata for this editor.
getUserData( editor )
Get the userdata from this editor.
numberOfNodes( editor )
Returns the number of nodes in this editor.
getInputByName( editor, inputname )
Get an input from the root node, by it's name.
getInputByIndex( editor, index )
Get an input from the root node, by it's index.
getState( editor )
Get the state. Enabled/Disabled.
setState( editor, state )
Set the state. 0 disables the rendering for this editor, and 1 enables it.
OpenNodeEditor( editor )
Open the editor window.
isOpenNodeEditor( editor )
Is the node editor open, and set to this NodeEditorID?
getRootNodeID( editor )
Get the NodeID of the root node from this editor.
getInputNodeID( editor )
Get the NodeID of the input node from this editor.
getEditorID( node )
Get a NodeEditorID for a NodeID.
connect( output, input )
Create a connection from the output to the input.
addNode( editor, servername )
Add a node to the flow using a server name.
destroyNode( node )
Destroy a node.
setXY( node, x, y )
Set the X and Y coordinates for the node.
setContext( editor, context)
Sets the context for the node editor to only display valid nodes with a matching SRVTAG_NODECONTEXT tag. Multiple tags may be used, separated with a "/" (forward slash).
getContext( editor )
Get the context for the node editor that was set with setContext.
usedItems( editor )
Get the array of all items used in all nodes for the editor. This can be used with the useItems callback for the plugin hosting the editor.

Example

The Node Displacement sample is a displacement plugin that utilises a node editor to create the displacement.