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


C++ Quat::CreateFromRotationRADIANS方法代码示例

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


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

示例1: Refresh

void Projectile::Refresh(const float &fDeltaTime)
{
	PhysicalObject::Refresh(fDeltaTime);

	//rotate the projectile based on the direction it is traveling

	//update the rotation for debug visual display
	Quat *quat = &(GetNode()->m_PosQuat.quat);
	Quat rotation;
	rotation.CreateFromRotationRADIANS(fDeltaTime * 0.75f * PI, m_vVelocity.x, m_vVelocity.y, m_vVelocity.z);
	*quat = rotation * *quat;
}
开发者ID:scottrick,项目名称:dgame,代码行数:12,代码来源:Projectile.cpp

示例2: HandleMouseMove

void NothingScene::HandleMouseMove(const int &dwX, const int &dwY, const int &dwDeltaX, const int &dwDeltaY)
{	
	//update the rotation for debug display based on the mouse movement!
	Quat *quat = &(m_PosQuat.quat);
	Quat rotation;
	VECTOR3 axis; 	
	axis.x = (float) dwDeltaY;	
	axis.y = (float) dwDeltaX;	

	rotation.CreateFromRotationRADIANS(PI / 360.0f * (float)(abs(dwDeltaX) + abs(dwDeltaY)), axis.x, axis.y, axis.z);
	*quat = rotation * *quat;
}
开发者ID:scottrick,项目名称:dgame,代码行数:12,代码来源:NothingScene.cpp

示例3: Refresh

void TestObject::Refresh(const float &fDeltaTime)
{
	return; //no rotating for now

	VECTOR3 *pos = &(m_pNode->m_PosQuat.pos);
	Quat *quat = &(m_pNode->m_PosQuat.quat);

	goto hacky;

	//update the position with some crappy bouncing thing
	if (bXUp)
	{
		pos->x += 0.05f;

		if (pos->x > 2.0f)
		{
			bXUp = !bXUp;
		}
	}
	else
	{
		pos->x -= 0.05f;

		if (pos->x < -2.0f)
		{
			bXUp = !bXUp;
		}
	}

hacky:
	//update the rotation!
	//rotate by small amount every time
	Quat rotation;

	VECTOR3 axis;
	axis.x = 0.1f;
	axis.y = 1.0f;
	axis.z = 0.2f;
	//NormalizeVECTOR3(axis);

	rotation.CreateFromRotationRADIANS(0.02f, axis.x, axis.y, axis.z);
	*quat = rotation * *quat;
}
开发者ID:scottrick,项目名称:dgame,代码行数:43,代码来源:TestObject.cpp

示例4: Fire

void Weapon::Fire()
{
	if (m_fCurrentCooldown <= 0.0f)
	{
		m_fCurrentCooldown = m_fCooldown;

		PhysicalObject *pOwner = GetOwner();
		
		if (pOwner)
		{
			Node			*pSourceNode = pOwner->GetNode();
			
			if (pSourceNode)
			{
				Projectile *pNewProjectile = new Projectile(GetNode());
				VECTOR3 vDirection;

				Matrix44 mat = pSourceNode->m_PosQuat.quat.ToMatrix();

				float yDisp = -(pSourceNode->m_vScale.y / 2.0f + pNewProjectile->GetNode()->m_vScale.y / 2.0f);

				if (pSourceNode->GetNodeFlags() & NODE_RENDER_UPSIDEDOWN)
				{
					yDisp *= -1.0f;
				}

				pNewProjectile->GetNode()->m_PosQuat.pos.x = mat.m[4] * yDisp + pSourceNode->m_PosQuat.pos.x;
				pNewProjectile->GetNode()->m_PosQuat.pos.y = mat.m[5] * yDisp + pSourceNode->m_PosQuat.pos.y;
				pNewProjectile->GetNode()->m_PosQuat.pos.z = mat.m[6] * yDisp + pSourceNode->m_PosQuat.pos.z;

				//calculate actual firing direction based on aim, and weapon spread
				int dwRandom = GenerateRandomInt(9);
				float fSpread = 0.0f;
				if (dwRandom < 7)
				{
					fSpread = GenerateRandomFloat(0.05f);
				}
				else if (dwRandom < 9)
				{
					fSpread = GenerateRandomFloat(0.15f) + 0.05f;
				}
				else
				{
					fSpread = GenerateRandomFloat(0.30f) + 0.2f;
				}
				
				if (GenerateRandomInt(1))
				{
					fSpread = -fSpread;
				}
				
				fSpread = fSpread * m_fFiringSpread;
				float fCos = cos(fSpread);
				float fSin = sin(fSpread);
				
				//vDirection.x = fCos * m_vAim.x + fSin * m_vAim.x;
				//vDirection.y = fCos * m_vAim.y - fSin * m_vAim.y;
				vDirection.x = fCos * m_vAim.x - fSin * m_vAim.y;
				vDirection.y = fSin * m_vAim.x + fCos * m_vAim.y;
				vDirection.z = 0.0f;

				NormalizeVECTOR3(vDirection);

				pNewProjectile->GetNode()->m_PosQuat.pos.z = pSourceNode->m_PosQuat.pos.z;
				pNewProjectile->SetMaxSpeed(m_fSpeed);

				pNewProjectile->SetVelocity(VECTOR3(m_fSpeed * vDirection.x, m_fSpeed * vDirection.y, m_fSpeed * vDirection.z));
				pNewProjectile->SetCreator(pOwner);
				pNewProjectile->SetWeapon(this);

				Quat *quat = &(pNewProjectile->GetNode()->m_PosQuat.quat);
				Quat rotation;
				rotation.CreateFromRotationRADIANS(fSpread, 0.0f, 0.0f, 1.0f);
				*quat = rotation * *quat;

				TestFireEvent *pTestFireEvent = new TestFireEvent();
				pTestFireEvent->SetProjectile(pNewProjectile);
				gEventManager()->AddEvent(pTestFireEvent);
				pTestFireEvent->Release();
				pNewProjectile->Release();	
			}
		}
	}
}
开发者ID:scottrick,项目名称:dgame,代码行数:84,代码来源:Weapon.cpp


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