Пример #1
0
 void FineTuningHeight(ECoordAxis axis)
 {
     // Fine tuning the relative height
     if (Input.GetKeyDown(KeyCode.UpArrow))
     {
         if (axis == ECoordAxis.X)
         {
             m_EndOffset.x += dataSource.Scale * pattern.size;
         }
         else if (axis == ECoordAxis.Y)
         {
             m_EndOffset.y += dataSource.Scale * pattern.size;
         }
         else if (axis == ECoordAxis.Z)
         {
             m_EndOffset.z += dataSource.Scale * pattern.size;
         }
     }
     else if (Input.GetKeyDown(KeyCode.DownArrow))
     {
         if (axis == ECoordAxis.X)
         {
             m_EndOffset.x -= dataSource.Scale * pattern.size;
         }
         else if (axis == ECoordAxis.Y)
         {
             m_EndOffset.y -= dataSource.Scale * pattern.size;
         }
         else if (axis == ECoordAxis.Z)
         {
             m_EndOffset.z -= dataSource.Scale * pattern.size;
         }
     }
 }
Пример #2
0
    protected override void ExtraAdjust()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (m_Direction == ECoordAxis.Y)
            {
                m_Direction = ECoordAxis.X;
            }
            else if (m_Direction == ECoordAxis.Z)
            {
                m_Direction = ECoordAxis.Y;
            }
            else if (m_Direction == ECoordAxis.X)
            {
                m_Direction = ECoordAxis.Z;
            }
            else
            {
                m_Direction = ECoordAxis.Y;
            }
        }
        Transform shapegizmo = null;

        if (m_GizmoCube.m_ShapeGizmo != null)
        {
            shapegizmo = m_GizmoCube.m_ShapeGizmo.GetChild(0);
        }
        switch (m_Direction)
        {
        case ECoordAxis.X:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, 90);
            }
            break;

        case ECoordAxis.Y:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
            break;

        case ECoordAxis.Z:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(90, 0, 0);
            }
            break;

        default:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
            break;
        }
    }
Пример #3
0
    public static bool RayAdjustHeight(Ray ray, ECoordAxis height_axis, Vector3 basepoint, out float height)
    {
        height = 0;
        if (height_axis == ECoordAxis.X)
        {
            height = basepoint.x;

            if (Mathf.Abs(ray.direction.y) < 0.001f && Mathf.Abs(ray.direction.z) < 0.001f)
            {
                return(false);
            }
            else
            {
                Vector3 horz      = Vector3.Cross(Vector3.right, ray.direction).normalized;
                Plane   ray_plane = new Plane(ray.origin, ray.GetPoint(10), ray.origin + horz * 10);
                Ray     vert      = new Ray(basepoint + Vector3.right * 2000, Vector3.left);
                float   enter     = 0;
                if (ray_plane.Raycast(vert, out enter))
                {
                    height = vert.GetPoint(enter).x;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        else if (height_axis == ECoordAxis.Y)
        {
            height = basepoint.y;
            if (Mathf.Abs(ray.direction.x) < 0.001f && Mathf.Abs(ray.direction.z) < 0.001f)
            {
                return(false);
            }
            else
            {
                Vector3 horz      = Vector3.Cross(Vector3.up, ray.direction).normalized;
                Plane   ray_plane = new Plane(ray.origin, ray.GetPoint(10), ray.origin + horz * 10);
                Ray     vert      = new Ray(basepoint + Vector3.up * 2000, Vector3.down);
                float   enter     = 0;
                if (ray_plane.Raycast(vert, out enter))
                {
                    height = vert.GetPoint(enter).y;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        else if (height_axis == ECoordAxis.Z)
        {
            height = basepoint.z;
            if (Mathf.Abs(ray.direction.x) < 0.001f && Mathf.Abs(ray.direction.y) < 0.001f)
            {
                return(false);
            }
            else
            {
                Vector3 horz      = Vector3.Cross(Vector3.forward, ray.direction).normalized;
                Plane   ray_plane = new Plane(ray.origin, ray.GetPoint(10), ray.origin + horz * 10);
                Ray     vert      = new Ray(basepoint + Vector3.forward * 2000, Vector3.back);
                float   enter     = 0;
                if (ray_plane.Raycast(vert, out enter))
                {
                    height = vert.GetPoint(enter).z;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }

        return(false);
    }
Пример #4
0
    protected override void ExtraAdjust()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (m_Direction == ECoordAxis.Y)
            {
                m_Direction = ECoordAxis.X;
            }
            else if (m_Direction == ECoordAxis.Z)
            {
                m_Direction = ECoordAxis.Y;
            }
            else if (m_Direction == ECoordAxis.X)
            {
                m_Direction = ECoordAxis.Z;
            }
            else
            {
                m_Direction = ECoordAxis.Y;
            }
        }
        Transform shapegizmo = null;

        if (m_GizmoCube.m_ShapeGizmo != null)
        {
            shapegizmo = m_GizmoCube.m_ShapeGizmo.GetChild(0);
        }
        switch (m_Direction)
        {
        case ECoordAxis.X:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, -90);
            }
            break;

        case ECoordAxis.Y:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
            break;

        case ECoordAxis.Z:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(90, 0, 0);
            }
            break;

        default:
            if (shapegizmo != null)
            {
                shapegizmo.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
            break;
        }
        if (m_Direction == ECoordAxis.Y && Input.GetKey(KeyCode.UpArrow) ||
            m_Direction == ECoordAxis.X && Input.GetKey(VCEInput.s_RightKeyCode) ||
            m_Direction == ECoordAxis.Z && Input.GetKey(VCEInput.s_ForwardKeyCode))
        {
            m_PositiveScale += 0.05f;
            if (m_PositiveScale > 1.0f)
            {
                m_NegativeScale -= (m_PositiveScale - 1.0f);
                m_PositiveScale  = 1.0f;
            }
            if (m_NegativeScale < 0.0f)
            {
                m_NegativeScale = 0;
            }
        }
        if (m_Direction == ECoordAxis.Y && Input.GetKey(KeyCode.DownArrow) ||
            m_Direction == ECoordAxis.X && Input.GetKey(VCEInput.s_LeftKeyCode) ||
            m_Direction == ECoordAxis.Z && Input.GetKey(VCEInput.s_BackKeyCode))
        {
            m_NegativeScale += 0.05f;
            if (m_NegativeScale > 1.0f)
            {
                m_PositiveScale -= (m_NegativeScale - 1.0f);
                m_NegativeScale  = 1.0f;
            }
            if (m_PositiveScale < 0.0f)
            {
                m_PositiveScale = 0;
            }
        }
        m_ConeGizmo.m_NegativeScale = m_NegativeScale;
        m_ConeGizmo.m_PositiveScale = m_PositiveScale;
    }