Debian Codegraph @

utils/fgai/AIObject.hxx

raw symbols SCIP
1 // Copyright (C) 2009 - 2012 Mathias Froehlich
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 #ifndef AIObject_hxx
18 #define AIObject_hxx
19
20 #include <list>
21 #include <string>
22 #include <simgear/math/SGGeometry.hxx>
23 #include <simgear/structure/SGWeakReferenced.hxx>
24 #include <simgear/timing/timestamp.hxx>
25
26 #include "AIEnvironment.hxx"
27 #include "AIManager.hxx"
28 #include "AIPhysics.hxx"
29
30 namespace fgai {
31
32 class AIBVHPager;
33
34 class AIObject : public SGWeakReferenced {
35 public:
36 AIObject();
37 virtual ~AIObject();
38
39 // also register the required hla objects here
40 virtual void init(AIManager& manager);
41 virtual void update(AIManager& manager, const SGTimeStamp& simTime);
42 virtual void shutdown(AIManager& manager);
43
44 void setGroundCache(const AIPhysics& physics, AIBVHPager& pager, const SGTimeStamp& dt);
45 bool getGroundIntersection(SGVec3d& point, SGVec3d& normal, const SGLineSegmentd& lineSegment) const;
46 bool getGroundIntersection(SGPlaned& plane, const SGLineSegmentd& lineSegment) const;
47
48 const SGTimeStamp& getSimTime() const
49 { return _simTime; }
50
51 const AIEnvironment& getEnvironment() const
52 { return *_environment; }
53 AIEnvironment& getEnvironment()
54 { return *_environment; }
55
56 const AISubsystemGroup& getSubsystemGroup() const
57 { return *_subsystemGroup; }
58 AISubsystemGroup& getSubsystemGroup()
59 { return *_subsystemGroup; }
60
61 const AIPhysics& getPhysics() const
62 { return *_physics; }
63 AIPhysics& getPhysics()
64 { return *_physics; }
65
66 protected:
67 void setPhysics(AIPhysics* physics)
68 { _physics = physics; }
69
70 private:
71 friend class AIManager;
72
73 // The simulation time
74 SGTimeStamp _simTime;
75
76 // The iterator to our own list entry in the manager class
77 AIManager::ObjectList::iterator _objectListIterator;
78
79 // The components we have for an ai object
80 SGSharedPtr<AIEnvironment> _environment;
81 SGSharedPtr<AISubsystemGroup> _subsystemGroup;
82 SGSharedPtr<AIPhysics> _physics;
83
84 /// The equivalent of the ground cache for FGInterface.
85 SGSharedPtr<simgear::BVHNode> _node;
86 /// The sphere we really queried for the ground cache
87 SGSphered _querySphere;
88 };
89
90 } // namespace fgai
91
92 #endif