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

KX_BlenderClientObject.h

Go to the documentation of this file.
00001 #ifndef __KX_BLENDERCLIENTOBJECT
00002 #define __KX_BLENDERCLIENTOBJECT
00003 
00004 #include "KX_BlenderGL.h"
00005 #include "BL_BlenderOrientation.h"
00006 #include "BL_BlenderIPO.h"
00007 
00008 #include "KX_IClientObject.h"
00009 #include "MT_Point3.h"
00010 #include "MT_Vector3.h"
00011 
00012 
00013 
00014         
00015 class KX_BlenderClientObject : public KX_IClientObject
00016 {
00017         struct Object*  m_blenderobject;
00018         MT_Point3                       m_savedBlenderPos;              // save position when gameengine returns
00019         MT_Vector3                      m_savedBlenderRot;              // save blender euler rotations
00020 
00021         public:
00022         KX_BlenderClientObject(struct Object* blenderobj)
00023                 :m_blenderobject(blenderobj)

00024         {
00025                 SavePosition();
00026         }
00027 
00028         virtual ~KX_BlenderClientObject()

00029         {
00030 
00031         }
00032 
00033         
00034         //virtual const MT_Matrix3x3&   GetOrientation()
00035         //{
00036 //
00037 //      }
00038         virtual         MT_Vector3      GetEuler()

00039         {
00040                 return BL_GetBlenderRotation((struct Object*)this->GetBlenderObject());
00041         }
00042 
00043         virtual void ConvertIPOTransform(KX_IPOTransform& ipo_xform) const;
00044 
00045         virtual void SetEuler(const MT_Vector3& euler)

00046         {
00047                 BL_SetBlenderRotation((struct Object*)this->GetBlenderObject(),euler);
00048         }
00049         
00050         virtual void SavePosition()

00051         {
00052                 m_savedBlenderPos = BL_GetBlenderPosition(m_blenderobject);
00053                 m_savedBlenderRot = BL_GetBlenderRotation(m_blenderobject);
00054         }
00055 
00056         virtual void RestorePosition()

00057         {
00058                 BL_SetBlenderPosition(m_blenderobject,m_savedBlenderPos);
00059                 BL_SetBlenderRotation(m_blenderobject,m_savedBlenderRot);
00060         }
00061 
00062         struct Object*  GetBlenderObject()
00063         {
00064                 return m_blenderobject;
00065         }
00066         virtual bool HasParent()

00067         {
00068                 return BL_HasParent(m_blenderobject);
00069         }
00070         virtual void WhereIsObject()

00071         {
00072                 BL_WhereIsObjectSimul(m_blenderobject);
00073         }
00074         virtual MT_Transform GetTransformation()

00075         {
00076                 return MT_Transform((float*)BL_GetTransformationMatrix(m_blenderobject));
00077         }
00078 
00079         virtual MT_Vector3      GetScaling()

00080         {
00081                 return BL_GetBlenderScaling(m_blenderobject);
00082         }
00083         
00084         void KX_EulToMat3(const double* eul, MT_Matrix3x3& mat)

00085         {
00086                 double ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
00087                 
00088                 ci = cos(eul[0]); 
00089                 cj = cos(eul[1]); 
00090                 ch = cos(eul[2]);
00091                 si = sin(eul[0]); 
00092                 sj = sin(eul[1]); 
00093                 sh = sin(eul[2]);
00094                 cc = ci*ch; 
00095                 cs = ci*sh; 
00096                 sc = si*ch; 
00097                 ss = si*sh;
00098 
00099                 mat[0][0] = cj*ch; 
00100                 mat[1][0] = sj*sc-cs; 
00101                 mat[2][0] = sj*cc+ss;
00102                 mat[0][1] = cj*sh; 
00103                 mat[1][1] = sj*ss+cc; 
00104                 mat[2][1] = sj*cs-sc;
00105                 mat[0][2] = -sj;         
00106                 mat[1][2] = cj*si;    
00107                 mat[2][2] = cj*ci;
00108 
00109         }
00110 
00111         virtual MT_Matrix3x3 GetScalinglessMatrix()

00112         {
00113                 MT_Matrix3x3 mat3;
00114                 MT_Vector3 blenderrot = BL_GetBlenderRotation(m_blenderobject);
00115                 KX_EulToMat3(blenderrot.getValue(),mat3);
00116                 return mat3;
00117         }
00118         virtual MT_Point3       GetOrigin()

00119         {
00120                 return BL_GetBlenderPosition(m_blenderobject);
00121         }
00122         virtual void SetPosition(MT_Point3 pos)

00123         {
00124                 BL_SetBlenderPosition(m_blenderobject,pos);
00125         }
00126         virtual bool HasIpo()

00127         {
00128                 return BL_HasIPO(m_blenderobject);
00129         }
00130         
00131 
00132         virtual void WhereIsObjectTime(float curframetime)

00133         {
00134 //              where_is_object_time((Object*) this->GetBlenderObject(), curframetime);
00135         }
00136 
00137         virtual void DisplaySymbolicShape(int drawmode)

00138         {
00139                 BL_DisplaySymbolicShapes(m_blenderobject,drawmode);
00140         }
00141 
00142         virtual void SetEulerFromMatrix(const MT_Matrix3x3& basis)

00143         {
00144                 
00145                 float eul[3];
00146                 float mat3[3][3];
00147 
00148                 for (int i=0;i<3;i++) {
00149                         for (int j=0;j<3;j++) {
00150                                 mat3[i][j] = basis[j][i];
00151                         }
00152                 }
00153                 BL_Mat3ToEul(mat3,eul);
00154 
00155                 SetEuler(MT_Vector3(eul));
00156 
00157         }
00158         
00159 };
00160 
00161 #endif //__KX_BLENDERCLIENTOBJECT

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