102 lines
2.8 KiB
C++
102 lines
2.8 KiB
C++
//
|
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
|
//
|
|
// This software is provided 'as-is', without any express or implied
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
// arising from the use of this software.
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
// including commercial applications, and to alter it and redistribute it
|
|
// freely, subject to the following restrictions:
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
// claim that you wrote the original software. If you use this software
|
|
// in a product, an acknowledgment in the product documentation would be
|
|
// appreciated but is not required.
|
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
// misrepresented as being the original software.
|
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
//
|
|
|
|
#ifndef RECASTSAMPLE_H
|
|
#define RECASTSAMPLE_H
|
|
|
|
#include "DebugDraw.h"
|
|
#include "DetourNavMesh.h"
|
|
|
|
struct DebugDrawGL : public duDebugDraw
|
|
{
|
|
virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f);
|
|
virtual void vertex(const float* pos, unsigned int color);
|
|
virtual void vertex(const float x, const float y, const float z, unsigned int color);
|
|
virtual void end();
|
|
};
|
|
|
|
enum SampleToolType
|
|
{
|
|
TOOL_NONE = 0,
|
|
TOOL_TILE_EDIT,
|
|
TOOL_NAVMESH_TESTER,
|
|
TOOL_OFFMESH_LINK,
|
|
};
|
|
|
|
struct SampleTool
|
|
{
|
|
virtual ~SampleTool() {}
|
|
virtual int type() = 0;
|
|
virtual void init(class Sample* sample) = 0;
|
|
virtual void reset() = 0;
|
|
virtual void handleMenu() = 0;
|
|
virtual void handleClick(const float* p, bool shift) = 0;
|
|
virtual void handleRender() = 0;
|
|
virtual void handleRenderOverlay(double* proj, double* model, int* view) = 0;
|
|
};
|
|
|
|
|
|
class Sample
|
|
{
|
|
protected:
|
|
class InputGeom* m_geom;
|
|
dtNavMesh* m_navMesh;
|
|
|
|
float m_cellSize;
|
|
float m_cellHeight;
|
|
float m_agentHeight;
|
|
float m_agentRadius;
|
|
float m_agentMaxClimb;
|
|
float m_agentMaxSlope;
|
|
float m_regionMinSize;
|
|
float m_regionMergeSize;
|
|
float m_edgeMaxLen;
|
|
float m_edgeMaxError;
|
|
float m_vertsPerPoly;
|
|
float m_detailSampleDist;
|
|
float m_detailSampleMaxError;
|
|
|
|
SampleTool* m_tool;
|
|
|
|
public:
|
|
Sample();
|
|
virtual ~Sample();
|
|
|
|
void setTool(SampleTool* tool);
|
|
|
|
virtual void handleSettings();
|
|
virtual void handleTools();
|
|
virtual void handleDebugMode();
|
|
virtual void handleClick(const float* p, bool shift);
|
|
virtual void handleRender();
|
|
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
|
virtual void handleMeshChanged(class InputGeom* geom);
|
|
virtual bool handleBuild();
|
|
|
|
virtual class InputGeom* getInputGeom() { return m_geom; }
|
|
virtual class dtNavMesh* getNavMesh() { return m_navMesh; }
|
|
virtual float getAgentRadius() { return m_agentRadius; }
|
|
virtual float getAgentHeight() { return m_agentHeight; }
|
|
|
|
void resetCommonSettings();
|
|
void handleCommonSettings();
|
|
};
|
|
|
|
|
|
#endif // RECASTSAMPLE_H
|