Selection
1,206
0
Advertisement

Today I worked on mouse picking. I can click the exclamation mark using query masks and I have enabled a bounding box around the quest marker when I click it so that the selection is visible. Also I have a camera look working with the right mouse button but that is temporary until I get some camera movement implemented.
Here is the selection code:
def select_object(self, evt): scene_manager = self.screenMgr.getSceneMgr() mouse_pos = CEGUI.MouseCursor.getSingleton().getPosition() mouse_x = mouse_pos.d_x mouse_y = mouse_pos.d_y trans_x = float(mouse_x/self.screenMgr.getViewPort().actualWidth) trans_y = float(mouse_y/self.screenMgr.getViewPort().actualHeight) mouse_ray = self.game_camera.getCameraToViewportRay(trans_x, trans_y) if self.ray_scene_query: self.ray_scene_query.setRay(mouse_ray) else: self.ray_scene_query = scene_manager.createRayQuery(mouse_ray) self.ray_scene_query.setSortByDistance(True) self.ray_scene_query.setQueryMask(self.EXCLAIM_MASK) result = self.ray_scene_query.execute() if len(result) > 0: for item in result: if item.movable: print item.movable.getName() item.movable.getParentSceneNode().showBoundingBox(True) CEGUI.WindowManager.getSingleton().getWindow("desptxt").setText(item.movable.getName()+" selected") self.ray_scene_query.clearResults()Advertisement
Advertisement
Advertisement
Discussion