本文整理汇总了C++中Matrix3x4类的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x4类的具体用法?C++ Matrix3x4怎么用?C++ Matrix3x4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix3x4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentAnchor
/**
* @brief
* Returns the current joint anchor position
*/
void RagdollJoint::GetCurrentAnchor(Vector3 &vPosition) const
{
const Joint *pJoint = static_cast<Joint*>(m_pJointHandler->GetElement());
if (pJoint)
pJoint->GetCurrentPivotPoint(vPosition);
// We need to calculate the current anchor by hand :(
else {
// Get the attached body
const RagdollBody *pAttachedBody = m_pParentRagdoll->GetBody(sAttached);
if (pAttachedBody && pAttachedBody->bEnabled) {
// Get the attached physics body
const Body *pBody = static_cast<Body*>(pAttachedBody->GetBody());
if (pBody) {
// Get initial physics body transform matrix
Matrix3x4 mInitTrans;
mInitTrans.FromQuatTrans(pAttachedBody->qRot, pAttachedBody->vPos);
// Get current physics body transform matrix
Matrix3x4 mTrans;
pBody->GetTransformMatrix(mTrans);
// Get the current joint anchor in local space
const Vector3 vLocalAnchor = mInitTrans.GetInverted()*vJointAnchor;
// Get the current joint anchor in world space
vPosition = vLocalAnchor;
vPosition *= mTrans;
}
}
}
}
示例2: GetSceneContext
/**
* @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;
}
示例3: switch
const Matrix3x4& Light::GetVolumeTransform(Camera* camera)
{
if (!node_)
return Matrix3x4::IDENTITY;
switch (lightType_)
{
case LIGHT_DIRECTIONAL:
{
Matrix3x4 quadTransform;
Vector3 near, far;
// Position the directional light quad in halfway between far & near planes to prevent depth clipping
camera->GetFrustumSize(near, far);
quadTransform.SetTranslation(Vector3(0.0f, 0.0f, (camera->GetNearClip() + camera->GetFarClip()) * 0.5f));
quadTransform.SetScale(Vector3(far.x_, far.y_, 1.0f)); // Will be oversized, but doesn't matter (gets frustum clipped)
volumeTransform_ = camera->GetEffectiveWorldTransform() * quadTransform;
break;
}
case LIGHT_SPOT:
{
float yScale = tanf(fov_ * M_DEGTORAD * 0.5f) * range_;
float xScale = aspectRatio_ * yScale;
volumeTransform_ = Matrix3x4(node_->GetWorldPosition(), node_->GetWorldRotation(), Vector3(xScale, yScale, range_));
}
break;
case LIGHT_POINT:
volumeTransform_ = Matrix3x4(node_->GetWorldPosition(), Quaternion::IDENTITY, range_);
break;
}
return volumeTransform_;
}
示例4: DrawDebugGeometry
void NavArea::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
{
if (debug && IsEnabledEffective())
{
Matrix3x4 mat;
mat.SetTranslation(node_->GetWorldPosition());
debug->AddBoundingBox(boundingBox_, mat, Color::GREEN, depthTest);
}
}
示例5: GetFullscreenQuadTransform
Matrix3x4 Light::GetFullscreenQuadTransform(Camera* camera)
{
Matrix3x4 quadTransform;
Vector3 near, far;
// Position the directional light quad in halfway between far & near planes to prevent depth clipping
camera->GetFrustumSize(near, far);
quadTransform.SetTranslation(Vector3(0.0f, 0.0f, (camera->GetNearClip() + camera->GetFarClip()) * 0.5f));
quadTransform.SetScale(Vector3(far.x_, far.y_, 1.0f)); // Will be oversized, but doesn't matter (gets frustum clipped)
return camera->GetEffectiveWorldTransform() * quadTransform;
}
示例6: GetWorldTransform
void Node::SetParent(Node* parent)
{
if (parent)
{
Matrix3x4 oldWorldTransform = GetWorldTransform();
parent->AddChild(this);
Matrix3x4 newTransform = parent->GetWorldTransform().Inverse() * oldWorldTransform;
SetTransform(newTransform.Translation(), newTransform.Rotation(), newTransform.Scale());
}
}
示例7: updateProjection
void Camera::updateFrustum()
{
if (projectionDirty_)
updateProjection();
Matrix3x4 transform = Matrix3x4::translationMatrix(position);
transform.rotateY(degToRad(-yaw - 180.0f));
transform.rotateX(degToRad(-pitch));
frustum_.setTransform(transform);
frustumDirty_ = false;
}
示例8: a
void RectangularMatrixTest::row() {
const Matrix3x4 a(Vector4(1.0f, 2.0f, 3.0f, 4.0f),
Vector4(5.0f, 6.0f, 7.0f, 8.0f),
Vector4(9.0f, 10.0f, 11.0f, 12.0f));
CORRADE_COMPARE(a.row(1), Vector3(2.0f, 6.0f, 10.0f));
}
示例9: vector
void RectangularMatrixTest::data() {
Matrix3x4 m;
Vector4 vector(4.0f, 5.0f, 6.0f, 7.0f);
m[2] = vector;
m[1][1] = 1.0f;
m[0][2] = 1.5f;
CORRADE_COMPARE(m[1][1], 1.0f);
CORRADE_COMPARE(m[0][2], 1.5f);
CORRADE_COMPARE(m[2], vector);
CORRADE_COMPARE(m, Matrix3x4(Vector4(0.0f, 0.0f, 1.5f, 0.0f),
Vector4(0.0f, 1.0f, 0.0f, 0.0f),
Vector4(4.0f, 5.0f, 6.0f, 7.0f)));
/* Pointer chasings, i.e. *(b.data()[1]), are not possible */
constexpr Matrix3x4 a(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
Vector4(4.5f, 4.0f, 7.0f, 3.0f),
Vector4(7.0f, -1.7f, 8.0f, 0.0f));
constexpr Vector4 b = a[2];
constexpr Float c = a[1][2];
constexpr Float d = *a.data();
CORRADE_COMPARE(b, Vector4(7.0f, -1.7f, 8.0f, 0.0f));
CORRADE_COMPARE(c, 7.0f);
CORRADE_COMPARE(d, 3.0f);
}
示例10: GetParentBody
//[-------------------------------------------------------]
//[ Public virtual PLPhysics::Joint functions ]
//[-------------------------------------------------------]
void JointUniversal::GetCurrentPivotPoint(Vector3 &vPosition) const
{
const PLPhysics::Body *pParentBody = GetParentBody();
if (pParentBody) {
// Get transform matrix
Quaternion qQ;
pParentBody->GetRotation(qQ);
Vector3 vPos;
pParentBody->GetPosition(vPos);
Matrix3x4 mTrans;
mTrans.FromQuatTrans(qQ, vPos);
// Get the current joint anchor in world space
vPosition = m_vLocalAnchor;
vPosition *= mTrans;
}
}
示例11: GetTransform
/**
* @brief
* Returns the view matrix
*/
Matrix3x4 &SNCamera::GetViewMatrix()
{
// Calculate view matrix if required
if (m_bAutoUpdate && (m_nInternalCameraFlags & RecalculateViewMatrix)) {
// Calculate view matrix
m_mView.View(CalculateViewRotation(), GetTransform().GetPosition());
if (GetFlags() & FlipY) {
Matrix3x4 mScale;
mScale.SetScaleMatrix(1.0f, -1.0f, 1.0f);
m_mView *= mScale;
}
// Recalculation done
m_nInternalCameraFlags &= ~RecalculateViewMatrix;
}
// Return the view matrix
return m_mView;
}
示例12: Matrix3x4
BoundingBox CollisionShape::GetWorldBoundingBox() const
{
if (shape_ && node_)
{
// Use the rigid body's world transform if possible, as it may be different from the rendering transform
RigidBody* body = GetComponent<RigidBody>();
Matrix3x4 worldTransform = body ? Matrix3x4(body->GetPosition(), body->GetRotation(), node_->GetWorldScale()) :
node_->GetWorldTransform();
Vector3 worldPosition(worldTransform * position_);
Quaternion worldRotation(worldTransform.Rotation() * rotation_);
btTransform shapeWorldTransform(ToBtQuaternion(worldRotation), ToBtVector3(worldPosition));
btVector3 aabbMin, aabbMax;
shape_->getAabb(shapeWorldTransform, aabbMin, aabbMax);
return BoundingBox(ToVector3(aabbMin), ToVector3(aabbMax));
}
else
return BoundingBox();
}
示例13: UpdateBatches
void Skybox::UpdateBatches(const FrameInfo& frame)
{
distance_ = 0.0f;
if (frame.frameNumber_ != lastFrame_)
{
customWorldTransforms_.Clear();
lastFrame_ = frame.frameNumber_;
}
// Add camera position to fix the skybox in space. Use effective world transform to take reflection into account
Matrix3x4 customWorldTransform = node_->GetWorldTransform();
customWorldTransform.SetTranslation(node_->GetWorldPosition() + frame.camera_->GetEffectiveWorldTransform().Translation());
HashMap<Camera*, Matrix3x4>::Iterator it = customWorldTransforms_.Insert(MakePair(frame.camera_, customWorldTransform));
for (unsigned i = 0; i < batches_.Size(); ++i)
{
batches_[i].worldTransform_ = &it->second_;
batches_[i].distance_ = 0.0f;
}
}
示例14: diagonal
void RectangularMatrixTest::diagonal() {
Vector3 diagonal(-1.0f, 5.0f, 11.0f);
Matrix4x3 a(Vector3(-1.0f, 1.0f, 3.0f),
Vector3( 4.0f, 5.0f, 7.0f),
Vector3( 8.0f, 9.0f, 11.0f),
Vector3(12.0f, 13.0f, 15.0f));
CORRADE_COMPARE(a.diagonal(), diagonal);
Matrix3x4 b(Vector4(-1.0f, 4.0f, 8.0f, 12.0f),
Vector4( 1.0f, 5.0f, 9.0f, 13.0f),
Vector4( 3.0f, 7.0f, 11.0f, 15.0f));
CORRADE_COMPARE(b.diagonal(), diagonal);
}
示例15: Matrix3x4
Matrix3x4 SceneNode::getLocalTransform()
{
Matrix3x4 transform = Matrix3x4();
transform.translate(position_);
transform.rotateX(radToDeg(rotation_.x_));
transform.rotateY(radToDeg(rotation_.y_));
transform.rotateZ(radToDeg(rotation_.z_));
transform.scale(scale_);
return transform;
}