Exemplo n.º 1
0
void EdGizmo::OnKeyPressed( const EdSceneViewport& viewport, const EKeyCode key )
{
	if( key == EKeyCode::Key_M
		|| key == EKeyCode::Key_T )
	{
		m_currentMode = Gizmo_Translate;
	}
	if( key == EKeyCode::Key_R )
	{
		m_currentMode = Gizmo_Rotate;
	}
	if( key == EKeyCode::Key_E )
	{
		m_currentMode = Gizmo_Scale;
	}

	if( m_selected != nil )
	{
		switch( m_currentMode )
		{
		case EGizmoMode::Gizmo_Translate :
			break;

		case EGizmoMode::Gizmo_Scale :
			break;

		case EGizmoMode::Gizmo_Rotate :
			{
				Matrix3	rotMatix;
				if( key == EKeyCode::Key_Left )
				{
					rotMatix.SetRotationX( -DEG2RAD(1) );
					this->RotateObject( rotMatix );
				}
				if( key == EKeyCode::Key_Right )
				{
					rotMatix.SetRotationX( +DEG2RAD(1) );
					this->RotateObject( rotMatix );
				}
				if( key == EKeyCode::Key_Up )
				{
					rotMatix.SetRotationZ( -DEG2RAD(1) );
					this->RotateObject( rotMatix );
				}
				if( key == EKeyCode::Key_Down )
				{
					rotMatix.SetRotationZ( +DEG2RAD(1) );
					this->RotateObject( rotMatix );
				}
			}
			break;
		}
	}
}
Exemplo n.º 2
0
void Map::RotateX(float dt)
{
	float angle = (PI/8.0f)*dt*0.001f;
	if((this->mAngleX+angle) > -this->mMaxAngleX && (this->mAngleX+angle) < this->mMaxAngleX)
	{
		Matrix3 temp;
		temp.SetRotationZ(this->mAngleZ);
		Vector3 xA = Vector3(1,0,0);
		Vector3 xAnew = temp * xA;
		this->mMesh->RotateAxis(xAnew.GetD3DVec(), angle);
		this->mAngleX +=angle;
	}
}
Exemplo n.º 3
0
void Map::Update(const float dt)
{
	if(this->mIsRotating)
	{		
		float angle;
		float speed = PI/26.0f;
		if(this->mTargetAngleX <0)
			angle = -speed*dt*0.001f;
		else
			angle = speed*dt*0.001f;
		Matrix3 temp;
		temp.SetRotationZ(this->mAngleZ);
		Vector3 xA = Vector3(1,0,0);
		Vector3 xAnew = temp * xA;
		this->mAngleX += angle;
		this->mMesh->RotateAxis(xAnew.GetD3DVec(), angle);
		
		if(this->mTargetAngleZ <0)
			angle = -speed*dt*0.001f;
		else
			angle = speed*dt*0.001f;
		this->mAngleZ += angle;
		this->mMesh->RotateAxis(D3DXVECTOR3(0,0,1), angle);
	}
	if(this->mMeshHotZone)
	{
		
		Vector3 scalingMesh = this->mMesh->GetScaling();
		Vector3 pos = this->mMesh->GetPosition();
		D3DXMATRIX quat;
		D3DXMatrixRotationQuaternion(&quat, &this->mMesh->GetRotation()); 
		
		Matrix4 rotate(quat);
		rotate.TransposeThis();

		Matrix4 scaling;
		scaling.SetScale(scalingMesh);

		Matrix4 translate;
		translate.SetTranslate(pos);
	
		Matrix4 rotateY;
		rotateY.SetRotationY(dt*0.001f*(PI/2.0f));
		Matrix4 newRotate = rotateY*rotate;
		
		

		Matrix4 world = translate*rotate*scaling;
		Vector3 posHotZone = Vector3(13.5f,2.5,13.5f);
		Vector3 newPos4HotZoneMesh = world * posHotZone;
		
		
		Vector4 newYrot = rotate*Vector4(0,1,0,0);
		Vector3 newYrot2 = Vector3(newYrot.x, newYrot.y, newYrot.z);


		D3DXQUATERNION q = this->mMesh->GetRotation();
		

		this->mMeshHotZone->SetQuaternion(this->mMesh->GetRotation());
		this->mAngleY += dt*0.001f*(PI/2.0f);

		this->mMeshHotZone->SetQuaternion(q);
		this->mMeshHotZone->SetPosition(newPos4HotZoneMesh.GetD3DVec());
		this->mMeshHotZone->RotateAxis(newYrot2.GetD3DVec(), this->mAngleY);
		
		Vector3 hotPos = Vector3(13.5f,4.5,13.5f);
		Vector3 newHotPos = world * hotPos;
		/* test to see that the flag mesh is not straight and thats true. */
		//this->mMeshHotZone->RotateAxis(D3DXVECTOR3(0,1,0), dt*0.001f*(PI/2.0f));
		this->mHotZonePosition = newHotPos;
	}
	float newdt = dt * 0.001f;
	float fraction = 1.0f - this->mShrink * newdt;
	this->mMesh->Scale(D3DXVECTOR3(fraction,1,fraction));
	this->mScaledRadius *= fraction;//this->mScaledRadius/this->mRadius;
}