Cortex  10.0.0-a4
ProceduralHolder.h
1 //
3 // Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IECOREMAYA_PROCEDURALHOLDER_H
36 #define IECOREMAYA_PROCEDURALHOLDER_H
37 
38 #include <map>
39 
40 #include "OpenEXR/ImathMatrix.h"
41 
42 #include "IECoreGL/IECoreGL.h"
43 
44 #include "IECoreMaya/ParameterisedHolder.h"
45 
46 #include "IECore/ParameterisedProcedural.h"
47 
48 #include "maya/MPxComponentShape.h"
49 #include "maya/MArrayDataBuilder.h"
50 
51 namespace IECoreGL
52 {
53 IE_CORE_FORWARDDECLARE( Scene );
54 IE_CORE_FORWARDDECLARE( State );
55 IE_CORE_FORWARDDECLARE( BoxPrimitive );
56 IE_CORE_FORWARDDECLARE( Primitive );
57 IE_CORE_FORWARDDECLARE( Group );
58 IE_CORE_FORWARDDECLARE( NameStateComponent );
59 IE_CORE_FORWARDDECLARE( Renderer );
60 }
61 
62 namespace IECoreMaya
63 {
64 
69 {
70  friend class ProceduralHolderUI;
72 
73  public :
74 
76  virtual ~ProceduralHolder();
77 
78  virtual void postConstructor();
79 
80  static void *creator();
81  static MStatus initialize();
82  static MTypeId id;
83 
84  virtual bool isBounded() const;
85  virtual MBoundingBox boundingBox() const;
86  virtual MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray );
87  virtual MStatus compute( const MPlug &plug, MDataBlock &dataBlock );
88 
89  virtual void componentToPlugs( MObject &component, MSelectionList &selectionList ) const;
90  virtual MatchResult matchComponent( const MSelectionList &item, const MAttributeSpecArray &spec, MSelectionList &list );
91 
93  MStatus setProcedural( const std::string &className, int classVersion );
95  IECore::ParameterisedProceduralPtr getProcedural( std::string *className = 0, int *classVersion = 0 );
96 
98  IECoreGL::ConstScenePtr scene();
99 
100  static MObject aGLPreview;
101  static MObject aCulling;
102  static MObject aTransparent;
103  static MObject aDrawBound;
104  static MObject aDrawCoordinateSystems;
105  static MObject aProceduralComponents;
106 
107  static MObject aComponentQueries;
108 
109  static MObject aComponentTransform;
110  static MObject aComponentTranslate;
111  static MObject aComponentTranslateX;
112  static MObject aComponentTranslateY;
113  static MObject aComponentTranslateZ;
114  static MObject aComponentRotate;
115  static MObject aComponentRotateX;
116  static MObject aComponentRotateY;
117  static MObject aComponentRotateZ;
118  static MObject aComponentScale;
119  static MObject aComponentScaleX;
120  static MObject aComponentScaleY;
121  static MObject aComponentScaleZ;
122 
123  static MObject aComponentBound;
124  static MObject aComponentBoundMin;
125  static MObject aComponentBoundMinX;
126  static MObject aComponentBoundMinY;
127  static MObject aComponentBoundMinZ;
128  static MObject aComponentBoundMax;
129  static MObject aComponentBoundMaxX;
130  static MObject aComponentBoundMaxY;
131  static MObject aComponentBoundMaxZ;
132  static MObject aComponentBoundCenter;
133  static MObject aComponentBoundCenterX;
134  static MObject aComponentBoundCenterY;
135  static MObject aComponentBoundCenterZ;
136 
139  virtual MPxGeometryIterator* geometryIteratorSetup( MObjectArray&, MObject&, bool );
140 
143  virtual void transformUsing( const MMatrix &mat, const MObjectArray &componentList, MPxSurfaceShape::MVertexCachingMode cachingMode, MPointArray *pointCache );
144 
145  private :
146 
147  mutable bool m_boundDirty;
148  mutable MBoundingBox m_bound;
149 
150  bool m_sceneDirty;
151  IECoreGL::ScenePtr m_scene;
152  IECoreGL::RendererPtr m_lastRenderer;
153 
156  typedef std::map<IECore::InternedString, std::pair< unsigned int, IECoreGL::GroupPtr > > ComponentsMap;
157  typedef std::map< int, std::set< std::pair< std::string, IECoreGL::GroupPtr > > > ComponentToGroupMap;
158  typedef std::map< int, Imath::Box3f > ComponentToBoundMap;
159  typedef std::map<IECore::InternedString, Imath::M44f> ComponentTransformsMap;
160 
161  void buildComponents();
162  void buildComponents( IECoreGL::ConstNameStateComponentPtr nameState, IECoreGL::GroupPtr group, const Imath::M44f &parentTransform );
163 
164  Imath::Box3f componentBound( int idx ) const;
165 
166  ComponentsMap m_componentsMap;
167  ComponentToGroupMap m_componentToGroupMap;
168  ComponentTransformsMap m_componentTransforms;
169 
170  mutable ComponentToBoundMap m_componentToBoundMap;
171 
172 };
173 
174 } // namespace IECoreMaya
175 
176 #endif // IECOREMAYA_PROCEDURALHOLDER_H
The namespace within which all CoreGL functionality is defined.
Definition: AlphaTexture.h:41
virtual void transformUsing(const MMatrix &mat, const MObjectArray &componentList, MPxSurfaceShape::MVertexCachingMode cachingMode, MPointArray *pointCache)
Definition: ProceduralHolderComponentBoundIterator.h:58
Definition: ProceduralHolder.h:68
virtual MPxGeometryIterator * geometryIteratorSetup(MObjectArray &, MObject &, bool)
MStatus setProcedural(const std::string &className, int classVersion)
Calls setParameterised( className, classVersion, "IECORE_PROCEDURAL_PATHS" ).
The IECoreMaya namespace holds all the functionality of libIECoreMaya.
Definition: BoolParameterHandler.h:44
Definition: ParameterisedHolder.h:70
IECore::ParameterisedProceduralPtr getProcedural(std::string *className=0, int *classVersion=0)
Returns runTimeCast( getProcedural( className, classVersion ) )...
IECoreGL::ConstScenePtr scene()
Returns an up to date scene from the procedural.