示例#1
0
void CameraSceneNode::SetLookAtPoint(Vec3 lap)
{
	//mOgreSceneNode->lookAt(lap, Ogre::Node::TS_WORLD);

	Vec3 z = -(lap - GetPosition()); z.normalise(); // z
	Vec3 x = z.crossProduct(Vec3::NEGATIVE_UNIT_Y); x.normalise(); // x
	Vec3 y = -x.crossProduct(z); y.normalise(); // y

	Ogre::Matrix3 R;
	R.FromAxes(x, y, z);

	Quat q; q.FromRotationMatrix(R);
	mOgreSceneNode->setOrientation(q);

	this->SetOrientation(mOgreSceneNode->getOrientation()*this->GetParent()->GetOrientation().Inverse());
}
示例#2
0
void
BuildTank::setBadGun(Ogre::Radian theta){
		Ogre::Quaternion gunOrientation = mTankGunNode->getOrientation() ;
		// convert orientation to a matrix
		Ogre::Matrix3 tGunMatrix3;
		gunOrientation.ToRotationMatrix( tGunMatrix3 );

		Ogre::Vector3 xBasis = Ogre::Vector3(Ogre::Math::Cos(theta),0, - Ogre::Math::Sin(theta));
		Ogre::Vector3 yBasis = Ogre::Vector3(0,1,0);
		Ogre::Vector3 zBasis = Ogre::Vector3(Ogre::Math::Sin(theta),0,Ogre::Math::Cos(theta));
		Ogre::Matrix3 rotate;
		rotate.FromAxes(xBasis, yBasis, zBasis);
		mGunOrientation = rotate * tGunMatrix3;

		mTankGunNode->setOrientation(Ogre::Quaternion(mGunOrientation));
}
示例#3
0
void 
BuildTank::yawTurret(Ogre::Radian theta)
{
	Ogre::Quaternion turretOrientation = mTankTurretNode->getOrientation() ;
	// convert orientation to a matrix
	Ogre::Matrix3 yawTMatrix3;
	turretOrientation.ToRotationMatrix(yawTMatrix3);

	Ogre::Vector3 xBasis = Ogre::Vector3(Ogre::Math::Cos(theta),0, - Ogre::Math::Sin(theta));
    Ogre::Vector3 yBasis = Ogre::Vector3(0,1,0);
    Ogre::Vector3 zBasis = Ogre::Vector3(Ogre::Math::Sin(theta),0,Ogre::Math::Cos(theta));
    Ogre::Matrix3 rotate;
    rotate.FromAxes(xBasis, yBasis, zBasis);
    mTurretOrientation = rotate *  yawTMatrix3 ;

	mTankTurretNode->setOrientation(Ogre::Quaternion(mTurretOrientation));
}
示例#4
0
//Rotate the tank
void 
BuildTank::yawTank(Ogre::Radian theta)
{
	Ogre::Quaternion orientation = mTankBodyNode->_getDerivedOrientation() ;
	// convert orientation to a matrix
	Ogre::Matrix3 matrix3;
	orientation.ToRotationMatrix( matrix3 );

	Ogre::Vector3 xBasis = Ogre::Vector3(Ogre::Math::Cos(theta),0, - Ogre::Math::Sin(theta));
    Ogre::Vector3 yBasis = Ogre::Vector3(0,1,0);
    Ogre::Vector3 zBasis = Ogre::Vector3(Ogre::Math::Sin(theta),0,Ogre::Math::Cos(theta));
    Ogre::Matrix3 rotate;
    rotate.FromAxes(xBasis, yBasis, zBasis);
    mTankOrientation = rotate *  matrix3 ;

	mTankBodyNode->setOrientation(Ogre::Quaternion(mTankOrientation));
}