i want to put down mouse every pos under the screen and get the position by Vector2 mousePos = QuickGUI::MouseCursor::getSingleton().getPixelPosition(); then, i can put a model on this position. but i try some ways, it didn't work. anyone can give some advice?
thans a lot!
This functionality is shown in Intermediate Tutorial 3:
// Setup the ray scene query, use CEGUI's mouse position
CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();
Ray mouseRay = mCamera->getCameraToViewportRay(mousePos.d_x/float(arg.state.width), mousePos.d_y/float(arg.state.height));
// Execute query
RaySceneQueryResult &result = mRaySceneQuery->execute();
RaySceneQueryResult::iterator itr = result.begin( );
// Get results, create a node/entity on the position
if (itr != result.end() && itr->worldFragment)
This code is using CEGUI, the only difference is that you need to derive the getCameraToViewportRay paramters from data QuickGUI gives you. Get the pixel position and divide width by screen width, height by screen height..
thanks. but i don't use terrian. and i just tried another way. i don't know whether is passible.
Actually the code works regardless of terrain. Just remove the "&& itr->worldFragment" part. Basically you will cast a ray through the camera, and all movable objects will be returned. You can also add masks to objects to distinguish movable objects, if you need.