Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ if doConfigure :
nukePythonSources = sorted( glob.glob( "src/IECoreNuke/bindings/*.cpp" ) )
nukePythonScripts = glob.glob( "python/IECoreNuke/*.py" )
nukePluginSources = sorted( glob.glob( "src/IECoreNuke/plugin/*.cpp" ) )
nukeNodeNames = [ "ieObject", "ieOp", "ieDrawable", "ieDisplay" ]
nukeNodeNames = [ "ieObject", "ieOp", "ieDrawable", "ieDisplay", "ieLiveScene", "sccWriter" ]

# nuke library
nukeEnv.Append( LIBS = [ "boost_signals" + env["BOOST_LIB_SUFFIX"] ] )
Expand Down Expand Up @@ -2717,7 +2717,12 @@ if doConfigure :
for nodeName in nukeNodeNames :

nukeStubEnv = nukePluginEnv.Clone( IECORE_NAME=nodeName )
nukeStubName = "plugins/nuke/" + os.path.basename( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ) + ".tcl"
# In order to have our custom file format (scc) displayed in the file_type knob of the WriteGeo node, we need to install
# a dummy library with "[fileExtension]Writer"
if nodeName == "sccWriter":
nukeStubName = "plugins/nuke/" + os.path.basename( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME$SHLIBSUFFIX" ) )
else:
nukeStubName = "plugins/nuke/" + os.path.basename( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ) + ".tcl"
nukeStub = nukePluginEnv.Command( nukeStubName, nukePlugin, "echo 'load ieCore' > $TARGET" )
nukeStubInstall = nukeStubEnv.Install( os.path.dirname( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ), nukeStub )
nukeStubEnv.Alias( "install", nukeStubInstall )
Expand Down
9 changes: 9 additions & 0 deletions include/IECoreNuke/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,21 @@ IECORENUKE_API Imath::M44f convert( const DD::Image::Matrix4 &from );
template<>
IECORENUKE_API Imath::M44d convert( const DD::Image::Matrix4 &from );

template<>
IECORENUKE_API DD::Image::Matrix4 convert( const Imath::M44d &from );

template<>
IECORENUKE_API Imath::Box2i convert( const DD::Image::Box &from );

template<>
IECORENUKE_API DD::Image::Box3 convert( const Imath::Box3f &from );

template<>
IECORENUKE_API Imath::Box3f convert( const DD::Image::Box3 &from );

template<>
IECORENUKE_API Imath::Box3d convert( const DD::Image::Box3 &from );

} // namespace IECore

#endif // IECORENUKE_CONVERT_H
132 changes: 132 additions & 0 deletions include/IECoreNuke/LiveScene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IECORENUKE_LIVESCENE_H
#define IECORENUKE_LIVESCENE_H

#include "DDImage/GeoOp.h"
#include "DDImage/GeometryList.h"

#include "IECore/PathMatcher.h"

#include "IECoreScene/SceneInterface.h"

#include "IECoreNuke/Export.h"
#include "IECoreNuke/TypeIds.h"

namespace IECoreNuke
{

IE_CORE_FORWARDDECLARE( LiveScene );

/// A read-only class for representing a live Nuke scene as an IECore::SceneInterface
class IECORENUKE_API LiveScene : public IECoreScene::SceneInterface
{
public :

static const std::string& nameAttribute;

IE_CORE_DECLARERUNTIMETYPEDEXTENSION( LiveScene, LiveSceneTypeId, IECoreScene::SceneInterface );

LiveScene();
LiveScene( DD::Image::GeoOp *op, const std::string rootPath="/" );

~LiveScene() override;

std::string fileName() const override;

Name name() const override;
void path( Path &p ) const override;

Imath::Box3d readBound( double time ) const override;
void writeBound( const Imath::Box3d &bound, double time );

IECore::ConstDataPtr readTransform( double time ) const override;
Imath::M44d readTransformAsMatrix( double time ) const override;
IECore::ConstDataPtr readWorldTransform( double time ) const;
Imath::M44d readWorldTransformAsMatrix( double time ) const;
void writeTransform( const IECore::Data *transform, double time ) override;

bool hasAttribute( const Name &name ) const override;
void attributeNames( NameList &attrs ) const override;
IECore::ConstObjectPtr readAttribute( const Name &name, double time ) const override;
void writeAttribute( const Name &name, const IECore::Object *attribute, double time ) override;

bool hasTag( const Name &name, int filter = SceneInterface::LocalTag ) const override;
void readTags( NameList &tags, int filter = SceneInterface::LocalTag ) const override;
void writeTags( const NameList &tags ) override;

NameList setNames( bool includeDescendantSets = true ) const override;
IECore::PathMatcher readSet( const Name &name, bool includeDescendantSets = true, const IECore::Canceller *canceller = nullptr ) const override;
void writeSet( const Name &name, const IECore::PathMatcher &set ) override;
void hashSet( const Name& setName, IECore::MurmurHash &h ) const override;

bool hasObject() const override;
IECore::ConstObjectPtr readObject( double time, const IECore::Canceller *canceller = nullptr ) const override;
IECoreScene::PrimitiveVariableMap readObjectPrimitiveVariables( const std::vector<IECore::InternedString> &primVarNames, double time ) const override;
void writeObject( const IECore::Object *object, double time ) override;

void childNames( NameList &childNames ) const override;
bool hasChild( const Name &name ) const override;
IECoreScene::SceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override;
IECoreScene::ConstSceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override;
IECoreScene::SceneInterfacePtr createChild( const Name &name ) override;

IECoreScene::SceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override;
IECoreScene::ConstSceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override;

void hash( HashType hashType, double time, IECore::MurmurHash &h ) const override;

static double timeToFrame( const double& time );
static double frameToTime( const int& frame );

private:

DD::Image::GeoOp *op() const;
DD::Image::GeometryList geometryList( const double* time=nullptr ) const;

std::string geoInfoPath( const int& index ) const;

DD::Image::GeoOp *m_op;
std::string m_rootPath;
IECore::PathMatcher m_pathMatcher;
typedef std::map<unsigned, std::string> objectPathMap;
mutable objectPathMap m_objectPathMap;
};

IE_CORE_DECLAREPTR( LiveScene );

} // namespace IECoreNuke

#endif // IECORENUKE_LIVESCENE_H
70 changes: 70 additions & 0 deletions include/IECoreNuke/LiveSceneHolder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IECORENUKE_LIVESCENEHOLDER_H
#define IECORENUKE_LIVESCENEHOLDER_H

#include "DDImage/GeoOp.h"

#include "IECoreNuke/Export.h"
#include "IECoreNuke/LiveScene.h"


namespace IECoreNuke
{

/// This Op does no processing, but simply provides a single LiveSceneKnob.
/// This is mainly used for the LiveSceneKnob test cases.
class IECORENUKE_API LiveSceneHolder : public DD::Image::GeoOp
{

public :

LiveSceneHolder( Node *node );
virtual ~LiveSceneHolder();

virtual void knobs( DD::Image::Knob_Callback f );
virtual const char *Class() const;
virtual const char *node_help() const;

private :

static const Description g_description;
static DD::Image::Op *build( Node *node );

};

} // namespace IECoreNuke

#endif // IECORENUKE_LIVESCENEHOLDER_H
94 changes: 94 additions & 0 deletions include/IECoreNuke/LiveSceneKnob.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IECORENUKE_LIVESCENEKNOB_H
#define IECORENUKE_LIVESCENEKNOB_H

#include "IECoreNuke/Export.h"

#include "IECoreNuke/LiveSceneHolder.h"
#include "IECoreNuke/LiveScene.h"

IECORE_PUSH_DEFAULT_VISIBILITY
#include "DDImage/Knobs.h"
IECORE_POP_DEFAULT_VISIBILITY

namespace IECoreNuke
{

/// A nuke knob capable of holding arbitrary IECore::LiveScenes.
class IECORENUKE_API LiveSceneKnob : public DD::Image::Knob
{

public :

IECoreNuke::LiveScenePtr getValue();

/// Call this from an Op::knobs() implementation to create an LiveSceneKnob.
static LiveSceneKnob *sceneKnob( DD::Image::Knob_Callback f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label );

protected :

LiveSceneKnob( DD::Image::Knob_Closure *f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label = 0 );
virtual ~LiveSceneKnob();

virtual const char *Class() const;

private :

IECoreNuke::LiveScenePtr m_value;
IECoreNuke::LiveSceneHolder* m_op;

};

namespace Detail
{

// Used to implement the python binding
struct PythonLiveSceneKnob : public IECore::RefCounted
{

IE_CORE_DECLAREMEMBERPTR( PythonLiveSceneKnob );

LiveSceneKnob *sceneKnob;

};

IE_CORE_DECLAREPTR( PythonLiveSceneKnob );

} // namespace Detail

} // namespace IECoreNuke

#endif // IECORENUKE_LIVESCENEKNOB_H
2 changes: 2 additions & 0 deletions include/IECoreNuke/SceneCacheReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class IECORENUKE_API SceneCacheReader : public DD::Image::SourceGeo

// only the first reader allocates the shared data
SharedData *m_data;

std::map<int, DD::Image::Matrix4> m_indexToWorldTransform;
};

} // namespace IECoreNuke
Expand Down
Loading