Free Electron
SurfaceAccessibleMaya.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __maya_SurfaceAccessibleMaya_h__
8 #define __maya_SurfaceAccessibleMaya_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Maya Surface Binding
17 
18  @ingroup maya
19 *//***************************************************************************/
20 class FE_DL_EXPORT SurfaceAccessibleMaya:
21  public SurfaceAccessibleBase,
22  public CastableAs<SurfaceAccessibleMaya>
23 {
24  public:
26  m_pMeshArrayData(NULL),
27  m_pFnMesh(NULL),
28  m_pGroupIt(NULL),
29  m_useTransform(FALSE) {}
30 virtual ~SurfaceAccessibleMaya(void)
31  {
32  if(m_pFnMesh)
33  {
34  delete m_pFnMesh;
35  }
36  if(m_pGroupIt)
37  {
38  delete m_pGroupIt;
39  }
40  }
41 
42  //* as SurfaceAccessibleI
43 
45 
46 virtual void bind(Instance a_instance)
47  { setMeshData(
48  a_instance.cast<MDataHandle>()); }
49 virtual BWORD isBound(void)
50  { return (m_pMeshArrayData ||
51  !m_meshData.asMesh().isNull()); }
52 
53 virtual void groupNames(Array<String>& a_rGroupNames,
54  SurfaceAccessibleI::Element
55  a_element) const;
56 
57  using SurfaceAccessibleBase::attributeSpecs;
58 
59 virtual void attributeSpecs(
61  a_rSpecs,
62  String a_node,
63  SurfaceAccessibleI::Element
64  a_element) const;
65 
67 
68 virtual sp<SurfaceAccessorI> accessor(String a_node,
69  SurfaceAccessibleI::Element a_element,
70  String a_name,
71  SurfaceAccessibleI::Creation a_create,
72  SurfaceAccessibleI::Writable
73  a_writable);
74 virtual sp<SurfaceAccessorI> accessor(String a_node,
75  SurfaceAccessibleI::Element a_element,
76  SurfaceAccessibleI::Attribute
77  a_attribute,
78  SurfaceAccessibleI::Creation a_create,
79  SurfaceAccessibleI::Writable
80  a_writable);
81 
82  using SurfaceAccessibleBase::discard;
83 
84 virtual BWORD discard(SurfaceAccessibleI::Element a_element,
85  String a_name);
86 
88 
89 virtual sp<SurfaceI> surface(String a_group,
90  SurfaceI::Restrictions a_restrictions);
91 
92  //* TODO
93 /*
94  using SurfaceAccessibleBase::subSurface;
95 
96 virtual sp<SurfaceI> subSurface(U32 a_subIndex,String a_group,
97  SurfaceI::Restrictions a_restrictions);
98 */
99 
100 virtual void append_not(sp<SurfaceAccessibleI>
101  a_spSurfaceAccessibleI,
102  const SpatialTransform* a_pTransform);
103 
104 virtual void instance(sp<SurfaceAccessibleI>
105  a_spSurfaceAccessibleI,
107  a_rTransformArray);
108 
109  //* Maya specific
110  void setMeshNode(const MObject a_meshNode)
111  {
112  m_meshNode=a_meshNode;
113  }
114 const MObject meshNode(void)
115  { return m_meshNode; }
116  void setMeshData(const MDataHandle a_meshData)
117  {
118  m_meshData=a_meshData;
119  m_spSurfaceI=NULL;
120 
121  if(m_pMeshArrayData)
122  {
123  delete m_pMeshArrayData;
124  m_pMeshArrayData=NULL;
125  }
126 
127  if(m_pFnMesh)
128  {
129  delete m_pFnMesh;
130  }
131 
132  //* not thread safe
133  m_pFnMesh=new MFnMesh(m_meshData.asMesh());
134  }
135 const MDataHandle meshData(void)
136  { return m_meshData; }
137 
138  void setMeshArrayData(
139  const MArrayDataHandle& a_meshArrayData)
140  {
141  m_pMeshArrayData=new MArrayDataHandle(
142  a_meshArrayData);
143  m_spSurfaceI=NULL;
144 
145  m_meshData=MDataHandle();
146 
147  if(m_pFnMesh)
148  {
149  delete m_pFnMesh;
150  }
151 
152  m_pFnMesh=NULL;
153  }
154  MArrayDataHandle& meshArrayData(void)
155  { return *m_pMeshArrayData; }
156  void setGroupIt(MItGeometry* a_pGroupIt)
157  {
158  if(m_pGroupIt)
159  {
160  delete m_pGroupIt;
161  }
162  m_pGroupIt=a_pGroupIt;
163  }
164 
165  void clearTransform(void)
166  {
167  m_useTransform=FALSE;
168  }
169  void setTransform(SpatialTransform a_transform)
170  {
171  m_useTransform=TRUE;
172  m_transform=a_transform;
173  }
174 
175  protected:
176 
177 virtual void reset(void);
178 
179  sp<SurfaceAccessorMaya> createAccessor(void)
180  {
181  sp<SurfaceAccessorMaya> spAccessor(
182  new SurfaceAccessorMaya);
183  spAccessor->setMaster(registry()->master());
184  spAccessor->setMeshNode(m_meshNode);
185  spAccessor->setMeshData(m_meshData);
186  spAccessor->setGroupIt(m_pGroupIt);
187  if(m_useTransform)
188  {
189  spAccessor->setTransform(m_transform);
190  }
191  else
192  {
193  spAccessor->clearTransform();
194  }
195  return spAccessor;
196  }
197 
198  private:
199  sp<SurfaceI> m_spSurfaceI;
200 
201  MObject m_meshNode;
202  MDataHandle m_meshData;
203  MArrayDataHandle* m_pMeshArrayData;
204  MFnMesh* m_pFnMesh;
205  MItGeometry* m_pGroupIt;
206 
207  BWORD m_useTransform;
208  SpatialTransform m_transform;
209 };
210 
211 } /* namespace ext */
212 } /* namespace fe */
213 
214 #endif /* __maya_SurfaceAccessibleMaya_h__ */
Common Functionality for Accessible Surface.
Definition: SurfaceAccessibleBase.h:20
virtual sp< SurfaceI > surface(void)
Return current underlying SurfaceI.
Definition: SurfaceAccessibleBase.h:143
Maya Surface Binding.
Definition: SurfaceAccessibleMaya.h:20
Smart pointer used with types represented by BaseType.
Definition: Instance.h:28
kernel
Definition: namespace.dox:3
virtual void bind(Instance a_instance)
associate with model data
Definition: SurfaceAccessibleMaya.h:46
virtual void bind(Instance a_instance)
associate with model data
Definition: SurfaceAccessibleBase.h:31
Maya Surface Editing Implementation.
Definition: SurfaceAccessorMaya.h:30
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
virtual BWORD isBound(void)
Return true if surface is available.
Definition: SurfaceAccessibleMaya.h:49
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192
virtual sp< SurfaceAccessorI > accessor(String a_node, Element a_element, String a_name, Creation a_create, Writable a_writable)
Return access to an attribute.
Definition: SurfaceAccessibleBase.h:87