Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_MotionState.cpp
| Context not available. | |||||
| #include "KX_MotionState.h" | #include "KX_MotionState.h" | ||||
| #include "SG_Spatial.h" | #include "SG_Spatial.h" | ||||
| KX_MotionState::KX_MotionState(SG_Spatial* node) : m_node(node) | KX_MotionState::KX_MotionState(SG_Spatial *node) | ||||
| :m_node(node) | |||||
| { | { | ||||
| } | } | ||||
| Context not available. | |||||
| { | { | ||||
| } | } | ||||
| void KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ) | void KX_MotionState::GetWorldPosition(float& posX, float& posY, float& posZ) | ||||
| { | { | ||||
| const MT_Point3& pos = m_node->GetWorldPosition(); | const MT_Vector3& pos = m_node->GetWorldPosition(); | ||||
| posX = pos[0]; | posX = pos[0]; | ||||
| posY = pos[1]; | posY = pos[1]; | ||||
| posZ = pos[2]; | posZ = pos[2]; | ||||
| } | } | ||||
| void KX_MotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ) | void KX_MotionState::GetWorldScaling(float& scaleX, float& scaleY, float& scaleZ) | ||||
| { | { | ||||
| const MT_Vector3& scale = m_node->GetWorldScaling(); | const MT_Vector3& scale = m_node->GetWorldScaling(); | ||||
| scaleX = scale[0]; | scaleX = scale[0]; | ||||
| Context not available. | |||||
| scaleZ = scale[2]; | scaleZ = scale[2]; | ||||
| } | } | ||||
| void KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) | void KX_MotionState::GetWorldOrientation(float& quatIma0, float& quatIma1, float& quatIma2, float& quatReal) | ||||
| { | { | ||||
| MT_Quaternion orn = m_node->GetWorldOrientation().getRotation(); | MT_Quaternion orn = m_node->GetWorldOrientation().getRotation(); | ||||
| quatIma0 = orn[0]; | quatIma0 = orn[0]; | ||||
| Context not available. | |||||
| quatIma2 = orn[2]; | quatIma2 = orn[2]; | ||||
| quatReal = orn[3]; | quatReal = orn[3]; | ||||
| } | } | ||||
| void KX_MotionState::GetWorldOrientation(float* ori) | void KX_MotionState::GetWorldOrientation(float *ori) | ||||
| { | { | ||||
| const MT_Matrix3x3& mat = m_node->GetWorldOrientation(); | const MT_Matrix3x3& mat = m_node->GetWorldOrientation(); | ||||
| mat.getValue(ori); | mat.getValue(ori); | ||||
| } | } | ||||
| void KX_MotionState::SetWorldOrientation(const float* ori) | void KX_MotionState::SetWorldOrientation(const float *ori) | ||||
| { | { | ||||
| m_node->SetLocalOrientation(ori); | m_node->SetLocalOrientation(ori); | ||||
| } | } | ||||
| void KX_MotionState::SetWorldPosition(float posX,float posY,float posZ) | void KX_MotionState::SetWorldPosition(float posX, float posY, float posZ) | ||||
| { | { | ||||
| m_node->SetLocalPosition(MT_Point3(posX,posY,posZ)); | m_node->SetLocalPosition(MT_Vector3(posX, posY, posZ)); | ||||
| //m_node->SetWorldPosition(MT_Point3(posX,posY,posZ)); | //m_node->SetWorldPosition(MT_Vector3(posX,posY,posZ)); | ||||
| } | } | ||||
| void KX_MotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) | void KX_MotionState::SetWorldOrientation(float quatIma0, float quatIma1, float quatIma2, float quatReal) | ||||
| { | { | ||||
| MT_Quaternion orn; | MT_Quaternion orn; | ||||
| orn[0] = quatIma0; | orn[0] = quatIma0; | ||||
| Context not available. | |||||
| orn[2] = quatIma2; | orn[2] = quatIma2; | ||||
| orn[3] = quatReal; | orn[3] = quatReal; | ||||
| m_node->SetLocalOrientation(orn); | m_node->SetLocalOrientation(MT_Matrix3x3(orn)); | ||||
| //m_node->SetWorldOrientation(orn); | //m_node->SetWorldOrientation(orn); | ||||
| } | } | ||||
| void KX_MotionState::CalculateWorldTransformations() | void KX_MotionState::CalculateWorldTransformations() | ||||
| { | { | ||||
| //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation | //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation | ||||
| //bool parentUpdated = false; | //bool parentUpdated = false; | ||||
| //m_node->ComputeWorldTransforms(NULL, parentUpdated); | //m_node->ComputeWorldTransforms(NULL, parentUpdated); | ||||
| } | } | ||||
| Context not available. | |||||