19 #ifndef ___WALKPOLY_HEADER___ 20 #define ___WALKPOLY_HEADER___ 25 #include <csgeom/vector3.h> 26 #include <csgeom/box.h> 27 #include <iutil/objreg.h> 28 #include <csutil/array.h> 29 #include <csutil/csstring.h> 30 #include <csutil/list.h> 43 void Dump3(
const char* name,
const csVector3 &p);
44 void Dump(
const char* name,
const csBox3 &b);
45 void Dump(
const char* name,
const csVector3 &p);
47 float Calc2DDistance(
const csVector3 &a,
const csVector3 &b);
48 float AngleDiff(
float a1,
float a2);
57 void Calc(
const csVector3 &p1,
const csVector3 &p2);
58 void CalcPerp(
const csVector3 &begin,
const csVector3 &end);
59 float CalcDist(
const csVector3 &point);
60 float CalcRel(
const csVector3 &point);
61 void Copy(ps2DLine &dest);
83 class psSpatialIndexNode
85 friend class psSpatialIndex;
91 psSpatialIndexNode* FindNodeOfPoint(
const csVector3 &p);
94 void Add(psWalkPoly* poly);
101 csList<psWalkPoly*>* GetPolys()
117 psSpatialIndexNode* child1, * child2;
118 psSpatialIndexNode* parent;
126 csList<psWalkPoly*> polys;
137 void Add(psWalkPoly* poly);
144 psSpatialIndexNode* FindNodeOfPoint(
const csVector3 &p, psSpatialIndexNode* hint=NULL);
150 psWalkPoly* FindPolyOfPoint(
const csVector3 &p, psSpatialIndexNode* hint=NULL);
152 psANode* FindNearbyANode(
const csVector3 &pos);
155 psSpatialIndexNode root;
162 psSeed(csVector3 pos, iSector* sector,
float quality);
163 psSeed(csVector3 edgePos, csVector3 pos, iSector* sector,
float quality);
164 void SaveToString(csString &str);
165 void LoadFromXML(iDocumentNode* node, iEngine* engine);
170 csVector3 pos, edgePos;
177 psSeedSet(iObjectRegistry* objReg);
178 psSeed PickUpBestSeed();
179 void AddSeed(
const psSeed &seed);
182 return seeds.IsEmpty();
185 bool LoadFromString(
const csString &str);
186 bool LoadFromFile(
const csString &path);
188 void SaveToString(csString &str);
189 bool SaveToFile(
const csString &path);
192 iObjectRegistry* objReg;
193 csList<psSeed> seeds;
207 csVector3 begin, end;
218 csArray<psWalkPolyCont> conts;
221 bool touching, stuck;
227 psWalkPolyVert(
const csVector3 &pos);
231 psWalkPoly* FindCont(
const csVector3 &point);
233 void CalcLineTo(
const csVector3 &point);
239 friend class psWalkPoly;
241 psWalkPolyMap(iObjectRegistry* objReg);
244 void SetObjReg(iObjectRegistry* objReg)
250 void AddPoly(psWalkPoly*);
253 bool CheckDirectPath(csVector3 start, csVector3 goal);
259 csString DumpPolys();
261 void BuildBasicAMap(psAMap &AMap);
263 void LoadFromXML(iDocumentNode* node);
264 bool LoadFromString(
const csString &str);
265 bool LoadFromFile(
const csString &path);
267 void SaveToString(csString &str);
268 bool SaveToFile(
const csString &path);
270 psANode* FindNearbyANode(
const csVector3 &pos);
272 psWalkPoly* FindPoly(
int id);
276 void DeleteContsWith(psWalkPoly* poly);
280 csList<psWalkPoly*> polys;
281 psSpatialIndex index;
283 csHash<psWalkPoly*> polyByID;
285 iObjectRegistry* objReg;
298 friend class psWalkPolyMap;
305 void AddVert(
const csVector3 &pos,
int beforeIndex=-1);
308 return verts.GetSize();
311 void AddNode(psANode* node);
312 void DeleteNode(psANode* node);
314 void SetSector(iSector* sector);
320 bool MoveToNextPoly(
const csVector3 &goal, csVector3 &point, psWalkPoly* &nextPoly);
322 void AddSeeds(psMapWalker* walker, psSeedSet &seeds);
325 bool CheckConvexity(
int vertNum);
330 void Cut(
const csVector3 &cut1,
const csVector3 &cut2);
332 void Intersect(
const psWalkPoly &other);
334 float EstimateY(
const csVector3 &point);
336 void Dump(
const char* name);
337 void DumpJS(
const char* name);
339 void DumpPolyJS(
const char* name);
341 int Stretch(psMapWalker &walker, psWalkPolyMap &map,
float stepSize);
342 void GlueToNeighbours(psMapWalker &walker, psWalkPolyMap &map);
346 float GetTriangleArea(
int vertNum);
347 float GetLengthOfEdges();
348 void GetShape(
float &
min,
float &
max);
349 float GetNarrowness();
351 void PruneUnboundVerts(psMapWalker &walker);
352 void PruneInLineVerts();
354 bool IsNearWalls(psMapWalker &walker,
int vertNum);
357 bool StretchVert(psMapWalker &walker, psWalkPolyMap &map,
int vertNum,
const csVector3 &newPos,
float stepSize);
359 void SetMini(psMapWalker &walker,
const csVector3 &pos,
int numVerts);
372 bool CollidesWithPolys(psWalkPolyMap &map, csList<psWalkPoly*>* polys);
374 void SaveToString(csString &str);
375 void LoadFromXML(iDocumentNode* node, iEngine* engine);
378 void CalcConts(psWalkPolyMap &map);
380 void RecalcAllEdges();
382 void ConnectNodeToPoly(psANode* node,
bool bidirectional);
384 bool TouchesPoly(psWalkPoly* poly);
385 bool NeighboursTouchEachOther();
387 psANode* GetFirstNode();
398 bool PointIsIn(
const csVector3 &p,
float maxRel=0);
400 csVector3 GetClosestPoint(
const csVector3 &point,
float &angle);
406 return nodes.GetSize();
409 bool ReachableFromNeighbours();
411 psWalkPoly* GetNearNeighbour(
const csVector3 &pos,
float maxDist);
413 void DeleteContsWith(psWalkPoly* poly);
415 bool NeighbourSupsMe(psWalkPoly* neighbour);
417 void MovePointInside(csVector3 &point,
const csVector3 &goal);
421 void RecalcEdges(
int vertNum);
423 int FindClosestEdge(
const csVector3 pos);
427 psWalkPoly* FindCont(
const csVector3 &point,
int edgeNum);
432 bool MoveToBorder(
const csVector3 &goal, csVector3 &point,
int &edgeNum);
439 int GetNeighbourIndex(
int vertNum,
int offset)
const;
441 bool HandleProblems(psMapWalker &walker, psWalkPolyMap &map,
int vertNum,
const csVector3 &oldPos);
442 csVector3 GetClosestCollisionPoint(csList<psWalkPoly*> &collisions, ps2DLine &line);
443 bool HandlePolyCollisions(psWalkPolyMap &map,
int vertNum,
const csVector3 &oldPos);
449 csArray<psWalkPolyVert> verts;
453 csArray<psANode*> nodes;
psNPCClient * npcclient
Global connection to the NPC Client.
bool CheckValidity(iDocument *musicalScore, csRef< iDocumentNode > &partNode)
Checks if the given document is a valid musical score and provide the <part> node.
The main NPC Client class holding references to important superclient objects.
void Split(const csString &str, csArray< csString > &arr)
Split a csString into an array of sctrings.