当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix4::LookAt方法代码示例

本文整理汇总了C++中Matrix4::LookAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::LookAt方法的具体用法?C++ Matrix4::LookAt怎么用?C++ Matrix4::LookAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix4的用法示例。


在下文中一共展示了Matrix4::LookAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ViewMatrix

Matrix4 ArcBallCameraController::ViewMatrix(Matrix4 &viewMatrix_)
{
	if (m_bRecomputeViewMatrix == true)
	{
		m_bRecomputeViewMatrix = false;
		viewMatrix_.LookAt(m_Target - (Direction() * m_fDistance), m_Target, Up());
	}

	return viewMatrix_;
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:10,代码来源:ArcBallCameraController.cpp

示例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);
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:51,代码来源:ArcBallCameraController.cpp


注:本文中的Matrix4::LookAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。