Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreCursor.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreStableHeaders.h"
00026 
00027 #include "OgreCursor.h" 
00028 #include "OgreEventListeners.h"
00029 
00030 
00031 namespace Ogre {
00032 
00033     //-----------------------------------------------------------------------
00034 
00035     Cursor::Cursor() :
00036         MouseMotionTarget(),
00037         MouseTarget()
00038     {
00039         mXLowLimit = 0;
00040         mXHighLimit = 1;
00041         mYLowLimit = 0;
00042         mYHighLimit = 1;
00043         mZLowLimit = 0;
00044         mZHighLimit = 1;
00045 
00046         mScale = 1;
00047         mMouseX = 0.5;
00048         mMouseY = 0.5;
00049         mMouseZ = 0.5;
00050 
00051         mRelX = 0.0;
00052         mRelY = 0.0;
00053         mRelZ = 0.0;
00054     }
00055 
00056     //-----------------------------------------------------------------------
00057 
00058     Cursor::~Cursor()
00059     {
00060     }
00061 
00062     //-----------------------------------------------------------------------
00063     void Cursor::addToX(Real val)
00064     {
00065         Real valReal = val * mScale;
00066         mRelX = valReal;
00067         mMouseX = limit(mMouseX + valReal,mXLowLimit, mXHighLimit);
00068     }
00069 
00070     //-----------------------------------------------------------------------
00071     void Cursor::addToY(Real val)
00072     {
00073         Real valReal = val * mScale;
00074         mRelY = valReal;
00075         mMouseY = limit(mMouseY + valReal,mYLowLimit, mYHighLimit);
00076     }
00077 
00078     //-----------------------------------------------------------------------
00079     void Cursor::addToZ(Real val)
00080     {
00081         Real valReal = val * mScale;
00082         mRelZ = valReal;
00083         mMouseZ = limit(mMouseZ + valReal,mZLowLimit, mZHighLimit);
00084     }
00085 
00086     //-----------------------------------------------------------------------
00087     void Cursor::processEvent(InputEvent* e)
00088     {
00089         switch(e->getID()) 
00090         {
00091         case MouseEvent::ME_MOUSE_PRESSED:
00092         case MouseEvent::ME_MOUSE_RELEASED:
00093         case MouseEvent::ME_MOUSE_CLICKED:
00094         case MouseEvent::ME_MOUSE_ENTERED:
00095         case MouseEvent::ME_MOUSE_EXITED:
00096             processMouseEvent(static_cast<MouseEvent*>(e));
00097             break;
00098         case MouseEvent::ME_MOUSE_MOVED:
00099         case MouseEvent::ME_MOUSE_DRAGGED:
00100             processMouseMotionEvent(static_cast<MouseEvent*>(e));
00101             break;
00102         }
00103 
00104         mRelX = 0.0;
00105         mRelY = 0.0;
00106         mRelZ = 0.0;
00107     }
00108 
00109     //-----------------------------------------------------------------------
00110     Real Cursor::getX() const
00111     {
00112         return mMouseX;
00113     }
00114 
00115     //-----------------------------------------------------------------------
00116     Real Cursor::getY() const
00117     {
00118         return mMouseY;
00119     }
00120 
00121     //-----------------------------------------------------------------------
00122     Real Cursor::getZ() const
00123     {
00124         return mMouseZ;
00125     }
00126 
00127     //-----------------------------------------------------------------------
00128     Real Cursor::getLeft(void) const 
00129     {
00130         return getX();
00131     }
00132 
00133     //-----------------------------------------------------------------------
00134     Real Cursor::getTop(void) const 
00135     {
00136         return getY();
00137 
00138     }
00139 
00140     //-----------------------------------------------------------------------
00141     PositionTarget* Cursor::getPositionTargetParent() const
00142     {
00143         return NULL;
00144     }
00145 
00146 }
00147 

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:18 2004