#include <SceneLoaderOpI.h>
Public Member Functions | |
SceneLoaderOpI (bool importEnabled=false) | |
virtual Op * | getSceneLoaderOp ()=0 |
Return the Op the interface is attached to. Should return 'this'. Must implement. | |
virtual SceneLoaderOpI * | asSceneLoader () |
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 AxisOp * | asAxisLoaderOp () |
If loader is attached to an AxisOp subclass return 'this'. Default returns nullptr. | |
virtual CameraOp * | asCameraLoaderOp () |
If loader is attached to a CameraOp subclass return 'this'. Default returns nullptr. | |
virtual LightOp * | asLightLoaderOp () |
If loader is attached to a LightOp subclass return 'this'. Default returns nullptr. | |
virtual Iop * | asGeomLoaderIop () |
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 ×, 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. | |
Interface class for abstracting Ops which can import 3D scene prim data.
|
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().
|
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().
|
inlinevirtual |
If loader is attached to an AxisOp subclass return 'this'. Default returns nullptr.
Reimplemented in DD::Image::AxisOp.
|
inlinevirtual |
If loader is attached to a CameraOp subclass return 'this'. Default returns nullptr.
Reimplemented in DD::Image::CameraOp.
|
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().
|
protectedvirtual |
Call this from owner Op::knob_changed(). Updates loader gui and does node data reloads.
References _importerEnabled, enableSceneLoaderKnobs(), enableXformExtractKnobs(), DD::Image::ValueStuffI::get_value(), getSceneLoaderOp(), DD::Image::Knob::inputChange, DD::Image::Op::knob(), DD::Image::Op::script_command(), DD::Image::Op::script_result(), DD::Image::Op::script_unlock(), DD::Image::Knob::showPanel, and updateScenePrim().
|
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().
|
virtual |
Adds the scene import controls. filters sets a custom filter to use on the scene prim popup. If addXformOptions is true the knobs to control local parent extraction matrix decomposition options, etc are added. If addTimeOption is true the knobs to control frame offset and fps during import are added. Call this from owner Op::knobs().
References _importer, _importerEnabled, addSceneLoaderTimeOptionKnobs(), addSceneLoaderXformOptionKnobs(), DD::Image::BeginClosedGroup(), DD::Image::Bool_knob(), DD::Image::ClearFlags(), DD::Image::Knob::DISABLED, DD::Image::Divider(), DD::Image::Knob::DO_NOT_WRITE, DD::Image::Knob::EARLY_STORE, DD::Image::EndGroup(), DD::Image::Knob::ENDLINE, DD::Image::Enumeration_knob(), DD::Image::File_knob(), DD::Image::Int_knob(), DD::Image::INVISIBLE, DD::Image::Knob::KNOB_CHANGED_ALWAYS, DD::Image::Knob::NO_ANIMATION, DD::Image::Knob::NO_MULTIVIEW, DD::Image::Knob::NO_UNDO, DD::Image::Obsolete_knob(), DD::Image::Path_knob(), sceneLoaderSourceInput(), DD::Image::Script_knob(), DD::Image::SetFlags(), DD::Image::Knob::SHOW_SCENE_PICK_BUTTON, DD::Image::Knob::STARTLINE, and DD::Image::Tooltip().
Referenced by DD::Image::AxisOp::addImportOptionsKnobs(), and DD::Image::AxisOp::createAxisOpKnobs().
|
virtual |
Enable/disable knobs filled in by the scene importer.
Reimplemented in DD::Image::AxisOp.
References DD::Image::Knob::enable(), DD::Image::ValueStuffI::get_value(), getSceneLoaderOp(), and DD::Image::Op::knob().
Referenced by _sceneLoaderKnobChanged(), and DD::Image::AxisOp::enableSceneLoaderKnobs().
|
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().
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().
|
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().
|
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().
|
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().
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.
|
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. |