- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# quadturtle.h

Go to the documentation of this file.

    00001 //**************************************************************************/
    00002 // Copyright (c) 2008 Autodesk, Inc.
    00003 // All rights reserved.
    00004 //
    00005 // Use of this software is subject to the terms of the Autodesk license
    00006 // agreement provided at the time of installation or download, or which
    00007 // otherwise accompanies this software in either electronic or hard copy form.
    00008 //
    00009 //**************************************************************************/
    00010 // DESCRIPTION:
    00011 // CREATED: August 2011
    00012 //**************************************************************************/
    00013
    00014 #ifndef __MUDBOXSDK_QUADTURTLE_H__
    00015 #define __MUDBOXSDK_QUADTURTLE_H__
    00016
    00017 namespace mudbox {
    00018
    00019 // Represent a quad face on a 4-sided mesh. This turtle can move and turn around on the mesh.
    00020 //  iSide=0       iSide=1
    00021 //  <----o        -----o
    00022 //  |    |        |    |
    00023 //  |    |        V    |
    00024 //  ------        ------
    00025 //
    00026 //
    00027 //  <----------               -----<-----              -----------                -----------
    00028 //  | F  |    |               |    | F  |              |    |    |                |    |    |
    00029 //  |    |    |   F.Right()   |    |    |    F.Down()  |    |    |   F.TurnLeft() |    |    |
    00030 //  -----------   ========>   -----------    =======>  -----<-----   ===========> -----------
    00031 //  |    |    |               |    |    |              |    | F  |                |    | F  |
    00032 //  |    |    |               |    |    |              |    |    |                |    V    |
    00033 //  -----------               -----------              -----------                -----------
    00034 //
    00035
    00036 class MBDLL_DECL QuadTurtle
    00037 {
    00038 public:
    00039     QuadTurtle(const Mesh *pMesh, unsigned int iFaceIndex, unsigned int iSide = 0);
    00040
    00041     inline bool operator ==(const QuadTurtle &q) const;
    00042
    00043     inline unsigned int CornerIndex(unsigned int iC) const;
    00044
    00045     inline Vector CornerPosition( unsigned int iC ) const;
    00046
    00047     inline unsigned int Adjacency( unsigned int iDirection ) const;
    00048
    00049     inline bool HasAdjacentQuad(unsigned int iDirection) const;
    00050
    00051     // Before you move this turtle, make sure it has neighborhood in the direction.
    00052     // Otherwise, it doesn't move.
    00053     // 0: forward; 1: move left; 2: backward; 3: move right.
    00054     // if iDirection > 3, iDirecton = iDirection % 4;
    00055     QuadTurtle &Step(unsigned int iDirection);
    00056
    00057     inline QuadTurtle &Up(void)    { return Step(0); }
    00058     inline QuadTurtle &Left(void)  { return Step(1); }
    00059     inline QuadTurtle $Down(void)  { return Step(2); }
    00060     inline QuadTurtle &Right(void) { return Step(3); }
    00061
    00062     inline QuadTurtle &TurnLeft(void)  { m_iSide = (m_iSide + 1) % 4; return *this; }
    00063     inline QuadTurtle &TurnRight(void) { m_iSide = (m_iSide + 3) % 4; return *this; }
    00064
    00065 private:
    00066     const Mesh *m_pMesh;
    00067     unsigned int m_iFaceIndex;
    00068     unsigned int m_iSide;
    00069 };
    00070
    00071 }; // end of namespace mudbox
    00072
    00073 #endif //__MUDBOXSDK_QUADTURTLE_H__