I will paste here the interfacte of CelGraph and its components. At the moment I am finishing some details on A* and I will soon be finishing an application for testing CelGraph and pathfinding.
struct iCelEdge : public virtual iBase
SCF_INTERFACE (iCelEdge, 0, 0, 1);
virtual void SetState(bool open) = 0;
virtual void SetSuccessor(iCelNode* node) = 0;
virtual bool GetState() = 0;
virtual iCelNode* GetSuccessor() = 0;
struct iCelNode : public virtual iBase
SCF_INTERFACE (iCelNode, 0, 0, 1);
virtual void AddSuccessor(iCelNode* node, bool state) = 0;
virtual void SetMapNode(iMapNode* node);
virtual void Heuristic(int cost, iCelNode* goal)= 0;
virtual csVector3 GetPosition() = 0;
virtual csArray iCelNode* GetSuccessors() = 0;
virtual csArray iCelNode* GetAllSuccessors() = 0;
virtual int GetHeuristic () = 0;
virtual int GetCost () = 0;
struct iCelPath : public virtual iBase
SCF_INTERFACE (iCelPath, 0, 0, 1);
virtual void AddNode(iMapNode* node) = 0;
virtual void InsertNode(size_t pos, iMapNode* node) = 0;
virtual iMapNode* Next() = 0;
virtual iMapNode* Previous() = 0;
virtual bool HasNext();
virtual bool HasPrevious();
struct iCelGraph : public virtual iBase
SCF_INTERFACE (iCelGraph, 0, 0, 1);
virtual void AddNode(iCelNode* node) = 0;
virtual void AddEdge(iCelNode* from, iCelNode* to, bool state) = 0;
virtual iCelNode* GetClosest(csVector3 position) = 0;
virtual iCelPath* ShortestPath(iCelNode* from, iCelNode* goal) = 0;
Cohesion, Separation and Direction Matching (this name is going to change probably for Velocity Matching) options are available now
by pressing keys '3', '4', and '5' in the steer application.
Cohesion will work pushing the entity towards the center of mass of a group of entities.
Separation will push the entity away
and Direction Matching will push it towards the same direction a group of entities have.
I've made some advances in pcsteer. Collision Avoidance is still not working, I've tried many things to solve it but I am having problems with csSectorHitBeamResult, I am using it to detect the nearest collision but, most of the time it fails to detect collisions even if it is in front of a wall =S. well, if any of you know how to fix this, please tell me =P.
However, I added the Pursue behaviour, it can be used in the steering application by pressing the 'p' key.
The npc will then pursue the player.
Pursue is different from Seek in:
1. It continues updating the players position until Interrupt() or StopMovement() are called.
2. It predicts a target future position: target_position += velocity*prediction
So Pursue can be used whenever you want an npc to follow a moving target and seek could be used if you want the npc to look for an object or any other non-moving targets.
Well, thats all for now =-)
I've been working in Steering Behaviours this last weeks and I will continue working on it for about two more weeeks I think.
The steering property class is located at plugins/propclass/steer/
right now it supports seeking (with and withour arrival checking) and fleeing.
I already started collision avoidance but it is not fullu working (I hope I'll find out why tomorrow =P)
I've also created a Steering application which is located at apps/tutorial/steering/
All of the above is located it: https://cel.svn.sourceforge.net/svnroot/cel/cel/branches/soc2007/ai
To excecute the steering application you only need to run: ./steering (./steering -relight the first time).
The steering application is based in walktut, it is actually an upgrade on walktut. It has the same entities plus one npc which is able to perform
any action included in pcsteer.
Here is a little tutorial on how to test it:
1 Activates arrival checking
2 Activates collision avoidance (this is not working right now)
s Seek (The npc will run in the players direction)
f Flee (The npc will run in the oposite direction to the player)
This is all for now, hope some of you have time to download and test this application, the idea is that I could get feedback in time to perform any changed =)
|<< <||Current||> >>|