void makBoneTrans2(INode* pNode , sBoneTrans_t& boneTrans , Matrix3& mat) { Point3 Trans = mat.GetTrans(); Matrix3 RotMat = mat; Matrix3 ScaleMat = mat; RotMat.NoScale(); ScaleMat = mat * Inverse(RotMat); //算出Scale Matrix; RotMat.NoTrans(); Quat RotQuat(RotMat); //ScaleMat.NoRot(); //ScaleMat.NoTrans(); boneTrans.m_Rotate = conv_type<sQuat_t , Quat>(RotQuat); boneTrans.m_Trans = conv_type<sVector_t ,Point3 >(Trans); boneTrans.m_Scale.x = ScaleMat.GetRow(0).x; boneTrans.m_Scale.y = ScaleMat.GetRow(1).y; boneTrans.m_Scale.z = ScaleMat.GetRow(2).z; if( abs(boneTrans.m_Scale.x - boneTrans.m_Scale.y) > 0.000001 || abs(boneTrans.m_Scale.y - boneTrans.m_Scale.z) > 0.000001 || abs(boneTrans.m_Scale.z - boneTrans.m_Scale.x) > 0.000001 ) { std::wstring _NodeName = INodeName(pNode); XEVOL_LOG(eXL_DEBUG_HIGH , L" {警告} : 骨头[ %s ] 的上有NonUniformScale\r\n", _NodeName.c_str() ); } }
void RigidBody::UpdatePosition() { if (m_IsDynamic) { EditOwner()->EditChild<Transform>()->EditPosition() += m_Velocity* Constants::PhysicsDeltaTime; Quaternion RotQuat(1, m_AngularVelocity[0] * Constants::PhysicsDeltaTime * 0.5f, m_AngularVelocity[1] * Constants::PhysicsDeltaTime * 0.5f, m_AngularVelocity[2] * Constants::PhysicsDeltaTime * 0.5f); QuaternionRotate(GetOwner()->GetChild<Transform>()->GetRotation(), m_AngularVelocity, m_AngularMomentum); RotQuat.normalize(); if (!RotQuat.isZero()) { EditOwner()->EditChild<Transform>()->EditRotation() *= RotQuat; EditOwner()->EditChild<Transform>()->EditRotation().normalize(); } else { m_AngularMomentum = Vector3::Zero; } } }