2
// C++ Interface: IWorldPickListener
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2006
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
23
#ifndef EMBEROGREIWORLDPICKLISTENER_H
24
#define EMBEROGREIWORLDPICKLISTENER_H
26
#include "EmberOgrePrerequisites.h"
29
class RaySceneQueryResultEntry;
38
The kind of mouse click operation.
50
Mouse picking info from the windowing system.
52
struct MousePickerArgs
55
The x coords in local window space.
59
The y coords in local window space.
64
The type of picking (either singe or double click).
66
MousePickType pickType;
71
@author Erik Hjortsberg <erik.hjortsberg@gmail.com>
73
When a pick operation is performed in the world, i.e. when the user clicks the mouse on something in the world, the AvatarCamera will first check what was picked, which will most often result in a list of Ogre::MovableObjects, and then for each of these objects as its internal list of IWorldPickListener instances whether any of those knows how to handle the object picked.
74
This allows us a great deal of flexibility when we want to add support for different types of things that can be interacted with in the world.
76
The first stage of the picking action is that the initializePickingContext() method is called. This allows the listeners to do some cleanup before the actual processing. Then processPickResult(...) will be called for each object, in order of the nearness to the camera (nearer objects being handled first). If any of the listeners sets the argument continuePicking to false, the picking action will then end, and endPickingContext() will be called.
78
Normal operation for an implementation of this is then, if it can handle the object picked, to mark it, but wait with performing the action action until endPickingContext(...) is called (as opposed to performing the action directly when processPickResult(...) is called).
81
class IWorldPickListener
85
virtual ~IWorldPickListener() {}
88
@brief Called at the start of a picking context.
89
This allows the pickers to be reset and to keep state for each picking.
91
virtual void initializePickingContext() {}
94
@brief Called when the picking is over, either because one of the processPickResult calls set continuePicking to false, or because there are no more objects to pick.
95
* @param mousePickerArgs The original mouse picking arguments.
97
virtual void endPickingContext(const MousePickerArgs& mousePickerArgs) {}
100
* @brief Processes the pick result.
101
* This will be called for each picked object.
102
* This is where you need to put your logic checking whether the picked object is something that your implementation knows how to handle. If you don't want any other listeners to then act on the object (which you in most cases don't want) you need to set the continuePicking argument to false.
103
* @param continuePicking set this to false if you don't want to process any more pick results, or don't want any other IWorldPickListener to process the pick any more
104
* @param entry The actual pick entry.
105
* @param cameraRay The ray which resulted in the pick.
106
* @param mousePickerArgs The original mouse picker arguments.
108
virtual void processPickResult(bool& continuePicking, Ogre::RaySceneQueryResultEntry& entry, Ogre::Ray& cameraRay, const MousePickerArgs& mousePickerArgs) = 0;