Changeset 141 for code/branches/main_reto/src/OrxonoxShip.cpp
- Timestamp:
- Nov 1, 2007, 7:48:48 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/src/OrxonoxShip.cpp
r136 r141 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * 21 * Author: 22 * Reto Grieder 23 * Co-authors: 24 * ... 25 * 26 */ 27 1 28 #include "OrxonoxShip.h" 2 29 3 30 4 31 OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode) 5 : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(1000), thrust(0), sideThrust(0), n(0), 32 : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), 33 baseThrust(1000), thrust(0), sideThrust(0), n(0), 6 34 bulletSpeed(400) 7 35 { … … 16 44 bool OrxonoxShip::initialise() 17 45 { 18 // load all the resources needed (no resource groups yet, so the allInit is not executed!) 19 //ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 46 // load all the resources needed (no resource groups yet, 47 // so the allInit is not executed!) 48 // ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 20 49 21 50 // create the "space ship" (currently a fish..) … … 64 93 { 65 94 // TODO: Names must be unique! 66 SceneNode *temp = mRootNode->getParentSceneNode()->createChildSceneNode("BulletNode" + StringConverter::toString(n)); 95 SceneNode *temp = mRootNode->getParentSceneNode()->createChildSceneNode( 96 "BulletNode" + StringConverter::toString(n)); 67 97 temp->setOrientation(mRootNode->getOrientation()); 68 98 temp->setPosition(mRootNode->getPosition()); 69 99 temp->setScale(Vector3(1, 1, 1) * 10); 70 100 temp->yaw(Degree(-90)); 71 return new Bullet(temp, 72 mSceneMgr->createEntity("bullet" + StringConverter::toString(n++), "Barrel.mesh"), 73 speed + (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() * bulletSpeed); 101 return new Bullet(temp, mSceneMgr->createEntity("bullet" 102 + StringConverter::toString(n++), "Barrel.mesh"), speed 103 + (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() 104 * bulletSpeed); 74 105 } 75 106 76 bool OrxonoxShip::tick(unsigned long time, floatdeltaTime)107 bool OrxonoxShip::tick(unsigned long time, Real deltaTime) 77 108 { 78 speed += (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() * thrust * deltaTime; 79 speed += (mRootNode->getLocalAxes() * Vector3(-1, 0, 0)).normalisedCopy() * sideThrust * deltaTime; 109 Quaternion quad = mRootNode->getOrientation(); 110 quad.normalise(); 111 speed += quad * Vector3(0, 0, -1) * thrust * deltaTime; 112 speed += quad * Vector3(-1, 0, 0) * sideThrust * deltaTime; 80 113 81 114 mRootNode->translate(speed * deltaTime);
Note: See TracChangeset
for help on using the changeset viewer.