~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/IWorldPickListener.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// C++ Interface: IWorldPickListener
 
3
//
 
4
// Description: 
 
5
//
 
6
//
 
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2006
 
8
//
 
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.
 
13
// 
 
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.
 
18
// 
 
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.//
 
22
//
 
23
#ifndef EMBEROGREIWORLDPICKLISTENER_H
 
24
#define EMBEROGREIWORLDPICKLISTENER_H
 
25
 
 
26
#include "EmberOgrePrerequisites.h"
 
27
 
 
28
namespace Ogre {
 
29
class RaySceneQueryResultEntry;
 
30
class Ray;
 
31
}
 
32
 
 
33
namespace EmberOgre {
 
34
 
 
35
 
 
36
 
 
37
/**
 
38
The kind of mouse click operation.
 
39
*/
 
40
enum MousePickType
 
41
{
 
42
        ///Simple click
 
43
        MPT_CLICK = 1,
 
44
        ///Double click
 
45
        MPT_DOUBLECLICK = 2
 
46
 
 
47
};
 
48
 
 
49
/**
 
50
Mouse picking info from the windowing system.
 
51
*/
 
52
struct MousePickerArgs
 
53
{
 
54
        /**
 
55
        The x coords in local window space.
 
56
        */
 
57
        float windowX;
 
58
        /**
 
59
        The y coords in local window space.
 
60
        */
 
61
        float windowY;
 
62
        
 
63
        /**
 
64
        The type of picking (either singe or double click).
 
65
        */
 
66
        MousePickType pickType;
 
67
};
 
68
 
 
69
 
 
70
/**
 
71
        @author Erik Hjortsberg <erik.hjortsberg@gmail.com>
 
72
        
 
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.
 
75
        
 
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.
 
77
        
 
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).
 
79
        
 
80
*/
 
81
class IWorldPickListener
 
82
{
 
83
public:
 
84
 
 
85
virtual ~IWorldPickListener() {}
 
86
 
 
87
/**
 
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.
 
90
*/
 
91
virtual void initializePickingContext() {}
 
92
 
 
93
/**
 
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.
 
96
 */
 
97
virtual void endPickingContext(const MousePickerArgs& mousePickerArgs) {}
 
98
 
 
99
/**
 
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.
 
107
 */
 
108
virtual void processPickResult(bool& continuePicking, Ogre::RaySceneQueryResultEntry& entry, Ogre::Ray& cameraRay, const MousePickerArgs& mousePickerArgs) = 0;
 
109
 
 
110
 
 
111
};
 
112
 
 
113
}
 
114
 
 
115
#endif