Blender  V2.59
KX_MotionState.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: KX_MotionState.cpp 35171 2011-02-25 13:35:59Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #include "KX_MotionState.h"
00035 #include "SG_Spatial.h"
00036 
00037 KX_MotionState::KX_MotionState(SG_Spatial* node) : m_node(node)
00038 {
00039 
00040 }
00041 
00042 KX_MotionState::~KX_MotionState()
00043 {
00044 }
00045 
00046 void    KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ)
00047 {
00048         const MT_Point3& pos = m_node->GetWorldPosition();
00049         posX = pos[0];
00050         posY = pos[1];
00051         posZ = pos[2];
00052 }
00053 
00054 void    KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
00055 {
00056         const MT_Vector3& scale = m_node->GetWorldScaling();
00057         scaleX = scale[0];
00058         scaleY = scale[1];
00059         scaleZ = scale[2];
00060 }
00061 
00062 void    KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
00063 {
00064         MT_Quaternion orn = m_node->GetWorldOrientation().getRotation();
00065         quatIma0 = orn[0];
00066         quatIma1 = orn[1];
00067         quatIma2 = orn[2];
00068         quatReal = orn[3];
00069 }
00070         
00071 void    KX_MotionState::getWorldOrientation(float* ori)
00072 {
00073         const MT_Matrix3x3& mat = m_node->GetWorldOrientation();
00074         mat.getValue(ori);
00075 }
00076         
00077 void    KX_MotionState::setWorldOrientation(const float* ori)
00078 {
00079         m_node->SetLocalOrientation(ori);
00080 }
00081         
00082 void    KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
00083 {
00084         m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
00085         //m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
00086 }
00087 
00088 void    KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
00089 {
00090         MT_Quaternion orn;
00091         orn[0] = quatIma0;
00092         orn[1] = quatIma1;
00093         orn[2] = quatIma2;
00094         orn[3] = quatReal;
00095 
00096         m_node->SetLocalOrientation(orn);
00097         //m_node->SetWorldOrientation(orn);
00098 
00099 }
00100 
00101 void    KX_MotionState::calculateWorldTransformations()
00102 {
00103         //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation
00104         //bool parentUpdated = false;
00105         //m_node->ComputeWorldTransforms(NULL, parentUpdated);
00106 }
00107 
00108