Exemplo n.º 1
0
void CreateTool::MouseMove( const MouseMoveInput& e )
{
	if ( !m_Instance.ReferencesObject() )
	{
		return;
	}

	if ( m_PaintTimer.IsAlive() )
	{
		m_InstanceUpdateOffsets = true;
	}

	// get position
	Vector3 translation;
	Vector3 normal;
	DetermineTranslationAndNormal( e.GetPosition().x, e.GetPosition().y, translation, normal );

	Matrix4 position;
	FinalizeOrientation( position, translation, normal );

	m_InstanceTranslation = translation;
	m_InstanceNormal = ( normal == Vector3::Zero ) ? Editor::UpVector : normal;

	// hide the temporary object when painting and moving
	if ( m_PaintTimer.IsAlive() )
	{
		position *= Matrix4( Scale( 0.0f, 0.0f, 0.0f ) );
	}

	// set position
	m_Instance->SetObjectTransform( position );

	// evaluate
	m_Instance->Evaluate( GraphDirections::Downstream );

	// render
	m_Scene->Execute(true);

	Base::MouseMove(e);
}
Exemplo n.º 2
0
void CurveCreateTool::MouseMove( const MouseMoveInput& e )
{
    if ( m_Instance.ReferencesObject() )
    {
        uint32_t countControlPoints = m_Instance->GetNumberControlPoints();

        if ( countControlPoints > 0 )
        {
            Vector3 position;
            PickPosition( e.GetPosition().x, e.GetPosition().y, position );

            CurveControlPoint* current = m_Instance->GetControlPointByIndex( countControlPoints - 1 );
            current->SetPosition( position );

            m_Instance->Dirty();

            m_Scene->Execute( true );
        }
    }

    Base::MouseMove( e );
} 
Exemplo n.º 3
0
void CurveEditTool::MouseMove( const MouseMoveInput& e )
{
    if ( GetEditMode() )
    {
        m_ControlPointManipulator->MouseMove( e );

        if ( e.Dragging() )
        {
            // clear the current highlight
            m_Scene->ClearHighlight( ClearHighlightArgs(true) );

            // disallow selection when dragging
            m_AllowSelection = false;
        }
    }

    Base::MouseMove( e );
}
Exemplo n.º 4
0
void TransformManipulator::MouseMove( const MouseMoveInput& e )
{
    if ( e.Dragging() )
    {
        // clear the current highlight
        m_Scene->ClearHighlight( ClearHighlightArgs (true) );

        // disallow selection when dragging
        m_AllowSelection = false;
    }
    else
    {
        // reset cached button state
        m_Left = m_Middle = m_Right = false;

        // allow selection when not dragging
        m_AllowSelection = true;
    }
}
Exemplo n.º 5
0
void Camera::MouseMove( const MouseMoveInput& e )
{
    if (e.LeftIsDown() && !e.MiddleIsDown())
    {
        m_MovementMode = MovementModes::Orbit;
    }
    else if (e.MiddleIsDown() && !e.LeftIsDown())
    {
        m_MovementMode = MovementModes::Track;
    }
    else if ((e.LeftIsDown() && e.MiddleIsDown()) || e.RightIsDown())
    {
        m_MovementMode = MovementModes::Dolly;
    }
    else
    {
        return;
    }

    int deltaX = e.GetPosition().x - m_Prev.x;
    int deltaY = e.GetPosition().y - m_Prev.y;

    switch (m_MovementMode)
    {
    case MovementModes::Orbit:
        {
            switch (m_ProjectionMode)
            {
            case ProjectionModes::Perspective:
                {
                    Matrix4 inverseOrientation = m_Orientation.Inverted();

                    // newO = inv(oldO) * eulerY * oldO * eulerX
                    // this puts eulerY in the world frame, and keeps eulerX in the camera's frame
                    m_Orientation *= inverseOrientation * Matrix4 (AngleAxis (deltaX * m_Sensitivity * 0.01f, UpVector)) * m_Orientation * Matrix4(AngleAxis (deltaY * m_Sensitivity * 0.01f, SideVector));
                    m_Orientation.Orthogonalize();
                    m_Orientation.Normalize();

                    break;
                }
            }
            break;
        }

    case MovementModes::Track:
        {
            Vector3 p1;
            ViewportToPlaneVertex( (float32_t)m_Prev.x, (float32_t)m_Prev.y, IntersectionPlanes::Viewport, p1);
            Vector3 p2;
            ViewportToPlaneVertex( (float32_t)e.GetPosition().x, (float32_t)e.GetPosition().y, IntersectionPlanes::Viewport, p2);

            // Track vector is the translation of the m_Pivot from the starting planar intersection to the current planar intersection
            m_Pivot += p1 - p2;

            break;
        }

    case MovementModes::Dolly:
        {
            // Dolly distance is the mouse distance traveled
            float dolly = (float32_t)(-deltaX) + (float32_t)(-deltaY);

            // Factor dolly distance by the distance to our pivot point
            dolly *= m_Offset / 200.0f;

            // Update our distance to the pivot point
            if (m_Offset + dolly > FarClipDistance)
            {
                m_Offset = FarClipDistance;
            }
            else if (m_Offset + dolly < NearClipDistance)
            {
                m_Offset = NearClipDistance;
            }
            else
            {
                m_Offset += dolly;
            }

            break;
        }
    }

    Update( true );

    m_Prev = Point(e.GetPosition().x, e.GetPosition().y);
}