Changeset 417


Ignore:
Timestamp:
11/16/05 11:09:15 (19 years ago)
Author:
mattausch
Message:

added object place mode in demo. quake style movements

Location:
trunk/VUT
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp

    r415 r417  
    141141mDemoFps(0), 
    142142mUseDemoFps(false), 
    143 mUseArbQueries(false) 
     143mUseArbQueries(false), 
     144mUseBufferedInputMouse(false) 
    144145{ 
    145146        //mInputDevice = PlatformManager::getSingleton().createInputReader(); 
     
    156157        mInputDevice = mEventProcessor->getInputReader();        
    157158 
     159        mInputDevice->setBufferedInput(true, mUseBufferedInputMouse); 
     160 
    158161        // create ray query executor, used to place objects in terrain 
    159162        mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 
     
    216219void TerrainFrameListener::mousePressed(MouseEvent* e) 
    217220{ 
    218      // Left mouse button down 
    219      if (e->getButtonID() & InputEvent::BUTTON0_MASK) 
    220      { 
    221                  CEGUI::MouseCursor::getSingleton().hide(); 
    222  
    223                  // Setup the ray scene query 
    224          Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 
     221        // Left mouse button down 
     222        if (e->getButtonID() & InputEvent::BUTTON0_MASK) 
     223        { 
     224                CEGUI::MouseCursor::getSingleton().hide(); 
     225 
     226                // Setup the ray scene query 
     227                Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 
    225228                  
    226                  //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 
    227                   
    228                  Real val = Math::RangeRandom(0, 360); // random rotation 
    229  
    230                  // get results, create a node/entity on the position 
    231                  mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 
    232                          mouseRay.getOrigin()/*queryResult*/, Vector3(val, 0, 0),  
    233                          msObjectCaptions[mCurrentObjectType]); 
    234                  
    235          mLMouseDown = true;  
    236      } 
    237      // Right mouse button down 
    238      else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 
    239      { 
     229                //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 
     230                Real val = Math::RangeRandom(0, 360); // random rotation 
     231 
     232                // get results, create a node/entity on the position 
     233                mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 
     234                        mouseRay.getOrigin(), Vector3(val, 0, 0),  
     235                        msObjectCaptions[mCurrentObjectType]); 
     236                 
     237                mLMouseDown = true;  
     238        } 
     239        // Right mouse button down 
     240        /*else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 
     241        { 
    240242         CEGUI::MouseCursor::getSingleton().hide(); 
    241243         mRMouseDown = true; 
    242      } 
     244        }*/ 
    243245} 
    244246//----------------------------------------------------------------------- 
     
    289291//----------------------------------------------------------------------- 
    290292void TerrainFrameListener::mouseDragged(MouseEvent *e) 
    291  { 
    292          // If we are dragging the left mouse button.             
    293          if (mLMouseDown) 
    294      { 
    295                  if (!mCurrentObject) 
    296                          return; 
    297  
    298                  Vector3 queryResult; 
    299                  Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 
    300  
    301                  if (mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay)) 
    302                  { 
    303                          // apply offset so object is ON terrain 
    304                          queryResult.y += msObjectTerrainOffsets[mCurrentObjectType]; 
    305                          mCurrentObject->setPosition(queryResult); 
    306                  } 
    307      } 
    308          // If we are dragging the right mouse button. 
    309          if (mRMouseDown) 
    310          { 
    311                  //mCamera->yaw(-e->getRelX() * mRotateSpeed); 
    312                  //mCamera->pitch(-e->getRelY() * mRotateSpeed); 
    313                  mCamNode->yaw(-e->getRelX() * mRotateSpeed); 
    314                  mCamNode->pitch(-e->getRelY() * mRotateSpeed); 
    315          } 
     293{ 
     294        // If we are dragging the left mouse button.              
     295        if (mLMouseDown) 
     296    { 
     297                if (!mCurrentObject) 
     298                        return; 
     299 
     300                Vector3 queryResult; 
     301                Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 
     302 
     303                if (mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay)) 
     304                { 
     305                        // apply offset so object is ON terrain 
     306                        queryResult.y += msObjectTerrainOffsets[mCurrentObjectType]; 
     307                        mCurrentObject->setPosition(queryResult); 
     308                } 
     309        } 
    316310} 
    317311//----------------------------------------------------------------------- 
     
    370364                return false; 
    371365        } 
    372 /*      if (!processUnbufferedMouseInput(evt)) 
    373         {       return false;   }*/ 
     366        if (!mUseBufferedInputMouse) 
     367        { 
     368                if (!processUnbufferedMouseInput(evt)) 
     369                {        
     370                        return false;    
     371                } 
     372        } 
    374373 
    375374        //-- set parameters for visualization 
     
    593592} 
    594593 
     594 
     595bool TerrainFrameListener::processUnbufferedMouseInput(const FrameEvent& evt) 
     596{ 
     597        /* Rotation factors, may not be used if the second mouse button is pressed. */ 
     598 
     599    /* If the second mouse button is pressed, then the mouse movement results in  
     600       sliding the camera, otherwise we rotate. */ 
     601    if (mInputDevice->getMouseButton(1)) 
     602    { 
     603                mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13; 
     604                mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13; 
     605        } 
     606        else 
     607        { 
     608                mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13); 
     609                mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13); 
     610        } 
     611 
     612        return true; 
     613} 
    595614//----------------------------------------------------------------------- 
    596615bool TerrainFrameListener::frameEnded(const FrameEvent& evt) 
     
    12011220                toggleUseArbQueries(); 
    12021221                break; 
    1203  
     1222        case KC_O: 
     1223                switchMouseMode(); 
     1224                break; 
    12041225        //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 
    12051226        //KEY_PRESSED(KC_F4, 0.3, loadFrames()); 
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h

    r343 r417  
    111111   bool frameStarted(const FrameEvent& evt); 
    112112   bool frameEnded(const FrameEvent& evt); 
    113    //bool processUnbufferedKeyInput(const FrameEvent& evt); 
    114      
     113      
    115114 
    116115   /* MouseListener callbacks. */ 
     
    172171    bool processUnbufferedKeyInput(const FrameEvent& evt); 
    173172    bool processUnbufferedMouseInput(const FrameEvent& evt); 
     173 
     174        void switchMouseMode()  
     175        { 
     176        mUseBufferedInputMouse = !mUseBufferedInputMouse; 
     177                mInputDevice->setBufferedInput(true, mUseBufferedInputMouse); 
     178        } 
    174179 
    175180        /** Shows the frame / algorithm statistics. 
     
    393398        float mPureRenderTimeFps; 
    394399        TestCullingTerrainApplication *mApplication; 
     400 
     401        bool mUseBufferedInputMouse; 
    395402}; 
    396403 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r350 r417  
    231231 
    232232        // Set ambient light 
    233         mAmbientLight = ColourValue(0.5 , 0.5, 0.5); 
     233        mAmbientLight = ColourValue(0.5, 0.5, 0.5); 
    234234        mSceneMgr->setAmbientLight(mAmbientLight); 
    235235         
     
    316316        Vector3 scale(val, val, val);  
    317317        const float maxHeight = 75; 
    318         // to provide much occlusion, 
     318         
     319        // In order to provide much occlusion, 
    319320        // height is restricted to maxHeight => no objects are created on peaks 
    320321        mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos)); 
    321322        mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, maxHeight, mTerrainMaxPos.z)); 
    322         std::stringstream d; d << "objscale: " << scale[0]; 
    323         Ogre::LogManager::getSingleton().logMessage(d.str()); 
     323         
     324        //std::stringstream d; d << "objscale: " << scale[0]; 
     325        //Ogre::LogManager::getSingleton().logMessage(d.str()); 
     326         
    324327        mTerrainContentGenerator->SetScale(scale); 
    325328        mTerrainContentGenerator->SetOffset(TerrainFrameListener::msObjectTerrainOffsets[objectType]); 
  • trunk/VUT/work/iv/IVFrameListener.cpp

    r345 r417  
    258258                return false; 
    259259        } 
    260 /*      if (!processUnbufferedMouseInput(evt)) 
    261         {       return false;   }*/ 
     260        if (!processUnbufferedMouseInput(evt)) 
     261        {        
     262                return false;    
     263        } 
    262264 
    263265        // --- set parameters for visualization 
     
    313315                break; 
    314316        };       
     317 
     318        return true; 
     319} 
     320 
     321bool IVFrameListener::processUnbufferedMouseInput(const FrameEvent& evt) 
     322{ 
     323        /* Rotation factors, may not be used if the second mouse button is pressed. */ 
     324 
     325    /* If the second mouse button is pressed, then the mouse movement results in  
     326       sliding the camera, otherwise we rotate. */ 
     327    if (mInputDevice->getMouseButton(1)) 
     328    { 
     329                mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13; 
     330                mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13; 
     331        } 
     332        else 
     333        { 
     334                mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13); 
     335                mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13); 
     336        } 
     337 
    315338 
    316339        return true; 
Note: See TracChangeset for help on using the changeset viewer.