Exemplo n.º 1
0
        public InfluenceVolumeUI()
            : base(k_ShapeCount + k_AnimBoolFields)
        {
            isSectionExpandedShape.value = true;

            boxBaseHandle            = new Gizmo6FacesBox(monochromeFace: true, monochromeSelectedFace: true);
            boxInfluenceHandle       = new Gizmo6FacesBoxContained(boxBaseHandle, monochromeFace: true, monochromeSelectedFace: true);
            boxInfluenceNormalHandle = new Gizmo6FacesBoxContained(boxBaseHandle, monochromeFace: true, monochromeSelectedFace: true);

            Color[] handleColors = new Color[]
            {
                HDReflectionProbeEditor.k_handlesColor[0][0],
                HDReflectionProbeEditor.k_handlesColor[0][1],
                HDReflectionProbeEditor.k_handlesColor[0][2],
                HDReflectionProbeEditor.k_handlesColor[1][0],
                HDReflectionProbeEditor.k_handlesColor[1][1],
                HDReflectionProbeEditor.k_handlesColor[1][2]
            };
            boxBaseHandle.handleColors            = handleColors;
            boxInfluenceHandle.handleColors       = handleColors;
            boxInfluenceNormalHandle.handleColors = handleColors;

            boxBaseHandle.faceColors                    = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
            boxBaseHandle.faceColorsSelected            = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
            boxInfluenceHandle.faceColors               = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
            boxInfluenceHandle.faceColorsSelected       = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
            boxInfluenceNormalHandle.faceColors         = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
            boxInfluenceNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
        }
        public HDReflectionProbeUI()
            : base(k_AnimBoolsCount)
        {
            isSectionExpandedProxyVolume.value     = true;
            isSectionExpandedCaptureSettings.value = true;
            isSectionExpandedInfluenceVolume.value = true;
            isSectionExpandedAdditional.value      = false;

            alternativeBoxInfluenceHandle   = new Gizmo6FacesBox(monochromeFace: true, monochromeSelectedFace: true);
            alternativeBoxBlendHandle       = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace: true, monochromeSelectedFace: true);
            alternativeBoxBlendNormalHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace: true, monochromeSelectedFace: true);

            Color[] handleColors = new Color[]
            {
                HDReflectionProbeEditor.k_handlesColor[0][0],
                HDReflectionProbeEditor.k_handlesColor[0][1],
                HDReflectionProbeEditor.k_handlesColor[0][2],
                HDReflectionProbeEditor.k_handlesColor[1][0],
                HDReflectionProbeEditor.k_handlesColor[1][1],
                HDReflectionProbeEditor.k_handlesColor[1][2]
            };
            alternativeBoxInfluenceHandle.handleColors   = handleColors;
            alternativeBoxBlendHandle.handleColors       = handleColors;
            alternativeBoxBlendNormalHandle.handleColors = handleColors;

            alternativeBoxInfluenceHandle.faceColors           = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
            alternativeBoxInfluenceHandle.faceColorsSelected   = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
            alternativeBoxBlendHandle.faceColors               = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
            alternativeBoxBlendHandle.faceColorsSelected       = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
            alternativeBoxBlendNormalHandle.faceColors         = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
            alternativeBoxBlendNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
        }
Exemplo n.º 3
0
        static void DrawGizmos_FadeHandle(
            InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
            Vector3 boxOffset, Vector3 boxSizeOffset,
            float sphereOffset,
            bool isSolid, Color color, bool isNormal)
        {
            var mat = Gizmos.matrix;
            var c   = Gizmos.color;

            Gizmos.matrix = matrix;
            Gizmos.color  = color;
            switch (d.shapeType)
            {
            case ShapeType.Box:
            {
                Gizmo6FacesBox refBox = isNormal ? s.boxInfluenceNormalHandle : s.boxInfluenceHandle;
                refBox.center = d.boxBaseOffset + boxOffset;
                refBox.size   = d.boxBaseSize + boxSizeOffset;
                refBox.DrawHull(isSolid);
                break;
            }

            case ShapeType.Sphere:
            {
                if (isSolid)
                {
                    Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
                }
                else
                {
                    Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
                }
                break;
            }
            }
            Gizmos.matrix = mat;
            Gizmos.color  = c;
        }
        static void DrawBoxHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box)
        {
            box.center = d.offset.vector3Value;
            box.size   = d.boxSize.vector3Value;

            EditorGUI.BeginChangeCheck();
            box.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Base Volume AABB");

                d.offset.vector3Value = box.center;
                var size = box.size;

                Vector3 blendPositive       = d.boxBlendDistancePositive.vector3Value;
                Vector3 blendNegative       = d.boxBlendDistanceNegative.vector3Value;
                Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
                Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
                for (int i = 0; i < 3; ++i)
                {
                    size[i] = Mathf.Max(0f, size[i]);
                }
                d.boxSize.vector3Value = size;
                Vector3 halfSize = size * .5f;
                for (int i = 0; i < 3; ++i)
                {
                    blendPositive[i]       = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
                    blendNegative[i]       = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
                    blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
                    blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
                }
                d.boxBlendDistancePositive.vector3Value       = blendPositive;
                d.boxBlendDistanceNegative.vector3Value       = blendNegative;
                d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
                d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;

                if (d.editorAdvancedModeEnabled.boolValue)
                {
                    d.editorAdvancedModeBlendDistancePositive.vector3Value       = d.boxBlendDistancePositive.vector3Value;
                    d.editorAdvancedModeBlendDistanceNegative.vector3Value       = d.boxBlendDistanceNegative.vector3Value;
                    d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
                    d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
                }
                else
                {
                    d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(
                        d.boxBlendDistancePositive.vector3Value.x,
                        d.boxBlendDistancePositive.vector3Value.y,
                        d.boxBlendDistancePositive.vector3Value.z,
                        d.boxBlendDistanceNegative.vector3Value.x,
                        d.boxBlendDistanceNegative.vector3Value.y,
                        d.boxBlendDistanceNegative.vector3Value.z);
                    d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
                    d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(
                        d.boxBlendNormalDistancePositive.vector3Value.x,
                        d.boxBlendNormalDistancePositive.vector3Value.y,
                        d.boxBlendNormalDistancePositive.vector3Value.z,
                        d.boxBlendNormalDistanceNegative.vector3Value.x,
                        d.boxBlendNormalDistanceNegative.vector3Value.y,
                        d.boxBlendNormalDistanceNegative.vector3Value.z);
                    d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
                }

                d.Apply();
            }
        }
        static void DrawBoxFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box, SerializedProperty positive, SerializedProperty negative)
        {
            box.center = d.offset.vector3Value - (positive.vector3Value - negative.vector3Value) * 0.5f;
            box.size   = d.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
            box.allHandleControledByOne = !d.editorAdvancedModeEnabled.boolValue;

            EditorGUI.BeginChangeCheck();
            box.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence Volume");

                var influenceCenter   = d.offset.vector3Value;
                var halfInfluenceSize = d.boxSize.vector3Value * .5f;

                var centerDiff            = box.center - influenceCenter;
                var halfSizeDiff          = halfInfluenceSize - box.size * .5f;
                var positiveNew           = halfSizeDiff - centerDiff;
                var negativeNew           = halfSizeDiff + centerDiff;
                var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, halfInfluenceSize));
                var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, halfInfluenceSize));

                positive.vector3Value = blendDistancePositive;
                negative.vector3Value = blendDistanceNegative;

                d.Apply();
            }
        }