本文整理汇总了C++中Matrix4::Invert方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::Invert方法的具体用法?C++ Matrix4::Invert怎么用?C++ Matrix4::Invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::Invert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unproject
Vector3 Renderer::Unproject(const Vector3& screenPoint) const
{
// Convert screenPoint to device coordinates (between -1 and +1)
Vector3 deviceCoord = screenPoint;
deviceCoord.x /= (mWidth) * 0.5f;
deviceCoord.y /= (mHeight) * 0.5f;
// First, undo the projection
Matrix4 unprojection = mProj;
unprojection.Invert();
Vector3 unprojVec = TransformWithPerspDiv(deviceCoord, unprojection);
// Now undo the view matrix
Matrix4 uncamera = mView;
uncamera.Invert();
return Transform(unprojVec, uncamera);
}
示例2: SetCamera
/// <summary>
/// Sets up a quaternion & position from vector camera components
/// and oriented the camera up
/// </summary>
/// <param name="eye">The camera position</param>
/// <param name="lookAt">The camera's look-at point</param>
/// <param name="up"></param>
void ArcBallCameraController::SetCamera(Vector3F position, Vector3F target, Vector3F up)
{
m_bRecomputeViewMatrix = true;
//Create a look at matrix, to simplify matters a bit
Matrix4 temp;
temp.LookAt(position, target, up);
//invert the matrix, since we're determining the
//orientation from the rotation matrix in RH coords
temp.Invert();
//set the position
m_Target = target;
//set distance
m_fDistance = (target - position).Length();
//create the new aspect from the look-at matrix
m_ArcBallOrientation.FromMatrix(temp);
//When setting a new eye-view direction
//in one of the gamble-locked modes, the yaw and
//pitch gimble must be calculated.
//first, get the direction projected on the x/z plne
Vector3F dir = Direction();
dir.y = 0.0f;
if (dir.Length() == 0.0f)
{
dir = Vector3F::Forward();
}
dir.Normalize();
//find the yaw of the direction on the x/z plane
//and use the sign of the x-component since we have 360 degrees
//of freedom
m_fArcBallYaw = (acosf(-dir.z) * Sign(dir.x));
//Get the pitch from the angle formed by the Up vector and the
//the forward direction, then subtracting Pi / 2, since
//we pitch is zero at Forward, not Up.
m_fArcBallPitch = -(acosf(Vector3F::Dot(Vector3F::Up(), Direction())) - MATH_PI_DIV_2);
}
示例3: ViewToWorld
bool Screenport::ViewToWorld( const grinliz::Vector2F& v, const grinliz::Matrix4* _mvpi, grinliz::Ray* ray ) const
{
Matrix4 mvpi;
if ( _mvpi ) {
mvpi = *_mvpi;
}
else {
Matrix4 mvp;
ViewProjection3D( &mvp );
mvp.Invert( &mvpi );
}
// View normalized:
Vector4F in = { 2.0f * v.x / screenWidth - 1.0f,
2.0f * v.y / screenHeight - 1.0f,
0.f, //v.z*2.0f-1.f,
1.0f };
Vector4F out0, out1;
MultMatrix4( mvpi, in, &out0 );
in.z = 1.0f;
MultMatrix4( mvpi, in, &out1 );
if ( out0.w == 0.0f ) {
return false;
}
ray->origin.x = out0.x / out0.w;
ray->origin.y = out0.y / out0.w;
ray->origin.z = out0.z / out0.w;
ray->direction.x = out1.x / out1.w - ray->origin.x;
ray->direction.y = out1.y / out1.w - ray->origin.y;
ray->direction.z = out1.z / out1.w - ray->origin.z;
return true;
}