Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_MouseActuator.cpp
| Context not available. | |||||
| #include "KX_GameObject.h" | #include "KX_GameObject.h" | ||||
| #include "MT_Vector3.h" | #include "MT_Vector3.h" | ||||
| #include "MT_Scalar.h" | #include "MT_Scalar.h" | ||||
| #include "MT_assert.h" | #include "BLI_utildefines.h" | ||||
| #include "limits.h" | #include "limits.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| Context not available. | |||||
| m_oldposition[1] = position[1]; | m_oldposition[1] = position[1]; | ||||
| } | } | ||||
| else { | |||||
| //printf("\nNo input device detected for mouse actuator\n"); | |||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| Context not available. | |||||
| SCA_IActuator::ProcessReplica(); | SCA_IActuator::ProcessReplica(); | ||||
| } | } | ||||
| void KX_MouseActuator::Replace_IScene(SCA_IScene *scene) | |||||
| { | |||||
| /* Changes the event manager when the scene changes in case of lib loading. | |||||
| * Using an event manager in an actuator is not a regular behaviour which is | |||||
| * to avoid if it is possible. | |||||
| */ | |||||
| SCA_LogicManager *logicmgr = ((KX_Scene *)scene)->GetLogicManager(); | |||||
| m_eventmgr = (SCA_MouseManager *)logicmgr->FindEventManager(m_eventmgr->GetType()); | |||||
| } | |||||
| void KX_MouseActuator::getMousePosition(float* pos) | void KX_MouseActuator::getMousePosition(float* pos) | ||||
| { | { | ||||
| MT_assert(m_mouse); | BLI_assert(m_mouse); | ||||
| const SCA_InputEvent & xevent = m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEX); | const SCA_InputEvent & xevent = m_mouse->GetInput(SCA_IInputDevice::MOUSEX); | ||||
| const SCA_InputEvent & yevent = m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEY); | const SCA_InputEvent & yevent = m_mouse->GetInput(SCA_IInputDevice::MOUSEY); | ||||
| pos[0] = m_canvas->GetMouseNormalizedX(xevent.m_eventval); | pos[0] = m_canvas->GetMouseNormalizedX(xevent.m_values[xevent.m_values.size() - 1]); | ||||
| pos[1] = m_canvas->GetMouseNormalizedY(yevent.m_eventval); | pos[1] = m_canvas->GetMouseNormalizedY(yevent.m_values[yevent.m_values.size() - 1]); | ||||
| } | } | ||||
| void KX_MouseActuator::setMousePosition(float fx, float fy) | void KX_MouseActuator::setMousePosition(float fx, float fy) | ||||
| Context not available. | |||||
| KX_PYATTRIBUTE_RW_FUNCTION("limit_x", KX_MouseActuator, pyattr_get_limit_x, pyattr_set_limit_x), | KX_PYATTRIBUTE_RW_FUNCTION("limit_x", KX_MouseActuator, pyattr_get_limit_x, pyattr_set_limit_x), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("limit_y", KX_MouseActuator, pyattr_get_limit_y, pyattr_set_limit_y), | KX_PYATTRIBUTE_RW_FUNCTION("limit_y", KX_MouseActuator, pyattr_get_limit_y, pyattr_set_limit_y), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("angle", KX_MouseActuator, pyattr_get_angle, pyattr_set_angle), | KX_PYATTRIBUTE_RW_FUNCTION("angle", KX_MouseActuator, pyattr_get_angle, pyattr_set_angle), | ||||
| { NULL } //Sentinel | KX_PYATTRIBUTE_NULL //Sentinel | ||||
| }; | }; | ||||
| PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| Context not available. | |||||