Getting a ray from the mouse and camera

SDKTrays (OGRE default GUI)

  1. Override createFrameListener to show the cursor.
    void MarbleGame::createFrameListener(void) {
    	BaseApplication::createFrameListener();
    	mTrayMgr->showCursor();
    }
    
  2. When you need the ray from the camera through the cursor call:
    Ogre::Ray ray = mTrayMgr->getCursorRay(mCamera);
    

CEGUI

  1. Look at the code in the mouseMoved method in OGRE's Intermediate Tutorial 3
  2. You will call getCameraToViewportRay with the scene coordinates of the mouse (numbers between (0, 0) for the top left to (1, 1) for the bottom right.


Clif Presser<cpresser@gettysburg.edu>
Last modified: Wed Apr 15 11:45:23 EDT 2015