123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef __CCNAV_MESH_DEBUG_DRAW_H__
- #define __CCNAV_MESH_DEBUG_DRAW_H__
- #include "base/ccConfig.h"
- #if CC_USE_NAVMESH
- #include "renderer/CCGLProgram.h"
- #include "renderer/CCCustomCommand.h"
- #include "renderer/CCRenderState.h"
- #include "math/Vec3.h"
- #include "recast/DebugUtils/DebugDraw.h"
- #include <string>
- #include <vector>
- NS_CC_BEGIN
- class Renderer;
- class NavMeshDebugDraw : public duDebugDraw
- {
- public:
- NavMeshDebugDraw();
- virtual ~NavMeshDebugDraw();
- virtual void depthMask(bool state) override;
- virtual void texture(bool ) override {};
- virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f) override;
- virtual void vertex(const float* pos, unsigned int color) override;
- virtual void vertex(const float x, const float y, const float z, unsigned int color) override;
- virtual void vertex(const float* pos, unsigned int color, const float* uv) override;
- virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v) override;
- virtual void end() override;
- void draw(Renderer* renderer);
- void clear();
- private:
- GLenum getPrimitiveType(duDebugDrawPrimitives prim);
- void drawImplement(const cocos2d::Mat4& transform, uint32_t flags);
- static Vec4 getColor(unsigned int col);
- private:
- struct V3F_C4F
- {
- Vec3 position;
- Vec4 color;
- };
- struct Primitive
- {
- GLenum type;
- bool depthMask;
- unsigned short start;
- unsigned short end;
- float size;
- };
- std::vector<V3F_C4F> _vertices;
- std::vector<Primitive*> _primitiveList;
- Primitive *_currentPrimitive;
- GLProgram *_program;
- CustomCommand _customCmd;
- RenderState::StateBlock* _stateBlock;
- GLenum _primitiveType;
- bool _currentDepthMask;
- GLuint _vbo;
- bool _dirtyBuffer;
- };
- NS_CC_END
- #endif
- #endif
|