Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/main_reto/src/OrxonoxShip.cpp @ 130

Last change on this file since 130 was 130, checked in by rgrieder, 16 years ago
File size: 1.5 KB
Line 
1#include "OrxonoxShip.h"
2
3
4OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode)
5        : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100), thrust(0), sideThrust(0)
6{
7}
8
9
10OrxonoxShip::~OrxonoxShip()
11{
12}
13
14
15bool OrxonoxShip::initialise()
16{
17        // load all the resources needed (no resource groups yet, so the allInit is not executed!)
18        //ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
19
20        // create the "space ship" (currently a fish..)
21        mShip = mSceneMgr->createEntity("Ship", "fish.mesh");
22        SceneNode *fishNode = mRootNode->createChildSceneNode("fishNode");
23        fishNode->yaw(Degree(-90));
24        fishNode->attachObject(mShip);
25        fishNode->setScale(Vector3(10, 10, 10));
26
27        return true;
28}
29
30
31void OrxonoxShip::setThrust(const Real value)
32{
33        thrust = value * baseThrust;
34}
35
36void OrxonoxShip::setSideThrust(const Real value)
37{
38        sideThrust = value * baseThrust;
39}
40
41void OrxonoxShip::setYaw(const Radian value)
42{
43        mRootNode->yaw(value);
44}
45
46void OrxonoxShip::setPitch(const Radian value)
47{
48        mRootNode->pitch(value);
49}
50
51void OrxonoxShip::setRoll(const Radian value)
52{
53        mRootNode->roll(value);
54}
55
56Real OrxonoxShip::getThrust()
57{
58        return thrust;
59}
60
61
62bool OrxonoxShip::tick(unsigned long time, float deltaTime)
63{
64        speed += (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() * thrust * deltaTime;
65        speed += (mRootNode->getLocalAxes() * Vector3(1, 0,  0)).normalisedCopy() * sideThrust * deltaTime;
66
67        mRootNode->translate(speed * deltaTime);
68
69        return true;
70}
Note: See TracBrowser for help on using the repository browser.