Exemple #1
0
        internal override bool IsVisible(Transform handle)
        {
            CardinalAxisType axisType = GetAxisType(handle);

            return(IsActive &&
                   ((axisType == CardinalAxisType.X && config.ShowRotationHandleForX) ||
                    (axisType == CardinalAxisType.Y && config.ShowRotationHandleForY) ||
                    (axisType == CardinalAxisType.Z && config.ShowRotationHandleForZ)));
        }
Exemple #2
0
        internal void CreateLinks(RotationHandles rotationHandles, Transform parent, Vector3 currentBoundsExtents)
        {
            // create links
            if (links != null)
            {
                GameObject link;
                Vector3    linkDimensions = GetLinkDimensions(currentBoundsExtents);
                for (int i = 0; i < RotationHandles.NumEdges; ++i)
                {
                    if (config.WireframeShape == WireframeType.Cubic)
                    {
                        link = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        GameObject.Destroy(link.GetComponent <BoxCollider>());
                    }
                    else
                    {
                        link = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                        GameObject.Destroy(link.GetComponent <CapsuleCollider>());
                    }
                    link.name = "link_" + i.ToString();

                    CardinalAxisType axisType            = rotationHandles.GetAxisType(i);
                    float            wireframeEdgeRadius = config.WireframeEdgeRadius;
                    if (axisType == CardinalAxisType.Y)
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.y, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(0.0f, 90.0f, 0.0f));
                    }
                    else if (axisType == CardinalAxisType.Z)
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.z, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(90.0f, 0.0f, 0.0f));
                    }
                    else//X
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.x, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(0.0f, 0.0f, 90.0f));
                    }

                    link.transform.position = rotationHandles.GetEdgeCenter(i);
                    link.transform.parent   = parent;
                    Renderer linkRenderer = link.GetComponent <Renderer>();
                    linkRenderers.Add(linkRenderer);

                    if (config.WireframeMaterial != null)
                    {
                        linkRenderer.material = config.WireframeMaterial;
                    }

                    links.Add(new Link(link.transform, axisType));
                }
            }
        }
Exemple #3
0
        internal void CreateLinks(ref Vector3[] boundsCorners, Transform parent, Vector3 currentBoundsExtents)
        {
            // create links
            if (links != null)
            {
                GameObject link;
                Vector3    linkDimensions = GetLinkDimensions(currentBoundsExtents);
                for (int i = 0; i < VisualUtils.EdgeAxisType.Length; ++i)
                {
                    if (config.WireframeShape == WireframeType.Cubic)
                    {
                        link = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        Object.Destroy(link.GetComponent <BoxCollider>());
                    }
                    else
                    {
                        link = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                        Object.Destroy(link.GetComponent <CapsuleCollider>());
                    }
                    link.name = "link_" + i.ToString();

                    CardinalAxisType axisType            = VisualUtils.EdgeAxisType[i];
                    float            wireframeEdgeRadius = config.WireframeEdgeRadius;
                    if (axisType == CardinalAxisType.Y)
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.y, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(0.0f, 90.0f, 0.0f));
                    }
                    else if (axisType == CardinalAxisType.Z)
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.z, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(90.0f, 0.0f, 0.0f));
                    }
                    else//X
                    {
                        link.transform.localScale = new Vector3(wireframeEdgeRadius, linkDimensions.x, wireframeEdgeRadius);
                        link.transform.Rotate(new Vector3(0.0f, 0.0f, 90.0f));
                    }

                    link.transform.position = VisualUtils.GetLinkPosition(i, ref boundsCorners);
                    link.transform.parent   = parent;
                    Renderer linkRenderer = link.GetComponent <Renderer>();

                    if (config.WireframeMaterial != null)
                    {
                        linkRenderer.material = config.WireframeMaterial;
                    }

                    link.SetActive(config.ShowWireFrame);
                    links.Add(new Link(link.transform, axisType));
                }
            }
        }
        private Vector3 GetRotationAxis(Transform handle)
        {
            CardinalAxisType axisType = rotationHandles.GetAxisType(handle);

            if (axisType == CardinalAxisType.X)
            {
                return(rigRoot.transform.right);
            }
            else if (axisType == CardinalAxisType.Y)
            {
                return(rigRoot.transform.up);
            }
            else
            {
                return(rigRoot.transform.forward);
            }
        }
        internal override bool IsVisible(Transform handle)
        {
            if (!IsActive)
            {
                return(false);
            }
            else
            {
                CardinalAxisType axisType = GetAxisType(handle);
                switch (axisType)
                {
                case CardinalAxisType.X:
                    return(config.ShowHandleForX);

                case CardinalAxisType.Y:
                    return(config.ShowHandleForY);

                case CardinalAxisType.Z:
                    return(config.ShowHandleForZ);
                }

                return(false);
            }
        }
Exemple #6
0
 public Link(Transform linkTransform, CardinalAxisType linkAxis)
 {
     transform = linkTransform;
     axisType  = linkAxis;
 }