diff --git a/SConstruct b/SConstruct index 2370fb1e08..448708cac2 100644 --- a/SConstruct +++ b/SConstruct @@ -2445,7 +2445,6 @@ if doConfigure : houdiniTestEnv["ENV"]["HOUDINI_OTLSCAN_PATH"] = "./plugins/houdini:&" houdiniTestEnv["ENV"]["IECORE_OP_PATHS"] = "./test/IECoreHoudini/ops" - houdiniTestEnv["ENV"]["IECORE_PROCEDURAL_PATHS"] = "./test/IECoreHoudini/procedurals" houdiniPythonExecutable = "hython" diff --git a/include/IECoreHoudini/GEO_CortexPrimitive.h b/include/IECoreHoudini/GEO_CortexPrimitive.h index b4a5d2e1aa..674a567bb0 100644 --- a/include/IECoreHoudini/GEO_CortexPrimitive.h +++ b/include/IECoreHoudini/GEO_CortexPrimitive.h @@ -143,8 +143,7 @@ class GEO_CortexPrimitive : public GEO_Primitive virtual int intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1 ) const; /// Set the IECore::Object contained by this GEO_Primitive. Note that in most situations - /// this method takes a copy of the object. However, for ParameterisedProcedurals it does - /// not, and it is the users responsibility to treat the contained object as const. + /// this method takes a copy of the object. void setObject( const IECore::Object *object ); /// Get the IECore::Object contained by this GEO_Primitive const IECore::Object *getObject() const; diff --git a/include/IECoreHoudini/SOP_ProceduralHolder.h b/include/IECoreHoudini/SOP_ProceduralHolder.h deleted file mode 100644 index e224732e48..0000000000 --- a/include/IECoreHoudini/SOP_ProceduralHolder.h +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2012, 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 IECOREHOUDINI_SOPPROCEDURALHOLDER_H -#define IECOREHOUDINI_SOPPROCEDURALHOLDER_H - -#ifdef IECOREHOUDINI_WITH_GL - - #include "IECoreGL/Scene.h" - -#endif - -#include "IECoreHoudini/SOP_ParameterisedHolder.h" - -namespace IECoreHoudini -{ - -/// SOP class for representing a IECore::ParameterisedProcedural in Houdini -class SOP_ProceduralHolder : public SOP_ParameterisedHolder -{ - public : - - /// standard houdini ctor and parameter variables - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - -#ifdef IECOREHOUDINI_WITH_GL - - /// returns a GL scene, rendering it if necessary - IECoreGL::ConstScenePtr scene(); - -#endif - - protected : - - SOP_ProceduralHolder( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_ProceduralHolder(); - - virtual OP_ERROR cookMySop( OP_Context &context ); - - private : - -#ifdef IECOREHOUDINI_WITH_GL - - // our cache GL scene - IECoreGL::ScenePtr m_scene; - -#endif - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPPROCEDURALHOLDER_H diff --git a/menus/IECoreHoudini/cortex.shelf b/menus/IECoreHoudini/cortex.shelf index d031e6d6f8..0d915e17a5 100644 --- a/menus/IECoreHoudini/cortex.shelf +++ b/menus/IECoreHoudini/cortex.shelf @@ -11,16 +11,6 @@ soptoolutils.genericTool(kwargs, 'ieOpHolder')]]> - - - - SOP - - Cortex - - - diff --git a/python/IECoreHoudini/FnProceduralHolder.py b/python/IECoreHoudini/FnProceduralHolder.py deleted file mode 100644 index c6837be585..0000000000 --- a/python/IECoreHoudini/FnProceduralHolder.py +++ /dev/null @@ -1,61 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2012, 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. -# -########################################################################## - -import hou - -import IECore -import IECoreHoudini - -class FnProceduralHolder( IECoreHoudini.FnParameterisedHolder ) : - - _nodeType = "ieProceduralHolder" - - @staticmethod - # see FnParameterisedHolder for a description of the parameters - def create( name, type, version=None, path="IECORE_PROCEDURAL_PATHS", parent=None, contextArgs={} ) : - - return IECoreHoudini.FnParameterisedHolder._doCreate( FnProceduralHolder._nodeType, name, type, version, path, parent, contextArgs ) - - ## Convenience method to call setParameterised with the environment variable - # for the searchpaths set to "IECORE_PROCEDURAL_PATHS". - def setProcedural( self, className, classVersion=None, updateGui=True ) : - - self.setParameterised( className, classVersion, "IECORE_PROCEDURAL_PATHS", updateGui ) - - def getProcedural( self ) : - - return self.getParameterised() diff --git a/python/IECoreHoudini/Utils.py b/python/IECoreHoudini/Utils.py index 5f7911d70c..79b680daf5 100644 --- a/python/IECoreHoudini/Utils.py +++ b/python/IECoreHoudini/Utils.py @@ -40,10 +40,6 @@ python module. ''' -# returns an instance of a procedural loaded using the defaultProceduralLoader -def proc(type, ver): - return IECore.ClassLoader.defaultProceduralLoader().load(type,ver)() - # returns an instance of an op loaded using the defaultOpLoader def op(type, ver): return IECore.ClassLoader.defaultOpLoader().load(type,ver)() @@ -126,14 +122,6 @@ def setHoudiniParm( node, p ): if p.typeId()==IECore.TypeId.Box3dParameter: node.parmTuple( "parm_%s" % p.name ).set( list(value) ) -# updates all the houdini parameters based on an Op/Procedural's parameter values -def syncSopParametersWithProcedural(n): - fn = IECoreHoudini.FnProceduralHolder( n ) - parms = fn.getParameterised().parameters().values() - for p in parms: - if n.parm("parm_%s"%p.name): - setHoudiniParm( n, p ) - def syncSopParametersWithOp(n): fn = IECoreHoudini.FnOpHolder( n ) parms = fn.getParameterised().parameters().values() @@ -141,36 +129,7 @@ def syncSopParametersWithOp(n): if n.parm("parm_%s"%p.name): setHoudiniParm( n, p ) -# reloads a procedural based on the values of the type/version parameters -# \todo: this can be combined with the reloadOp code -def reloadProcedural(): - n = hou.node(".") - type = n.evalParm("__opType") - ver = n.evalParm("__opVersion") - if type=="" or ver=="": - return - ver = int(ver) - fn = IECoreHoudini.FnProceduralHolder(n) - IECore.ClassLoader.defaultProceduralLoader().refresh() - cl = IECoreHoudini.proc( type, ver ) - - # cache our existing parameters - parms = fn.getParameterised().parameters().values() - saved_parms = {} - for p in parms: - saved_parms[p.name] = p.getValue().value - - # reload parameter interface - fn.setParameterised(cl) - - # restore parameter values - for p in saved_parms.keys(): - hparm = n.parm("parm_%s" % p) - if hparm: - hparm.set( saved_parms[p] ) - # reloads an op based on the values of the type/version parameters -# \todo: this can be combined with the reloadProc code def reloadOp(): n = hou.node(".") type = n.evalParm("__opType") diff --git a/python/IECoreHoudini/__init__.py b/python/IECoreHoudini/__init__.py index 9fcd2db79e..60bf2975cf 100644 --- a/python/IECoreHoudini/__init__.py +++ b/python/IECoreHoudini/__init__.py @@ -47,7 +47,6 @@ # function sets from FnParameterisedHolder import FnParameterisedHolder from FnOpHolder import FnOpHolder -from FnProceduralHolder import FnProceduralHolder # misc utility methods from TestCase import TestCase diff --git a/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp b/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp index 7dc24b3ba9..cc7b43466b 100644 --- a/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp +++ b/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp @@ -35,7 +35,6 @@ #include "boost/python.hpp" #include "IECore/CompoundObject.h" -#include "IECoreScene/ParameterisedProcedural.h" #include "IECoreHoudini/FromHoudiniCortexObjectConverter.h" #include "IECoreHoudini/GEO_CortexPrimitive.h" @@ -111,11 +110,6 @@ ObjectPtr FromHoudiniCortexObjectConverter::doDetailConversion( const GU_Detail if ( object ) { - if ( object->isInstanceOf( IECoreScene::ParameterisedProcedural::staticTypeId() ) ) - { - return boost::const_pointer_cast( object ); - } - return object->copy(); } diff --git a/src/IECoreHoudini/GEO_CortexPrimitive.cpp b/src/IECoreHoudini/GEO_CortexPrimitive.cpp index 627784bb64..4c8b228dcc 100644 --- a/src/IECoreHoudini/GEO_CortexPrimitive.cpp +++ b/src/IECoreHoudini/GEO_CortexPrimitive.cpp @@ -51,7 +51,6 @@ #include "IECoreScene/CoordinateSystem.h" #include "IECoreScene/Group.h" #include "IECoreScene/MatrixTransform.h" -#include "IECoreScene/ParameterisedProcedural.h" #include "IECoreScene/Primitive.h" #include "IECoreScene/TransformOp.h" #include "IECoreScene/VisibleRenderable.h" @@ -400,15 +399,8 @@ const IECore::Object *GEO_CortexPrimitive::getObject() const void GEO_CortexPrimitive::setObject( const IECore::Object *object ) { - if ( object->isInstanceOf( IECoreScene::ParameterisedProcedural::staticTypeId() ) ) - { - m_object = const_cast( object ); - } - else - { - /// \todo: should this be a deep copy? - m_object = object->copy(); - } + /// \todo: should this be a deep copy? + m_object = object->copy(); } const char *GEO_CortexPrimitive::typeName = "CortexObject"; diff --git a/src/IECoreHoudini/SOP_CortexConverter.cpp b/src/IECoreHoudini/SOP_CortexConverter.cpp index 02e18024de..289aa5e100 100644 --- a/src/IECoreHoudini/SOP_CortexConverter.cpp +++ b/src/IECoreHoudini/SOP_CortexConverter.cpp @@ -43,7 +43,6 @@ #include "IECoreScene/CapturingRenderer.h" #include "IECoreScene/Group.h" -#include "IECoreScene/ParameterisedProcedural.h" #include "IECoreScene/WorldBlock.h" #include "IECorePython/ScopedGILLock.h" #include "IECorePython/ScopedGILRelease.h" @@ -189,25 +188,6 @@ void SOP_CortexConverter::doConvert( const GU_DetailHandle &handle, const std::s return; } - if ( IECoreScene::ParameterisedProcedural *procedural = IECore::runTimeCast( result.get() ) ) - { - IECoreScene::CapturingRendererPtr renderer = new IECoreScene::CapturingRenderer(); - // We are acquiring and releasing the GIL here to ensure that it is released when we render. This has - // to be done because a procedural might jump between c++ and python a few times (i.e. if it spawns - // subprocedurals that are implemented in python). In a normal call to cookMySop, this wouldn't be an - // issue, but if cookMySop was called from HOM, hou.Node.cook appears to be holding onto the GIL. - IECorePython::ScopedGILLock gilLock; - { - IECorePython::ScopedGILRelease gilRelease; - { - IECoreScene::WorldBlock worldBlock( renderer ); - procedural->render( renderer.get() ); - } - } - - result = boost::const_pointer_cast( IECore::runTimeCast( renderer->world() ) ); - } - ToHoudiniGeometryConverterPtr converter = ( type == Cortex ) ? new ToHoudiniCortexObjectConverter( result.get() ) : ToHoudiniGeometryConverter::create( result.get() ); converter->nameParameter()->setTypedValue( name ); converter->attributeFilterParameter()->setTypedValue( attributeFilter ); diff --git a/src/IECoreHoudini/SOP_ParameterisedHolder.cpp b/src/IECoreHoudini/SOP_ParameterisedHolder.cpp index 5fef54913e..4b959b51fc 100644 --- a/src/IECoreHoudini/SOP_ParameterisedHolder.cpp +++ b/src/IECoreHoudini/SOP_ParameterisedHolder.cpp @@ -43,7 +43,6 @@ #include "IECore/Op.h" #include "IECoreScene/CapturingRenderer.h" #include "IECoreScene/Group.h" -#include "IECoreScene/ParameterisedProcedural.h" #include "IECoreScene/WorldBlock.h" #include "IECorePython/ScopedGILLock.h" @@ -184,26 +183,6 @@ void SOP_ParameterisedHolder::setInputParameterValue( IECore::Parameter *paramet { return; } - - if ( IECoreScene::ParameterisedProcedural *procedural = IECore::runTimeCast( result.get() ) ) - { - IECoreScene::CapturingRendererPtr renderer = new IECoreScene::CapturingRenderer(); - // We are acquiring and releasing the GIL here to ensure that it is released when we render. This has - // to be done because a procedural might jump between c++ and python a few times (i.e. if it spawns - // subprocedurals that are implemented in python). In a normal call to cookMySop, this wouldn't be an - // issue, but if cookMySop was called from HOM, hou.Node.cook appears to be holding onto the GIL. - IECorePython::ScopedGILLock gilLock; - { - IECorePython::ScopedGILRelease gilRelease; - { - IECoreScene::WorldBlock worldBlock( renderer ); - procedural->render( renderer.get() ); - } - } - - result = boost::const_pointer_cast( IECore::runTimeCast( renderer->world() ) ); - } - parameter->setValidatedValue( result ); } catch ( const IECore::Exception &e ) diff --git a/src/IECoreHoudini/SOP_ProceduralHolder.cpp b/src/IECoreHoudini/SOP_ProceduralHolder.cpp deleted file mode 100644 index 97f18d80b6..0000000000 --- a/src/IECoreHoudini/SOP_ProceduralHolder.cpp +++ /dev/null @@ -1,167 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, 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. -// -////////////////////////////////////////////////////////////////////////// - -#include "GA/GA_AIFBlindData.h" -#include "UT/UT_Interrupt.h" -#include "PRM/PRM_Parm.h" - -#include "IECore/SimpleTypedData.h" -#include "IECoreScene/ParameterisedProcedural.h" - -#include "IECorePython/ScopedGILLock.h" - -#ifdef IECOREHOUDINI_WITH_GL - - #include "IECoreGL/Renderer.h" - #include "IECoreGL/Camera.h" - -#endif - -#include "IECoreHoudini/SOP_ProceduralHolder.h" -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -OP_Node *SOP_ProceduralHolder::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new SOP_ProceduralHolder( net, name, op ); -} - -SOP_ProceduralHolder::SOP_ProceduralHolder( OP_Network *net, const char *name, OP_Operator *op ) - : SOP_ParameterisedHolder( net, name, op ), - -#ifdef IECOREHOUDINI_WITH_GL - - m_scene( 0 ) - -#endif - -{ - getParm( pParameterisedSearchPathEnvVar.getToken() ).setValue( 0, "IECORE_PROCEDURAL_PATHS", CH_STRING_LITERAL ); -} - -SOP_ProceduralHolder::~SOP_ProceduralHolder() -{ -} - -#ifdef IECOREHOUDINI_WITH_GL - -/// Redraws the OpenGL Scene if the procedural is marked as having changed (aka dirty) -IECoreGL::ConstScenePtr SOP_ProceduralHolder::scene() -{ - IECoreScene::ParameterisedProceduralPtr procedural = IECore::runTimeCast( getParameterised() ); - if ( !procedural ) - { - return 0; - } - - if ( m_dirty || !m_scene ) - { - IECorePython::ScopedGILLock gilLock; - try - { - IECoreGL::RendererPtr renderer = new IECoreGL::Renderer(); - renderer->setOption( "gl:mode", new IECore::StringData( "deferred" ) ); - renderer->worldBegin(); - procedural->render( renderer.get() ); - renderer->worldEnd(); - m_scene = renderer->scene(); - m_scene->setCamera( 0 ); // houdini will be providing the camera when we draw the scene - } - catch( const std::exception &e ) - { - std::cerr << e.what() << std::endl; - } - catch( ... ) - { - std::cerr << "Unknown!" << std::endl; - } - - m_dirty = false; - } - - return m_scene; -} - -#endif - -/// Cook the SOP! This method does all the work -OP_ERROR SOP_ProceduralHolder::cookMySop( OP_Context &context ) -{ - IECore::MessageHandler::Scope handlerScope( getMessageHandler() ); - - // some defaults and useful variables - float now = context.getTime(); - - // force eval of our nodes parameters with our hidden parameter expression - evalInt( "__evaluateParameters", 0, now ); - - // update parameters on procedural from our Houdini parameters - IECoreScene::ParameterisedProceduralPtr procedural = IECore::runTimeCast( getParameterised() ); - - // check for a valid parameterised on this SOP - if ( !procedural ) - { - UT_String msg( "Procedural Holder has no parameterised class to operate on!" ); - addError( SOP_MESSAGE, msg ); - return error(); - } - - if( lockInputs(context) >= UT_ERROR_ABORT ) - { - return error(); - } - - // start our work - UT_Interrupt *boss = UTgetInterrupt(); - boss->opStart("Building ProceduralHolder Geometry..."); - gdp->clearAndDestroy(); - - setParameterisedValues( now ); - - ToHoudiniCortexObjectConverterPtr converter = new ToHoudiniCortexObjectConverter( procedural.get() ); - if ( !converter->convert( myGdpHandle ) ) - { - addError( SOP_MESSAGE, "Unable to store procedural on gdp" ); - } - - // tidy up & go home! - boss->opEnd(); - unlockInputs(); - return error(); -} diff --git a/src/IECoreHoudini/plugin/Plugin.cpp b/src/IECoreHoudini/plugin/Plugin.cpp index 4ef10e5519..748d807a4e 100644 --- a/src/IECoreHoudini/plugin/Plugin.cpp +++ b/src/IECoreHoudini/plugin/Plugin.cpp @@ -53,7 +53,6 @@ #include "IECoreHoudini/OBJ_SceneCacheTransform.h" #include "IECoreHoudini/SOP_OpHolder.h" #include "IECoreHoudini/SOP_ParameterisedHolder.h" -#include "IECoreHoudini/SOP_ProceduralHolder.h" #include "IECoreHoudini/SOP_CortexConverter.h" #include "IECoreHoudini/SOP_SceneCacheSource.h" #include "IECoreHoudini/SOP_SceneCacheTransform.h" @@ -108,13 +107,6 @@ void newSopOperator(OP_OperatorTable *table) ); opHolder->setIconName( "CortexLogoMini" ); - OP_Operator *proceduralHolder = new OP_Operator( - "ieProceduralHolder", "Cortex Procedural", - SOP_ProceduralHolder::create, SOP_ParameterisedHolder::parameters, 0, 4, - SOP_ParameterisedHolder::variables, OP_FLAG_GENERATOR - ); - proceduralHolder->setIconName( "CortexLogoMini" ); - OP_Operator *converter = new OP_Operator( SOP_CortexConverter::typeName, "Cortex Convert", SOP_CortexConverter::create, SOP_CortexConverter::parameters, 1, 1, @@ -137,14 +129,12 @@ void newSopOperator(OP_OperatorTable *table) /// \todo: get a new icon sceneCacheTransform->setIconName( "SOP_xform" ); - table->addOperator( proceduralHolder ); table->addOperator( opHolder ); table->addOperator( converter ); table->addOperator( sceneCacheSource ); table->addOperator( sceneCacheTransform ); table->addOpHidden( opHolder->getName() ); - table->addOpHidden( proceduralHolder->getName() ); table->addOpHidden( converter->getName() ); table->addOpHidden( sceneCacheSource->getName() ); table->addOpHidden( sceneCacheTransform->getName() ); diff --git a/test/IECoreHoudini/All.py b/test/IECoreHoudini/All.py index fbd3b40490..45eb4ab29d 100644 --- a/test/IECoreHoudini/All.py +++ b/test/IECoreHoudini/All.py @@ -41,7 +41,6 @@ import IECoreHoudini import hou -from ProceduralHolder import * from OpHolder import * from ActiveTake import * from NodeHandle import * diff --git a/test/IECoreHoudini/CortexConverterSop.py b/test/IECoreHoudini/CortexConverterSop.py index f61c6f413f..b1435b37ee 100644 --- a/test/IECoreHoudini/CortexConverterSop.py +++ b/test/IECoreHoudini/CortexConverterSop.py @@ -106,27 +106,6 @@ def testPolygonConversion(self): self.assertEqual( len(geo.pointAttribs()), len(h_geo.pointAttribs()) ) self.assertEqual( len(geo.prims()), len(h_geo.prims()) ) - # test converting a procedural - def testProceduralConversion( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - holder = geo.createNode( "ieProceduralHolder" ) - fn = IECoreHoudini.FnProceduralHolder( holder ) - fn.setProcedural( "pointRender", 1 ) - holder.parm( "parm_npoints" ).set( 123 ) - converter = holder.createOutputNode( "ieCortexConverter" ) - geo = converter.geometry() - self.assertEqual( len(geo.points()), 123 ) - self.assertEqual( len(geo.prims()), 1 ) - - fn.setProcedural( "meshRender", 1 ) - holder.parm( "parm_path" ).set( "test/IECoreHoudini/data/torus_with_normals.cob" ) - geo = converter.geometry() - self.assertEqual( len(geo.points()), 100 ) - self.assertEqual( len(geo.prims()), 100 ) - self.assertEqual( sorted([ x.name() for x in geo.pointAttribs() ]), [ "N" ] + TestCortexConverterSop.PointPositionAttribs ) - self.assertTrue( geo.findPointAttrib( "N" ).isTransformedAsNormal() ) - def scene( self ) : geo = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) diff --git a/test/IECoreHoudini/ProceduralHolder.py b/test/IECoreHoudini/ProceduralHolder.py deleted file mode 100644 index 0de8d300d0..0000000000 --- a/test/IECoreHoudini/ProceduralHolder.py +++ /dev/null @@ -1,586 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2015, 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. -# -########################################################################## - -import hou -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os -import shutil - -class TestProceduralHolder( IECoreHoudini.TestCase ): - - def testProceduralHolder(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - proc = geo.createNode( "ieProceduralHolder" ) - self.assert_( proc ) - fn = IECoreHoudini.FnProceduralHolder( proc ) - self.assert_( fn ) - return fn - - def testLoadProcedural(self): - fn = self.testProceduralHolder() - cl = IECore.ClassLoader.defaultProceduralLoader().load( "sphereProcedural", 0 )() - fn.setParameterised( cl ) - self.assertNotEqual( fn.getParameterised(), None ) - self.assertEqual( fn.getParameterised(), cl ) - return fn - - # tests creation within contexts (simulating from UIs) - def testContextCreator( self ) : - # test generic creation - n = IECoreHoudini.FnProceduralHolder.create( "test", "parameterTypes" ) - self.assertEqual( n.path(), "/obj/test/test" ) - - # test contextArgs outside UI mode fallback to generic behaviour - contextArgs = { "toolname" : "ieProceduralHolder" } - n2 = IECoreHoudini.FnProceduralHolder.create( "test", "parameterTypes", contextArgs=contextArgs ) - self.assertEqual( n2.path(), "/obj/test1/test" ) - - # test parent arg - geo = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - n3 = IECoreHoudini.FnProceduralHolder.create( "test", "parameterTypes", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n3.path(), "/obj/geo1/test" ) - - # test automatic conversion - contextArgs["shiftclick"] = True - n4 = IECoreHoudini.FnProceduralHolder.create( "test", "parameterTypes", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n4.path(), "/obj/geo1/test1" ) - self.assertEqual( len(n4.outputConnectors()[0]), 1 ) - self.assertEqual( n4.outputConnectors()[0][0].outputNode().type().name(), "ieCortexConverter" ) - - # test automatic conversion and output connections - mountain = geo.createNode( "mountain" ) - contextArgs["outputnodename"] = mountain.path() - n5 = IECoreHoudini.FnOpHolder.create( "test", "parameterTypes", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n5.path(), "/obj/geo1/test2" ) - self.assertEqual( len(n5.outputConnectors()[0]), 1 ) - converter = n5.outputConnectors()[0][0].outputNode() - self.assertEqual( converter.type().name(), "ieCortexConverter" ) - self.assertEqual( len(converter.outputConnectors()[0]), 1 ) - outputNode = converter.outputConnectors()[0][0].outputNode() - self.assertEqual( outputNode.type().name(), "mountain::2.0" if hou.applicationVersion()[0] >= 16 else "mountain" ) - self.assertEqual( outputNode, mountain ) - - def testProceduralParameters(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - proc = geo.createNode( "ieProceduralHolder" ) - fn = IECoreHoudini.FnProceduralHolder( proc ) - fn.setProcedural( "parameterTypes", 1 ) - - # set a lot of parameters via houdini - proc.parmTuple("parm_a").set( [123] ) - proc.parmTuple("parm_d").set( ["hello"] ) - proc.parmTuple("parm_g").set( (2,4) ) - proc.parmTuple("parm_h").set( (1,4,8) ) - proc.parmTuple("parm_i").set( (2,4) ) - proc.parmTuple("parm_i_3").set( (1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 ) ) - proc.parmTuple("parm_i_4").set( (1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 ) ) - proc.parmTuple("parm_compound_j").set( (1,4,8) ) - proc.parmTuple("parm_compound_k").set( (1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 ) ) - proc.parmTuple("parm_l").set( (1,0,0) ) - proc.parmTuple("parm_m").set( (1,1,0,1) ) - proc.parmTuple("parm_o").set( ["myFile.tif"] ) - proc.parmTuple("parm_p").set( [os.getcwd()] ) - proc.parmTuple("parm_q").set( [True] ) - proc.parmTuple("parm_r").set( ["mySequence.####.tif"] ) - proc.parmTuple("parm_s").set( [-1, -2, 10, 20] ) - proc.parmTuple("parm_s_1").set( [-1, -2, 10, 20] ) - proc.parmTuple("parm_s_2").set( [-1, -2, -3, 10, 20, 30] ) - proc.parmTuple("parm_t").set( [-1, -2, -3, 10, 20, 30] ) - proc.parmTuple("parm_u").set( (64, 128) ) - proc.parmTuple("parm_v").set( (25,26,27) ) - - # flush our parameters through to our parameterised procedural - proc.cook(force=True) - - # generate our bounds - parameterised = fn.getParameterised() - self.failUnless( parameterised.isInstanceOf( IECore.TypeId.RunTimeTyped ) ) - box = parameterised.bound() - self.assertEqual( box, IECore.Box3f( IECore.V3f(0,0,0), IECore.V3f(1,1,1) ) ) - return ( proc, parameterised ) - - def testLotsQuickly(self): - n = [] - for i in range(1000): - n.append( IECoreHoudini.FnProceduralHolder.create( "cortex_sphere", "sphereProcedural", 1 ) ) - for _n in n: - _n.destroy() - - def testSaveAndLoad(self): - save_file = "test/proceduralHolder_testData/proceduralSave_test.hip" - - # create a few procedurals - n = [] - for i in range( 10 ): - n.append( IECoreHoudini.FnProceduralHolder.create( "cortex_sphere", "sphereProcedural", 1 ) ) - for i in range( 10 ): - n.append( IECoreHoudini.FnProceduralHolder.create( "cortex_params", "parameterTypes", 1 ) ) - - # set some values - path1 = n[0].path() - n[0].parm("parm_radius").set(10) - n[0].parm("parm_theta").set(90) - path2 = n[9].path() - n[9].parm("parm_radius").set(5) - n[9].parm("parm_theta").set(45) - - # save scene - hou.hipFile.save(save_file) - - # new scene - hou.hipFile.clear(suppress_save_prompt=True) - - # open scene - hou.hipFile.load(save_file) - - # check parameters - proc = hou.node(path1) - self.failUnless( proc ) - self.assertEqual( proc.evalParm( "__className" ), "sphereProcedural" ) - self.assertEqual( proc.evalParm( "__classVersion" ), "1" ) - self.assertEqual( proc.evalParm("parm_radius"), 10 ) - self.assertEqual( proc.evalParm("parm_theta"), 90 ) - proc = hou.node(path2) - self.failUnless( proc ) - self.assertEqual( proc.evalParm( "__className" ), "sphereProcedural" ) - self.assertEqual( proc.evalParm( "__classVersion" ), "1" ) - self.assertEqual( proc.evalParm("parm_radius"), 5 ) - self.assertEqual( proc.evalParm("parm_theta"), 45 ) - - def testObjectWasDeleted(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - proc = geo.createNode( "ieProceduralHolder" ) - fn = IECoreHoudini.FnProceduralHolder( proc ) - cl = IECore.ClassLoader.defaultProceduralLoader().load( "sphereProcedural", 1 )() - proc.destroy() - self.assertEqual( fn.hasParameterised(), False ) - fn.setParameterised(cl) - - def testProceduralReloadParameters(self): - sphere = IECoreHoudini.FnProceduralHolder.create( "cortex_sphere", "sphereProcedural", 1 ) - - # check the reload button doesn't clear expressions - sphere.parm("parm_radius").setExpression("sin($FF)") - hou.setFrame(0) - rad = sphere.evalParm("parm_radius") - self.assert_( rad > 0 ) - hou.setFrame(100) - rad = sphere.evalParm("parm_radius") - self.assert_( rad > 0.984 ) - self.assert_( rad < 0.985 ) - sphere.parm( "__classReloadButton" ).pressButton() - rad = sphere.evalParm("parm_radius") - self.assert_( rad > 0.984 ) - self.assert_( rad < 0.985 ) - self.assertEqual( sphere.parm("parm_radius").expression(), "sin($FF)" ) - hou.setFrame(0) - rad = sphere.evalParm("parm_radius") - self.assert_( rad > 0 ) - - # now change the version to v2 and check things are still ok - sphere.parm( "__classVersion" ).set( "2" ) - # if we're changing the menu programatically then we need to call pressButton()!! - sphere.parm( "__classVersion" ).pressButton() - self.assert_( not sphere.evalParm("parm_extra") ) - sphere.parm("parm_extra").set(True) - self.failUnless( sphere.evalParm("parm_extra") ) - rad = sphere.evalParm("parm_radius") - self.assert_( rad < 0.015 ) - hou.setFrame(100) - rad = sphere.evalParm("parm_radius") - self.assert_( rad > 0.984 ) - self.assert_( rad < 0.985 ) - - def testHiddenParameters( self ): - ( proc, cl ) = self.testProceduralParameters() - # check the hidden userData works - self.assertEqual( proc.parmTuple("parm_a").parmTemplate().isHidden(), True ) - self.assertEqual( proc.parmTuple("parm_b").parmTemplate().isHidden(), False ) - self.assertEqual( proc.parmTuple("parm_c").parmTemplate().isHidden(), True ) - self.assertEqual( proc.parmTuple("parm_d").parmTemplate().isHidden(), False ) - # check setting the parameter still works - proc.parmTuple("parm_a").set( [123] ) - proc.cook(force=True) - self.assertEqual( cl['a'].getValue().value, 123 ) - - def testParameterLabels( self ): - ( proc, cl ) = self.testProceduralParameters() - # check the hidden userData works - self.assertEqual( proc.parmTuple("parm_a").parmTemplate().label(), "Int" ) - self.assertEqual( proc.parmTuple("parm_b").parmTemplate().label(), "B" ) - self.assertEqual( proc.parmTuple("parm_c").parmTemplate().label(), "Double" ) - self.assertEqual( proc.parmTuple("parm_d").parmTemplate().label(), "D" ) - - def testMatchString(self): - (op,fn)=self.testProceduralParameters() - fn = IECoreHoudini.FnProceduralHolder(op) - self.assertEqual( op.parm( "__classMatchString" ).eval(), "*" ) - op.parm( "__className" ).set( "sphereProcedural" ) - op.parm( "__className" ).pressButton() - cl = fn.getParameterised() - self.assertEqual( cl.typeName(), "sphereProcedural" ) - op.parm( "__classMatchString" ).set( "nestedChild" ) - results = fn.classNames() - self.assertEqual( len(fn.classNames()), 1 ) - op.parm( "__className" ).set( "sphereProcedural" ) # this still works, should it be invalid? - op.parm( "__className" ).pressButton() - cl = fn.getParameterised() - self.assertEqual( cl.typeName(), "sphereProcedural" ) - op.parm( "__classMatchString" ).set( "*" ) - self.assert_( len(fn.classNames()) > 1 ) - - def createProcedural( self, path="primitiveParameters/multiple", version=1 ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - proc = geo.createNode( "ieProceduralHolder" ) - fn = IECoreHoudini.FnProceduralHolder( proc ) - fn.setProcedural( path, version ) - - return ( proc, fn ) - - def testObjectParameterConversion( self ) : - ( proc, fn ) = self.createProcedural() - torus = proc.createInputNode( 2, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 100 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 0 ) - - torus.parm( "type" ).set( 1 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 100 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 0 ) - - def testObjectParameterWithMultipleTypesConversion( self ) : - ( proc, fn ) = self.createProcedural() - torus = proc.createInputNode( 3, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 100 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 0 ) - - torus.parm( "type" ).set( 1 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.numPoints, 100 ) - - def testPointsParameterConversion( self ) : - ( proc, fn ) = self.createProcedural() - torus = proc.createInputNode( 1, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.numPoints, 100 ) - - torus.parm( "type" ).set( 1 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.numPoints, 100 ) - - def testMeshParameterConversion( self ) : - ( proc, fn ) = self.createProcedural( "primitiveParameters/meshRender" ) - torus = proc.createInputNode( 0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.numFaces(), 100 ) - - torus.parm( "type" ).set( 1 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.numFaces(), 100 ) - - # test an proceduralHolder with multiple inputs - def testMultipleInputs( self ) : - ( proc, fn ) = self.createProcedural() - torus = proc.createInputNode( 0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - box = proc.createInputNode( 2, "box" ) - torus2 = proc.createInputNode( 3, "torus" ) - torus2.parm( "rows" ).set( 10 ) - torus2.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 208 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 206 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 0 ) - - torus2.parm( "type" ).set( 1 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(converterSop.geometry().points()), 208 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 106 ) - self.assertEqual( result.children()[0]["P"].data.size(), 108 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 100 ) - - # test using op holders and procedural holders as inputs - def testCortexInputs( self ) : - ( proc, fn ) = self.createProcedural() - torus = proc.parent().createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - op = torus.createOutputNode( "ieOpHolder" ) - IECoreHoudini.FnOpHolder( op ).setOp( "objectDebug", 1 ) - op.parm( "parm_quiet" ).set( True ) - proc.setInput( 0, op ) - box = proc.createInputNode( 2, "box" ) - proc2 = proc.createInputNode( 3, "ieProceduralHolder" ) - fn2 = IECoreHoudini.FnProceduralHolder( proc2 ) - fn2.setProcedural( "primitiveParameters/meshRender", 1 ) - torus2 = proc2.createInputNode( 0, "torus" ) - torus2.parm( "rows" ).set( 10 ) - torus2.parm( "cols" ).set( 10 ) - proc.cook() - self.assertEqual( len( proc.errors() ), 0) - self.assertEqual( len( proc2.errors() ), 0 ) - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( len(proc.geometry().points()), 1 ) - self.assertEqual( len(proc2.geometry().points()), 1 ) - self.assertEqual( len(op.geometry().points()), 1 ) - converterSop = op.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.numFaces(), 100 ) - converterSop = proc2.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 100 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.numFaces(), 100 ) - converterSop = proc.createOutputNode( "ieCortexConverter" ) - self.assertEqual( len(converterSop.geometry().points()), 208 ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( converterSop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.Group ) - self.assertEqual( result.children()[0].typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result.children()[0].numFaces(), 206 ) - self.assertEqual( result.children()[1].typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result.children()[1].numPoints, 0 ) - - def testAnimatedValues( self ) : - - sphere = IECoreHoudini.FnProceduralHolder.create( "test", "sphereProcedural", 1 ) - fn = IECoreHoudini.FnProceduralHolder( sphere ) - sphere.parm( "parm_radius" ).setExpression( "$FF" ) - hou.setFrame( 1 ) - self.assertEqual( sphere.evalParm( "parm_radius" ), 1 ) - self.assertEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 1 ) - hou.setFrame( 12.25 ) - self.assertEqual( sphere.evalParm( "parm_radius" ), 12.25 ) - # values haven't been flushed yet - self.assertAlmostEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 1 ) - # so we flush them - fn.setParameterisedValues() - self.assertAlmostEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 12.25 ) - - def testNameFilter( self ) : - - meshRender = IECoreHoudini.FnProceduralHolder.create( "meshRender", "primitiveParameters/meshRender", 1 ) - - boxA = meshRender.parent().createNode( "box" ) - nameA = boxA.createOutputNode( "name" ) - nameA.parm( "name1" ).set( "boxA" ) - - boxB = meshRender.parent().createNode( "box" ) - transformB = boxB.createOutputNode( "xform" ) - transformB.parm( "tx" ).set( 5 ) - nameB = transformB.createOutputNode( "name" ) - nameB.parm( "name1" ).set( "boxB" ) - - boxC = meshRender.parent().createNode( "box" ) - transformC = boxC.createOutputNode( "xform" ) - transformC.parm( "tx" ).set( 10 ) - nameC = transformC.createOutputNode( "name" ) - nameC.parm( "name1" ).set( "boxC" ) - - merge = meshRender.parent().createNode( "merge" ) - merge.setInput( 0, nameA ) - merge.setInput( 1, nameB ) - merge.setInput( 2, nameC ) - meshRender.setInput( 0, merge ) - - # converts all 3 meshes as one (because the parameter type forces it) - geo = meshRender.geometry() - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECore.Box3f( IECore.V3f( -0.5, -0.5, -0.5 ), IECore.V3f( 10.5, 0.5, 0.5 ) ) ) - - # setting to one name limits the bounds - meshRender.parm( "parm_mesh_nameFilter" ).set( "boxB" ) - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECore.Box3f( IECore.V3f( 4.5, -0.5, -0.5 ), IECore.V3f( 5.5, 0.5, 0.5 ) ) ) - - # setting to multiple names expands the bounds, but not all the way - meshRender.parm( "parm_mesh_nameFilter" ).set( "* ^boxA" ) - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECore.Box3f( IECore.V3f( 4.5, -0.5, -0.5 ), IECore.V3f( 10.5, 0.5, 0.5 ) ) ) - - # multiple CortexObjects cause warnings (because the parameter wants one mesh only) - converter = merge.createOutputNode( "ieCortexConverter" ) - converter.parm( "resultType" ).set( 0 ) # Cortex - meshRender.setInput( 0, converter ) - meshRender.parm( "__classReloadButton" ).pressButton() # clear the procedural parm values - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertNotEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECoreScene.MeshPrimitive().bound() ) - - # a single CortexObject will work fine - meshRender.parm( "parm_mesh_nameFilter" ).set( "boxB" ) - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECore.Box3f( IECore.V3f( 4.5, -0.5, -0.5 ), IECore.V3f( 5.5, 0.5, 0.5 ) ) ) - - # disabling the nameFilter brings the warnings back - meshRender.setInput( 0, converter ) - meshRender.parm( "parm_mesh_useNameFilter" ).set( False ) - meshRender.parm( "__classReloadButton" ).pressButton() # clear the procedural parm values - self.assertEqual( len(geo.prims()), 1 ) - self.assertEqual( geo.prims()[0].type(), hou.primType.Custom ) - self.assertEqual( len( meshRender.errors() ), 0 ) - self.assertNotEqual( len( meshRender.warnings() ), 0 ) - proc = IECoreHoudini.FromHoudiniGeometryConverter.create( meshRender ).convert() - self.assertTrue( proc.isInstanceOf( IECoreScene.TypeId.ParameterisedProcedural ) ) - self.assertEqual( proc.bound(), IECoreScene.MeshPrimitive().bound() ) - - def setUp( self ) : - IECoreHoudini.TestCase.setUp( self ) - if not os.path.exists( "test/proceduralHolder_testData" ): - os.mkdir( "test/proceduralHolder_testData" ) - - def tearDown( self ) : - if os.path.exists( "test/proceduralHolder_testData" ): - shutil.rmtree( "test/proceduralHolder_testData" ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/procedurals/deformationBlur/deformationBlur-1.py b/test/IECoreHoudini/procedurals/deformationBlur/deformationBlur-1.py deleted file mode 100644 index 065f13f407..0000000000 --- a/test/IECoreHoudini/procedurals/deformationBlur/deformationBlur-1.py +++ /dev/null @@ -1,117 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# -# Deformation Blur -# -# This cookbook example injects two different geometries at different time -# two time samples creating deformation blur. -# -# Motion blur is defined in a very similar fashion to RenderMan. First we call -# motionBegin() with a list of time samples. You can have as many motion samples -# as your renderer will allow. For each time sample we then inject some -# geometry. It is important that the topology remain consistent between time -# samples, otherwise the renderer will complain. We finish by calling -# motionEnd(). Remember not to inject anything but geometry samples between -# motionBegin() and motionEnd(). -# -# Don't forget to turn on motion blur in your renderer -# -# In OpenGL all samples will be rendered simultaneously. Refer to the -# RenderSwitch example for code that can differentiate based on which renderer -# is currently rendering. -# -# In general the code will look like: -# -# renderer.motionBegin( [ sample1, sample2, ... ] ) -# sample1_geometry.render( renderer ) -# sample2_geometry.render( renderer ) -# ... -# renderer.motionEnd() -# -#===== -import IECore - -class deformationBlur(ParameterisedProcedural): - - #===== - # Init - def __init__(self) : - ParameterisedProcedural.__init__( self, "DeformationBlur procedural." ) - geo1 = IECore.PathParameter( name="geo1", description="Geometry #1", - defaultValue="test_data/deform1.cob" ) - geo2 = IECore.PathParameter( name="geo2", description="Geometry #2", - defaultValue="test_data/deform2.cob" ) - self.parameters().addParameters( [geo1, geo2] ) - - #===== - # It's important that the bounding box extend to contain both geometry - # samples. - def doBound(self, args) : - bbox = IECore.Box3f() - geo1 = IECore.Reader.create( args['geo1'].value ).read() - geo2 = IECore.Reader.create( args['geo2'].value ).read() - bbox.extendBy( geo1.bound() ) - bbox.extendBy( geo2.bound() ) - return bbox - - #===== - # Nothing to do - def doRenderState(self, renderer, args) : - pass - - #===== - # Render our two motion samples - def doRender(self, renderer, args): - - # load our geometry - geo1 = IECore.Reader.create( args['geo1'].value ).read() - geo2 = IECore.Reader.create( args['geo2'].value ).read() - - # get the shutter open/close values from the renderer - shutter = renderer.getOption('shutter').value # this is a V2f - - # if motion blur is not enabled then both shutter open & close will - # be zero. - do_moblur = ( shutter.length() > 0 ) - - # inject the motion samples - renderer.motionBegin( [ shutter[0], shutter[1] ] ) - geo1.render( renderer ) - geo2.render( renderer ) - renderer.motionEnd() - -#===== -# Register our procedural -IECore.registerRunTimeTyped( deformationBlur ) diff --git a/test/IECoreHoudini/procedurals/meshRender/meshRender-1.py b/test/IECoreHoudini/procedurals/meshRender/meshRender-1.py deleted file mode 100644 index dfccd9890d..0000000000 --- a/test/IECoreHoudini/procedurals/meshRender/meshRender-1.py +++ /dev/null @@ -1,64 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Mesh Render -# -# This cookbook example demonstrates how to load & render a mesh primitive from -# disk using a path specified through a path parameter. -# -#===== - -import IECore -import IECoreScene - -class meshRender(IECoreScene.ParameterisedProcedural) : - - def __init__(self) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders a mesh." ) - path = IECore.PathParameter( "path", "Path", "" ) - self.parameters().addParameter( path ) - - def doBound(self, args) : - geo = IECore.Reader.create( args['path'].value ).read() - return geo.bound() - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - geo = IECore.Reader.create( args['path'].value ).read() - geo.render( renderer ) - -#register -IECore.registerRunTimeTyped( meshRender ) diff --git a/test/IECoreHoudini/procedurals/nestedChild/nestedChild-1.py b/test/IECoreHoudini/procedurals/nestedChild/nestedChild-1.py deleted file mode 100644 index 3587f21977..0000000000 --- a/test/IECoreHoudini/procedurals/nestedChild/nestedChild-1.py +++ /dev/null @@ -1,59 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Nested Child -# -# This cookbook example renders a unit cube. It is designed to be called by -# the nestedParent example to demonstrate how to inject nested procedurals. -# -#===== - -import IECore - -class nestedChild(ParameterisedProcedural) : - - def __init__(self) : - ParameterisedProcedural.__init__( self, "Child procedural." ) - - def doBound(self, args) : - return IECore.Box3f( IECore.V3f( -.5 ), IECore.V3f( .5 ) ) - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -.5 ), IECore.V3f( .5 ) ) ).render( renderer ) - -# register -IECore.registerRunTimeTyped( nestedChild ) diff --git a/test/IECoreHoudini/procedurals/nestedParent/nestedParent-1.py b/test/IECoreHoudini/procedurals/nestedParent/nestedParent-1.py deleted file mode 100644 index 626118918f..0000000000 --- a/test/IECoreHoudini/procedurals/nestedParent/nestedParent-1.py +++ /dev/null @@ -1,90 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Nested Parent -# -# This cookbook example demonstrates how to inject many child procedurals from -# a single parent procedural. -# -# Here we create a random point cloud and inject the nestedChild procedural -# for each point. -# -#===== - -import IECore -from random import * -import IECoreGL - -class nestedParent(ParameterisedProcedural) : - - def __init__(self) : - ParameterisedProcedural.__init__( self, "Description here." ) - self.__pdata = [] - seed(0) - for i in range(100): - self.__pdata.append( IECore.V3f( random()*10, random()*10, random()*10 ) ) - - def doBound(self, args) : - return IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 10 ) ) - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - # loop through our points - for p in self.__pdata: - - # push the transform state - renderer.transformBegin() - - # concatenate a transformation matrix - renderer.concatTransform( IECore.M44f().createTranslated( p ) ) - - # create an instance of our child procedural - procedural = IECore.ClassLoader.defaultProceduralLoader().load( "nestedChild", 1 )() - - # do we want to draw our child procedural immediately or defer - # until later? - immediate_draw = False - if renderer.typeId()==IECoreGL.Renderer.staticTypeId(): - immediate_draw = True - - # render our child procedural - procedural.render( renderer, withGeometry=True, immediateGeometry=immediate_draw ) - - # pop the transform state - renderer.transformEnd() - -# register -IECore.registerRunTimeTyped( nestedParent ) diff --git a/test/IECoreHoudini/procedurals/parameterTypes/parameterTypes-1.py b/test/IECoreHoudini/procedurals/parameterTypes/parameterTypes-1.py deleted file mode 100644 index b85c1e5931..0000000000 --- a/test/IECoreHoudini/procedurals/parameterTypes/parameterTypes-1.py +++ /dev/null @@ -1,311 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2011, 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. -# -########################################################################## - -import IECore -import IECoreScene - -import os - -class parameterTypes( IECoreScene.ParameterisedProcedural ) : - - def __init__( self ) : - - IECoreScene.ParameterisedProcedural.__init__( self, "test parameter types" ) - - self.parameters().addParameters( - - [ - - IECore.IntParameter( - name = "a", - description = "An int which has a very long description to help test the help formatting. i wonder if there's anything more interesting i could write here.", - defaultValue = 1, - userData = { 'UI': { "label" : IECore.StringData( "Int" ), "update" : IECore.BoolData( True ), "visible" : IECore.BoolData( False ) } } - ), - - IECore.FloatParameter( - name = "b", - description = "A float which has a very long description to help test the help formatting. i wonder if there's anything more interesting i could write here.", - defaultValue = 2, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ), - - IECore.DoubleParameter( - name = "c", - description = "A double", - defaultValue = 3, - userData = { 'UI': { "label" : IECore.StringData( "Double" ), "update" : IECore.BoolData( True ), "visible" : IECore.BoolData( False ) } } - ), - - IECore.StringParameter( - name = "d", - description = "A string", - defaultValue = "ssss", - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ), - - IECore.IntVectorParameter( - name = "e", - description = "An array of ints", - defaultValue = IECore.IntVectorData( [ 4, -1, 2 ] ), - ), - - IECore.StringVectorParameter( - name = "f", - description = "An array of strings", - defaultValue = IECore.StringVectorData( ["one", "two", "three" ]), - ), - - IECore.V2fParameter( - name = "g", - description = "A v2f", - defaultValue = IECore.V2fData( IECore.V2f( 1,2 ) ), - userData = { 'UI': { "label" : IECore.StringData( "V2f" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.V3fParameter( - name = "h", - description = "a v3f", - defaultValue = IECore.V3fData( IECore.V3f( 1, 1, 1 ) ), - presets = ( - ( "x", IECore.V3f( 1, 0, 0 ) ), - ( "y", IECore.V3f( 0, 1, 0 ) ), - ( "z", IECore.V3f( 0, 0, 1 ) ) - ), - userData = { 'UI': { "label" : IECore.StringData( "V3f" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.V2dParameter( - name = "i", - description = "a v2d", - defaultValue = IECore.V2dData( IECore.V2d( 1, 1 ) ), - userData = { 'UI': { "label" : IECore.StringData( "V2d" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.V3dParameter( - name = "i_2", - description = "a v3d", - defaultValue = IECore.V3dData( IECore.V3d( 1, 1, 0 ) ), - userData = { 'UI': { "label" : IECore.StringData( "V2d" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.CompoundParameter( - - name = "compound", - description = "a compound parameter", - userData = { 'UI': { "label" : IECore.StringData( "My Compound" ) } }, - members = [ - - IECore.V3dParameter( - name = "j", - description = "a v3d", - defaultValue = IECore.V3dData( IECore.V3d( 8, 16, 32 ) ), - presets = ( - ( "one", IECore.V3d( 1 ) ), - ( "two", IECore.V3d( 2 ) ) - ), - userData = { "label":IECore.StringData("Compound->V3d") } - ), - - IECore.M44fParameter( - name = "k", - description = "an m44f", - defaultValue = IECore.M44fData( ), - presets = ( - ( "one", IECore.M44f( 1 ) ), - ( "two", IECore.M44f( 2 ) ) - ) - ), - - ] - - ), - - IECore.Color3fParameter( - name = "l", - description = "a color3f", - defaultValue = IECore.Color3fData( IECore.Color3f( 1, 0, 1 )), - userData = { 'UI': { "label" : IECore.StringData( "Colour 3" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.Color4fParameter( - name = "m", - description = "a color4f", - defaultValue = IECore.Color4fData( IECore.Color4f( 1, 0, 1, 0.5 ) ), - userData = { 'UI': { "label" : IECore.StringData( "Colour 4" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.FileNameParameter( - name = "o", - description = "tif file please!", - defaultValue = "test.tif", - extensions = "tif", - allowEmptyString = True, - userData = { 'UI': { "label" : IECore.StringData( "File Name" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.DirNameParameter( - name = "p", - description = "directory please!", - defaultValue = os.getcwd(), - check = IECore.DirNameParameter.CheckType.MustExist, - allowEmptyString = True, - userData = { 'UI': { "label" : IECore.StringData( "Dir Name" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.BoolParameter( - name = "q", - description = "blah", - defaultValue = True, - userData = { 'UI': { "label" : IECore.StringData( "Boolean" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.FileSequenceParameter( - name = "r", - description = "File sequence please!", - defaultValue = "/path/to/sequence.####.tif", - userData = { 'UI': { "label" : IECore.StringData( "File Seq" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.Box2dParameter( - name = "s", - description = "boxboxbox", - defaultValue = IECore.Box2d( IECore.V2d( -1 ), IECore.V2d( 1 ) ) - ), - - IECore.Box2iParameter( - name = "s_1", - description = "boxboxbox2i", - defaultValue = IECore.Box2i( IECore.V2i( -1 ), IECore.V2i( 1 ) ) - ), - - IECore.Box3iParameter( - name = "s_2", - description = "boxboxbox3i", - defaultValue = IECore.Box3i( IECore.V3i( -1 ), IECore.V3i( 1 ) ) - ), - - IECore.Box3fParameter( - name = "t", - description = "boxboxbox", - defaultValue = IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) - ), - - IECore.V2iParameter( - name = "u", - description = "A v2i", - defaultValue = IECore.V2iData( IECore.V2i( 2, 2 ) ), - userData = { 'UI': { "label" : IECore.StringData( "V2i" ), "update" : IECore.BoolData( True ) } } - ), - - - IECore.V3iParameter( - name = "v", - description = "A v3i", - defaultValue = IECore.V3iData( IECore.V3i( 5, 5, 5 ) ), - userData = { 'UI': { "label" : IECore.StringData( "V3i" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.FrameListParameter( - name = "w", - description = "A FrameList", - defaultValue = "", - ), - - IECore.M44fParameter( - name = "i_3", - description = "an m44f", - defaultValue = IECore.M44fData( ), - presets = ( - ( "one", IECore.M44f( 1 ) ), - ( "two", IECore.M44f( 2 ) ) - ), - userData = { 'UI': { "label" : IECore.StringData( "M44f" ), "update" : IECore.BoolData( True ) } } - ), - - IECore.M44dParameter( - name = "i_4", - description = "an m44d", - defaultValue = IECore.M44dData( ), - presets = ( - ( "one", IECore.M44d( 1 ) ), - ( "two", IECore.M44d( 2 ) ) - ), - userData = { 'UI': { "label" : IECore.StringData( "M44d" ), "update" : IECore.BoolData( True ) } } - ), - ] - ) - - def doBound(self, args) : - assert args["a"].value==123 - assert args["b"].value > 1.9999 - assert args["c"].value==3 - assert args["d"].value=="hello" - #assert args["e"] == IntVectorData( [2, 4, 5] ) - #assert args["f"] == StringVectorData( ["one", "two", "three"] ) - assert args["g"] == IECore.V2fData( IECore.V2f( 2, 4 ) ) - assert args["h"] == IECore.V3fData( IECore.V3f( 1, 4, 8 ) ) - assert args["i"] == IECore.V2dData( IECore.V2d( 2, 4 ) ) - assert args["compound"]["j"] == IECore.V3dData( IECore.V3d( 1, 4, 8 ) ) - assert args["compound"]["k"] == IECore.M44fData( IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) - assert args["i_3"] == IECore.M44fData( IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) - assert args["i_4"] == IECore.M44dData( IECore.M44d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) - assert args["l"] == IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) - assert args["m"] == IECore.Color4fData( IECore.Color4f( 1, 1, 0, 1 ) ) - assert args["o"] == IECore.StringData( "myFile.tif" ) - assert args["p"] == IECore.StringData( os.getcwd() ) - assert args["q"] == IECore.BoolData( True ) - assert args["r"] == IECore.StringData( "mySequence.####.tif" ) - assert args["s"] == IECore.Box2dData( IECore.Box2d( IECore.V2d( -1, -2 ), IECore.V2d( 10, 20 ) ) ) - assert args["s_1"] == IECore.Box2iData( IECore.Box2i( IECore.V2i( -1, -2 ), IECore.V2i( 10, 20 ) ) ) - assert args["s_2"] == IECore.Box3iData( IECore.Box3i( IECore.V3i( -1, -2, -3 ), IECore.V3i( 10, 20, 30 ) ) ) - assert args["t"] == IECore.Box3fData( IECore.Box3f( IECore.V3f( -1, -2, -3), IECore.V3f( 10, 20, 30) ) ) - assert args["u"] == IECore.V2iData( IECore.V2i( 64, 128 ) ) - assert args["v"] == IECore.V3iData( IECore.V3i( 25, 26, 27 ) ) - #assert self["w"].getFrameListValue().asList() == FrameRange( 0, 500, 250 ).asList() - - return IECore.Box3f( IECore.V3f(0,0,0), IECore.V3f(1,1,1) ) - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f(0,0,0), IECore.V3f(1,1,1) ) ) - box.render( renderer ) - return IECore.IntData( 1 ) - -IECore.registerRunTimeTyped( parameterTypes ) diff --git a/test/IECoreHoudini/procedurals/pointRender/pointRender-1.py b/test/IECoreHoudini/procedurals/pointRender/pointRender-1.py deleted file mode 100644 index 4542b92ffb..0000000000 --- a/test/IECoreHoudini/procedurals/pointRender/pointRender-1.py +++ /dev/null @@ -1,91 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Point Render -# -# This cookbook example demonstrates how to create and render a Cortex -# PointsPrimitive. The procedural creates a points primitive and fills it with -# a specified number of points, within a specified bounding box. -# -#===== - -import IECore -import IECoreScene - -from random import * - -#generate a points primitive filling the bbox with npoints -def generatePoints( bbox, npoints ): - seed(0) - size = bbox.size() - pdata = IECore.V3fVectorData() - for i in range(npoints): - pdata.append( IECore.V3f( random() * size.x + bbox.min.x, - random() * size.y + bbox.min.y, - random() * size.z + bbox.min.z ) ) - return IECoreScene.PointsPrimitive( pdata ) - -#our point render procedural -class pointRender( IECoreScene.ParameterisedProcedural ) : - def __init__(self) : - IECoreScene.ParameterisedProcedural.__init__( self, "Description here." ) - bbox = IECore.Box3fParameter( "bbox", "Bounds for points.", IECore.Box3f(IECore.V3f(0), IECore.V3f(1)) ) - npoints = IECore.IntParameter( "npoints", "Number of points.", 100, minValue=0, maxValue=10000 ) - width = IECore.FloatParameter( "width", "Point width", 0.05 ) - self.parameters().addParameters( [ bbox, npoints, width ] ) - self.__points = None - self.__npoints = None - self.__bbox = None - - def generatePoints(self, args): - if args['npoints'].value!=self.__npoints or args['bbox'].value!=self.__bbox: - self.__points = generatePoints( args['bbox'].value, args['npoints'].value ) - self.__npoints = args['npoints'].value - self.__bbox = args['bbox'].value - return self.__points - - def doBound(self, args) : - self.generatePoints(args) - return self.__points.bound() - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - self.generatePoints(args) - self.__points['width'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, args['width'] ) - self.__points.render( renderer ) - -#register -IECore.registerRunTimeTyped( pointRender ) diff --git a/test/IECoreHoudini/procedurals/primitiveParameters/meshRender/meshRender-1.py b/test/IECoreHoudini/procedurals/primitiveParameters/meshRender/meshRender-1.py deleted file mode 100644 index 9f15852cdd..0000000000 --- a/test/IECoreHoudini/procedurals/primitiveParameters/meshRender/meshRender-1.py +++ /dev/null @@ -1,59 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, 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. -# -########################################################################## - -import IECore -import IECoreScene - -class meshRender( IECoreScene.ParameterisedProcedural ) : - - def __init__( self ) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders all of it's input geo" ) - self.parameters().addParameters( [ - IECoreScene.MeshPrimitiveParameter( - name = "mesh", - description = "A mesh (Houdini polygons)", - defaultValue = IECoreScene.MeshPrimitive(), - ), - ] ) - - def doBound( self, args ) : - return args['mesh'].bound() - - def doRenderState( self, renderer, args ) : - pass - - def doRender( self, renderer, args ) : - args['mesh'].render( renderer ) - -IECore.registerRunTimeTyped( meshRender ) diff --git a/test/IECoreHoudini/procedurals/primitiveParameters/multiple/multiple-1.py b/test/IECoreHoudini/procedurals/primitiveParameters/multiple/multiple-1.py deleted file mode 100644 index 71c963c220..0000000000 --- a/test/IECoreHoudini/procedurals/primitiveParameters/multiple/multiple-1.py +++ /dev/null @@ -1,88 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, 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. -# -########################################################################## - -import IECore -import IECoreScene - -class multiple( IECoreScene.ParameterisedProcedural ) : - - def __init__( self ) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders all of it's input geo" ) - self.parameters().addParameters( [ - IECoreScene.MeshPrimitiveParameter( - name = "mesh", - description = "A mesh (Houdini polygons)", - defaultValue = IECoreScene.MeshPrimitive(), - ), - IECoreScene.PointsPrimitiveParameter( - name = "points", - description = "Points", - defaultValue = IECoreScene.PointsPrimitive( 0 ), - ), - IECore.ObjectParameter( - name = "meshOnlyObject", - description = "A mesh (Houdini polygons)", - defaultValue = IECoreScene.MeshPrimitive(), - types = [ IECoreScene.TypeId.MeshPrimitive ] - ), - IECore.ObjectParameter( - name = "meshPointsOrGroupObject", - description = "A mesh (Houdini polygons) or points", - defaultValue = IECoreScene.MeshPrimitive(), - types = [ IECoreScene.TypeId.MeshPrimitive, IECoreScene.TypeId.PointsPrimitive, IECoreScene.TypeId.Group ] - ), - ] ) - - def doBound( self, args ) : - meshBound = args['mesh'].bound() - pointsBound = args['points'].bound() - meshPointsOrGroupBound = args['meshPointsOrGroupObject'].bound() - meshOnlyBound = args['meshOnlyObject'].bound() - - bound = IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 0 ) ) - bound.min = min( min( min( meshBound.min, pointsBound.min ), meshPointsOrGroupBound.min ), meshOnlyBound.min ) - bound.max = max( max( max( meshBound.max, pointsBound.max ), meshPointsOrGroupBound.max ), meshOnlyBound.max ) - - return bound - - def doRenderState( self, renderer, args ) : - pass - - def doRender( self, renderer, args ) : - args['mesh'].render( renderer ) - args['points'].render( renderer ) - args['meshPointsOrGroupObject'].render( renderer ) - args['meshOnlyObject'].render( renderer ) - -IECore.registerRunTimeTyped( multiple ) diff --git a/test/IECoreHoudini/procedurals/primitiveVariables/primitiveVariables-1.py b/test/IECoreHoudini/procedurals/primitiveVariables/primitiveVariables-1.py deleted file mode 100644 index a503be1601..0000000000 --- a/test/IECoreHoudini/procedurals/primitiveVariables/primitiveVariables-1.py +++ /dev/null @@ -1,103 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Primitive Variables -# -# This cookbook example demonstrates how to assign a primitive variable -# to a renderable. It is based very closely on the Points Render cookbook -# example, but adds an additional Cs primitive variable which shaders can -# use to colour the points. -# -#===== - -import IECore -from random import * - -#generate a points primitive filling the bbox with npoints -def generatePoints( bbox, npoints ): - seed(0) - size = bbox.size() - pdata = IECore.V3fVectorData() - for i in range(npoints): - pdata.append( IECore.V3f( random() * size.x + bbox.min.x, - random() * size.y + bbox.min.y, - random() * size.z + bbox.min.z ) ) - return PointsPrimitive( pdata ) - -#our primitive variable render procedural -class primitiveVariables(ParameterisedProcedural) : - - def __init__(self): - ParameterisedProcedural.__init__( self, "Description here." ) - bbox = IECore.Box3fParameter( "bbox", "Bounds for points.", IECore.Box3f(IECore.V3f(0), IECore.V3f(1)) ) - npoints = IECore.IntParameter( "npoints", "Number of points.", 100, minValue=0, maxValue=10000 ) - width = IECore.FloatParameter( "width", "Point width", 0.05 ) - self.parameters().addParameters( [ bbox, npoints, width ] ) - self.__points = None - self.__npoints = None - self.__bbox = None - - def generatePoints(self, args): - if args['npoints'].value!=self.__npoints or args['bbox'].value!=self.__bbox: - self.__points = generatePoints( args['bbox'].value, args['npoints'].value ) - self.__npoints = args['npoints'].value - self.__bbox = args['bbox'].value - return self.__points - - def doBound(self, args): - self.generatePoints(args) - return self.__points.bound() - - def doRenderState(self, renderer, args): - pass - - def doRender(self, renderer, args): - self.generatePoints(args) - self.__points['width'] = PrimitiveVariable( PrimitiveVariable.Interpolation.Constant, args['width'] ) - - # create an array of colours, one per point - colours = [] - for i in range( self.__points['P'].data.size() ): - colours.append( IECore.Color3f( random(), random(), random() ) ) - print colours[-1] - colour_data = IECore.Color3fVectorData( colours ) - - # attach as a Cs primitive variable - self.__points['Cs'] = PrimitiveVariable( PrimitiveVariable.Interpolation.Varying, colour_data ) - - # render - self.__points.render( renderer ) - -#register -IECore.registerRunTimeTyped( primitiveVariables ) diff --git a/test/IECoreHoudini/procedurals/renderMode/renderMode-1.py b/test/IECoreHoudini/procedurals/renderMode/renderMode-1.py deleted file mode 100644 index b5241d4b72..0000000000 --- a/test/IECoreHoudini/procedurals/renderMode/renderMode-1.py +++ /dev/null @@ -1,69 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Render Mode -# -# This cookbook example demonstrates how to render based on the current -# rendering context - specifically differentiating between OpenGL and RenderMan. -# This procedural renders a cube in OpenGL but a sphere in RenderMan. -# -#===== - -import IECore -import IECoreGL -import IECoreRI - -class renderMode(ParameterisedProcedural) : - - def __init__(self) : - ParameterisedProcedural.__init__( self, "RenderMode cookbook example." ) - - def doBound(self, args) : - return IECore.Box3f( IECore.V3f( -1, -1, -1 ), IECore.V3f( 1, 1, 1 ) ) - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - - # This checks the renderer against the GL renderer type - if renderer.typeId()==IECoreGL.Renderer.staticTypeId(): - MeshPrimitive.createBox( IECore.Box3f( IECore.V3f(-1), IECore.V3f(1) ) ).render( renderer ) - - # This checks the renderer against the RenderMan renderer type - if renderer.typeId()==IECoreRI.Renderer.staticTypeId(): - renderer.sphere( -1, 1, -1, 360, {} ) - -# register -IECore.registerRunTimeTyped( renderMode ) diff --git a/test/IECoreHoudini/procedurals/simpleGeometry/simpleGeometry-1.py b/test/IECoreHoudini/procedurals/simpleGeometry/simpleGeometry-1.py deleted file mode 100644 index a79195b4ee..0000000000 --- a/test/IECoreHoudini/procedurals/simpleGeometry/simpleGeometry-1.py +++ /dev/null @@ -1,58 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Simple Geometry -# -# This example is just about the simplest procedural you can get. It renders -# a cube! -#===== -import IECore - -class simpleGeometry(ParameterisedProcedural) : - - def __init__(self) : - ParameterisedProcedural.__init__( self, "Simple Geometry." ) - - def doBound(self, args) : - return IECore.Box3f( IECore.V3f(-1), IECore.V3f(1) ) - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - box = MeshPrimitive.createBox( IECore.Box3f( IECore.V3f(-1), IECore.V3f(1) ) ) - box.render( renderer ) - -# register -IECore.registerRunTimeTyped( simpleGeometry ) diff --git a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-1.py b/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-1.py deleted file mode 100644 index 6a15b26666..0000000000 --- a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-1.py +++ /dev/null @@ -1,81 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2011, 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. -# -########################################################################## - -from __future__ import with_statement -import IECore -import IECoreScene - -# renders a sphere -class sphereProcedural( IECoreScene.ParameterisedProcedural ) : - def __init__( self ) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders a sphere." ) - - rad_param = IECore.FloatParameter( - name = "radius", - description = "Sphere radius.", - defaultValue = 1, - minValue = 0.01, - maxValue = 100.0, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ) - - theta_param = IECore.FloatParameter( - name = "theta", - description = "Sphere theta.", - defaultValue = 360, - minValue = 1, - maxValue = 360, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ) - - self.parameters().addParameters( [rad_param, theta_param] ) - - def doBound( self, args ) : - rad = args["radius"].value - return IECore.Box3f( IECore.V3f(-rad,-rad,-rad), IECore.V3f(rad,rad,rad) ) - - def doRenderState( self, renderer, args ) : - pass - - def doRender( self, renderer, args ) : - rad = args["radius"].value - theta = args["theta"].value - with IECoreScene.AttributeBlock( renderer ): - renderer.sphere( rad, -1, 1, theta, {} ) - -# register -IECore.registerRunTimeTyped( sphereProcedural ) diff --git a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-2.py b/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-2.py deleted file mode 100644 index 1c622663d9..0000000000 --- a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-2.py +++ /dev/null @@ -1,83 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2011, 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. -# -########################################################################## - -from __future__ import with_statement -import IECore -import IECoreScene - -# renders a sphere -class sphereProcedural( IECoreScene.ParameterisedProcedural ) : - def __init__( self ) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders a sphere." ) - - rad_param = IECore.FloatParameter( - name = "radius", - description = "Sphere radius.", - defaultValue = 1, - minValue = 0.01, - maxValue = 100.0, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ) - - theta_param = IECore.FloatParameter( - name = "theta", - description = "Sphere theta.", - defaultValue = 360, - minValue = 1, - maxValue = 360, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ) - - extra_parm = IECore.BoolParameter( "extra", "Extra", False ) - - self.parameters().addParameters( [rad_param, theta_param, extra_parm] ) - - def doBound( self, args ) : - rad = args["radius"].value - return IECore.Box3f( IECore.V3f(-rad,-rad,-rad), IECore.V3f(rad,rad,rad) ) - - def doRenderState( self, renderer, args ) : - pass - - def doRender( self, renderer, args ) : - rad = args["radius"].value - theta = args["theta"].value - with IECoreScene.AttributeBlock( renderer ): - renderer.sphere( rad, -1, 1, theta, {} ) - -# register -IECore.registerRunTimeTyped( sphereProcedural ) diff --git a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-3.py b/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-3.py deleted file mode 100644 index b7653d14fe..0000000000 --- a/test/IECoreHoudini/procedurals/sphereProcedural/sphereProcedural-3.py +++ /dev/null @@ -1,83 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2011, 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. -# -########################################################################## - -from __future__ import with_statement -import IECore -import IECoreScene - -# renders a sphere -class sphereProcedural( IECoreScene.ParameterisedProcedural ) : - def __init__( self ) : - IECoreScene.ParameterisedProcedural.__init__( self, "Renders a sphere." ) - - rad_param = IECore.FloatParameter( - name = "radius", - description = "Sphere radius.", - defaultValue = 1, - minValue = 0.01, - maxValue = 100.0, - userData = { 'UI': { "update" : IECore.BoolData( True ) } } - ) - - theta_param = IECore.FloatParameter( - name = "theta", - description = "Sphere theta.", - defaultValue = 360, - minValue = 1, - maxValue = 360, - userData = { 'UI': { "update" : IECore.BoolData( False ) } } - ) - - extra_parm = IECore.BoolParameter( "extra", "Extra", False ) - - self.parameters().addParameters( [rad_param, theta_param, extra_parm] ) - - def doBound( self, args ) : - rad = args["radius"].value - return IECore.Box3f( IECore.V3f(-rad,-rad,-rad), IECore.V3f(rad,rad,rad) ) - - def doRenderState( self, renderer, args ) : - pass - - def doRender( self, renderer, args ) : - rad = args["radius"].value - theta = args["theta"].value - with IECoreScene.AttributeBlock( renderer ): - renderer.sphere( rad, -1, 1, theta, {} ) - -# register -IECore.registerRunTimeTyped( sphereProcedural ) diff --git a/test/IECoreHoudini/procedurals/subdRender/subdRender-1.py b/test/IECoreHoudini/procedurals/subdRender/subdRender-1.py deleted file mode 100644 index f295ddb479..0000000000 --- a/test/IECoreHoudini/procedurals/subdRender/subdRender-1.py +++ /dev/null @@ -1,64 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Subd Render -# -# This cookbook example demonstrates how to load & render a mesh primitive and -# render it as a subdivision surface. -# -#===== - -import IECore - -class subdRender(ParameterisedProcedural) : - - def __init__(self) : - ParameterisedProcedural.__init__( self, "Renders a mesh as a subd." ) - path = IECore.PathParameter( "path", "Path", "" ) - self.parameters().addParameter( path ) - - def doBound(self, args) : - geo = IECore.Reader.create( args['path'].value ).read() - return geo.bound() - - def doRenderState(self, renderer, args) : - pass - - def doRender(self, renderer, args) : - geo = IECore.Reader.create( args['path'].value ).read() - geo.interpolation = "catmullClark" - geo.render( renderer ) - -# register -IECore.registerRunTimeTyped( subdRender ) diff --git a/test/IECoreHoudini/procedurals/transformationBlur/transformationBlur-1.py b/test/IECoreHoudini/procedurals/transformationBlur/transformationBlur-1.py deleted file mode 100644 index bd659a67dc..0000000000 --- a/test/IECoreHoudini/procedurals/transformationBlur/transformationBlur-1.py +++ /dev/null @@ -1,141 +0,0 @@ -#===== -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# 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. -# -#===== -# Transformation Blur -# -# This cookbook example injects multiple transformation matrices at different -# time samples. These transforms move a single geometry over time, causing -# transformation motion blur. -# -# Motion blur is defined in a very similar fashion to RenderMan. First we call -# motionBegin() with a list of time samples. You can have as many motion samples -# as your renderer will allow. For each time sample we then inject a -# transformation matrix. We finish by calling motionEnd(). Remember not to -# inject anything but transformation matrices (one per sample) between -# motionBegin() and motionEnd(). Be sure not to mix up deformation blur and -# transformation blur samples between the same motionBegin() and motionEnd() -# statements. -# -# Don't forget to turn on motion blur in your renderer -# -# In OpenGL all samples will be rendered simultaneously. Refer to the -# RenderSwitch example for code that can differentiate based on which renderer -# is currently rendering. -# -# In general the code will look like: -# -# renderer.motionBegin( [ sample1, sample2, ... ] ) -# renderer.concatTransform( matrix1 ) -# renderer.concatTransform( matrix2 ) -# ... -# renderer.motionEnd() -# geometry.render( renderer ) -# -#===== - -import IECore -import IECoreGL -import math - -#===== -# return a list of floats representing a stepped range -def frange(start, stop, step): - width = stop - start - n = int(round(width / step)) - return [start + step*i for i in range(n)] - -#===== -# our transformation blur procedural -class transformationBlur(ParameterisedProcedural): - - #===== - # Init - def __init__(self): - ParameterisedProcedural.__init__( self, - "TransformationBlur procedural." ) - - # create some transformation matrices - self.transforms = [] - for i in range(8): - self.transforms.append( IECore.M44f().createTranslated( - IECore.V3f( i, math.sin(i), 0 ) ) ) - - #===== - # our bounding box - this should encompass the entire blurred geometry - def doBound(self, args): - sphere_bbox = IECore.Box3f( IECore.V3f(-1,-1,-1), IECore.V3f(1,1,1) ) - bbox = IECore.Box3f() - for mtx in self.transforms: - bbox.extendBy( sphere_bbox.min * mtx ) - bbox.extendBy( sphere_bbox.max * mtx ) - return bbox - - #===== - # Nothing to do - def doRenderState(self, renderer, args): - pass - - #===== - # Render our transform-blurred geometry - def doRender(self, renderer, args): - - # work out samples &shutter information - shutter = renderer.getOption('shutter').value - shutter_length = shutter[1] - shutter[0] - - # if we don't have motion blur enabled, make sure we still have some - # samples - if shutter_length==0: - shutter_length=1 - - # create a list of sample times - sample_times = frange( shutter[0], shutter[1], - float(shutter_length)/(len(self.transforms)) ) - - # draw all the samples in OpenGL - if renderer.typeId() == IECoreGL.Renderer.staticTypeId(): - for mtx in self.transforms: - renderer.setTransform( mtx ) - renderer.sphere( 1, -1, 1, 360, {} ) - else: - # inject our transformation motion blur samples - renderer.motionBegin( sample_times ) - for mtx in self.transforms: - renderer.concatTransform( mtx ) - renderer.motionEnd() - renderer.sphere( 1, -1, 1, 360, {} ) - -#===== -# Register our procedural -IECore.registerRunTimeTyped( transformationBlur )