Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 128


Ignore:
Timestamp:
Oct 30, 2007, 11:43:48 PM (16 years ago)
Author:
rgrieder
Message:
 
Location:
code/branches/main_reto
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/include/OrxonoxShip.h

    r127 r128  
    1212        virtual ~OrxonoxShip();
    1313
    14         /*void setThrust(float);
    15         void setSideThrust(float);*/
     14        virtual bool initialise();
    1615
    17         virtual bool initialise();
     16        void setThrust(const Real);
     17        void setSideThrust(const Real);
     18        void setYaw(const Radian);
     19        void setPitch(const Radian);
     20        void setRoll(const Radian);
     21
     22        bool tick(unsigned long, float);
    1823
    1924protected:
     
    2126        SceneNode *mRootNode;
    2227        Entity *mShip;
     28
     29        Vector3 speed;
     30        float thrust, sideThrust, baseThrust;
    2331};
    2432
  • code/branches/main_reto/src/OrxonoxShip.cpp

    r127 r128  
    22
    33
    4 OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode) : mSceneMgr(mSceneMgr), mRootNode(mNode)
     4OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode)
     5        : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100)
    56{
    67}
     
    1920        // create the "space ship" (currently a fish..)
    2021        mShip = mSceneMgr->createEntity("Ship", "fish.mesh");
    21         mRootNode->setScale(Vector3(10, 10, 10));
    22         mRootNode->attachObject(mShip);
     22        SceneNode *fishNode = mRootNode->createChildSceneNode("fishNode");
     23        fishNode->yaw(Degree(-90));
     24        fishNode->attachObject(mShip);
     25        fishNode->setScale(Vector3(10, 10, 10));
    2326
    2427        return true;
    2528}
     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;
     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
     56
     57bool OrxonoxShip::tick(unsigned long time, float deltaTime)
     58{
     59        speed += (mRootNode->getLocalAxes() * Vector3(0, 0, 1)).normalisedCopy() * thrust * deltaTime;
     60
     61        mRootNode->translate(speed * deltaTime);
     62
     63        return true;
     64}
  • code/branches/main_reto/src/RunManager.cpp

    r127 r128  
    284284        // 2nd mouse button - slide, otherwise rotate
    285285        const MouseState &ms = mMouse->getMouseState();
    286         if( ms.buttonDown( MB_Right ) )
    287         {
    288                 mTranslateVector.x += ms.X.rel * 0.13;
    289                 mTranslateVector.y -= ms.Y.rel * 0.13;
    290         }
    291         else
    292         {
    293                 mRotX = Degree(-ms.X.rel * 0.13);
    294                 mRotY = Degree(-ms.Y.rel * 0.13);
    295         }
     286        mRotX = Degree(-ms.X.rel * 0.13);
     287        mRotY = Degree(-ms.Y.rel * 0.13);
     288
     289        mShip->setYaw(mRotX);
     290        mShip->setPitch(mRotY);
    296291
    297292        return true;
     
    304299        // Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW
    305300        //(e.g. airplane)
    306         mCamera->yaw(mRotX);
    307         mCamera->pitch(mRotY);
    308         mCamera->moveRelative(mTranslateVector);
     301        //mCamera->yaw(mRotX);
     302        //mCamera->pitch(mRotY);
     303        //mCamera->moveRelative(mTranslateVector);
     304
     305        mShipNode->translate(mShipNode->getLocalAxes() * mTranslateVector);
    309306}
    310307
  • code/branches/main_reto/weapon_framework/weapon_framework.vcproj

    r127 r128  
    204204                        </File>
    205205                        <File
    206                                 RelativePath="..\include\OrxonoxShip.cpp"
     206                                RelativePath="..\src\OrxonoxShip.cpp"
    207207                                >
    208208                        </File>
Note: See TracChangeset for help on using the changeset viewer.