Object and Goods are abstract.
When I derive a class called TruckArrive from it, the titled error occurs.
Please help
#pragma once
#include <string>
#include "..\NavMeshLoader.h"
#include "..\Pathfinding\Detour\Include\DetourCommon.h"
#include "..\Pathfinding\Recast\Include\Recast.h"
#include "DetourNavMeshQuery.h"
#include "..\Objects\Objects.h"
class Idle;
class Objects;
class Goods;
#ifdef WIN32
# define snprintf _snprintf
#endif
// Uncomment this to dump all the requests in stdout.
#define DUMP_REQS
// Returns a random number [0..1)
static float frand()
{
// return ((float)(rand() & 0xffff)/(float)0xffff);
return (float)rand()/(float)RAND_MAX;
}
inline bool inRange(const float* v1, const float* v2, const float r, const float h)
{
const float dx = v2[0] - v1[0];
const float dy = v2[1] - v1[1];
const float dz = v2[2] - v1[2];
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
}
static int fixupCorridor(dtPolyRef* path, const int npath, const int maxPath,
const dtPolyRef* visited, const int nvisited)
{
int furthestPath = -1;
int furthestVisited = -1;
// Find furthest common polygon.
for (int i = npath-1; i >= 0; --i)
{
bool found = false;
for (int j = nvisited-1; j >= 0; --j)
{
if (path[i] == visited[j])
{
furthestPath = i;
furthestVisited = j;
found = true;
}
}
if (found)
break;
}
// If no intersection found just return current path.
if (furthestPath == -1 || furthestVisited == -1)
return npath;
// Concatenate paths.
// Adjust beginning of the buffer to include the visited.
const int req = nvisited - furthestVisited;
const int orig = rcMin(furthestPath+1, npath);
int size = rcMax(0, npath-orig);
if (req+size > maxPath)
size = maxPath-req;
if (size)
memmove(path+req, path+orig, size*sizeof(dtPolyRef));
// Store visited
for (int i = 0; i < req; ++i)
path[i] = visited[(nvisited-1)-i];
return req+size;
}
static bool getSteerTarget(dtNavMeshQuery* navQuery, const float* startPos, const float* endPos,
const float minTargetDist,
const dtPolyRef* path, const int pathSize,
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef,
float* outPoints = 0, int* outPointCount = 0)
{
// Find steer target.
static const int MAX_STEER_POINTS = 3;
float steerPath[MAX_STEER_POINTS*3];
unsigned char steerPathFlags[MAX_STEER_POINTS];
dtPolyRef steerPathPolys[MAX_STEER_POINTS];
int nsteerPath = 0;
navQuery->findStraightPath(startPos, endPos, path, pathSize,
steerPath, steerPathFlags, steerPathPolys, &nsteerPath, MAX_STEER_POINTS);
if (!nsteerPath)
return false;
if (outPoints && outPointCount)
{
*outPointCount = nsteerPath;
for (int i = 0; i < nsteerPath; ++i)
dtVcopy(&outPoints[i*3], &steerPath[i*3]);
}
// Find vertex far enough to steer to.
int ns = 0;
while (ns < nsteerPath)
{
// Stop at Off-Mesh link or when point is further than slop away.
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
!inRange(&steerPath[ns*3], startPos, minTargetDist, 1000.0f))
break;
ns++;
}
// Failed to find good point to steer to.
if (ns >= nsteerPath)
return false;
dtVcopy(steerPos, &steerPath[ns*3]);
steerPos[1] = startPos[1];
steerPosFlag = steerPathFlags[ns];
steerPosRef = steerPathPolys[ns];
return true;
}
class Activity
{
public:
Objects *Actor;
Goods *Target;
Activity() : Actor(0), Target(0) { }
Activity( Objects* actor, Goods* target ) : Actor(actor), Target(target)
{
NavMesh::GetNavMeshLoader().loadAll("Data\\all_tiles_navmesh.bin");
mStep = 0;
}
~Activity()
{
dtFreeNavMeshQuery(m_navQuery);
m_navQuery = NULL;
}
void InitNavMesh(const dtNavMesh *navMesh);
private:
void SetNavMesh(const dtNavMesh* navMesh) { m_navMesh = navMesh; }
protected:
void findPath();
void ReCalc();
public:
virtual bool OnUpdate(float seconds) = 0;
void Update(float seconds);
Activity *FindBestActivity(Objects *actor);
std::string ToString();
private:
// *todo separate these into a module
dtNavMeshQuery* m_navQuery;
const dtNavMesh *m_navMesh;
dtQueryFilter m_filter;
dtStatus m_pathFindStatus;
enum ToolMode
{
TOOLMODE_PATHFIND_FOLLOW,
TOOLMODE_PATHFIND_STRAIGHT,
TOOLMODE_PATHFIND_SLICED,
TOOLMODE_RAYCAST,
TOOLMODE_DISTANCE_TO_WALL,
TOOLMODE_FIND_POLYS_IN_CIRCLE,
TOOLMODE_FIND_POLYS_IN_SHAPE,
TOOLMODE_FIND_LOCAL_NEIGHBOURHOOD,
};
ToolMode m_toolMode;
int m_straightPathOptions;
static const int MAX_POLYS = 256;
static const int MAX_SMOOTH = 2048;
dtPolyRef m_startRef;
dtPolyRef m_endRef;
dtPolyRef m_polys[MAX_POLYS];
dtPolyRef m_parent[MAX_POLYS];
int m_npolys;
float m_straightPath[MAX_POLYS*3];
unsigned char m_straightPathFlags[MAX_POLYS];
dtPolyRef m_straightPathPolys[MAX_POLYS];
int m_nstraightPath;
float m_polyPickExt[3];
float m_smoothPath[MAX_SMOOTH*3];
int m_nsmoothPath;
float m_queryPoly[4*3];
static const int MAX_RAND_POINTS = 64;
float m_randPoints[MAX_RAND_POINTS*3];
int m_nrandPoints;
bool m_randPointsInCircle;
float m_spos[3];
float m_epos[3];
float m_hitPos[3];
float m_hitNormal[3];
bool m_hitResult;
float m_distanceToWall;
float m_neighbourhoodRadius;
float m_randomRadius;
bool m_sposSet;
bool m_eposSet;
int m_pathIterNum;
dtPolyRef m_pathIterPolys[MAX_POLYS];
int m_pathIterPolyCount;
float m_prevIterPos[3], m_iterPos[3], m_steerPos[3], m_targetPos[3];
static const int MAX_STEER_POINTS = 10;
float m_steerPoints[MAX_STEER_POINTS*3];
int m_steerPointCount;
private:
class NavMesh
{
public:
static NavMeshLoader& GetNavMeshLoader()
{
static NavMeshLoader m_NavMeshLoader;
return m_NavMeshLoader;
}
};
public:
void SetSrcPos(const D3DXVECTOR3& src);
void SetDestPos(const D3DXVECTOR3& dest);
float* GetPath(int index);
private:
float m_SrcPos[3];
float m_DestPos[3];
protected:
// iterating the path
int mStep;
};
Thanks
Jack