Mudbox/curve.h Source File

curve.h
Go to the documentation of this file.
1 
2 //**************************************************************************/
3 // Copyright (c) 2008 Autodesk, Inc.
4 // All rights reserved.
5 //
6 // Use of this software is subject to the terms of the Autodesk license
7 // agreement provided at the time of installation or download, or which
8 // otherwise accompanies this software in either electronic or hard copy form.
9 //
10 //**************************************************************************/
11 // DESCRIPTION:
12 // CREATED: September 2011
13 //**************************************************************************/
14 
15 namespace mudbox {
16 
17 class NURBSCurve;
19 
20 class MBDLL_DECL CurveBase : virtual public GroupNode
21 {
23 
24 public:
25 
27  CurveBase();
29  virtual ~CurveBase();
30 
32  virtual void Render();
33 
35  virtual void Serialize(Stream &s);
36 
38  void SetSelected(bool bTOrF) { m_bSelected = bTOrF; }
39  bool Selected() const { return m_bSelected; }
40 
42  virtual void SetClosed(bool bTOrF) { m_bClosed = bTOrF; }
43  bool Closed() const { return m_bClosed; }
44 
46  virtual mudbox::Color Color( void ) const { return mudbox::Color( m_aColor[0], m_aColor[1], m_aColor[2], m_aColor[3] ); };
47  virtual void SetColor( const mudbox::Color &cColor ) { m_aColor[0] = cColor.r; m_aColor[1] = cColor.g; m_aColor[2] = cColor.b; m_aColor[3] = cColor.a; };
48  virtual void ResetColor( void ) { m_aColor[0] = -1; };
49 
53  virtual void SetGeometry(mudbox::Geometry *pGeom);
54  mudbox::Geometry *Geometry() const;
55 
57  virtual const AxisAlignedBoundingBox &BoundingBox() { return m_AABB; }
58 
60  virtual void CopyTo( Node *pNode) const;
61 
64  virtual float Length() const;
65 
66 protected:
67 
70  float m_aColor[4];
71 
73  aptr<mudbox::Geometry> m_pGeometry;
74 
77 
80 };
81 
83 {
84  CurvePoint();
85 
87 
88  // Surface point contains all of the above info
90 };
91 
93 {
95 public:
96  MudboxCurve();
97  virtual ~MudboxCurve();
98 
101  virtual int AddPoint(const CurvePoint &pt);
102 
105  virtual bool SetPoint(int index, const CurvePoint &pt);
106 
109  virtual bool SetPoint(int index, const Vector &pt);
110 
113  virtual const CurvePoint &Point(int index) const;
114 
116  virtual Vector WorldPosition(int iIndex) const;
117 
119  virtual int PointCount() const;
120 
123  virtual bool Point(int index, CurvePoint &point);
124 
126  virtual const QList<CurvePoint> &Points() const;
127 
130  virtual bool InsertPoint(int before, const CurvePoint &pt);
131 
134  virtual bool RemovePoint(int index);
135 
137  virtual void Serialize(Stream &s);
138 
140  virtual const AxisAlignedBoundingBox &BoundingBox();
141 
143  virtual void CopyTo(Node *pNode) const;
144 
146  virtual bool IsConstrainedToSurface( void ) const;
147 
149  virtual void CreateSpline( float fSmoothness );
150 
152  virtual float SplineSmoothness() const;
153 
156  virtual void SetSplineSmoothness( float fSmoothness );
157 
160  virtual void BeginEdit();
161 
163  virtual void EndEdit();
164 
166  virtual bool IsBeingEdited() const;
167 
171  virtual NURBSCurve *Spline() const;
172 
173  virtual int ToSplineIndex( int iPointIndex ) const;
174 
176  virtual bool IsSpline( void ) const;
177 
179  virtual void ProjectPoint( const Vector &vPoint, Vector &vResult ) const;
180 
183  {
184  CT_3D = 0,
186  };
187 
189  virtual void SetCurveType(enum CurveType ct);
190 
192  virtual enum CurveType CurveType() const;
193 
195  virtual NURBSCurve *FalloffCurve();
196 
197 #ifdef _CW_DEBUG
198  QVector<Vector> m_TmpPoints;
199 #endif
200 
201 protected:
202 
206  enum CurveType m_eCurveType;
207 };
208 
211 Vector MBDLL_DECL WindowPositionNormalized(const MudboxCurve *pCurve, int iIndex) ;
212 
215 Vector MBDLL_DECL WindowPosition(const MudboxCurve *pCurve, int iIndex) ;
216 
218 public:
220  {
221  CurveHit(MudboxCurve *pCurve, int iPointIndex, Vector point3D, Vector point2D, float distanceToMouse)
222  { Curve = pCurve; PointIndex = iPointIndex; Point3D = point3D; Point2D = point2D; DistanceToMouse = distanceToMouse; }
223 
224  CurveHit();
225 
231  };
232 
234  {
235  CTP_NONE = 0,
240  };
241 
242 public:
243  static void hitTestCurves(float fMouseX, float fMouseY, float distanceTolerance, QVector<CurveHit> &hitCurves, CurveTestPoints ctp = CTP_START_END, bool bTestLockedCurves = false, bool bTestClosedCurves = true);
244  // Returns the nearest point to the mouse position. Returns -1 if no point is inside the distance tolerance.
245  // On CTP_ALL mode, the curveHit will always be set to the nearest curve point, even it's out of distance tolerance.
246  static int hitTestCurvePoints(float fMouseX, float fMouseY, float distanceTolerance, MudboxCurve *pCurve, CurveHit &curveHit, CurveTestPoints ctp = CTP_START_END);
247  static float projectPointToCurve(float fMouseX, float fMouseY, MudboxCurve * pCurve, int iPointIndex, Vector &vProjection);
248  static bool snapMouse(float fMouseX, float fMouseY, float fSnappingDistance, MudboxCurve *pCurve, float &fNewMouseX, float &fNewMouseY);
249 };
250 
253 public:
255  CurveHit();
258  // Screen space. x, y, z in [0, 1]. Origin at the bottom left.
260  };
261 
263  PickInfo(float fMouseX, float fMouseY, float fDistanceTolerance = 0, int iDepthTolerance = 0xFFF);
264  float fMouseX, fMouseY; // Screen space coord. x, y in [0, 1]. Origin at the bottom left.
266  int iDepthTolerance; // [0, MAX_INT] Depth dif out of tolernace will make candidate been eliminated.
267  };
268 
270  public:
271  virtual ~Eliminater() {}
272  // return false to accept the result, or true to eliminate it.
273  virtual bool Eliminate(AbstractCurvePicker * pPicker, const PickInfo & pPickInfo, CurveHit & pResult) = 0;
274  };
275 
276 public:
277  virtual ~AbstractCurvePicker() {}
278  virtual void SetCamera(Camera * pCamera);
279  virtual Camera * GetCamera() const;
280  virtual void SetFrameBufferSize(int iWidth, int iHeight);
281  virtual void GetFrameBufferSize(int & iWidth, int & iHeight);
282  virtual void QuickInit();
283  virtual void Invalidate();
284  virtual bool Pick(const PickInfo & pPickInfo, CurveHit & pResult, Eliminater * pEliminator = NULL);
285  virtual void CalculateProjection(CurveHit & pResult) const;
286 
287 private:
288  static AbstractCurvePicker * s_pActivePicker;
289 public:
290  static void SetActivePicker(AbstractCurvePicker * pPicker);
291  static AbstractCurvePicker * ActivePicker();
292 };
293 
294 
297 {
299 
300 public:
301  CurveOperator( MudboxCurve *pC = 0 );
302 
303  void Close( bool bMerge = false );
304 
305 private:
306  MudboxCurve *m_pCurve;
307 };
308 
309 
310 }; // end of namespace mudbox
abool m_bClosed
Definition: curve.h:69
Represents a 3D vector or point with S23E8 floating point elements.
Definition: math.h:35
virtual void SetClosed(bool bTOrF)
Creates a loop.
Definition: curve.h:42
Base class for Curve types.
Definition: curve.h:20
QList< CurvePoint > m_vPoints
Using QList for storage.
Definition: curve.h:205
CurveType
Curve type. Used to determine if curve is treated as a ViewCurve (2D) or a regular 3D curve...
Definition: curve.h:182
AxisAlignedBoundingBox m_AABB
3D world space bounding box const AxisAlignedBoundingBox &,
Definition: curve.h:78
Represents a bounding box whose axes are aligned with the coordinate system.
Definition: math.h:838
Describes a location somewhere on the surface of a Mesh.
Definition: mesh.h:340
This is the base class for most classes in the Mudbox SDK.
Definition: node.h:740
abool m_bSelected
Definition: curve.h:68
Represents a color with four components: red, green, blue, alpha.
Definition: math.h:674
virtual void ResetColor(void)
Definition: curve.h:48
Vector MBDLL_DECL WindowPositionNormalized(const MudboxCurve *pCurve, int iIndex)
Return the position of the specific point inside viewport in the 0-1 range.
float b
Definition: math.h:783
CurveHit(MudboxCurve *pCurve, int iPointIndex, Vector point3D, Vector point2D, float distanceToMouse)
Definition: curve.h:221
bool Closed() const
Definition: curve.h:43
float g
Definition: math.h:783
This is the base class for all nodes that are transformable objects in the Mudbox scene...
bool m_bRefreshBoundingBox
Definition: curve.h:79
virtual const AxisAlignedBoundingBox & BoundingBox()
Return world space bounding box.
Definition: curve.h:57
aptr< mudbox::Geometry > m_pGeometry
Mesh that this curve is associated with. Can be NULL.
Definition: curve.h:73
Vector MBDLL_DECL WindowPosition(const MudboxCurve *pCurve, int iIndex)
Return the position of the specific point inside viewport according to the current viewport size in p...
Represents a camera (point of view) in a Mudbox scene.
Definition: camera.h:20
Vector WorldPosition
Definition: curve.h:86
bool Selected() const
Definition: curve.h:39
Class: ConvolutionKernel.
Definition: array.h:15
mudbox::SurfacePoint SurfacePt
Definition: curve.h:89
Represents a 3d object in the scene.
Definition: geometry.h:18
Streams are used to read information from a file, or to write it to a file.
Definition: stream.h:39
virtual mudbox::Color Color(void) const
Control the color of the curve, default is green. Note that selected curves always rendered with yell...
Definition: curve.h:46
#define DECLARE_CLASS
This macro should be used in declaration of classes which are inherited from the Node class (or any d...
Definition: node.h:91
float a
Definition: math.h:783
GLdouble s
Definition: GLee.h:1173
float r
Definition: math.h:783
virtual void SetColor(const mudbox::Color &cColor)
Definition: curve.h:47
#define MBDLL_DECL
Definition: dllinterface.h:35
Internal class only, do not use.
Definition: curve.h:296
virtual ~AbstractCurvePicker()
Definition: curve.h:277
void SetSelected(bool bTOrF)
Set and get selection state.
Definition: curve.h:38
GLuint index
Definition: GLee.h:1704