本文整理汇总了C++中Mat4x4::Decompose方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::Decompose方法的具体用法?C++ Mat4x4::Decompose怎么用?C++ Mat4x4::Decompose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::Decompose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddShape
void PhysXPhysics::AddShape(Actor* pActor, PxGeometry* geometry, float density, const std::string& physicsMaterial, bool gravityEnabled, float linearDamping, float angularDamping, const std::string& bodyType)
{
BE_ASSERT(pActor);
ActorId actorId = pActor->GetId();
BE_ASSERTf(m_actorRigidBodyMap.find(actorId) == m_actorRigidBodyMap.end(), "Actor with more than one rigidbody");
Mat4x4 transform = Mat4x4::g_Identity;
TransformComponent* pTransformComponent = pActor->GetComponent<TransformComponent>(TransformComponent::g_Name);
if (pTransformComponent)
{
transform = pTransformComponent->GetTransform();
}
else
{
//Doesnt work without transform
BE_ERROR("Actor %s PhysicsComponent requires Shape to have Transform Component: %d", actorId);
return;
}
PhysicsMaterialData material(LookupMaterialData(physicsMaterial));
PxMaterial* mat = m_pPhysicsSdk->createMaterial(material.m_friction, material.m_friction, material.m_restitution);
Vec3 translation, scale;
Quaternion rotation;
bool ok = transform.Decompose(translation, rotation, scale);
PxQuat pxRot;
PxVec3 pxLoc;
Vec3ToPxVec(translation, &pxLoc);
QuaternionToPxQuat(rotation, &pxRot);
PxTransform t(pxLoc, pxRot);
if (bodyType == "Dynamic")
{
PxRigidDynamic* body = PxCreateDynamic(*m_pPhysicsSdk, t, *geometry, *mat, density);
body->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, !gravityEnabled);
PxRigidBodyExt::updateMassAndInertia(*body, density);
body->setLinearDamping(linearDamping);
body->setAngularDamping(angularDamping);
m_pScene->addActor(*body);
m_actorRigidBodyMap[actorId] = body;
m_rigidBodyActorMap[body] = actorId;
}
else
{
BE_ERROR("[Physics] BodyType not supported: %s", bodyType.c_str());
return;
}
}