1 /*****************************************************************************
2  * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
3  * @file
4  * @author  Jim E. Brooks  http://www.palomino3d.org
5  * @brief   Craft class (base class for aircraft).
6  *//*
7  * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
8  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
9  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
10  *****************************************************************************/
11 
12 #define OBJECT_CRAFT_CC 1
13 #include "base/module.hh"
14 #include "base/random.hh"
15 #include "base/clamp.hh"
16 using namespace base;
17 #include "view/module.hh"
18 using namespace view;
19 #include "physics/module.hh"
20 #include "physics/physics_aircraft.hh"
21 using namespace physics;
22 #include "control/module.hh"
23 #include "control/conf.hh"
24 #include "control/command.hh"
25 #include "control/events.hh"
26 using namespace control;
27 #include "world/module.hh"
28 using namespace world;
29 #include "object/module.hh"
30 #include "object/defs.hh"
31 #include "object/craft.hh"
32 
33 namespace object {
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /////////////////////////////////  Craft  //////////////////////////////////////
37 ////////////////////////////////////////////////////////////////////////////////
38 
39 /*****************************************************************************
40  * ctor/dtor.
41  *****************************************************************************/
Craft(shptr<Graph> graph,const WorldVertex & pos)42 Craft::Craft( shptr<Graph> graph, const WorldVertex& pos )
43 :   Parent(graph,pos),
44     mThrottle(0.0f)
45 {
46     SET_TYPESIG(this,TYPESIG_CRAFT);
47 }
48 
~Craft()49 Craft::~Craft()
50 {
51     INVALIDATE_TYPESIG(this,TYPESIG_CRAFT);
52 }
53 
54 /*****************************************************************************
55  * Reset.
56  *****************************************************************************/
57 void
Reset(void)58 Craft::Reset( void )
59 {
60 CHECK_TYPESIG(this,TYPESIG_CRAFT);
61 
62     Parent::Reset();
63 
64     mThrottle = 0.0f;
65 }
66 
67 /*****************************************************************************
68  * Set throttle.
69  * throttle = {0.0,..,1.0}
70  * @param   throttle
71  *          This method will clamp if necessary.
72  *****************************************************************************/
73 void
SetThrottle(const fp throttle)74 Craft::SetThrottle( const fp throttle )
75 {
76 CHECK_TYPESIG(this,TYPESIG_CRAFT);
77 
78     mThrottle = Clamp1( throttle );
79 }
80 
81 /*****************************************************************************
82  * @return Throttle {0.0,..,1.0}.
83  *****************************************************************************/
84 fp
GetThrottle(void)85 Craft::GetThrottle( void )
86 {
87 CHECK_TYPESIG(this,TYPESIG_CRAFT);
88 
89     return mThrottle;
90 }
91 
92 } // namespace object
93