Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KX_RadarSensor.cpp

Go to the documentation of this file.
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;// = ((KX_GameObject*)GetParent())->GetWorldPosition();
00051         // a collision cone is oriented
00052         // center the cone correctly 
00053         // depends on the radar 'axis'
00054         switch (m_axis)
00055         {
00056         case 0: // X Axis
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: // Y Axis
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: // Z Axis
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 }

Generated at Thu Feb 1 13:03:06 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000