コード例 #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));
        }
コード例 #2
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);
        }
コード例 #3
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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #6
0
        /// <summary>
        /// Unregisters a volume from the manager
        /// </summary>
        /// <param name="volume">The volume to remove</param>
        public void Unregister(AuraVolume volume)
        {
            _culler.Unregister(volume);

            if (_registredVolumes.Contains(volume))
            {
                _registredVolumes.Remove(volume);

                volume.OnTextureMaskStateChanged -= Volume_onTextureMaskStateChanged;
                volume.OnTextureMaskChanged      -= Volume_onTextureMaskChanged;
            }
        }
コード例 #7
0
        /// <summary>
        /// Registers a new volume to the manager
        /// </summary>
        /// <param name="volume">The volume to add</param>
        public void Register(AuraVolume volume)
        {
            _culler.Register(volume);

            if (!_registredVolumes.Contains(volume))
            {
                _registredVolumes.Add(volume);

                volume.OnTextureMaskStateChanged += Volume_onTextureMaskStateChanged;
                volume.OnTextureMaskChanged      += Volume_onTextureMaskChanged;
            }
        }
コード例 #8
0
        static void DrawGizmoForAuraVolume(AuraVolume component, GizmoType gizmoType)
        {
            bool  isFaded = (int)gizmoType == (int)GizmoType.NonSelected || (int)gizmoType == (int)GizmoType.NotInSelectionHierarchy || (int)gizmoType == (int)GizmoType.NonSelected + (int)GizmoType.NotInSelectionHierarchy;
            float opacity = isFaded ? 0.5f : 1.0f;

            // Draws the gizmo only if depth > pixel's
            Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;
            DrawGizmo(component, opacity * 0.25f);

            // Then draws the gizmo only if depth <= pixel's
            Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
            DrawGizmo(component, opacity);
        }
コード例 #9
0
ファイル: AuraVolume.cs プロジェクト: Dod8431/SMTW_PC_VERSION
        static void DrawGizmoForAuraVolume(AuraVolume component, GizmoType gizmoType)
        {
            bool  isFaded = (int)gizmoType == (int)GizmoType.NonSelected || (int)gizmoType == (int)GizmoType.NotInSelectionHierarchy || (int)gizmoType == (int)GizmoType.NonSelected + (int)GizmoType.NotInSelectionHierarchy;
            float opacity = isFaded ? 0.25f : 1.0f;

            switch (component.volumeShape.shape)
            {
            case VolumeTypeEnum.Global:
            {
                DrawGlobal(component, opacity);
            }
            break;

            case VolumeTypeEnum.Planar:
            {
                DrawPlanar(component, opacity);
            }
            break;

            case VolumeTypeEnum.Box:
            {
                DrawBox(component, opacity);
            }
            break;

            case VolumeTypeEnum.Sphere:
            {
                DrawSphere(component, opacity);
            }
            break;

            case VolumeTypeEnum.Cylinder:
            {
                DrawCylinder(component, opacity);
            }
            break;

            case VolumeTypeEnum.Cone:
            {
                DrawCone(component, opacity);
            }
            break;
            }
        }
コード例 #10
0
        /// <summary>
        /// Draws the gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="opacity">The gizmo opacity</param>
        private static void DrawGizmo(AuraVolume component, float opacity)
        {
            switch (component.volumeShape.shape)
            {
            case VolumeTypeEnum.Global:
            {
                DrawGlobal(component, opacity);
            }
            break;

            case VolumeTypeEnum.Planar:
            {
                DrawPlanar(component, opacity);
            }
            break;

            case VolumeTypeEnum.Box:
            {
                DrawBox(component, opacity);
            }
            break;

            case VolumeTypeEnum.Sphere:
            {
                DrawSphere(component, opacity);
            }
            break;

            case VolumeTypeEnum.Cylinder:
            {
                DrawCylinder(component, opacity);
            }
            break;

            case VolumeTypeEnum.Cone:
            {
                DrawCone(component, opacity);
            }
            break;
            }
        }
コード例 #11
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));
            }
        }
コード例 #12
0
 /// <summary>
 /// Called when a volume has changes on its texture mask texture
 /// </summary>
 /// <param name="volume">The volume in which the texture mask texture has changed</param>
 private void Volume_onTextureMaskChanged(AuraVolume volume)
 {
     ResetCandidateTexturesAndGenerateVolumeTexture();
 }