Ejemplo n.º 1
0
        private int Hit(Vector2 pointer, Vector3[] vertices, Vector3[] normals)
        {
            float minMag = float.MaxValue;
            int   index  = -1;

            for (int i = 0; i < vertices.Length; ++i)
            {
                Vector3 normal = normals[i];
                normal = HandlesTransform.MultiplyVector(normal);
                Vector3 vertex      = vertices[i];
                Vector3 vertexWorld = HandlesTransform.MultiplyPoint(vertices[i]);

                if (Mathf.Abs(Vector3.Dot((SceneCamera.transform.position - vertexWorld).normalized, normal.normalized)) > 0.999f)
                {
                    continue;
                }

                if (!HitOverride(i, vertex, normal))
                {
                    continue;
                }

                Vector2 vertexScreen = SceneCamera.WorldToScreenPoint(vertexWorld);
                float   distance     = (vertexScreen - pointer).magnitude;
                if (distance < minMag && distance <= SelectionMargin)
                {
                    minMag = distance;
                    index  = i;
                }
            }

            return(index);
        }
Ejemplo n.º 2
0
        protected Plane GetDragPlane()
        {
            Vector3 toCam           = SceneCamera.transform.position - HandlesTransform.MultiplyPoint(HandlesPositions[m_dragIndex]); // SceneCamera.cameraToWorldMatrix.MultiplyVector(Vector3.forward);
            Vector3 dragPlaneVector = toCam.normalized;

            Vector3 position = m_handlesTransform.MultiplyPoint(Vector3.zero);

            Plane dragPlane = new Plane(dragPlaneVector, position);

            return(dragPlane);
        }
Ejemplo n.º 3
0
        protected override void OnCommandBufferRefresh(IRTECamera camera)
        {
            base.OnCommandBufferRefresh(camera);
            if (Target == null)
            {
                return;
            }

            Vector3 scale = Target.lossyScale * Radius;

            scale = Vector3.one * Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z));

            GizmoUtility.DrawCubeHandles(camera.CommandBuffer, Target.TransformPoint(Center), Target.rotation, scale, HandleProperties);
            GizmoUtility.DrawWireSphere(camera.CommandBuffer, camera.Camera, Target.TransformPoint(Center), Target.rotation, scale, LineProperties);

            if (IsDragging)
            {
                scale = Target.lossyScale;
                scale = Vector3.one * Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z));

                GizmoUtility.DrawSelection(camera.CommandBuffer, HandlesTransform.MultiplyPoint(Center + HandlesPositions[DragIndex]), Target.rotation, scale, SelectionProperties);
            }
        }
Ejemplo n.º 4
0
        protected override void DrawOverride(Camera camera)
        {
            base.DrawOverride(camera);

            if (Target == null)
            {
                return;
            }

            Vector3 scale = Target.lossyScale * Radius;

            scale = Vector3.one * Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z));

            RuntimeGizmos.DrawCubeHandles(Target.TransformPoint(Center), Target.rotation, scale, HandlesColor);
            RuntimeGizmos.DrawWireSphereGL(camera, Target.TransformPoint(Center), Target.rotation, scale, LineColor);

            if (IsDragging)
            {
                scale = Target.lossyScale;
                scale = Vector3.one * Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z));
                RuntimeGizmos.DrawSelection(HandlesTransform.MultiplyPoint(Center + HandlesPositions[DragIndex]), Target.rotation, scale, SelectionColor);
            }
        }