torqueRecast.h

Engine/source/navigation/torqueRecast.h

More...

Classes:

class

Stores information about a link.

Public Enumerations

enum
PolyAreas {
  GroundArea 
  WaterArea 
  OffMeshArea 
  NumAreas 
}
enum
PolyFlags {
  WalkFlag = 1 << 0
  SwimFlag = 1 << 1
  JumpFlag = 1 << 2
  LedgeFlag = 1 << 3
  DropFlag = 1 << 4
  ClimbFlag = 1 << 5
  TeleportFlag = 1 << 6
  AllFlags = 0xffff
}

Public Functions

rcCol(unsigned int col, U8 & r, U8 & g, U8 & b, U8 & a)

Convert a Rcast colour integer to RGBA components.

RCtoDTS(const F32 * min, const F32 * max)

Detailed Description

Public Enumerations

PolyAreas

Enumerator

GroundArea
WaterArea
OffMeshArea
NumAreas
PolyFlags

Enumerator

WalkFlag = 1 << 0
SwimFlag = 1 << 1
JumpFlag = 1 << 2
LedgeFlag = 1 << 3
DropFlag = 1 << 4
ClimbFlag = 1 << 5
TeleportFlag = 1 << 6
AllFlags = 0xffff

Public Functions

DTStoRC(const Box3F & box)

DTStoRC(const Point3F & point)

DTStoRC(F32 x, F32 y, F32 z)

rcCol(unsigned int col, U8 & r, U8 & g, U8 & b, U8 & a)

Convert a Rcast colour integer to RGBA components.

RCtoDTS(const F32 * min, const F32 * max)

RCtoDTS(const F32 * xyz)

RCtoDTS(const Point3F & point)

RCtoDTS(F32 x, F32 y, F32 z)

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2013 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _TORQUE_RECAST_H_
 25#define _TORQUE_RECAST_H_
 26
 27#include "console/simSet.h"
 28#include "math/mPoint3.h"
 29#include "math/mBox.h"
 30
 31inline Point3F DTStoRC(F32 x, F32 y, F32 z) { return Point3F(x, z, -y); }
 32inline Point3F DTStoRC(const Point3F& point){ return Point3F(point.x, point.z, -point.y); }
 33inline Point3F RCtoDTS(const F32* xyz)      { return Point3F(xyz[0], -xyz[2], xyz[1]); }
 34inline Point3F RCtoDTS(F32 x, F32 y, F32 z) { return Point3F(x, -z, y); }
 35inline Point3F RCtoDTS(const Point3F& point){ return Point3F(point.x, -point.z, point.y); }
 36inline Box3F DTStoRC(const Box3F& box)
 37{
 38   return Box3F(box.minExtents.x, box.minExtents.z, -box.maxExtents.y,
 39                  box.maxExtents.x, box.maxExtents.z, -box.minExtents.y);
 40}
 41inline Box3F RCtoDTS(const F32 *min, const F32 *max)
 42{
 43   return Box3F(min[0], -max[2], min[1], max[0], -min[2], max[1]);
 44}
 45
 46/// Convert a Rcast colour integer to RGBA components.
 47inline void rcCol(unsigned int col, U8 &r, U8 &g, U8 &b, U8 &a)
 48{
 49   r = col % 256; col /= 256;
 50   g = col % 256; col /= 256;
 51   b = col % 256; col /= 256;
 52   a = col % 256;
 53}
 54
 55enum PolyAreas {
 56   GroundArea,
 57   WaterArea,
 58   OffMeshArea,
 59   NumAreas
 60};
 61
 62enum PolyFlags {
 63   WalkFlag = 1 << 0,
 64   SwimFlag = 1 << 1,
 65   JumpFlag = 1 << 2,
 66   LedgeFlag = 1 << 3,
 67   DropFlag = 1 << 4,
 68   ClimbFlag = 1 << 5,
 69   TeleportFlag = 1 << 6,
 70   AllFlags = 0xffff
 71};
 72
 73/// Stores information about a link.
 74struct LinkData {
 75   bool walk;
 76   bool jump;
 77   bool drop;
 78   bool swim;
 79   bool ledge;
 80   bool climb;
 81   bool teleport;
 82   LinkData(U16 flags = 0)
 83   {
 84      walk = flags & WalkFlag;
 85      jump = flags & JumpFlag;
 86      drop = flags & DropFlag;
 87      swim = flags & SwimFlag;
 88      ledge = flags & LedgeFlag;
 89      climb = flags & ClimbFlag;
 90      teleport = flags & TeleportFlag;
 91   }
 92   U16 getFlags() const
 93   {
 94      return
 95         (walk ? WalkFlag : 0) |
 96         (jump ? JumpFlag : 0) |
 97         (drop ? DropFlag : 0) |
 98         (swim ? SwimFlag : 0) |
 99         (ledge ? LedgeFlag : 0) |
100         (climb ? ClimbFlag : 0) |
101         (teleport ? TeleportFlag : 0);
102   }
103};
104
105#endif
106