Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 647 was 647, checked in by landauf, 16 years ago

good morning everybody!
did some changes in the steering of SpaceShip

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            Projectile* proj = new Projectile(this);
350            this->timeToReload_ = this->reloadTime_;
351        }
352
353        OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();
354        OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();
355
356        mKeyboard->capture();
357        mMouse->capture();
358
359
360        // #####################################
361        // ############# STEERING ##############
362        // #####################################
363
364        if (this->velocity_.x > this->maxSpeed_)
365            this->velocity_.x = this->maxSpeed_;
366        if (this->velocity_.x < -this->maxSideAndBackSpeed_)
367            this->velocity_.x = -this->maxSideAndBackSpeed_;
368        if (this->velocity_.y > this->maxSideAndBackSpeed_)
369            this->velocity_.y = this->maxSideAndBackSpeed_;
370        if (this->velocity_.y < -this->maxSideAndBackSpeed_)
371            this->velocity_.y = -this->maxSideAndBackSpeed_;
372        if (this->rotationRate_ > this->maxRotationRadian_)
373            this->rotationRate_ = this->maxRotationRadian_;
374        if (this->rotationRate_ < -this->maxRotationRadian_)
375            this->rotationRate_ = -this->maxRotationRadian_;
376
377        if (this->acceleration_.x == 0)
378        {
379            if (this->velocity_.x > 0)
380            {
381                this->velocity_.x -= (this->translationDamping_ * dt);
382                if (this->velocity_.x < 0)
383                    this->velocity_.x = 0;
384            }
385            else if (this->velocity_.x < 0)
386            {
387                this->velocity_.x += (this->translationDamping_ * dt);
388                if (this->velocity_.x > 0)
389                    this->velocity_.x = 0;
390            }
391        }
392
393        if (this->acceleration_.y == 0)
394        {
395            if (this->velocity_.y > 0)
396            {
397                this->velocity_.y -= (this->translationDamping_ * dt);
398                if (this->velocity_.y < 0)
399                    this->velocity_.y = 0;
400            }
401            else if (this->velocity_.y < 0)
402            {
403                this->velocity_.y += (this->translationDamping_ * dt);
404                if (this->velocity_.y > 0)
405                    this->velocity_.y = 0;
406            }
407        }
408
409        if (this->momentum_ == this->zeroRadian_)
410        {
411            if (this->rotationRate_ > this->zeroRadian_)
412            {
413                this->rotationRate_ -= (this->rotationDampingRadian_ * dt);
414                if (this->rotationRate_ < this->zeroRadian_)
415                    this->rotationRate_ = 0;
416            }
417            else if (this->rotationRate_ < this->zeroRadian_)
418            {
419                this->rotationRate_ += (this->rotationDampingRadian_ * dt);
420                if (this->rotationRate_ > this->zeroRadian_)
421                    this->rotationRate_ = 0;
422            }
423        }
424
425        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
426            this->acceleration_.x = this->translationAcceleration_;
427        else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
428            this->acceleration_.x = -this->translationAcceleration_;
429        else
430            this->acceleration_.x = 0;
431
432        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
433            this->acceleration_.y = -this->translationAcceleration_;
434        else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
435            this->acceleration_.y = this->translationAcceleration_;
436        else
437            this->acceleration_.y = 0;
438
439        if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
440            this->momentum_ = Radian(-this->rotationAccelerationRadian_);
441        else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
442            this->momentum_ = Radian(this->rotationAccelerationRadian_);
443        else
444            this->momentum_ = 0;
445
446        WorldEntity::tick(dt);
447
448        this->roll(this->mouseXRotation_ * dt);
449        if (this->bInvertYAxis_)
450            this->yaw(Radian(-this->mouseYRotation_ * dt));
451        else
452            this->yaw(Radian(this->mouseYRotation_ * dt));
453
454        if (this->acceleration_.x > 0)
455            this->tt_->setRate(emitterRate_);
456        else
457            this->tt_->setRate(0);
458
459/*
460        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
461            this->moveForward(speed);
462        else
463            this->moveForward(0);
464
465        if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
466            this->brakeForward(speed);
467        else
468            this->brakeForward(speed/10);
469
470        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
471            this->loopRight(loop);
472        else
473            this->loopRight(0);
474
475        if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
476            this->loopLeft(loop);
477        else
478            this->loopLeft(0);
479
480        if(moved)
481        {
482            if (mouseY<=0)
483                this->rotateUp(-mouseY*rotate);
484            if (mouseY>0)
485                this->rotateDown(mouseY*rotate);
486            if (mouseX>0)
487                this->rotateRight(mouseX*rotate);
488            if (mouseX<=0)
489                this->rotateLeft(-mouseX*rotate);
490
491            mouseY = 0;
492            mouseX = 0;
493            moved = false;
494        }*/
495/*        else
496        {
497            this->rotateUp(0);
498            this->rotateDown(0);
499            this->rotateRight(0);
500            this->rotateLeft(0);
501        }*/
502/*
503        if(moveForward_ > 0)
504        {
505            accelerationForward_ = moveForward_;
506            if(speedForward_ < maxSpeedForward_)
507                speedForward_ += accelerationForward_*dt;
508            if(speedForward_ > maxSpeedForward_)
509                speedForward_ = maxSpeedForward_;
510        }
511
512        if(moveForward_ <= 0)
513        {
514            accelerationForward_ = -brakeForward_;
515            if(speedForward_ > 0)
516                speedForward_ += accelerationForward_*dt;
517            if(speedForward_ < 0)
518                speedForward_ = 0;
519        }
520
521        if(rotateUp_ > 0)
522        {
523            accelerationRotateUpDown_ = rotateUp_;
524            if(speedRotateUpDown_ < maxSpeedRotateUpDown_)
525                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
526            if(speedRotateUpDown_ > maxSpeedRotateUpDown_)
527            speedRotateUpDown_ = maxSpeedRotateUpDown_;
528        }
529
530        if(rotateDown_ > 0)
531        {
532            accelerationRotateUpDown_ = rotateDown_;
533            if(speedRotateUpDown_ > -maxSpeedRotateUpDown_)
534                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
535            if(speedRotateUpDown_ < -maxSpeedRotateUpDown_)
536                speedRotateUpDown_ = -maxSpeedRotateUpDown_;
537        }
538
539        if(rotateUp_ == 0 && rotateDown_ == 0)
540        {
541            accelerationRotateUpDown_ = brakeRotate_;
542            if(speedRotateUpDown_ > 0)
543                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
544            if(speedRotateUpDown_ < 0)
545                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
546            if(fabs(speedRotateUpDown_) < accelerationRotateUpDown_*dt)
547                speedRotateUpDown_ = 0;
548        }
549
550        if(rotateRight_ > 0)
551        {
552            accelerationRotateRightLeft_ = rotateRight_;
553            if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_)
554                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
555            if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_)
556                speedRotateRightLeft_ = -maxSpeedRotateRightLeft_;
557        }
558
559        if(rotateLeft_ > 0)
560        {
561            accelerationRotateRightLeft_ = rotateLeft_;
562            if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_)
563                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
564            if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_)
565                speedRotateRightLeft_ = maxSpeedRotateRightLeft_;
566        }
567
568        if(rotateRight_ == 0 && rotateLeft_ == 0)
569        {
570            accelerationRotateRightLeft_ = brakeRotate_;
571            if(speedRotateRightLeft_ > 0)
572                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
573            if(speedRotateRightLeft_ < 0)
574                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
575            if(fabs(speedRotateRightLeft_) < accelerationRotateRightLeft_*dt)
576                speedRotateRightLeft_ = 0;
577        }
578
579        if(loopRight_ > 0)
580        {
581            accelerationLoopRightLeft_ = loopRight_;
582            if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_)
583                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
584            if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_)
585                speedLoopRightLeft_ = maxSpeedLoopRightLeft_;
586        }
587
588        if(loopLeft_ > 0)
589        {
590            accelerationLoopRightLeft_ = loopLeft_;
591            if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_)
592                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
593            if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_)
594                speedLoopRightLeft_ = -maxSpeedLoopRightLeft_;
595        }
596
597        if(loopLeft_ == 0 && loopRight_ == 0)
598        {
599            accelerationLoopRightLeft_ = brakeLoop_;
600            if(speedLoopRightLeft_ > 0)
601                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
602            if(speedLoopRightLeft_ < 0)
603                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
604            if(fabs(speedLoopRightLeft_) < accelerationLoopRightLeft_*dt)
605                speedLoopRightLeft_ = 0;
606        }
607
608        Vector3 transVector = Vector3::ZERO;
609*/
610/*
611        transVector.z = 1;
612        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
613        this->pitch(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
614        this->yaw(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
615        this->roll(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
616*/
617/*
618        transVector.x = 1;
619        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
620        this->yaw(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
621        this->roll(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
622        this->pitch(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
623*/
624    }
625/*
626    void SpaceShip::moveForward(float moveForward) {
627        moveForward_ = moveForward;
628    }
629
630    void SpaceShip::rotateUp(float rotateUp) {
631        rotateUp_ = rotateUp;
632    }
633
634    void SpaceShip::rotateDown(float rotateDown) {
635        rotateDown_ = rotateDown;
636    }
637
638    void SpaceShip::rotateLeft(float rotateLeft) {
639        rotateLeft_ = rotateLeft;
640    }
641
642    void SpaceShip::rotateRight(float rotateRight) {
643        rotateRight_ = rotateRight;
644    }
645
646    void SpaceShip::loopLeft(float loopLeft) {
647        loopLeft_ = loopLeft;
648    }
649
650    void SpaceShip::loopRight(float loopRight) {
651        loopRight_ = loopRight;
652    }
653
654    void SpaceShip::brakeForward(float brakeForward) {
655        brakeForward_ = brakeForward;
656    }
657
658    void SpaceShip::brakeRotate(float brakeRotate) {
659        brakeRotate_ = brakeRotate;
660    }
661
662    void SpaceShip::brakeLoop(float brakeLoop) {
663        brakeLoop_ = brakeLoop;
664    }
665
666    void SpaceShip::maxSpeedForward(float maxSpeedForward) {
667        maxSpeedForward_ = maxSpeedForward;
668    }
669
670    void SpaceShip::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) {
671        maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
672    }
673
674    void SpaceShip::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) {
675        maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
676    }
677
678    void SpaceShip::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) {
679        maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
680    }
681*/
682}
Note: See TracBrowser for help on using the repository browser.