Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/GameLogic/SCA_RadarSensor.cpp
- This file was moved from source/gameengine/Ketsji/KX_RadarSensor.cpp.
| Show All 19 Lines | |||||
| * | * | ||||
| * The Original Code is: all of this file. | * The Original Code is: all of this file. | ||||
| * | * | ||||
| * Contributor(s): none yet. | * Contributor(s): none yet. | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file gameengine/Ketsji/KX_RadarSensor.cpp | /** \file gameengine/GameLogic/SCA_RadarSensor.cpp | ||||
| * \ingroup ketsji | * \ingroup gamelogic | ||||
| */ | */ | ||||
| #include "KX_RadarSensor.h" | #include "SCA_RadarSensor.h" | ||||
| #include "KX_GameObject.h" | #include "KX_GameObject.h" | ||||
| #include "KX_PyMath.h" | #include "KX_PyMath.h" | ||||
| #include "PHY_IPhysicsController.h" | #include "PHY_IPhysicsController.h" | ||||
| #include "PHY_IMotionState.h" | #include "PHY_IMotionState.h" | ||||
| #include "DNA_sensor_types.h" | #include "DNA_sensor_types.h" | ||||
| /** | /** | ||||
| * RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape. | * RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape. | ||||
| */ | */ | ||||
| KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr, | SCA_RadarSensor::SCA_RadarSensor(SCA_EventManager* eventmgr, | ||||
| KX_GameObject* gameobj, | KX_GameObject* gameobj, | ||||
| PHY_IPhysicsController* physCtrl, | PHY_IPhysicsController* physCtrl, | ||||
| double coneradius, | double coneradius, | ||||
| double coneheight, | double coneheight, | ||||
| int axis, | int axis, | ||||
| double margin, | double margin, | ||||
| double resetmargin, | double resetmargin, | ||||
| bool bFindMaterial, | bool bFindMaterial, | ||||
| const STR_String& touchedpropname) | const STR_String& touchedpropname) | ||||
| : KX_NearSensor( | : SCA_NearSensor( | ||||
| eventmgr, | eventmgr, | ||||
| gameobj, | gameobj, | ||||
| //DT_NewCone(coneradius,coneheight), | //DT_NewCone(coneradius,coneheight), | ||||
| margin, | margin, | ||||
| resetmargin, | resetmargin, | ||||
| bFindMaterial, | bFindMaterial, | ||||
| touchedpropname, | touchedpropname, | ||||
| physCtrl), | physCtrl), | ||||
| m_coneradius(coneradius), | m_coneradius(coneradius), | ||||
| m_coneheight(coneheight), | m_coneheight(coneheight), | ||||
| m_axis(axis) | m_axis(axis) | ||||
| { | { | ||||
| m_client_info->m_type = KX_ClientObjectInfo::SENSOR; | m_client_info->m_type = KX_ClientObjectInfo::SENSOR; | ||||
| //m_client_info->m_clientobject = gameobj; | //m_client_info->m_clientobject = gameobj; | ||||
| //m_client_info->m_auxilary_info = NULL; | //m_client_info->m_auxilary_info = NULL; | ||||
| //sumoObj->setClientObject(&m_client_info); | //sumoObj->setClientObject(&m_client_info); | ||||
| } | } | ||||
| KX_RadarSensor::~KX_RadarSensor() | SCA_RadarSensor::~SCA_RadarSensor() | ||||
| { | { | ||||
| } | } | ||||
| CValue* KX_RadarSensor::GetReplica() | CValue* SCA_RadarSensor::GetReplica() | ||||
| { | { | ||||
| KX_RadarSensor* replica = new KX_RadarSensor(*this); | SCA_RadarSensor* replica = new SCA_RadarSensor(*this); | ||||
| replica->ProcessReplica(); | replica->ProcessReplica(); | ||||
| return replica; | return replica; | ||||
| } | } | ||||
| /** | /** | ||||
| * Transforms the collision object. A cone is not correctly centered | * Transforms the collision object. A cone is not correctly centered | ||||
| * for usage. */ | * for usage. */ | ||||
| void KX_RadarSensor::SynchronizeTransform() | void SCA_RadarSensor::SynchronizeTransform() | ||||
| { | { | ||||
| // Getting the parent location was commented out. Why? | // Getting the parent location was commented out. Why? | ||||
| MT_Transform trans; | MT_Transform trans; | ||||
| trans.setOrigin(((KX_GameObject*)GetParent())->NodeGetWorldPosition()); | trans.setOrigin(((KX_GameObject*)GetParent())->NodeGetWorldPosition()); | ||||
| trans.setBasis(((KX_GameObject*)GetParent())->NodeGetWorldOrientation()); | trans.setBasis(((KX_GameObject*)GetParent())->NodeGetWorldOrientation()); | ||||
| // What is the default orientation? pointing in the -y direction? | // What is the default orientation? pointing in the -y direction? | ||||
| // is the geometry correctly converted? | // is the geometry correctly converted? | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| /* Python Functions */ | /* Python Functions */ | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Python Integration Hooks */ | /* Python Integration Hooks */ | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| PyTypeObject KX_RadarSensor::Type = { | PyTypeObject SCA_RadarSensor::Type = { | ||||
| PyVarObject_HEAD_INIT(NULL, 0) | PyVarObject_HEAD_INIT(NULL, 0) | ||||
| "KX_RadarSensor", | "SCA_RadarSensor", | ||||
| sizeof(PyObjectPlus_Proxy), | sizeof(PyObjectPlus_Proxy), | ||||
| 0, | 0, | ||||
| py_base_dealloc, | py_base_dealloc, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| py_base_repr, | py_base_repr, | ||||
| 0,0,0,0,0,0,0,0,0, | 0,0,0,0,0,0,0,0,0, | ||||
| Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||||
| 0,0,0,0,0,0,0, | 0,0,0,0,0,0,0, | ||||
| Methods, | Methods, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| &KX_NearSensor::Type, | &SCA_NearSensor::Type, | ||||
| 0,0,0,0,0,0, | 0,0,0,0,0,0, | ||||
| py_base_new | py_base_new | ||||
| }; | }; | ||||
| PyMethodDef KX_RadarSensor::Methods[] = { | PyMethodDef SCA_RadarSensor::Methods[] = { | ||||
| {NULL} //Sentinel | {NULL} //Sentinel | ||||
| }; | }; | ||||
| PyAttributeDef KX_RadarSensor::Attributes[] = { | PyAttributeDef SCA_RadarSensor::Attributes[] = { | ||||
| KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3), | KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", SCA_RadarSensor, m_cone_origin, 3), | ||||
| KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", KX_RadarSensor, m_cone_target, 3), | KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", SCA_RadarSensor, m_cone_target, 3), | ||||
| KX_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight), | KX_PYATTRIBUTE_FLOAT_RO("distance", SCA_RadarSensor, m_coneheight), | ||||
| KX_PYATTRIBUTE_RO_FUNCTION("angle", KX_RadarSensor, pyattr_get_angle), | KX_PYATTRIBUTE_RO_FUNCTION("angle", SCA_RadarSensor, pyattr_get_angle), | ||||
| KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis), | KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, SCA_RadarSensor, m_axis), | ||||
| {NULL} //Sentinel | {NULL} //Sentinel | ||||
| }; | }; | ||||
| PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| KX_RadarSensor* self = static_cast<KX_RadarSensor*>(self_v); | SCA_RadarSensor* self = static_cast<SCA_RadarSensor*>(self_v); | ||||
| // The original angle from the gui was converted, so we recalculate the value here to maintain | // The original angle from the gui was converted, so we recalculate the value here to maintain | ||||
| // consistency between Python and the gui | // consistency between Python and the gui | ||||
| return PyFloat_FromDouble(MT_degrees(atan(self->m_coneradius / self->m_coneheight)) * 2); | return PyFloat_FromDouble(MT_degrees(atan(self->m_coneradius / self->m_coneheight)) * 2); | ||||
| } | } | ||||
| #endif // WITH_PYTHON | #endif // WITH_PYTHON | ||||