1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #include "OgreStableHeaders.h"
|
---|
26 |
|
---|
27 | #include "OgreCursor.h"
|
---|
28 | #include "OgreEventListeners.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 | //-----------------------------------------------------------------------
|
---|
34 |
|
---|
35 | Cursor::Cursor() :
|
---|
36 | MouseMotionTarget(),
|
---|
37 | MouseTarget()
|
---|
38 | {
|
---|
39 | mXLowLimit = 0;
|
---|
40 | mXHighLimit = 1;
|
---|
41 | mYLowLimit = 0;
|
---|
42 | mYHighLimit = 1;
|
---|
43 | mZLowLimit = 0;
|
---|
44 | mZHighLimit = 1;
|
---|
45 |
|
---|
46 | mScale = 1;
|
---|
47 | mMouseX = 0.5;
|
---|
48 | mMouseY = 0.5;
|
---|
49 | mMouseZ = 0.5;
|
---|
50 |
|
---|
51 | mRelX = 0.0;
|
---|
52 | mRelY = 0.0;
|
---|
53 | mRelZ = 0.0;
|
---|
54 | }
|
---|
55 |
|
---|
56 | //-----------------------------------------------------------------------
|
---|
57 |
|
---|
58 | Cursor::~Cursor()
|
---|
59 | {
|
---|
60 | }
|
---|
61 |
|
---|
62 | //-----------------------------------------------------------------------
|
---|
63 | void Cursor::addToX(Real val)
|
---|
64 | {
|
---|
65 | Real valReal = val * mScale;
|
---|
66 | mRelX = valReal;
|
---|
67 | mMouseX = limit(mMouseX + valReal,mXLowLimit, mXHighLimit);
|
---|
68 | }
|
---|
69 |
|
---|
70 | //-----------------------------------------------------------------------
|
---|
71 | void Cursor::addToY(Real val)
|
---|
72 | {
|
---|
73 | Real valReal = val * mScale;
|
---|
74 | mRelY = valReal;
|
---|
75 | mMouseY = limit(mMouseY + valReal,mYLowLimit, mYHighLimit);
|
---|
76 | }
|
---|
77 |
|
---|
78 | //-----------------------------------------------------------------------
|
---|
79 | void Cursor::addToZ(Real val)
|
---|
80 | {
|
---|
81 | Real valReal = val * mScale;
|
---|
82 | mRelZ = valReal;
|
---|
83 | mMouseZ = limit(mMouseZ + valReal,mZLowLimit, mZHighLimit);
|
---|
84 | }
|
---|
85 |
|
---|
86 | //-----------------------------------------------------------------------
|
---|
87 | void Cursor::processEvent(InputEvent* e)
|
---|
88 | {
|
---|
89 | switch(e->getID())
|
---|
90 | {
|
---|
91 | case MouseEvent::ME_MOUSE_PRESSED:
|
---|
92 | case MouseEvent::ME_MOUSE_RELEASED:
|
---|
93 | case MouseEvent::ME_MOUSE_CLICKED:
|
---|
94 | case MouseEvent::ME_MOUSE_ENTERED:
|
---|
95 | case MouseEvent::ME_MOUSE_EXITED:
|
---|
96 | processMouseEvent(static_cast<MouseEvent*>(e));
|
---|
97 | break;
|
---|
98 | case MouseEvent::ME_MOUSE_MOVED:
|
---|
99 | case MouseEvent::ME_MOUSE_DRAGGED:
|
---|
100 | processMouseMotionEvent(static_cast<MouseEvent*>(e));
|
---|
101 | break;
|
---|
102 | }
|
---|
103 |
|
---|
104 | mRelX = 0.0;
|
---|
105 | mRelY = 0.0;
|
---|
106 | mRelZ = 0.0;
|
---|
107 | }
|
---|
108 |
|
---|
109 | //-----------------------------------------------------------------------
|
---|
110 | Real Cursor::getX() const
|
---|
111 | {
|
---|
112 | return mMouseX;
|
---|
113 | }
|
---|
114 |
|
---|
115 | //-----------------------------------------------------------------------
|
---|
116 | Real Cursor::getY() const
|
---|
117 | {
|
---|
118 | return mMouseY;
|
---|
119 | }
|
---|
120 |
|
---|
121 | //-----------------------------------------------------------------------
|
---|
122 | Real Cursor::getZ() const
|
---|
123 | {
|
---|
124 | return mMouseZ;
|
---|
125 | }
|
---|
126 |
|
---|
127 | //-----------------------------------------------------------------------
|
---|
128 | Real Cursor::getLeft(void) const
|
---|
129 | {
|
---|
130 | return getX();
|
---|
131 | }
|
---|
132 |
|
---|
133 | //-----------------------------------------------------------------------
|
---|
134 | Real Cursor::getTop(void) const
|
---|
135 | {
|
---|
136 | return getY();
|
---|
137 |
|
---|
138 | }
|
---|
139 |
|
---|
140 | //-----------------------------------------------------------------------
|
---|
141 | PositionTarget* Cursor::getPositionTargetParent() const
|
---|
142 | {
|
---|
143 | return NULL;
|
---|
144 | }
|
---|
145 |
|
---|
146 | }
|
---|
147 |
|
---|