coverPoint.h

Engine/source/navigation/coverPoint.h

More...

Classes:

Public Typedefs

CoverPointSize 

Public Functions

Detailed Description

Public Typedefs

typedef CoverPoint::Size CoverPointSize 

Public Functions

DefineEnumType(CoverPointSize )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2014 Daniel Buckmaster
  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 _COVERPOINT_H_
 25#define _COVERPOINT_H_
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30#ifndef _GFXSTATEBLOCK_H_
 31#include "gfx/gfxStateBlock.h"
 32#endif
 33#ifndef _GFXVERTEXBUFFER_H_
 34#include "gfx/gfxVertexBuffer.h"
 35#endif
 36#ifndef _GFXPRIMITIVEBUFFER_H_
 37#include "gfx/gfxPrimitiveBuffer.h"
 38#endif
 39
 40class BaseMatInstance;
 41
 42class CoverPoint : public SceneObject
 43{
 44   typedef SceneObject Parent;
 45
 46   /// Network mask bits.
 47   enum MaskBits 
 48   {
 49      TransformMask = Parent::NextFreeMask << 0,
 50      NextFreeMask  = Parent::NextFreeMask << 1
 51   };
 52
 53public:
 54   CoverPoint();
 55   virtual ~CoverPoint();
 56
 57   DECLARE_CONOBJECT(CoverPoint);
 58
 59   /// Amount of cover provided at this point.
 60   enum Size {
 61      Prone,
 62      Crouch,
 63      Stand,
 64      NumSizes
 65   };
 66
 67   void setSize(Size size) { mSize = size; setMaskBits(TransformMask); }
 68   Size getSize() const { return mSize; }
 69
 70   /// Is this point occupied?
 71   bool isOccupied() const { return mOccupied; }
 72   void setOccupied(bool occ) { mOccupied = occ; setMaskBits(TransformMask); }
 73
 74   /// Get the normal of this point (i.e., the direction from which it provides cover).
 75   Point3F getNormal() const;
 76
 77   F32 getQuality() const { return mQuality; }
 78
 79   bool peekLeft() const { return mPeekLeft; }
 80   bool peekRight() const { return mPeekRight; }
 81   bool peekOver() const { return mPeekOver; }
 82
 83   void setPeek(bool left, bool right, bool over) { mPeekLeft = left, mPeekRight = right, mPeekOver = over; }
 84
 85   /// Init static buffers for rendering.
 86   static void initGFXResources();
 87
 88   /// @name SceneObject
 89   /// @{
 90   static void initPersistFields();
 91
 92   bool onAdd();
 93   void onRemove();
 94
 95   void onEditorEnable();
 96   void onEditorDisable();
 97   void inspectPostApply();
 98
 99   void setTransform(const MatrixF &mat);
100
101   void prepRenderImage(SceneRenderState *state);
102   void render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat);
103   /// @}
104
105   /// @name NetObject
106   /// @{
107   U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
108   void unpackUpdate(NetConnection *conn, BitStream *stream);
109   /// @}
110
111protected:
112
113private:
114   typedef GFXVertexPCN VertexType;
115   static GFXStateBlockRef smNormalSB;
116   static GFXVertexBufferHandle<VertexType> smVertexBuffer[NumSizes];
117
118   /// Size of this point.
119   Size mSize;
120   /// Quality of this point as cover.
121   F32 mQuality;
122
123   /// Can we look left around this cover?
124   bool mPeekLeft;
125   /// Can we look right around this cover?
126   bool mPeekRight;
127   /// Can we look up over this cover?
128   bool mPeekOver;
129
130   /// Is this point currently occupied?
131   bool mOccupied;
132};
133
134typedef CoverPoint::Size CoverPointSize;
135DefineEnumType(CoverPointSize);
136
137#endif
138