3ds Max C++ API Reference
INodePropertyManager Class Referenceabstract

The INodePropertyManager class manages properties that OSL is interested in. More...

#include <MaxOSLInterface.h>

Public Member Functions

virtual NodeProperties GetProperties (INode *node) const =0
 Get the properties for a particular INode. More...
 
virtual bool IsEnabled () const =0
 Check if the property manager is "enabled" from 3dsmax.ini. More...
 
virtual void Invalidate (INode *node)=0
 Invalidates the cache for a particular INode, or if NULL is passed, the cache for everything. More...
 

Detailed Description

The INodePropertyManager class manages properties that OSL is interested in.

This class manages properties attached to INode's (also known as "object properties" although they are actually on the object instance - i.e. INode). This contains both the 'standard' properties like 'nodeHandle' and 'wireColor' but also any user-properties the user has added in the Object Property dialog. The latter has names prepended by the string "usr_".

Pass in an INode and get the NodeProperties class back, which contains the mapping of properties. There are two options:

  • if your renderer is attaching properties e.g. to an internal mesh representation or scene database at scene translation time, use NodeProperties::GetNames() to retrieve the list of property names, and then iterate over them and call NodeProperties::GetValue(name) for each.
  • one can also look these up at render time, by directly calling NodeProperties::GetValue(name) from inside your renderer's OSL implementation of the getattribute() call.
    The lookup is using a fast hash table, so getting the value at render time should be reasonably performant, especially if the string is already a ustring and the is_ustring parameter is set to true. This is what Max's internal OSL implementation does.

The INodePropertyManager is retrieved from the IOSLGlobalInterface pointer, and the values are then directly looked up in the INodeProperty's value member (pseudocode, example lacks error checking):

INode *my_node = ....
// These are both pointers to static global singletons,
// so one only need to retrieve these values once...
auto inp = ifp->GetINodePropertyManager();
// Get the properties for this node
auto prop = inp->GetProperties(my_node);
// Example of getting the "nodeHandle" property
auto val = prop.GetValue("nodeHandle");
int nodeHandle = 0;
val.GetInt(&nodeHandle);
#define MAXOSL_GLOBAL_INTERFACE
Interface ID for the 3ds Max OSL global interface.
Definition: MaxOSLInterface.h:26
Definition: inode.h:55
Interface for the 3ds Max OSL global interface.
Definition: MaxOSLInterface.h:174
CoreExport Interface * GetCOREInterface()

A slightly more optimized version could do this:

// Lookup the ustring version of the pointer once only, since the
// same pointer value will forever be used for that particular text
// string, and OSL is internally only dealing with ustring values.
static const char *nodeHandleUString = ifp->GetUString("nodeHandle");
// Do the actual value lookup passing the ustring version, and setting
// is_ustring to true. This skips a string hashing step and additional
// lookup that would otherwise happen, and is much more run-time efficient
auto val = prop.GetValue(nodeHandleUstring, true);
See also
Class NodeProperties, Class INodePropertyValue

Member Function Documentation

◆ GetProperties()

virtual NodeProperties GetProperties ( INode node) const
pure virtual

Get the properties for a particular INode.

◆ IsEnabled()

virtual bool IsEnabled ( ) const
pure virtual

Check if the property manager is "enabled" from 3dsmax.ini.

This flag is informational, and might be deprecated.

For the Scanline renderer implementation this being false means that it will not use the property manager. It doesn't in any way deactivate the use of these classes.

◆ Invalidate()

virtual void Invalidate ( INode node)
pure virtual

Invalidates the cache for a particular INode, or if NULL is passed, the cache for everything.

The cache will be automagically rebuilt on the fly upon access.