123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include "Area.h"
- Direction getOppositeDirection( Direction dir )
- {
- switch( dir )
- {
- case NORTH:
- return SOUTH;
- case EAST:
- return WEST;
- case SOUTH:
- return NORTH;
- case WEST:
- return EAST;
- case TOP:
- return BOTTOM;
- case BOTTOM:
- return TOP;
- default:
- return NO_DIRECTION;
- }
- }
- Directions getDirections( Framework::Vec3<float> currentPos, Framework::Vec3<float> otherPos )
- {
- Directions result = NO_DIRECTION;
- if( currentPos.x < otherPos.x )
- result |= EAST;
- if( currentPos.x > otherPos.x )
- result |= WEST;
- if( currentPos.y < otherPos.y )
- result |= SOUTH;
- if( currentPos.y > otherPos.y )
- result |= NORTH;
- if( currentPos.z < otherPos.z )
- result |= TOP;
- if( currentPos.z > otherPos.z )
- result |= BOTTOM;
- return result;
- }
- Framework::Vec3<int> getDirection( Directions dir )
- {
- Framework::Vec3<int> result( 0, 0, 0 );
- if( (dir | NORTH) == dir )
- --result.y;
- if( (dir | EAST) == dir )
- ++result.x;
- if( (dir | SOUTH) == dir )
- ++result.y;
- if( (dir | WEST) == dir )
- --result.x;
- if( (dir | TOP) == dir )
- ++result.z;
- if( (dir | BOTTOM) == dir )
- --result.z;
- return result;
- }
- int getDirectionIndex( Direction dir )
- {
- if( dir == NORTH )
- return 0;
- if( dir == EAST )
- return 1;
- if( dir == SOUTH )
- return 2;
- if( dir == WEST )
- return 3;
- if( dir == TOP )
- return 4;
- if( dir == BOTTOM )
- return 5;
- assert( false );
- return -1;
- }
- Direction getDirectionFromIndex( int index )
- {
- return (Direction)(1 << index);
- }
|