Program Listing for File context.h

Return to documentation for file (src/o3ds/context.h)

#ifndef O3DS_CONTEXT_H
#define O3DS_CONTEXT_H

namespace O3DS
{


    enum Direction { None = 0, Left, Right, Forward, Back, Up, Down, Last };



    class Context
    {
    public:
        Context()
            : mX(None)
            , mY(None)
            , mZ(None)
        {};

        Context(const Context &other)
            : mX(other.mX)
            , mY(other.mY)
            , mZ(other.mZ)
        {}

        bool valid()
        {
            int aX = axisId(mX);
            int aY = axisId(mY);
            int aZ = axisId(mZ);

            if (aX == 0 || aY == 0 || aZ == 0) return false;
            if (aX == aY || aX == aZ || aY == aZ) return false;
            return true;
        }

        int axisId(enum Direction d)
        {
            if (d == Left || d == Right) return 1;
            if (d == Up || d == Down)  return 2;
            if (d == Forward || d == Back) return 3;
            return 0;
        }

        Context(Direction x, Direction y, Direction z)
            : mX(x), mY(y), mZ(z)
        {}

        Context Mobu()
        {
            return Context(Right, Up, Back);
        }

        Context Unreal()
        {
            return Context(Forward, Right, Up);
        }

        enum Direction mX;
        enum Direction mY;
        enum Direction mZ;

    };

}// namespace

#endif