Mudbox/quadturtle.h Source File

quadturtle.h
Go to the documentation of this file.
1 //**************************************************************************/
2 // Copyright (c) 2008 Autodesk, Inc.
3 // All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Autodesk license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 //
9 //**************************************************************************/
10 // DESCRIPTION:
11 // CREATED: August 2011
12 //**************************************************************************/
13 
14 #ifndef __MUDBOXSDK_QUADTURTLE_H__
15 #define __MUDBOXSDK_QUADTURTLE_H__
16 
17 namespace mudbox {
18 
19 // Represent a quad face on a 4-sided mesh. This turtle can move and turn around on the mesh.
20 // iSide=0 iSide=1
21 // <----o -----o
22 // | | | |
23 // | | V |
24 // ------ ------
25 //
26 //
27 // <---------- -----<----- ----------- -----------
28 // | F | | | | F | | | | | | |
29 // | | | F.Right() | | | F.Down() | | | F.TurnLeft() | | |
30 // ----------- ========> ----------- =======> -----<----- ===========> -----------
31 // | | | | | | | | F | | | F |
32 // | | | | | | | | | | V |
33 // ----------- ----------- ----------- -----------
34 //
35 
37 {
38 public:
39  QuadTurtle(const Mesh *pMesh, unsigned int iFaceIndex, unsigned int iSide = 0);
40 
41  inline bool operator ==(const QuadTurtle &q) const;
42 
43  inline unsigned int CornerIndex(unsigned int iC) const;
44 
45  inline Vector CornerPosition( unsigned int iC ) const;
46 
47  inline unsigned int Adjacency( unsigned int iDirection ) const;
48 
49  inline bool HasAdjacentQuad(unsigned int iDirection) const;
50 
51  // Before you move this turtle, make sure it has neighborhood in the direction.
52  // Otherwise, it doesn't move.
53  // 0: forward; 1: move left; 2: backward; 3: move right.
54  // if iDirection > 3, iDirecton = iDirection % 4;
55  QuadTurtle &Step(unsigned int iDirection);
56 
57  inline QuadTurtle &Up(void) { return Step(0); }
58  inline QuadTurtle &Left(void) { return Step(1); }
59  inline QuadTurtle $Down(void) { return Step(2); }
60  inline QuadTurtle &Right(void) { return Step(3); }
61 
62  inline QuadTurtle &TurnLeft(void) { m_iSide = (m_iSide + 1) % 4; return *this; }
63  inline QuadTurtle &TurnRight(void) { m_iSide = (m_iSide + 3) % 4; return *this; }
64 
65 private:
66  const Mesh *m_pMesh;
67  unsigned int m_iFaceIndex;
68  unsigned int m_iSide;
69 };
70 
71 }; // end of namespace mudbox
72 
73 #endif //__MUDBOXSDK_QUADTURTLE_H__
Represents a 3D vector or point with S23E8 floating point elements.
Definition: math.h:35
A Mesh is a collection of vertices organized into faces, and optional Texture Coordinate information...
Definition: mesh.h:452
QuadTurtle & Left(void)
Definition: quadturtle.h:58
QuadTurtle & TurnRight(void)
Definition: quadturtle.h:63
QuadTurtle & Up(void)
Definition: quadturtle.h:57
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
GLdouble GLdouble GLdouble GLdouble q
Definition: GLee.h:1197
QuadTurtle $Down(void)
Definition: quadturtle.h:59
QuadTurtle & TurnLeft(void)
Definition: quadturtle.h:62
Class: ConvolutionKernel.
Definition: array.h:15
QuadTurtle & Right(void)
Definition: quadturtle.h:60
#define MBDLL_DECL
Definition: dllinterface.h:35