Cortex  10.0.0-a4
SceneShapeUI.h
1 //
3 // Copyright (c) 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_SCENESHAPEUI_H
36 #define IECOREMAYA_SCENESHAPEUI_H
37 
38 #include "maya/MPxSurfaceShapeUI.h"
39 #include "maya/MTypes.h"
40 
41 #include "IECore/Object.h"
42 
43 #include "IECoreMaya/SceneShape.h"
44 #include "IECoreMaya/DisplayStyle.h"
45 
46 namespace IECoreGL
47 {
48 IE_CORE_FORWARDDECLARE( State );
49 IE_CORE_FORWARDDECLARE( Group );
50 IE_CORE_FORWARDDECLARE( StateComponent );
51 }
52 
53 
54 namespace IECoreMaya
55 {
56 
57 class SceneShapeUI : public MPxSurfaceShapeUI
58 {
59 
60  public :
61 
62  SceneShapeUI();
63  virtual ~SceneShapeUI();
64 
65  virtual void getDrawRequests( const MDrawInfo &info, bool objectAndActiveOnly, MDrawRequestQueue &requests );
66  virtual void draw( const MDrawRequest &request, M3dView &view ) const;
67  virtual bool select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const;
68 
70  #if MAYA_API_VERSION >= 201300
71  virtual bool snap( MSelectInfo &snapInfo ) const;
72  #endif
73 
74  static void *creator();
75 
76  private :
77 
78  typedef std::map< IECoreGL::GroupPtr, IECoreGL::StatePtr > StateMap;
79 
80  void hiliteGroups( IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr hilite, IECoreGL::StateComponentPtr base ) const;
81  void unhiliteGroupChildren( const std::string &name, IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr base ) const;
82  void resetHilites() const;
83 
85  void selectionRayToWorldSpacePoint( const MDagPath &camera, const MSelectInfo &selectInfo, float depth, MPoint &worldIntersectionPoint ) const;
86 
88  Imath::M44d worldTransform( const IECore::SceneInterface *scene, double time ) const;
89 
90  mutable StateMap m_stateMap;
91  mutable DisplayStyle m_displayStyle;
92 
93  enum DrawMode
94  {
95  SceneDrawMode,
96  BoundDrawMode,
97  };
98 
99  static void setWireFrameColors( MDrawRequest &request, M3dView::DisplayStatus status );
100 
101  struct LightingState {
102  unsigned int numMayaLights;
103  unsigned int numGlLights;
104  std::vector<Imath::Color4f> diffuses;
105  std::vector<Imath::Color4f> specs;
106  std::vector<Imath::Color4f> ambients;
107  };
108 
109  bool cleanupLights( const MDrawRequest &request, M3dView &view, LightingState *s ) const;
110  void restoreLights( LightingState *s ) const;
111 };
112 
113 } // namespace IECoreMaya
114 
115 #endif // IECOREMAYA_SCENESHAPEUI_H
The namespace within which all CoreGL functionality is defined.
Definition: AlphaTexture.h:41
Definition: SceneInterface.h:69
The IECoreMaya namespace holds all the functionality of libIECoreMaya.
Definition: BoolParameterHandler.h:44