Example #1
0
        /// <summary>
        /// Draws a "Cone" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawCone(AuraVolume component, float alpha)
        {
            float fadeFactor = GetFadeFactor(0);
            Color color      = component.gizmoColor;

            color.r *= fadeFactor;
            color.g *= fadeFactor;
            color.b *= fadeFactor;
            color.a *= alpha;
            CustomGizmo.DrawCone(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            fadeFactor = GetFadeFactor(0.5f);
            color      = component.gizmoColor;
            color.r   *= fadeFactor;
            color.g   *= fadeFactor;
            color.b   *= fadeFactor;
            color.a   *= alpha;
            float z  = 1.0f - component.volumeShape.fading.distanceConeFade;
            float xy = Mathf.Lerp(0, 1.0f - component.volumeShape.fading.angularConeFade, z);

            CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, 1), new Vector3(0, xy * 0.5f, z), component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, 1), new Vector3(0, -xy * 0.5f, z), component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.5f, 0.0f, 1), new Vector3(xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(-0.5f, 0.0f, 1), new Vector3(-xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            color    = component.gizmoColor;
            color.a *= alpha;
            CustomGizmo.DrawCone(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, new Vector3(xy, xy, z), color, GetThickness(component.transform.position));
        }
Example #2
0
        /// <summary>
        /// Draws a "Cylinder" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawCylinder(AuraVolume component, float alpha)
        {
            float fadeFactor = GetFadeFactor(0);
            Color color      = component.gizmoColor;

            color.r *= fadeFactor;
            color.g *= fadeFactor;
            color.b *= fadeFactor;
            color.a *= alpha;
            CustomGizmo.DrawCylinder(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            fadeFactor = GetFadeFactor(0.5f);
            color      = component.gizmoColor;
            color.r   *= fadeFactor;
            color.g   *= fadeFactor;
            color.b   *= fadeFactor;
            color.a   *= alpha;
            float x    = 1.0f - component.volumeShape.fading.widthCylinderFade;
            float yPos = (1.0f - component.volumeShape.fading.yPositiveCylinderFade) * 2 - 1;
            float yNeg = component.volumeShape.fading.yNegativeCylinderFade * 2 - 1;

            CustomGizmo.DrawLineSegment(new Vector3(0.5f, 0.5f, 0), new Vector3(x, yPos, 0) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(-0.5f, 0.5f, 0), new Vector3(-x, yPos, 0) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.5f, -0.5f, 0), new Vector3(x, yNeg, 0) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(-0.5f, -0.5f, 0), new Vector3(-x, yNeg, 0) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, 0.5f), new Vector3(0, yPos, x) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, -0.5f), new Vector3(0, yPos, -x) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, 0.5f), new Vector3(0, yNeg, x) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, -0.5f), new Vector3(0, yNeg, -x) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            color    = component.gizmoColor;
            color.a *= alpha;
            CustomGizmo.DrawCylinder(component.transform.localToWorldMatrix, (Vector3.up * ((1.0f - component.volumeShape.fading.yPositiveCylinderFade) + component.volumeShape.fading.yNegativeCylinderFade) * 0.5f) - Vector3.up * 0.5f, Quaternion.identity, new Vector3(x, 1.0f - component.volumeShape.fading.yPositiveCylinderFade - component.volumeShape.fading.yNegativeCylinderFade, x), color, GetThickness(component.transform.position));
        }
Example #3
0
        /// <summary>
        /// Draws a "Sphere" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawSphere(AuraVolume component, float alpha)
        {
            float fadeFactor = GetFadeFactor(0);
            Color color      = component.gizmoColor;

            color.r *= fadeFactor;
            color.g *= fadeFactor;
            color.b *= fadeFactor;
            color.a *= alpha;
            CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position) * 0.6666666666666f);

            fadeFactor = GetFadeFactor(0.5f);
            color      = component.gizmoColor;
            color.r   *= fadeFactor;
            color.g   *= fadeFactor;
            color.b   *= fadeFactor;
            color.a   *= alpha;
            float x = 1.0f - component.volumeShape.fading.distanceSphereFade;

            CustomGizmo.DrawLineSegment(Vector3.up * 0.5f, Vector3.up * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(Vector3.down * 0.5f, Vector3.down * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(Vector3.left * 0.5f, Vector3.left * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(Vector3.right * 0.5f, Vector3.right * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(Vector3.back * 0.5f, Vector3.back * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(Vector3.forward * 0.5f, Vector3.forward * x * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            color    = component.gizmoColor;
            color.a *= alpha;
            CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, Vector3.one * x, color, GetThickness(component.transform.position) * 0.6666666666666f);
        }
Example #4
0
        /// <summary>
        /// Draws a "Global" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawGlobal(AuraVolume component, float alpha)
        {
            Color color = component.gizmoColor;

            color.a = component.gizmoColor.a * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 0.25f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.9f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.8f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 2.25f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.7f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 4.0f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.6f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 6.25f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.5f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 9.0f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.4f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 12.25f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.3f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 16.0f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.2f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 20.25f), color, GetThickness(component.transform.position));
            color.a = component.gizmoColor.a * 0.1f * alpha;
            CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * 25.0f), color, GetThickness(component.transform.position));
        }
Example #5
0
        /// <summary>
        /// Draws a "Box" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawBox(AuraVolume component, float alpha)
        {
            float fadeFactor = GetFadeFactor(0);
            Color color      = component.gizmoColor;

            color.r *= fadeFactor;
            color.g *= fadeFactor;
            color.b *= fadeFactor;
            color.a *= alpha;
            CustomGizmo.DrawCube(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            fadeFactor = GetFadeFactor(0.5f);
            color      = component.gizmoColor;
            color.r   *= fadeFactor;
            color.g   *= fadeFactor;
            color.b   *= fadeFactor;
            color.a   *= alpha;
            float xPos = (1.0f - component.volumeShape.fading.xPositiveCubeFade) * 2 - 1;
            float xNeg = component.volumeShape.fading.xNegativeCubeFade * 2 - 1;
            float yPos = (1.0f - component.volumeShape.fading.yPositiveCubeFade) * 2 - 1;
            float yNeg = component.volumeShape.fading.yNegativeCubeFade * 2 - 1;
            float zPos = (1.0f - component.volumeShape.fading.zPositiveCubeFade) * 2 - 1;
            float zNeg = component.volumeShape.fading.zNegativeCubeFade * 2 - 1;

            Vector3 customPointA = new Vector3(xNeg, yPos, zNeg) * 0.5f;
            Vector3 customPointB = new Vector3(xPos, yPos, zNeg) * 0.5f;
            Vector3 customPointC = new Vector3(xPos, yNeg, zNeg) * 0.5f;
            Vector3 customPointD = new Vector3(xNeg, yNeg, zNeg) * 0.5f;
            Vector3 customPointE = new Vector3(xNeg, yPos, zPos) * 0.5f;
            Vector3 customPointF = new Vector3(xPos, yPos, zPos) * 0.5f;
            Vector3 customPointG = new Vector3(xPos, yNeg, zPos) * 0.5f;
            Vector3 customPointH = new Vector3(xNeg, yNeg, zPos) * 0.5f;

            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerA, new Vector3(xNeg, yPos, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerB, new Vector3(xPos, yPos, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerC, new Vector3(xPos, yNeg, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerD, new Vector3(xNeg, yNeg, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerE, new Vector3(xNeg, yPos, zPos) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerF, new Vector3(xPos, yPos, zPos) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerG, new Vector3(xPos, yNeg, zPos) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerH, new Vector3(xNeg, yNeg, zPos) * 0.5f, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            CustomGizmo.DrawLineSegment(customPointA, customPointB, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointB, customPointC, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointC, customPointD, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointD, customPointA, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointE, customPointF, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            CustomGizmo.DrawLineSegment(customPointF, customPointG, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointG, customPointH, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointH, customPointE, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointE, customPointF, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            CustomGizmo.DrawLineSegment(customPointA, customPointE, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointB, customPointF, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointC, customPointG, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
            CustomGizmo.DrawLineSegment(customPointD, customPointH, component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));
        }
Example #6
0
        /// <summary>
        /// Draws a "Planar" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawPlanar(AuraVolume component, float alpha)
        {
            float y = component.volumeShape.fading.heightPlaneFade;

            Color color = component.gizmoColor;

            color.a *= alpha;

            CustomGizmo.DrawSquare(component.transform.localToWorldMatrix, color, GetThickness(component.transform.position));

            int count = 10;

            for (int i = 0; i < count; ++i)
            {
                float scaledFactor = i * 1.0f / (float)count;
                float fadeFactor   = GetFadeFactor(scaledFactor);
                color    = component.gizmoColor;
                color.r *= fadeFactor;
                color.g *= fadeFactor;
                color.b *= fadeFactor;
                color.a *= alpha;
                CustomGizmo.DrawSquare(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.up * y * (1.0f - scaledFactor), Quaternion.identity, Vector3.one), color, GetThickness(component.transform.position));
            }
        }