Torque3D Documentation / _generateds / duDebugDrawTorque.h

duDebugDrawTorque.h

Engine/source/navigation/duDebugDrawTorque.h

More...

Classes:

class

Implements the duDebugDraw interface in Torque.

Detailed Description

  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 _DU_DEBUG_DRAW_TORQUE_H_
 25#define _DU_DEBUG_DRAW_TORQUE_H_
 26
 27#include "core/util/tVector.h"
 28#include <DebugDraw.h>
 29#include "gfx/gfxStateBlock.h"
 30
 31/// @brief Implements the duDebugDraw interface in Torque.
 32class duDebugDrawTorque: public duDebugDraw {
 33public:
 34   duDebugDrawTorque();
 35   ~duDebugDrawTorque();
 36
 37   /// Enable/disable Z read.
 38   void depthMask(bool state);
 39
 40   /// Enable/disable texturing. Not used.
 41   void texture(bool state);
 42
 43   /// Special colour overwrite for when I get picky about the colours Mikko chose.
 44   void overrideColor(unsigned int col);
 45
 46   /// Stop the colour override.
 47   void cancelOverride();
 48
 49   /// Begin drawing primitives.
 50   /// @param prim [in] primitive type to draw, one of rcDebugDrawPrimitives.
 51   /// @param size [in] size of a primitive, applies to point size and line width only.
 52   void begin(duDebugDrawPrimitives prim, float size = 1.0f);
 53
 54   /// All new buffers go into this group.
 55   void beginGroup(U32 group);
 56
 57   /// Submit a vertex
 58   /// @param pos [in] position of the verts.
 59   /// @param color [in] color of the verts.
 60   void vertex(const float* pos, unsigned int color);
 61
 62   /// Submit a vertex
 63   /// @param x,y,z [in] position of the verts.
 64   /// @param color [in] color of the verts.
 65   void vertex(const float x, const float y, const float z, unsigned int color);
 66
 67   /// Submit a vertex
 68   /// @param pos [in] position of the verts.
 69   /// @param color [in] color of the verts.
 70   void vertex(const float* pos, unsigned int color, const float* uv);
 71
 72   /// Submit a vertex
 73   /// @param x,y,z [in] position of the verts.
 74   /// @param color [in] color of the verts.
 75   void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v);
 76
 77   /// End drawing primitives.
 78   void end();
 79
 80   /// Render buffered primitive.
 81   void render();
 82
 83   /// Render buffered primitives in a group.
 84   void renderGroup(U32 group);
 85
 86   /// Delete buffered primitive.
 87   void clear();
 88      
 89private:
 90   GFXStateBlockDesc mDesc;
 91
 92   U32 mPrimType;
 93   bool mQuadsMode;
 94
 95   U32 mVertCount;
 96   F32 mStore[3][3];
 97
 98   U32 mGroup;
 99
100   struct Instruction {
101      // Contain either a point or a color command.
102      union {
103         struct {
104            U8 r, g, b, a;
105         } color;
106         struct {
107            float x, y, z;
108         } point;
109         U32 primType;
110      } data;
111      // Which type of data do we store?
112      enum {
113         COLOR,
114         POINT,
115         PRIMTYPE,
116      } type;
117      // Construct as color instruction.
118      Instruction(U8 r, U8 g, U8 b, U8 a) {
119         type = COLOR;
120         data.color.r = r;
121         data.color.g = g;
122         data.color.b = b;
123         data.color.a = a;
124      }
125      // Construct as point.
126      Instruction(float x, float y, float z) {
127         type = POINT;
128         data.point.x = x;
129         data.point.y = y;
130         data.point.z = z;
131      }
132      Instruction(U32 t = 0) {
133         type = PRIMTYPE;
134         data.primType = t;
135      }
136   };
137
138   struct Buffer {
139      U32 group;
140      Vector<Instruction> buffer;
141      GFXPrimitiveType primType;
142      Buffer(U32 type = 0) {
143         primType = (GFXPrimitiveType)type;
144         group = 0;
145      }
146   };
147   Vector<Buffer> mBuffers;
148
149   U32 mCurrColor;
150   U32 mOverrideColor;
151   bool mOverride;
152
153   void _vertex(const float x, const float y, const float z, unsigned int color);
154
155   void renderBuffer(Buffer &b);
156};
157
158#endif
159