Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/orxonox_tutorial/src/orxonox/objects/TutorialShip.cc @ 1862

Last change on this file since 1862 was 1862, checked in by rgrieder, 16 years ago

added some open ended stuff

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *                         TUTORIAL
6 */
7
8// for precompiled header files. Has to be first!
9#include "OrxonoxStableHeaders.h"
10// always include this class's header file first so that
11// it compiles on its own too.
12#include "TutorialShip.h"
13
14// Additional includes
15#include <OgreEntity.h>
16#include <OgreSceneNode.h>
17#include <OgreSceneManager.h>
18#include <OgreLight.h>
19#include "util/Convert.h"
20#include "util/Debug.h"
21#include "core/ConfigValueIncludes.h"
22#include "core/ConsoleCommand.h"
23#include "core/CoreIncludes.h"
24#include "core/input/InputManager.h"
25#include "core/XMLPort.h"
26#include "GraphicsEngine.h"
27
28namespace orxonox
29{
30    // Specify a console command that can be used in
31    // the shell or as key binding.
32    SetConsoleCommand(TutorialShip, fire, true)
33        .keybindMode(KeybindMode::OnHold);
34
35    // Make sure we can create an object of this class by XML
36    CreateFactory(TutorialShip);
37
38    // Constructor
39    TutorialShip::TutorialShip()
40    {
41        RegisterObject(TutorialShip);
42
43        // reset variables
44        this->hasSpecialEffects_ = false;
45
46        // set config values
47        this->setConfigValues();
48    }
49
50    // Destructor
51    TutorialShip::~TutorialShip()
52    {
53    }
54
55    // Sets the configurable member variables.
56    // They can be found later in orxonox.ini directly.
57    void TutorialShip::setConfigValues()
58    {
59        SetConfigValue(reloadTime_, 0.125)
60            .description("The reload time of the weapon in seconds");
61    }
62   
63    // Called when loading an object of this class with XML
64    // You don't have to know what exactly xmlelement is.
65    // And mode is not important yet (load/save).
66    void TutorialShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
67    {
68        // Load our parameter "specialEffects". Case sensitive!
69        XMLPortParam(TutorialShip, "specialEffects", setSpecialEffects,
70            hasSpecialEffects, xmlelement, mode);
71
72        // Calls SpaceShip::XMLPort so that the SpaceShip XML parameters
73        // are loaded too.
74        SUPER(TutorialShip, XMLPort, xmlelement, mode);
75
76        // Display a message in shell/logfile/console
77        COUT(3) << "TutorialShip was loaded." << std::endl;
78
79        // Additional tutorial expedition
80        //Ogre::SceneNode* shipNode = this->getNode();
81        //Ogre::SceneManager* mgr = GraphicsEngine::getInstance().getLevelSceneManager();
82        //Ogre::SceneNode* newNode = shipNode->createChildSceneNode("newNode");
83        //Ogre::BillboardSet* bbset = mgr->createBillboardSet("TutBBS");
84        //bbset->createBillboard(Vector3(0,0,0), ColourValue(1,1,1));
85        //bbset->setMaterialName("Examples/Flare");
86        //newNode->setPosition(Vector3(30,0,0));
87        //newNode->scale(Vector3(0.1));
88        //newNode->attachObject(bbset);
89    }
90
91    // XML save function. Also used by back end class SpaceShip
92    // to show or hide the special effects.
93    bool TutorialShip::hasSpecialEffects()
94    {
95        return this->hasSpecialEffects_;
96    }
97
98    // XML load function. Called by the XML macro above.
99    void TutorialShip::setSpecialEffects(bool value)
100    {
101        this->hasSpecialEffects_ = value;
102    }
103
104    /*** NOT SO IMPORTATANT... ***/
105
106    // run time update method. Gets called every frame with the delta time that
107    // has passed since the last frame.
108    void TutorialShip::tick(float dt)
109    {
110        // Also call the tick() method of the base clas.
111        SUPER(TutorialShip, tick, dt);
112    }
113
114    // virtual function used by back end class SpaceShip.
115    float TutorialShip::getReloadTime()
116    {
117        return this->reloadTime_;
118    }
119
120    // Fire a projectile. Delegated to the back end class SpaceShip.
121    // Function content is insignificant for the tutorial.
122    void TutorialShip::fire()
123    {
124        SpaceShip::getLocalShip()->doFire();
125    }
126}
Note: See TracBrowser for help on using the repository browser.