本文整理汇总了C++中Matrix3x4::Invert方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x4::Invert方法的具体用法?C++ Matrix3x4::Invert怎么用?C++ Matrix3x4::Invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x4
的用法示例。
在下文中一共展示了Matrix3x4::Invert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetViewportCorners
/**
* @brief
* Gets the current camera viewport corners
*/
bool SNCamera::GetViewportCorners(Vector3 &vUpperRight, Vector3 &vLowerRight, Vector3 &vLowerLeft, Vector3 &vUpperLeft, bool bContainerSpace, float fDistance)
{
// Get the viewport
const Renderer &cRenderer = GetSceneContext()->GetRendererContext().GetRenderer();
const uint32 nViewportWidth = static_cast<uint32>(cRenderer.GetViewport().GetWidth());
const uint32 nViewportHeight = static_cast<uint32>(cRenderer.GetViewport().GetHeight());
// Get near x/y/z
const float fAspectRadio = static_cast<float>(nViewportWidth)/(static_cast<float>(nViewportHeight)*m_fAspect);
const float e = static_cast<float>(1/Math::Tan(Math::DegToRad*m_fFOV*0.5f));
// Get viewport corners
vUpperRight.SetXYZ( fDistance/e, fAspectRadio*fDistance/e, -fDistance);
vLowerRight.SetXYZ( fDistance/e, -fAspectRadio*fDistance/e, -fDistance);
vLowerLeft.SetXYZ(-fDistance/e, -fAspectRadio*fDistance/e, -fDistance);
vUpperLeft.SetXYZ(-fDistance/e, fAspectRadio*fDistance/e, -fDistance);
// Transform the corners into container space?
if (bContainerSpace) {
Matrix3x4 mWorld = GetViewMatrix();
mWorld.Invert();
vUpperRight = mWorld*vUpperRight;
vLowerRight = mWorld*vLowerRight;
vLowerLeft = mWorld*vLowerLeft;
vUpperLeft = mWorld*vUpperLeft;
}
// Done
return true;
}
示例2: NewtonConstraintCreateUniversal
/**
* @brief
* Constructor
*/
JointUniversal::JointUniversal(PLPhysics::World &cWorld, PLPhysics::Body *pParentBody, PLPhysics::Body *pChildBody,
const Vector3 &vPivotPoint, const Vector3 &vPinDir1, const Vector3 &vPinDir2) :
PLPhysics::JointUniversal(cWorld, static_cast<World&>(cWorld).CreateJointImpl(), pParentBody, pChildBody, vPivotPoint, vPinDir1, vPinDir2)
{
// Deactivate the physics simulation if required
const bool bSimulationActive = cWorld.IsSimulationActive();
if (bSimulationActive)
cWorld.SetSimulationActive(false);
// Get the Newton physics world
Newton::NewtonWorld *pNewtonWorld = static_cast<World&>(cWorld).GetNewtonWorld();
// Flush assigned bodies (MUST be done before creating the joint!)
if (pParentBody)
static_cast<BodyImpl&>(pParentBody->GetBodyImpl()).Flush();
if (pChildBody)
static_cast<BodyImpl&>(pChildBody ->GetBodyImpl()).Flush();
// Get the Newton physics parent and child bodies
const Newton::NewtonBody *pNewtonParentBody = pParentBody ? static_cast<BodyImpl&>(pParentBody->GetBodyImpl()).GetNewtonBody() : nullptr;
const Newton::NewtonBody *pNewtonChildBody = pChildBody ? static_cast<BodyImpl&>(pChildBody ->GetBodyImpl()).GetNewtonBody() : nullptr;
// [TODO] ??
/*
if (pNewtonParentBody)
NewtonBodySetUserData(pNewtonParentBody, nullptr);
if (pNewtonChildBody)
NewtonBodySetUserData(pNewtonChildBody, nullptr);
*/
// Get body initial transform matrix
if (pParentBody) {
// Get transform matrix
Quaternion qQ;
pParentBody->GetRotation(qQ);
Vector3 vPos;
pParentBody->GetPosition(vPos);
Matrix3x4 mTrans;
mTrans.FromQuatTrans(qQ, vPos);
// And transform the initial joint anchor into the body object space
mTrans.Invert();
m_vLocalAnchor = mTrans*vPivotPoint;
}
// Create the Newton physics joint
Newton::NewtonJoint *pNewtonJoint = NewtonConstraintCreateUniversal(pNewtonWorld, m_vPivotPoint, m_vPinDir1,
m_vPinDir2, pNewtonChildBody, pNewtonParentBody);
// Set Newton universal callback function
NewtonUniversalSetUserCallback(pNewtonJoint, JointUserCallback);
// Initialize the Newton physics joint
static_cast<JointImpl&>(GetJointImpl()).InitializeNewtonJoint(*this, *pNewtonJoint);
// Reactivate the physics simulation if required
if (bSimulationActive)
cWorld.SetSimulationActive(bSimulationActive);
}