00001 #include "KX_RadarSensor.h"
00002 #include "KX_GameObject.h"
00006
00007 KX_RadarSensor::KX_RadarSensor(class SCA_EventManager* eventmgr,
00008 class KX_GameObject* gameobj,
00009 double coneradius,
00010 double coneheight,
00011 int axis,
00012 double margin,
00013 double resetmargin,
00014 class SM_Object* sumoObj,
00015 bool bFindMaterial,
00016 const CCString& touchedpropname,
00017 PyTypeObject* T)
00018
00019 : KX_NearSensor(
00020 eventmgr,
00021 gameobj,
00022 margin,
00023 resetmargin,
00024 sumoObj,
00025 bFindMaterial,
00026 touchedpropname,
00027 T),
00028 m_coneheight(coneheight),
00029 m_coneradius(coneradius),
00030 m_axis(axis)
00031 {
00032 m_client_info.m_type = 3;
00033 m_client_info.m_clientobject = gameobj;
00034 m_client_info.m_auxilary_info = NULL;
00035 sumoObj->setClientObject(&m_client_info);
00036 }
00037
00038
00039 KX_RadarSensor::~KX_RadarSensor()
00040 {
00041
00042 }
00043
00047
00048 void KX_RadarSensor::SynchronizeTransform()
00049 {
00050 MT_Transform trans;
00051
00052
00053
00054 switch (m_axis)
00055 {
00056 case 0:
00057 {
00058 MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
00059 trans.rotate(rotquatje);
00060 trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
00061 break;
00062 };
00063 case 1:
00064 {
00065 MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
00066 trans.rotate(rotquatje);
00067 trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
00068 break;
00069 };
00070 case 2:
00071 {
00072 MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90));
00073 trans.rotate(rotquatje);
00074 trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
00075 break;
00076 };
00077 default:
00078 {
00079 }
00080 }
00081
00082 m_sumoObj->setPosition(trans.getOrigin());
00083 m_sumoObj->setOrientation(trans.getRotation());
00084 m_sumoObj->calcXform();
00085 }