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


C++ Mtx44::SetToRotation方法代码示例

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


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

示例1: if

void CustomCam1::rotateCamVertical(float degrees)
{
	if (degrees + f_currentPitch > f_pitchLimit && degrees > 0)
	{
		degrees = f_pitchLimit - f_currentPitch;

		if (f_currentPitch >= f_pitchLimit)
		{
			degrees = 0.f;
		}
	}

	else if (degrees + f_currentPitch < -f_pitchLimit && degrees < 0)
	{
		degrees = -f_pitchLimit - f_currentPitch;

		if (f_currentPitch <= -f_pitchLimit)
		{
			degrees = 0.f;
		}
	}

	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
	Mtx44 rotation;
	target -= position;
	f_currentPitch += degrees;
	rotation.SetToRotation(static_cast<float>(degrees), right.x, right.y, right.z);
	target = rotation * target;
	target += position;
}
开发者ID:imweihenggit,项目名称:Studio-Project-4,代码行数:34,代码来源:CustomCam1.cpp

示例2: SetRotate

void CTransform::SetRotate( const float angle, const float rx, const float ry, const float rz, bool self)
{
	Mtx44 MtxBackToPosition;
	if (self)
	{
		Mtx44 MtxBackToOrigin;
		MtxBackToOrigin.a[12] = -Mtx.a[12];
		MtxBackToOrigin.a[13] = -Mtx.a[13];
		MtxBackToOrigin.a[14] = -Mtx.a[14];

		MtxBackToPosition.a[12] = Mtx.a[12];
		MtxBackToPosition.a[13] = Mtx.a[13];
		MtxBackToPosition.a[14] = Mtx.a[14];

		Mtx = Mtx + MtxBackToOrigin;
	}
	Mtx44 TempMtx;
	TempMtx.SetToRotation(angle, rx, ry, rz);

	Mtx =  Mtx * TempMtx ;

	if (self)
	{
		Mtx = Mtx + MtxBackToPosition;
	}
}
开发者ID:Glenn-Pao,项目名称:3D_Framework_Basic,代码行数:26,代码来源:Transform.cpp

示例3: movementFB

void AI::movementFB(double &dt, bool forward)
{
	Mtx44 rotation;

	if (forward)
	{
		if (e_State == ATTACK)
		{
			f_movementSpeed = f_move_run;
		}
		else
		{
			f_movementSpeed = f_move_walk;
		}

		vel += (getDirection(true).Normalize() * (f_movementSpeed)) * static_cast<float>(dt);
	}
	else
	{
		Lookat = Lookat - pos;
		rotation.SetToRotation(720 * static_cast<float>(dt), 0, 1, 0);
		Lookat = rotation * Lookat;
		Lookat = Lookat + pos;
		//Velocity += (getDirection(true).Normalize() * f_movementSpeed) * static_cast<float>(dt);
	}
}
开发者ID:Auranapse,项目名称:Studio-Project-3---Potato-Locomotive,代码行数:26,代码来源:AI.cpp

示例4: SpinCounterClockwise

void FPcamera::SpinCounterClockwise(const double dt)
{
	float angle = (float)(-TURN_SPEED * (float)dt);
	view = (target - position).Normalized();
	Mtx44 rotation;
	rotation.SetToRotation(angle, 0, 0, 1);
	view = rotation * view;
	target = position + view;
}
开发者ID:Chongjx,项目名称:Framework,代码行数:9,代码来源:FPcamera.cpp

示例5: LookAround

void CameraComponent::LookAround(double dt)
{
	auto infoC = this->getParent()->getComponent<InformationComponent>();

	if (infoC)
	{
		Mtx44 rotation;
		rotation.SetToRotation(m_Camera->getCameraYaw(),0, 1, 0);
		Vector3 curDirection = infoC->getDirection().Normalized();
		curDirection = rotation * curDirection;
		infoC->setDirection(curDirection);
	}
}
开发者ID:DarkPromise,项目名称:StudioProject4,代码行数:13,代码来源:CameraComponent.cpp

示例6:

void CPlayInfo3PV::UpdateDir(float yaw, float pitch)
{
	// Yaw
	Mtx44 rotation;
	rotation.SetToRotation(yaw, 0, 1, 0);
	curDirection = rotation * curDirection;
	Vector3 right = curDirection.Cross(curUp);
	right.y = 0;
	right.Normalize();
	curUp = right.Cross(curDirection).Normalized();

	// Pitch
	//rotation.SetToRotation(pitch, 1, 0, 0);

	right = curDirection.Cross(curUp);
	right.y = 0;
	right.Normalize();
	curUp = right.Cross(curDirection).Normalized();
	rotation.SetToRotation(pitch, right.x, right.y, right.z);

	curDirection = rotation * curDirection;
}
开发者ID:NothingMuch123,项目名称:Adv-GDev,代码行数:22,代码来源:PlayInfo3PV.cpp

示例7: movementLR

void AI::movementLR(double &dt, bool left, float rotation_speed)
{
	Mtx44 rotation;
	if (left == true)
	{
		Lookat = Lookat - pos;
		rotation.SetToRotation(-rotation_speed * static_cast<float>(dt), 0, 1, 0);
		Lookat = rotation * Lookat;
		Lookat = Lookat + pos;
		//Velocity += (getDirection(true).Normalize() * f_movementSpeed) * static_cast<float>(dt);

	}

	else
	{
		Lookat = Lookat - pos;
		rotation.SetToRotation(rotation_speed * static_cast<float>(dt), 0, 1, 0);
		Lookat = rotation * Lookat;
		Lookat = Lookat + pos;
		//Velocity += (getDirection(true).Normalize() * f_movementSpeed) * static_cast<float>(dt);
	}
}
开发者ID:Auranapse,项目名称:Studio-Project-3---Potato-Locomotive,代码行数:22,代码来源:AI.cpp

示例8: LookDown

/********************************************************************************
LookDown
********************************************************************************/
void TPCamera::LookDown(const double dt)
{
	//float pitch = (float)(-CAMERA_SPEED * Application::camera_pitch * (float)dt);
	float pitch = (float)(CAMERA_SPEED * (float)dt);
	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
	Mtx44 rotation;
	rotation.SetToRotation(pitch, right.x, right.y, right.z);
	view = rotation * view;
	target = position + view;
}
开发者ID:ElIgnis,项目名称:Alpha-AI,代码行数:17,代码来源:TPCamera.cpp

示例9: lookUp

void FPcamera::lookUp(const double dt)
{
	float pitch = (float)(-TURN_SPEED * Application::camera_pitch * (float)dt);
	rotationX -= pitch;
	view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
	Mtx44 rotation;
	rotation.SetToRotation(pitch, right.x, right.y, right.z);
	view = rotation * view;
	target = position + view;
}
开发者ID:Chongjx,项目名称:Framework,代码行数:14,代码来源:FPcamera.cpp

示例10: lookRight

void FPcamera::lookRight(const double dt)
{
	view = (target - position).Normalized();
	float yaw = (float)(-TURN_SPEED * Application::camera_yaw * (float)dt);
	rotationY += yaw;
	Mtx44 rotation;
	rotation.SetToRotation(yaw, 0, 1, 0);
	view = rotation * view;
	target = position + view;
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
}
开发者ID:Chongjx,项目名称:Framework,代码行数:14,代码来源:FPcamera.cpp

示例11: TurnRight

/********************************************************************************
Turn right
********************************************************************************/
void TPCamera::TurnRight(const double dt)
{
	Vector3 view = (target - position).Normalized();
	//	float yaw = (float)(-CAMERA_SPEED * Application::camera_yaw * (float)dt);
	float yaw = (float)(-CAMERA_SPEED * (float)dt);
	Mtx44 rotation;
	rotation.SetToRotation(yaw, 0, 1, 0);
	view = rotation * view;
	target = position + view;
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
}
开发者ID:ElIgnis,项目名称:Alpha-AI,代码行数:17,代码来源:TPCamera.cpp

示例12:

/********************************************************************************
LookRight
********************************************************************************/
void Camera3::LookRight(const double dt)
{
	float yaw = yawVelocity;
	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
	Mtx44 rotation;
	rotation.SetToRotation(yaw, 0, 1, 0);
	view = rotation * view;
	target = position + view;

	up = rotation * up;
}
开发者ID:barryHub20,项目名称:SP3,代码行数:18,代码来源:Camera3.cpp

示例13: lookDown

void FPcamera::lookDown(const double dt, float downValue)
{
	float pitch = (float)(-WALK_SPEED * Application::camera_pitch * (float)dt - downValue * (float)dt);
	recoil -= 5.f * (float)dt;;
	rotationX -= pitch;
	view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(view).Normalized();
	Mtx44 rotation;
	rotation.SetToRotation(pitch, right.x, right.y, right.z);
	view = rotation * view;
	target = position + view;
}
开发者ID:Chongjx,项目名称:Framework,代码行数:15,代码来源:FPcamera.cpp

示例14: LookPitch

void FPS_Cam::LookPitch(float pitchValue, double dt)
{
	float mspeed = mouse_speed * pitchValue * dt;

	FaceDirection = (target - position).Normalized();
	Vector3 right = FaceDirection.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(FaceDirection).Normalized();
	rotation22.SetToRotation(mspeed, right.x, right.y, right.z);
	FaceDirection = rotation22 * FaceDirection;
	target = position + FaceDirection;

	up = rotation22 * up;
}
开发者ID:Mamama22,项目名称:Framework-C-,代码行数:15,代码来源:FPS_Camera.cpp

示例15: LookYaw

void FPS_Cam::LookYaw(float yawValue, double dt)
{
	float mspeed = mouse_speed * yawValue;

	FaceDirection = (target - position).Normalized();
	Vector3 right = FaceDirection.Cross(up);
	right.y = 0;
	right.Normalize();
	up = right.Cross(FaceDirection).Normalized();
	rotation22.SetToRotation(mspeed * dt, 0, 1, 0);
	FaceDirection = rotation22 * FaceDirection;
	target = position + FaceDirection;

	up = rotation22 * up;
}
开发者ID:Mamama22,项目名称:Framework-C-,代码行数:15,代码来源:FPS_Camera.cpp


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