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