diff options
author | Jorge Bernal <jbernalmartinez@gmail.com> | 2014-06-26 02:47:30 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2014-06-26 02:47:37 +0400 |
commit | 7d99a4ded9d3d24c24ea2d5bcc488469cf60fa4a (patch) | |
tree | f56a5cb74013a4e0520e668570e9fe9f6d1d4a6a /source/gameengine/Converter/KX_ConvertActuators.cpp | |
parent | 11d1fea2850dd4071268034b133c924ce6396df9 (diff) |
BGE: New Mouse Actuator
Disclaimer: The author of this patch is Geoffrey Gollmer (gomer). I only updated the patch to the current git master status, reworked several parts to fit well with current coding style and applied several fixes.
This actuator allows users to show/hide the mouse cursor using logic bricks, as well as control object rotation with a mouse in the BGE.
The mouse rotation is flexible enough to allow any type of mouse look, as well as banking for flight controls.
{F94520}
{F91859}
Blend file for testing Mouse actuator (with default parameters and crosshair): {F94920}
Reviewers: moguri
Reviewed By: moguri
CC: gomer, lordodin
Differential Revision: https://developer.blender.org/D559
Diffstat (limited to 'source/gameengine/Converter/KX_ConvertActuators.cpp')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 7d5527d4cbb..45fc11b97d2 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -70,6 +70,7 @@ #include "KX_ParentActuator.h" #include "KX_SCA_DynamicActuator.h" #include "KX_SteeringActuator.h" +#include "KX_MouseActuator.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" @@ -1094,6 +1095,50 @@ void BL_ConvertActuators(const char* maggiename, baseact = tmpstact; break; } + case ACT_MOUSE: + { + bMouseActuator* mouAct = (bMouseActuator*) bact->data; + int mode = KX_MouseActuator::KX_ACT_MOUSE_NODEF; + + switch (mouAct->type) { + case ACT_MOUSE_VISIBILITY: + { + mode = KX_MouseActuator::KX_ACT_MOUSE_VISIBILITY; + break; + } + case ACT_MOUSE_LOOK: + { + mode = KX_MouseActuator::KX_ACT_MOUSE_LOOK; + break; + } + } + + bool visible = (mouAct->flag & ACT_MOUSE_VISIBLE) != 0; + bool use_axis[2] = {(mouAct->flag & ACT_MOUSE_USE_AXIS_X) != 0, (mouAct->flag & ACT_MOUSE_USE_AXIS_Y) != 0}; + bool reset[2] = {(mouAct->flag & ACT_MOUSE_RESET_X) != 0, (mouAct->flag & ACT_MOUSE_RESET_Y) != 0}; + bool local[2] = {(mouAct->flag & ACT_MOUSE_LOCAL_X) != 0, (mouAct->flag & ACT_MOUSE_LOCAL_Y) != 0}; + + SCA_MouseManager* eventmgr = (SCA_MouseManager*) logicmgr->FindEventManager(SCA_EventManager::MOUSE_EVENTMGR); + if (eventmgr) { + KX_MouseActuator* tmpbaseact = new KX_MouseActuator(gameobj, + ketsjiEngine, + eventmgr, + mode, + visible, + use_axis, + mouAct->threshold, + reset, + mouAct->object_axis, + local, + mouAct->sensitivity, + mouAct->limit_x, + mouAct->limit_y); + baseact = tmpbaseact; + } else { + //cout << "\n Couldn't find mouse event manager..."; - should throw an error here... + } + break; + } default: ; /* generate some error */ } |