Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/SpaceShip.cc @ 660

Last change on this file since 660 was 660, checked in by nicolasc, 16 years ago
  • added FIXME-tags - should be selfexplanatory
File size: 24.4 KB
Line 
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
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (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, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      ...
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "SpaceShip.h"
29#include "Projectile.h"
30
31#include "../../tinyxml/tinyxml.h"
32#include "../../misc/String2Number.h"
33#include "../core/CoreIncludes.h"
34#include "../Orxonox.h"
35
36#include "OgreCamera.h"
37#include <OgreRenderWindow.h>
38
39namespace orxonox
40{
41    CreateFactory(SpaceShip);
42
43    SpaceShip::SpaceShip()
44    {
45        RegisterObject(SpaceShip);
46
47        SetConfigValue(bInvertYAxis_, false);
48        SetConfigValue(reloadTime_, 0.125);
49
50        this->setMouseEventCallback_ = false;
51        this->bLMousePressed_ = false;
52        this->bRMousePressed_ = false;
53        this->mouseX_ = 0;
54        this->mouseY_ = 0;
55
56        this->camNode_ = 0;
57
58        this->tt_ = 0;
59        this->redNode_ = 0;
60        this->greenNode_ = 0;
61        this->blinkTime_ = 0;
62
63        this->timeToReload_ = 0;
64
65        this->maxSpeed_ = 0;
66        this->maxSideAndBackSpeed_ = 0;
67        this->maxRotation_ = 0;
68        this->translationAcceleration_ = 0;
69        this->rotationAcceleration_ = 0;
70        this->translationDamping_ = 0;
71        this->rotationDamping_ = 0;
72
73        this->maxRotationRadian_ = 0;
74        this->rotationAccelerationRadian_ = 0;
75        this->rotationDampingRadian_ = 0;
76        this->zeroRadian_ = Radian(0);
77
78        this->setRotationAxis(1, 0, 0);
79        this->setStatic(false);
80/*
81        this->moveForward_ = 0;
82        this->rotateUp_ = 0;
83        this->rotateDown_ = 0;
84        this->rotateRight_ = 0;
85        this->rotateLeft_ = 0;
86        this->loopRight_ = 0;
87        this->loopLeft_ = 0;
88        this->brakeForward_ = 0;
89        this->brakeRotate_ = 0;
90        this->brakeLoop_ = 0;
91        this->speedForward_ = 0;
92        this->speedRotateUpDown_ = 0;
93        this->speedRotateRightLeft_ = 0;
94        this->speedLoopRightLeft_ = 0;
95        this->maxSpeedForward_ = 0;
96        this->maxSpeedRotateUpDown_ = 0;
97        this->maxSpeedRotateRightLeft_ = 0;
98        this->maxSpeedLoopRightLeft_ = 0;
99        this->accelerationForward_ = 0;
100        this->accelerationRotateUpDown_ = 0;
101        this->accelerationRotateRightLeft_ = 0;
102        this->accelerationLoopRightLeft_ = 0;
103
104        this->speed = 250;
105        this->loop = 100;
106        this->rotate = 10;
107        this->mouseX = 0;
108        this->mouseY = 0;
109        this->maxMouseX = 0;
110        this->minMouseX = 0;
111        this->moved = false;
112
113        this->brakeRotate(rotate*10);
114        this->brakeLoop(loop);
115*/
116        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
117    }
118
119    SpaceShip::~SpaceShip()
120    {
121        if (this->tt_)
122            delete this->tt_;
123    }
124
125    void SpaceShip::loadParams(TiXmlElement* xmlElem)
126    {
127        Model::loadParams(xmlElem);
128
129
130        // START CREATING THRUSTER
131        this->tt_ = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
132        this->tt_->getParticleSystem()->setParameter("local_space","true");
133        this->tt_->newEmitter();
134/*
135        this->tt_->setDirection(Vector3(0,0,1));
136        this->tt_->setPositionOfEmitter(0, Vector3(20,-1,-15));
137        this->tt_->setPositionOfEmitter(1, Vector3(-20,-1,-15));
138*/
139        this->tt_->setDirection(Vector3(-1,0,0));
140        this->tt_->setPositionOfEmitter(0, Vector3(-15,20,-1));
141        this->tt_->setPositionOfEmitter(1, Vector3(-15,-20,-1));
142        this->tt_->setVelocity(50);
143
144        emitterRate_ = tt_->getRate();
145
146        Ogre::SceneNode* node2 = this->getNode()->createChildSceneNode(this->getName() + "particle2");
147        node2->setInheritScale(false);
148        tt_->addToSceneNode(node2);
149        // END CREATING THRUSTER
150
151        // START CREATING BLINKING LIGHTS
152        this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
153        this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
154
155        this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.7, -0.3));
156        this->redNode_->setInheritScale(false);
157        this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.7, -0.3));
158        this->greenNode_->setInheritScale(false);
159
160        this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
161        this->redNode_->setScale(0.3, 0.3, 0.3);
162
163        this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
164        this->greenNode_->setScale(0.3, 0.3, 0.3);
165        // END CREATING BLINKING LIGHTS
166
167
168/*
169        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
170        {
171            std::string forwardStr = xmlElem->Attribute("forward");
172            std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
173            std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
174            std::string looprightleftStr = xmlElem->Attribute("looprightleft");
175
176            String2Number<float>(this->maxSpeedForward_, forwardStr);
177            String2Number<float>(this->maxSpeedRotateUpDown_, rotateupdownStr);
178            String2Number<float>(this->maxSpeedRotateRightLeft_, rotaterightleftStr);
179            String2Number<float>(this->maxSpeedLoopRightLeft_, looprightleftStr);
180
181            COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
182        }
183*/
184        if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp"))
185        {
186
187            std::string msStr = xmlElem->Attribute("maxSpeed");
188            std::string msabsStr = xmlElem->Attribute("maxSideAndBackSpeed");
189            std::string mrStr = xmlElem->Attribute("maxRotation");
190            std::string taStr = xmlElem->Attribute("transAcc");
191            std::string raStr = xmlElem->Attribute("rotAcc");
192            std::string tdStr = xmlElem->Attribute("transDamp");
193            std::string rdStr = xmlElem->Attribute("rotDamp");
194
195            String2Number<float>(this->maxSpeed_, msStr);
196            String2Number<float>(this->maxSideAndBackSpeed_, msabsStr);
197            String2Number<float>(this->maxRotation_, mrStr);
198            String2Number<float>(this->translationAcceleration_, taStr);
199            String2Number<float>(this->rotationAcceleration_, raStr);
200            String2Number<float>(this->translationDamping_, tdStr);
201            String2Number<float>(this->rotationDamping_, rdStr);
202
203            this->maxRotationRadian_ = Radian(this->maxRotation_);
204            this->rotationAccelerationRadian_ = Radian(this->rotationAcceleration_);
205            this->rotationDampingRadian_ = Radian(this->rotationDamping_);
206
207            COUT(4) << "Loader: Initialized SpaceShip" << std::endl;
208        }
209
210        if (xmlElem->Attribute("camera"))
211        {
212            Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam");
213            this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
214/*
215//            node->setInheritOrientation(false);
216            cam->setPosition(Vector3(0,50,-150));
217            cam->lookAt(Vector3(0,20,0));
218            cam->roll(Degree(0));
219*/
220
221            cam->setPosition(Vector3(-150,0,50));
222//            cam->setPosition(Vector3(0,-350,0));
223            cam->lookAt(Vector3(0,0,20));
224            cam->roll(Degree(-90));
225
226            this->camNode_->attachObject(cam);
227            Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
228        }
229    }
230
231    int sgn(float x)
232    {
233        if (x >= 0)
234            return 1;
235        else
236            return -1;
237    }
238
239    bool SpaceShip::mouseMoved(const OIS::MouseEvent &e)
240    {
241/*
242        this->mouseX += e.state.X.rel;
243        if (this->bInvertMouse_)
244            this->mouseY += e.state.Y.rel;
245        else
246            this->mouseY -= e.state.Y.rel;
247
248//        if(mouseX>maxMouseX) maxMouseX = mouseX;
249//        if(mouseX<minMouseX) minMouseX = mouseX;
250//        cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
251
252        this->moved = true;
253*/
254        if (this->bRMousePressed_)
255        {
256            this->camNode_->roll(Degree(-e.state.X.rel * 0.10));
257            this->camNode_->yaw(Degree(e.state.Y.rel * 0.10));
258        }
259        else
260        {
261            float minDimension = e.state.height;
262            if (e.state.width < minDimension)
263                minDimension = e.state.width;
264
265            this->mouseX_ += e.state.X.rel;
266            if (this->mouseX_ < -minDimension)
267                this->mouseX_ = -minDimension;
268            if (this->mouseX_ > minDimension)
269                this->mouseX_ = minDimension;
270
271            this->mouseY_ += e.state.Y.rel;
272            if (this->mouseY_ < -minDimension)
273                this->mouseY_ = -minDimension;
274            if (this->mouseY_ > minDimension)
275                this->mouseY_ = minDimension;
276
277            float xRotation = this->mouseX_ / minDimension;
278            xRotation = xRotation*xRotation * sgn(xRotation);
279            xRotation *= -this->rotationAcceleration_;
280            if (xRotation > this->maxRotation_)
281                xRotation = this->maxRotation_;
282            if (xRotation < -this->maxRotation_)
283                xRotation = -this->maxRotation_;
284            this->mouseXRotation_ = Radian(xRotation);
285
286            float yRotation = this->mouseY_ / minDimension;
287            yRotation = yRotation*yRotation * sgn(yRotation);
288            yRotation *= this->rotationAcceleration_;
289            if (yRotation > this->maxRotation_)
290                yRotation = this->maxRotation_;
291            if (yRotation < -this->maxRotation_)
292                yRotation = -this->maxRotation_;
293            this->mouseYRotation_ = Radian(yRotation);
294        }
295
296        return true;
297    }
298
299    bool SpaceShip::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
300    {
301        if (id == OIS::MB_Left)
302            this->bLMousePressed_ = true;
303        else if (id == OIS::MB_Right)
304            this->bRMousePressed_ = true;
305
306        return true;
307    }
308
309    bool SpaceShip::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
310    {
311        if (id == OIS::MB_Left)
312            this->bLMousePressed_ = false;
313        else if (id == OIS::MB_Right)
314        {
315            this->bRMousePressed_ = false;
316            this->camNode_->resetOrientation();
317        }
318
319        return true;
320    }
321
322    void SpaceShip::tick(float dt)
323    {
324        if (!this->setMouseEventCallback_)
325        {
326            if (Orxonox::getSingleton()->getMouse())
327            {
328                Orxonox::getSingleton()->getMouse()->setEventCallback(this);
329                this->setMouseEventCallback_ = true;
330            }
331        }
332
333        if (this->redNode_ && this->greenNode_)
334        {
335            this->blinkTime_ += dt;
336            float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
337            float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
338            this->redNode_->setScale(redScale, redScale, redScale);
339            this->greenNode_->setScale(greenScale, greenScale, greenScale);
340        }
341
342        if (this->timeToReload_ > 0)
343            this->timeToReload_ -= dt;
344        else
345            this->timeToReload_ = 0;
346
347        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
348        {
349            // FIXME, unused var; try recycling of projectiles
350            Projectile* proj = new Projectile(this);
351            this->timeToReload_ = this->reloadTime_;
352        }
353
354        OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();
355        OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();
356
357        mKeyboard->capture();
358        mMouse->capture();
359
360
361        // #####################################
362        // ############# STEERING ##############
363        // #####################################
364
365        if (this->velocity_.x > this->maxSpeed_)
366            this->velocity_.x = this->maxSpeed_;
367        if (this->velocity_.x < -this->maxSideAndBackSpeed_)
368            this->velocity_.x = -this->maxSideAndBackSpeed_;
369        if (this->velocity_.y > this->maxSideAndBackSpeed_)
370            this->velocity_.y = this->maxSideAndBackSpeed_;
371        if (this->velocity_.y < -this->maxSideAndBackSpeed_)
372            this->velocity_.y = -this->maxSideAndBackSpeed_;
373        if (this->rotationRate_ > this->maxRotationRadian_)
374            this->rotationRate_ = this->maxRotationRadian_;
375        if (this->rotationRate_ < -this->maxRotationRadian_)
376            this->rotationRate_ = -this->maxRotationRadian_;
377
378        if (this->acceleration_.x == 0)
379        {
380            if (this->velocity_.x > 0)
381            {
382                this->velocity_.x -= (this->translationDamping_ * dt);
383                if (this->velocity_.x < 0)
384                    this->velocity_.x = 0;
385            }
386            else if (this->velocity_.x < 0)
387            {
388                this->velocity_.x += (this->translationDamping_ * dt);
389                if (this->velocity_.x > 0)
390                    this->velocity_.x = 0;
391            }
392        }
393
394        if (this->acceleration_.y == 0)
395        {
396            if (this->velocity_.y > 0)
397            {
398                this->velocity_.y -= (this->translationDamping_ * dt);
399                if (this->velocity_.y < 0)
400                    this->velocity_.y = 0;
401            }
402            else if (this->velocity_.y < 0)
403            {
404                this->velocity_.y += (this->translationDamping_ * dt);
405                if (this->velocity_.y > 0)
406                    this->velocity_.y = 0;
407            }
408        }
409
410        if (this->momentum_ == this->zeroRadian_)
411        {
412            if (this->rotationRate_ > this->zeroRadian_)
413            {
414                this->rotationRate_ -= (this->rotationDampingRadian_ * dt);
415                if (this->rotationRate_ < this->zeroRadian_)
416                    this->rotationRate_ = 0;
417            }
418            else if (this->rotationRate_ < this->zeroRadian_)
419            {
420                this->rotationRate_ += (this->rotationDampingRadian_ * dt);
421                if (this->rotationRate_ > this->zeroRadian_)
422                    this->rotationRate_ = 0;
423            }
424        }
425
426        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
427            this->acceleration_.x = this->translationAcceleration_;
428        else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
429            this->acceleration_.x = -this->translationAcceleration_;
430        else
431            this->acceleration_.x = 0;
432
433        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
434            this->acceleration_.y = -this->translationAcceleration_;
435        else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
436            this->acceleration_.y = this->translationAcceleration_;
437        else
438            this->acceleration_.y = 0;
439
440        if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
441            this->momentum_ = Radian(-this->rotationAccelerationRadian_);
442        else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
443            this->momentum_ = Radian(this->rotationAccelerationRadian_);
444        else
445            this->momentum_ = 0;
446
447        WorldEntity::tick(dt);
448
449        this->roll(this->mouseXRotation_ * dt);
450        if (this->bInvertYAxis_)
451            this->yaw(Radian(-this->mouseYRotation_ * dt));
452        else
453            this->yaw(Radian(this->mouseYRotation_ * dt));
454
455        if (this->acceleration_.x > 0)
456            this->tt_->setRate(emitterRate_);
457        else
458            this->tt_->setRate(0);
459
460/*
461        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
462            this->moveForward(speed);
463        else
464            this->moveForward(0);
465
466        if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
467            this->brakeForward(speed);
468        else
469            this->brakeForward(speed/10);
470
471        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
472            this->loopRight(loop);
473        else
474            this->loopRight(0);
475
476        if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
477            this->loopLeft(loop);
478        else
479            this->loopLeft(0);
480
481        if(moved)
482        {
483            if (mouseY<=0)
484                this->rotateUp(-mouseY*rotate);
485            if (mouseY>0)
486                this->rotateDown(mouseY*rotate);
487            if (mouseX>0)
488                this->rotateRight(mouseX*rotate);
489            if (mouseX<=0)
490                this->rotateLeft(-mouseX*rotate);
491
492            mouseY = 0;
493            mouseX = 0;
494            moved = false;
495        }*/
496/*        else
497        {
498            this->rotateUp(0);
499            this->rotateDown(0);
500            this->rotateRight(0);
501            this->rotateLeft(0);
502        }*/
503/*
504        if(moveForward_ > 0)
505        {
506            accelerationForward_ = moveForward_;
507            if(speedForward_ < maxSpeedForward_)
508                speedForward_ += accelerationForward_*dt;
509            if(speedForward_ > maxSpeedForward_)
510                speedForward_ = maxSpeedForward_;
511        }
512
513        if(moveForward_ <= 0)
514        {
515            accelerationForward_ = -brakeForward_;
516            if(speedForward_ > 0)
517                speedForward_ += accelerationForward_*dt;
518            if(speedForward_ < 0)
519                speedForward_ = 0;
520        }
521
522        if(rotateUp_ > 0)
523        {
524            accelerationRotateUpDown_ = rotateUp_;
525            if(speedRotateUpDown_ < maxSpeedRotateUpDown_)
526                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
527            if(speedRotateUpDown_ > maxSpeedRotateUpDown_)
528            speedRotateUpDown_ = maxSpeedRotateUpDown_;
529        }
530
531        if(rotateDown_ > 0)
532        {
533            accelerationRotateUpDown_ = rotateDown_;
534            if(speedRotateUpDown_ > -maxSpeedRotateUpDown_)
535                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
536            if(speedRotateUpDown_ < -maxSpeedRotateUpDown_)
537                speedRotateUpDown_ = -maxSpeedRotateUpDown_;
538        }
539
540        if(rotateUp_ == 0 && rotateDown_ == 0)
541        {
542            accelerationRotateUpDown_ = brakeRotate_;
543            if(speedRotateUpDown_ > 0)
544                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
545            if(speedRotateUpDown_ < 0)
546                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
547            if(fabs(speedRotateUpDown_) < accelerationRotateUpDown_*dt)
548                speedRotateUpDown_ = 0;
549        }
550
551        if(rotateRight_ > 0)
552        {
553            accelerationRotateRightLeft_ = rotateRight_;
554            if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_)
555                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
556            if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_)
557                speedRotateRightLeft_ = -maxSpeedRotateRightLeft_;
558        }
559
560        if(rotateLeft_ > 0)
561        {
562            accelerationRotateRightLeft_ = rotateLeft_;
563            if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_)
564                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
565            if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_)
566                speedRotateRightLeft_ = maxSpeedRotateRightLeft_;
567        }
568
569        if(rotateRight_ == 0 && rotateLeft_ == 0)
570        {
571            accelerationRotateRightLeft_ = brakeRotate_;
572            if(speedRotateRightLeft_ > 0)
573                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
574            if(speedRotateRightLeft_ < 0)
575                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
576            if(fabs(speedRotateRightLeft_) < accelerationRotateRightLeft_*dt)
577                speedRotateRightLeft_ = 0;
578        }
579
580        if(loopRight_ > 0)
581        {
582            accelerationLoopRightLeft_ = loopRight_;
583            if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_)
584                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
585            if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_)
586                speedLoopRightLeft_ = maxSpeedLoopRightLeft_;
587        }
588
589        if(loopLeft_ > 0)
590        {
591            accelerationLoopRightLeft_ = loopLeft_;
592            if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_)
593                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
594            if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_)
595                speedLoopRightLeft_ = -maxSpeedLoopRightLeft_;
596        }
597
598        if(loopLeft_ == 0 && loopRight_ == 0)
599        {
600            accelerationLoopRightLeft_ = brakeLoop_;
601            if(speedLoopRightLeft_ > 0)
602                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
603            if(speedLoopRightLeft_ < 0)
604                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
605            if(fabs(speedLoopRightLeft_) < accelerationLoopRightLeft_*dt)
606                speedLoopRightLeft_ = 0;
607        }
608
609        Vector3 transVector = Vector3::ZERO;
610*/
611/*
612        transVector.z = 1;
613        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
614        this->pitch(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
615        this->yaw(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
616        this->roll(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
617*/
618/*
619        transVector.x = 1;
620        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
621        this->yaw(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
622        this->roll(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
623        this->pitch(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
624*/
625    }
626/*
627    void SpaceShip::moveForward(float moveForward) {
628        moveForward_ = moveForward;
629    }
630
631    void SpaceShip::rotateUp(float rotateUp) {
632        rotateUp_ = rotateUp;
633    }
634
635    void SpaceShip::rotateDown(float rotateDown) {
636        rotateDown_ = rotateDown;
637    }
638
639    void SpaceShip::rotateLeft(float rotateLeft) {
640        rotateLeft_ = rotateLeft;
641    }
642
643    void SpaceShip::rotateRight(float rotateRight) {
644        rotateRight_ = rotateRight;
645    }
646
647    void SpaceShip::loopLeft(float loopLeft) {
648        loopLeft_ = loopLeft;
649    }
650
651    void SpaceShip::loopRight(float loopRight) {
652        loopRight_ = loopRight;
653    }
654
655    void SpaceShip::brakeForward(float brakeForward) {
656        brakeForward_ = brakeForward;
657    }
658
659    void SpaceShip::brakeRotate(float brakeRotate) {
660        brakeRotate_ = brakeRotate;
661    }
662
663    void SpaceShip::brakeLoop(float brakeLoop) {
664        brakeLoop_ = brakeLoop;
665    }
666
667    void SpaceShip::maxSpeedForward(float maxSpeedForward) {
668        maxSpeedForward_ = maxSpeedForward;
669    }
670
671    void SpaceShip::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) {
672        maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
673    }
674
675    void SpaceShip::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) {
676        maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
677    }
678
679    void SpaceShip::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) {
680        maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
681    }
682*/
683}
Note: See TracBrowser for help on using the repository browser.