Nuke binary plugins 16.0.1
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
DD::Image::SceneLoaderOpI Class Referenceabstract

#include <SceneLoaderOpI.h>

Inheritance diagram for DD::Image::SceneLoaderOpI:
DD::Image::AxisOp DD::Image::CameraOp DD::Image::LightOp DD::Image::ComplexLightOp

Public Member Functions

 SceneLoaderOpI (bool importEnabled=false)
 
virtual OpgetSceneLoaderOp ()=0
 Return the Op the interface is attached to. Should return 'this'. Must implement.
 
virtual SceneLoaderOpIasSceneLoader ()
 Allow subclasses to gain access to sibling functions.
 
virtual bool isSceneLoaderEnabled ()
 Is loader enabled? Base class returns the state of the 'import_enabled' knob.
 
virtual int32_t sceneLoaderSourceInput () const
 
virtual const char * defaultSceneLoaderPrimType ()
 Return the scene prim type to use when searching for a default to load - ie 'Camera', 'Xform', etc.
 
virtual AxisOpasAxisLoaderOp ()
 If loader is attached to an AxisOp subclass return 'this'. Default returns nullptr.
 
virtual CameraOpasCameraLoaderOp ()
 If loader is attached to a CameraOp subclass return 'this'. Default returns nullptr.
 
virtual LightOpasLightLoaderOp ()
 If loader is attached to a LightOp subclass return 'this'. Default returns nullptr.
 
virtual IopasGeomLoaderIop ()
 If loader is attached to an Iop subclass return 'this'. Default returns nullptr.
 
virtual void addSceneLoaderKnobs (Knob_Callback f, const std::string &filters, bool addTimeOption, bool addXformOptions=false)
 
virtual void addSceneLoaderTimeOptionKnobs (Knob_Callback f)
 Add time control knobs.
 
virtual void addSceneLoaderXformOptionKnobs (Knob_Callback f)
 Add xform decomposition control knobs.
 
virtual void enableSceneLoaderKnobs (bool importEnabled)
 Enable/disable knobs filled in by the scene importer.
 
virtual void enableSceneLoaderExtraKnobs (bool importEnabled)
 
virtual void enableXformExtractKnobs (bool xformExtractEnabled)
 Enable/disable knobs filled in by the xform decomposer.
 
int32_t updateScenePrim (bool force=false)
 
virtual int32_t importScenePrim (const usg::StageRef &stage, const std::string &primPath)=0
 
template<typename T >
size_t getAttribValuesTimeWarped (const usg::Attribute &attr, double attr_fps, fdk::TimeValueList &times, std::vector< T > &values) const
 
template<typename T >
bool copyAttribToKnobTimeWarped (const usg::Attribute &attr, double attr_fps, Knob *knob, bool force_keys, int32_t channel_start_offset, int32_t view) const
 
fdk::TimeValueList getOutputSampleTimes (const fdk::TimeValueList &input_times, double input_fps=0.0) const
 

Protected Member Functions

virtual void _loadSceneData (const OutputContext &storeContext, Hash &hash)
 
virtual int32_t _sceneLoaderKnobChanged (Knob *k, int32_t callAgain=0)
 
virtual void _validateSceneLoader (bool for_real)
 
virtual void _updateScenePrim (fdk::Hash &importHash)
 

Protected Attributes

ImporterControls _importer
 Scene prim importer controls & state.
 
bool _importerEnabled
 If true importer will extract prim attributes from scene source.
 
bool _importerInvalid
 If true any knobs set by the importer need to be re-stored.
 

Detailed Description

Interface class for abstracting Ops which can import 3D scene prim data.

Member Function Documentation

◆ getSceneLoaderOp()

virtual Op * DD::Image::SceneLoaderOpI::getSceneLoaderOp ( )
pure virtual

Return the Op the interface is attached to. Should return 'this'. Must implement.

Implemented in DD::Image::AxisOp.

Referenced by _loadSceneData(), _sceneLoaderKnobChanged(), _validateSceneLoader(), enableSceneLoaderKnobs(), enableXformExtractKnobs(), and updateScenePrim().

◆ sceneLoaderSourceInput()

virtual int32_t DD::Image::SceneLoaderOpI::sceneLoaderSourceInput ( ) const
inlinevirtual

Return the node input to use for the scene importer source which is usually a GeomOp. -1 indicates an internal importer implementation with no input connection. Default implementation returns -1.

Reimplemented in DD::Image::AxisOp.

Referenced by _loadSceneData(), addSceneLoaderKnobs(), and updateScenePrim().

◆ asAxisLoaderOp()

virtual AxisOp * DD::Image::SceneLoaderOpI::asAxisLoaderOp ( )
inlinevirtual

If loader is attached to an AxisOp subclass return 'this'. Default returns nullptr.

Reimplemented in DD::Image::AxisOp.

◆ asCameraLoaderOp()

virtual CameraOp * DD::Image::SceneLoaderOpI::asCameraLoaderOp ( )
inlinevirtual

If loader is attached to a CameraOp subclass return 'this'. Default returns nullptr.

Reimplemented in DD::Image::CameraOp.

◆ _loadSceneData()

void SceneLoaderOpI::_loadSceneData ( const OutputContext storeContext,
Hash hash 
)
protectedvirtual

Call this from owner Op::_knobStorePost() which is called after Op::knobs() but before Op::_validate(), and offers the loader a chance to confgure its input source(s) early (ie EARLY_STORE) and load the scene data.

If we end up loading a scene prim successfully there's a bunch of knobs who's contents will likely get changed, affecting the Op's local variables. But, since knobs() has already been called and the previously knobs stored at the prior values these vars are now out of date. This is a common Nuke issue when Knobs are changed outside the expected pattern, and is often experienced as an off-by-one delay in updating values when the Viewer changes frame, since changing the frame will force the knobs to store with their new contents, causing an update 'snap'.

The solution to this is to force the knobs to store after a known change has been applied, via Op::setKnobsToContext(force=true). That method will cause knobs() to be called again storing the new values, but that means Op::_knobStorePost() will also get called again, so we need to avoid a loop.

_importerInvalid is used to note whether we're in that second knobs() update cycle and avoid re-calling the loader again.

References _importer, _importerInvalid, getSceneLoaderOp(), DD::Image::Op::inputsValid(), DD::Image::Op::nodeName(), sceneLoaderSourceInput(), DD::Image::Op::setKnobsToContext(), and updateScenePrim().

Referenced by DD::Image::AxisOp::_knobStorePost().

◆ _sceneLoaderKnobChanged()

◆ _validateSceneLoader()

void SceneLoaderOpI::_validateSceneLoader ( bool  for_real)
protectedvirtual

Call this from owner Op::_validate(). Sets an error on owner Op if there is a loader error.

References _importer, DD::Image::Op::error(), and getSceneLoaderOp().

Referenced by DD::Image::AxisOp::_validate().

◆ addSceneLoaderKnobs()

void SceneLoaderOpI::addSceneLoaderKnobs ( Knob_Callback  f,
const std::string &  filters,
bool  addTimeOption,
bool  addXformOptions = false 
)
virtual

◆ enableSceneLoaderKnobs()

void SceneLoaderOpI::enableSceneLoaderKnobs ( bool  importEnabled)
virtual

◆ enableXformExtractKnobs()

void SceneLoaderOpI::enableXformExtractKnobs ( bool  xformExtractEnabled)
virtual

Enable/disable knobs filled in by the xform decomposer.

Reimplemented in DD::Image::AxisOp.

References DD::Image::Knob::enable(), getSceneLoaderOp(), and DD::Image::Op::knob().

Referenced by _sceneLoaderKnobChanged(), and DD::Image::AxisOp::enableXformExtractKnobs().

◆ updateScenePrim()

int32_t SceneLoaderOpI::updateScenePrim ( bool  force = false)

Check if the imported prim needs to be loaded or reloaded. If the prim needs reloading then importScenePrim() is called with the correct stage and prim path.

If force is true then the prim will always be reloaded.

Return codes: -1 - no prim data was loaded and no error (i.e. no change) 0 - prim data was loaded with no error 1 - there was an error and no prim data was loaded

If error was returned (1) check the error state and message in ScenePrimImport.

This should be called from an implemented Op::setOutputContext() method which get called immediately after Op::knobs() so that we can import and change knob contents BEFORE validate() is called.

This method will cause the scene prim to be loaded on initial script load, if knob values that affect the load state change, or if the input scene connection GeomState changes.

If force is true then importScenePrim() is always called, assuming there's a valid input stage.

References _importer, _importerEnabled, _updateScenePrim(), DD::Image::Op::append(), DD::Image::GeometryProviderI::buildStage(), DD::Image::Op::error(), getSceneLoaderOp(), importScenePrim(), DD::Image::Op::input(), DD::Image::Op::nodeName(), sceneLoaderSourceInput(), and DD::Image::Op::validate().

Referenced by _loadSceneData(), and _sceneLoaderKnobChanged().

◆ importScenePrim()

virtual int32_t DD::Image::SceneLoaderOpI::importScenePrim ( const usg::StageRef &  stage,
const std::string &  primPath 
)
pure virtual

Try to import prim data from the provided stage. Will return 1(error) if stage is invalid. If prim_path is empty then -1 will be returned indicating no change has occured, otherwise if prim_path is invalid or not present in stage then 1(error) will be returned.

Return codes: -1 - no prim data was loaded and no error, usually due to empty prim path 0 - prim data was loaded with no error 1 - there was an error and no prim data was loaded

Implemented in DD::Image::CameraOp, and DD::Image::AxisOp.

Referenced by updateScenePrim().

◆ getAttribValuesTimeWarped()

template<typename T >
size_t DD::Image::SceneLoaderOpI::getAttribValuesTimeWarped ( const usg::Attribute &  attr,
double  attr_fps,
fdk::TimeValueList &  times,
std::vector< T > &  values 
) const
inline

Retrieve the attribute values at times possibly modified by the importer time options. If there are no time samples in the attribute then only a single default-time value is returned, unaffected by the time options. If the output time of the samples have been affected the times array reflects the output time and not the time the attribute was sampled at.

If the importer is set to frame lock then only a single value is set, sampled at the lock time, regardless of the animation status of the attribute.

This method will always set at least one time and value if the attrib is valid.

Returns the number of value/times set, or 0 if there was a problem.

References _importer.

Referenced by copyAttribToKnobTimeWarped(), and DD::Image::CameraOp::importScenePrim().

◆ copyAttribToKnobTimeWarped()

template<typename T >
bool DD::Image::SceneLoaderOpI::copyAttribToKnobTimeWarped ( const usg::Attribute &  attr,
double  attr_fps,
Knob knob,
bool  force_keys,
int32_t  channel_start_offset,
int32_t  view 
) const
inline

Retrieve the attribute values at times possibly modified by the importer time options and save them into the target Knob. If force_keys is true then the Knob will have a keyframe set even if the sample attribute only has a default value (i.e. no time sample.) This likely only works for ArrayKnobs since they support animation. See Knob::set() for explanation of channel_start_offset and view options.

Returns true on success.

References _importer, getAttribValuesTimeWarped(), and DD::Image::Knob::set().

◆ getOutputSampleTimes()

TimeValueList SceneLoaderOpI::getOutputSampleTimes ( const fdk::TimeValueList &  input_times,
double  input_fps = 0.0 
) const

Generate output time values from an input time list using the current importer settings to possibly time warp / offset them. If no time change needed the returned times will be the input times. input_fps is only needed if this is changing the frame rate of the input samples. If left at the 0.0 default then no time warping is applied.

References _importer.

◆ _updateScenePrim()

virtual void DD::Image::SceneLoaderOpI::_updateScenePrim ( fdk::Hash &  importHash)
inlineprotectedvirtual

Subclass implementation of updateScenePrim(). If subclass has local values that should contribute to the import hash state which indicates if the scene needs reloading, it can append them to importHash. Default implementation does nothing.

Reimplemented in DD::Image::AxisOp.

Referenced by updateScenePrim().



©2025 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com