3ds Max C++ API Reference
BaseTranslator_INode Class Referenceabstract

Base class for translating an INode. More...

#include <BaseTranslator_INode.h>

+ Inheritance diagram for BaseTranslator_INode:

Public Member Functions

 BaseTranslator_INode (INode &node, const NotifierType notifierType, TranslatorGraphNode &graphNode)
 
 ~BaseTranslator_INode ()
 
virtual Interval CheckValidity (const TimeValue t, const Interval &previous_validity) const override
 Deferred checks whether this translator should be invalidated. More...
 
virtual void PreTranslate (const TimeValue translationTime, Interval &validity) override
 Called just before Translate() to enable pre-processing of any kind. More...
 
virtual void PostTranslate (const TimeValue translationTime, Interval &validity) override
 Called just after Translate() to enable post-processing of any kind. More...
 
virtual MtlResolveMaterial (Mtl *const mtl) const
 Resolves the given material by discarding any "wrapper" materials that should be ignored by the renderer. More...
 
- Public Member Functions inherited from Translator
 Translator (TranslatorGraphNode &graphNode)
 The constructor expects a reference to a TranslatorGraphNode. More...
 
virtual ~Translator ()
 
virtual TranslationResult Translate (const TimeValue translationTime, Interval &newValidity, ITranslationProgress &translationProgress, KeyframeList &keyframesNeeded)=0
 Performs the translation for which this class is responsible. More...
 
virtual TranslationResult TranslateKeyframe (const TimeValue frame_time, const TimeValue keyframe_time, ITranslationProgress &translationProgress)=0
 Performs translation for a single keyframe. More...
 
virtual void AccumulateStatistics (TranslatorStatistics &stats) const =0
 Called by the system to accumulate statistics on the translated scene. More...
 
void AccumulateGraphStatistics (TranslatorStatistics &statistics) const
 Accumulates statistics on the whole translate graph, starting at this translation node. More...
 
virtual MSTR GetTimingCategory () const =0
 Returns the string label to be used by the time reporting mechanism. More...
 
TranslatorGraphNode & GetGraphNode () const
 For internal use. More...
 

Static Public Member Functions

static MtlStaticResolveMaterial (Mtl *const mtl)
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Protected Member Functions

MotionTransforms EvaluateTransforms (const TimeValue t, Interval &validity) const
 Evaluates and returns the transform matrices for this INode. More...
 
INodeGetNode () const
 Returns the node being handled by this translator. More...
 
MtlGetMaterial () const
 Returns the material assigned to the node, resolving any wrapper materials in the process (e.g. Shell material, scripted material). More...
 
std::shared_ptr< const TranslationHelpers::INodeInstancingPoolGetNodePool (const TimeValue t)
 Returns the node pool to which this node belongs, useful for translating the node's Object with support for instances. More...
 
virtual bool CareAboutNotificationEvent (const NodeEventType eventType) const
 Enables the implementation to override what notification messages it wants to invalidate this translator. More...
 
virtual bool CareAboutRenderProperty (const PartID render_property_id) const
 Enables the implementation to specify to determine whether it cares about a specific node property changing. More...
 
virtual bool CareAboutDisplayProperty (const PartID display_property_id) const
 Enables the implementation to specify to determine whether it cares about a specific node property changing. More...
 
virtual bool CareAboutGIProperty (const PartID gi_property_id) const
 Enables the implementation to specify to determine whether it cares about a specific node property changing. More...
 
virtual bool CareAboutMissingUVWChannels () const =0
 Returns whether this translator translates a mesh for which we need to care if UVW channels are required by the material but missing on the mesh. More...
 
virtual std::vector< unsigned intGetMeshUVWChannelIDs () const =0
 Returns the UVW channel IDs which are used by the mesh that this node references. More...
 
virtual std::vector< MtlIDGetMeshMaterialIDs () const =0
 Returns the set of material IDs referenced by this mesh. More...
 
virtual void NotificationCallback_NotifyEvent (const IGenericEvent &genericEvent, void *userData) override final
 Called to process an event. More...
 
virtual void NotifyCameraChanged () final
 Notifies that something has changed in the camera. More...
 
virtual void NotifyPoolInstancedObjectChanged (const TranslationHelpers::INodeInstancingPool &node_pool, const NodeEventType event_type) override
 Notifies that the object, being instanced by the pool, has changed and needs to be re-translated. More...
 
virtual void NotifyPoolContentMaybeChanged (const TranslationHelpers::INodeInstancingPool &node_pool) override
 Notifies that the set of nodes, contained in the pool, may have changed. More...
 
- Protected Member Functions inherited from Translator
template<typename TranslatorType >
const TranslatorType * AcquireChildTranslator (const TranslatorKey &key, const TimeValue t, ITranslationProgress &translation_progress, TranslationResult &result)
 Acquires a dependency to a another translator and its outputs. More...
 
void Invalidate (const bool defer_invalidation_check=false)
 Invalidates this translator, typically as a result of a change notification callback. More...
 
void InvalidateParents ()
 Invalidates all parents of this translator. More...
 
void TranslatedObjectDeleted ()
 Flags the objects/inputs, being translated by this translated, as having been deleted. More...
 
IRenderSessionContextGetRenderSessionContext ()
 Returns the render session context for which this translator was created. More...
 
const IRenderSessionContextGetRenderSessionContext () const
 Returns the render session context for which this translator was created. More...
 
size_t GetNumOutputs () const
 Returns the number of outputs that are present on this translator. More...
 
template<typename OutputType >
std::shared_ptr< const OutputType > GetOutput (const size_t index) const
 Returns the output at the given index, dynamically cast to the given sub-class of ITranslatorOutput. More...
 
void SetNumOutputs (const size_t num)
 Initializes the size of the internal array, used to store the outputs. More...
 
void SetOutput (const size_t index, std::shared_ptr< const ITranslatorOutput > output)
 Initializes the output, at the given index, to the given value. More...
 
void ResetOutput (const size_t index)
 Deletes the output at the given index, such that GetOutput() will henceforth return null. More...
 
void ResetAllOutputs ()
 Deletes all outputs. More...
 
template<typename SimpleValueType >
void SetOutput_SimpleValue (const size_t output_index, const SimpleValueType &value)
 Shortcut method to initialize outputs which map to simple types that require no external cleanup code. More...
 
template<typename SimpleValueType >
SimpleValueType GetOutput_SimpleValue (const size_t output_index, const SimpleValueType &default_value) const
 Returns an output initialized using SetOutput_SimpleValue(). More...
 
- Protected Member Functions inherited from Noncopyable
 Noncopyable ()
 
 ~Noncopyable ()
 
- Protected Member Functions inherited from INotificationCallback
virtual ~INotificationCallback ()
 
- Protected Member Functions inherited from ICameraContainer::IChangeNotifier
virtual ~IChangeNotifier ()
 Protected destructor prevents deletion through this interface. More...
 

Protected Attributes

MotionBlurSettings m_last_translated_motion_settings
 

Additional Inherited Members

- Public Types inherited from Translator
typedef std::set< TimeValueKeyframeList
 

Detailed Description

Base class for translating an INode.

This base class provides basic, common functionality related to translating an INode. It handles:

  • Monitoring the INode and invalidating the translator on any changes.
  • Calling RenderBegin() on the INode before translation.
  • Evaluation of the node transform matrices and properties.

Constructor & Destructor Documentation

◆ BaseTranslator_INode()

BaseTranslator_INode ( INode node,
const NotifierType  notifierType,
TranslatorGraphNode &  graphNode 
)
Parameters
nodeThe node to be translated.
notifierTypeThe node's notifier type, to be used with the Notification System.
graphNodeThe graph node to be passed to Translator::Translator().

◆ ~BaseTranslator_INode()

Member Function Documentation

◆ CheckValidity()

virtual Interval CheckValidity ( const TimeValue  t,
const Interval previous_validity 
) const
overridevirtual

Deferred checks whether this translator should be invalidated.

Used in combination with a call to Invalidate(true), this method is called when checking the scene validity to see if this translator should be deferred invalidated. Deferred invalidation is necessary if the translator requires access to the scene to determine if it is in fact invalid. Accessing the scene within notification callbacks is generally unsafe, as some notifications are sent while the scene is in an intermediate state.

Parameters
tThe time at which the validity check is performed.
previous_validityThe current validity interval interval of the translator.
Returns
The new validity interval of the translator; empty if the translator is to be invalidated outright. Return previous_validity to leave the translator's validity as-is.

Implements Translator.

◆ PreTranslate()

virtual void PreTranslate ( const TimeValue  translationTime,
Interval validity 
)
overridevirtual

Called just before Translate() to enable pre-processing of any kind.

This method is to be used to perform per-processing that needs to happen before Translate() is called. A separate method is needed in case the class hierarchy results in a sub-classes Translate() being called before this class. Example uses of this method include calling IRenderSessionContext::CallRenderBegin() or MtlBase::Update().

Parameters
translationTimeThe time at which Translate() is about to be called.
[in,out]validityThe validity of the translator, to be intersected with the input value. The translator will be re-translated whenever the current time value falls outside of this validity.

Implements Translator.

◆ PostTranslate()

virtual void PostTranslate ( const TimeValue  translationTime,
Interval validity 
)
overridevirtual

Called just after Translate() to enable post-processing of any kind.

The principle is identical to that of PreTranslate(), except that this method is called immediately after the call to Translate().

Parameters
translationTimeThe time at which Translate() was just called.
[in,out]validityThe validity of the translator, to be intersected with the input value. The translator will be re-translated whenever the current time value falls outside of this validity.
Remarks
This method is called regardless of the return value of Translate().

Implements Translator.

◆ ResolveMaterial()

virtual Mtl* ResolveMaterial ( Mtl *const  mtl) const
virtual

Resolves the given material by discarding any "wrapper" materials that should be ignored by the renderer.

For example, in the case of a Shell material, this returns the Shell's sub-material that is flagged for rendering. This method may be overridden if necessary, to add support for renderer-specific behaviour.

Parameters
mtlThe material to be resolved (or un-wrapped).
Returns
The resolved material, free of wrappers which the renderer may not understand directly.

◆ StaticResolveMaterial()

static Mtl* StaticResolveMaterial ( Mtl *const  mtl)
static

◆ EvaluateTransforms()

MotionTransforms EvaluateTransforms ( const TimeValue  t,
Interval validity 
) const
protected

Evaluates and returns the transform matrices for this INode.

The evaluation takes into account the current motion blur parameters, from the INode and from the scene. The two transforms will be identical if and only motion blur is disabled for the INode.

Parameters
tThe time at which to evaluate the node transforms.
[in,out]validityThe validity interval of the node transforms will be intersected into this one.

◆ GetNode()

INode& GetNode ( ) const
protected

Returns the node being handled by this translator.

◆ GetMaterial()

Mtl* GetMaterial ( ) const
protected

Returns the material assigned to the node, resolving any wrapper materials in the process (e.g. Shell material, scripted material).

◆ GetNodePool()

std::shared_ptr<const TranslationHelpers::INodeInstancingPool> GetNodePool ( const TimeValue  t)
protected

Returns the node pool to which this node belongs, useful for translating the node's Object with support for instances.

A single Object need be translated for every node pool. The node pool may change between translations and therefore must be queried every time.

Parameters
tThe time used when evaluating the node to construct the instancing pool.
See also
INodeInstancingPool::IManagerGetPoolForNode()

◆ CareAboutNotificationEvent()

virtual bool CareAboutNotificationEvent ( const NodeEventType  eventType) const
protectedvirtual

Enables the implementation to override what notification messages it wants to invalidate this translator.

Parameters
eventTypeThe event type to potentially filter.
Returns
True if the event needs to evaluate this translator, false otherwise - in which case the event is ignored.

◆ CareAboutRenderProperty()

virtual bool CareAboutRenderProperty ( const PartID  render_property_id) const
protectedvirtual

Enables the implementation to specify to determine whether it cares about a specific node property changing.

This method covers the properties PART_REND_PROP_*.

◆ CareAboutDisplayProperty()

virtual bool CareAboutDisplayProperty ( const PartID  display_property_id) const
protectedvirtual

Enables the implementation to specify to determine whether it cares about a specific node property changing.

This method covers the properties PART_DISP_PROP_*.

◆ CareAboutGIProperty()

virtual bool CareAboutGIProperty ( const PartID  gi_property_id) const
protectedvirtual

Enables the implementation to specify to determine whether it cares about a specific node property changing.

This method covers the properties PART_GI_*.

◆ CareAboutMissingUVWChannels()

virtual bool CareAboutMissingUVWChannels ( ) const
protectedpure virtual

Returns whether this translator translates a mesh for which we need to care if UVW channels are required by the material but missing on the mesh.

These missing UVW channels will be automatically reported by the system.

See also
GetMeshUVWChannelIDs()
GetMeshMaterialIDs()

◆ GetMeshUVWChannelIDs()

virtual std::vector<unsigned int> GetMeshUVWChannelIDs ( ) const
protectedpure virtual

Returns the UVW channel IDs which are used by the mesh that this node references.

This is used to determine whether the node's material is dependent on any missing channels, for error reporting purposes. This is called in PostTranslate(), so it's recommended tha the list of UVW channels IDs be cached during the translation of the object.

Remarks
This is only called if CareAboutMissingUVWChannels() returns true.

◆ GetMeshMaterialIDs()

virtual std::vector<MtlID> GetMeshMaterialIDs ( ) const
protectedpure virtual

Returns the set of material IDs referenced by this mesh.

This is used to determine whether the node's material is dependent on any missing channels, for error reporting purposes.

Remarks
This is only called if CareAboutMissingUVWChannels() returns true.

◆ NotificationCallback_NotifyEvent()

virtual void NotificationCallback_NotifyEvent ( const IGenericEvent genericEvent,
void userData 
)
finaloverrideprotectedvirtual

Called to process an event.

Note that it is possible to monitor and stop monitoring events from within this notification callback. The notification system is specifically built to handle that.

Parameters
genericEventthe event in question
userDatathe user data passed to the Monitor*() call on notification client.

Implements INotificationCallback.

◆ NotifyCameraChanged()

virtual void NotifyCameraChanged ( )
finalprotectedvirtual

Notifies that something has changed in the camera.

Implements ICameraContainer::IChangeNotifier.

◆ NotifyPoolInstancedObjectChanged()

virtual void NotifyPoolInstancedObjectChanged ( const TranslationHelpers::INodeInstancingPool node_pool,
const NodeEventType  event_type 
)
overrideprotectedvirtual

Notifies that the object, being instanced by the pool, has changed and needs to be re-translated.

For example, would be called if the mesh of the instanced object were to change.

Parameters
node_poolThe pool which is sending the notification.
event_typeThe type of event that triggered this notification.

Implements INodeInstancingPool::INotifier.

◆ NotifyPoolContentMaybeChanged()

virtual void NotifyPoolContentMaybeChanged ( const TranslationHelpers::INodeInstancingPool node_pool)
overrideprotectedvirtual

Notifies that the set of nodes, contained in the pool, may have changed.

This method notifies that some nodes may have been added or removed to/from the pool. We say may have changed, because it's impossible to know for sure at this point due to node evaluations being disallowed (unsafe) in notification callbacks. The listener should use a deferred validity check (i.e. call Translator::Invalidte(true)) and later re-acquire the pool for the node being cared for. This re-acquisition of the pool will cause the nodes to be re-evaluated and the pools to be re-built accordingly.

Parameters
node_poolThe pool which is sending the notification.

Implements INodeInstancingPool::INotifier.

Member Data Documentation

◆ m_last_translated_motion_settings

MotionBlurSettings m_last_translated_motion_settings
mutableprotected