1 // Copyright (C) 2009 - 2012 Mathias Froehlich
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.
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.
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.
22 #include <simgear/math/SGGeometry.hxx>
23 #include <simgear/structure/SGWeakReferenced.hxx>
24 #include <simgear/timing/timestamp.hxx>
26 #include "AIEnvironment.hxx"
27 #include "AIManager.hxx"
28 #include "AIPhysics.hxx"
34 class AIObject : public SGWeakReferenced {
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);
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;
48 const SGTimeStamp& getSimTime() const
51 const AIEnvironment& getEnvironment() const
52 { return *_environment; }
53 AIEnvironment& getEnvironment()
54 { return *_environment; }
56 const AISubsystemGroup& getSubsystemGroup() const
57 { return *_subsystemGroup; }
58 AISubsystemGroup& getSubsystemGroup()
59 { return *_subsystemGroup; }
61 const AIPhysics& getPhysics() const
63 AIPhysics& getPhysics()
67 void setPhysics(AIPhysics* physics)
68 { _physics = physics; }
71 friend class AIManager;
73 // The simulation time
76 // The iterator to our own list entry in the manager class
77 AIManager::ObjectList::iterator _objectListIterator;
79 // The components we have for an ai object
80 SGSharedPtr<AIEnvironment> _environment;
81 SGSharedPtr<AISubsystemGroup> _subsystemGroup;
82 SGSharedPtr<AIPhysics> _physics;
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;