Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.