本文整理汇总了C++中Matrix3x4::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x4::Inverse方法的具体用法?C++ Matrix3x4::Inverse怎么用?C++ Matrix3x4::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x4
的用法示例。
在下文中一共展示了Matrix3x4::Inverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDecal
bool DecalSet::AddDecal(Drawable* target, const Vector3& worldPosition, const Quaternion& worldRotation, float size,
float aspectRatio, float depth, const Vector2& topLeftUV, const Vector2& bottomRightUV, float timeToLive, float normalCutoff,
unsigned subGeometry)
{
URHO3D_PROFILE(AddDecal);
// Do not add decals in headless mode
if (!node_ || !GetSubsystem<Graphics>())
return false;
if (!target || !target->GetNode())
{
URHO3D_LOGERROR("Null target drawable for decal");
return false;
}
// Check for animated target and switch into skinned/static mode if necessary
AnimatedModel* animatedModel = dynamic_cast<AnimatedModel*>(target);
if ((animatedModel && !skinned_) || (!animatedModel && skinned_))
{
RemoveAllDecals();
skinned_ = animatedModel != 0;
bufferDirty_ = true;
}
// Center the decal frustum on the world position
Vector3 adjustedWorldPosition = worldPosition - 0.5f * depth * (worldRotation * Vector3::FORWARD);
/// \todo target transform is not right if adding a decal to StaticModelGroup
Matrix3x4 targetTransform = target->GetNode()->GetWorldTransform().Inverse();
// For an animated model, adjust the decal position back to the bind pose
// To do this, need to find the bone the decal is colliding with
if (animatedModel)
{
Skeleton& skeleton = animatedModel->GetSkeleton();
unsigned numBones = skeleton.GetNumBones();
Bone* bestBone = 0;
float bestSize = 0.0f;
for (unsigned i = 0; i < numBones; ++i)
{
Bone* bone = skeleton.GetBone(i);
if (!bone->node_ || !bone->collisionMask_)
continue;
// Represent the decal as a sphere, try to find the biggest colliding bone
Sphere decalSphere
(bone->node_->GetWorldTransform().Inverse() * worldPosition, 0.5f * size / bone->node_->GetWorldScale().Length());
if (bone->collisionMask_ & BONECOLLISION_BOX)
{
float size = bone->boundingBox_.HalfSize().Length();
if (bone->boundingBox_.IsInside(decalSphere) && size > bestSize)
{
bestBone = bone;
bestSize = size;
}
}
else if (bone->collisionMask_ & BONECOLLISION_SPHERE)
{
Sphere boneSphere(Vector3::ZERO, bone->radius_);
float size = bone->radius_;
if (boneSphere.IsInside(decalSphere) && size > bestSize)
{
bestBone = bone;
bestSize = size;
}
}
}
if (bestBone)
targetTransform = (bestBone->node_->GetWorldTransform() * bestBone->offsetMatrix_).Inverse();
}
// Build the decal frustum
Frustum decalFrustum;
Matrix3x4 frustumTransform = targetTransform * Matrix3x4(adjustedWorldPosition, worldRotation, 1.0f);
decalFrustum.DefineOrtho(size, aspectRatio, 1.0, 0.0f, depth, frustumTransform);
Vector3 decalNormal = (targetTransform * Vector4(worldRotation * Vector3::BACK, 0.0f)).Normalized();
decals_.Resize(decals_.Size() + 1);
Decal& newDecal = decals_.Back();
newDecal.timeToLive_ = timeToLive;
Vector<PODVector<DecalVertex> > faces;
PODVector<DecalVertex> tempFace;
unsigned numBatches = target->GetBatches().Size();
// Use either a specified subgeometry in the target, or all
if (subGeometry < numBatches)
GetFaces(faces, target, subGeometry, decalFrustum, decalNormal, normalCutoff);
else
{
for (unsigned i = 0; i < numBatches; ++i)
GetFaces(faces, target, i, decalFrustum, decalNormal, normalCutoff);
}
// Clip the acquired faces against all frustum planes
//.........这里部分代码省略.........