UnityEditor.AvatarPreview.DoRenderPreview C# (CSharp) Méthode

DoRenderPreview() public méthode

public DoRenderPreview ( Rect previewRect, GUIStyle background ) : void
previewRect UnityEngine.Rect
background UnityEngine.GUIStyle
Résultat void
        public void DoRenderPreview(Rect previewRect, GUIStyle background)
        {
            Quaternion bodyRotation;
            Quaternion rootRotation;
            Vector3 rootPosition;
            Vector3 pivotPosition;
            float prevFloorHeight;
            float num2;
            Matrix4x4 matrixx;
            this.m_PreviewUtility.BeginPreview(previewRect, background);
            Vector3 bodyPosition = this.bodyPosition;
            if ((this.Animator != null) && this.Animator.isHuman)
            {
                rootRotation = this.Animator.rootRotation;
                rootPosition = this.Animator.rootPosition;
                bodyRotation = this.Animator.bodyRotation;
                pivotPosition = this.Animator.pivotPosition;
            }
            else if ((this.Animator != null) && this.Animator.hasRootMotion)
            {
                rootRotation = this.Animator.rootRotation;
                rootPosition = this.Animator.rootPosition;
                bodyRotation = Quaternion.identity;
                pivotPosition = Vector3.zero;
            }
            else
            {
                rootRotation = Quaternion.identity;
                rootPosition = Vector3.zero;
                bodyRotation = Quaternion.identity;
                pivotPosition = Vector3.zero;
            }
            bool oldFog = this.SetupPreviewLightingAndFx();
            Vector3 forward = (Vector3) (bodyRotation * Vector3.forward);
            forward[1] = 0f;
            Quaternion directionRot = Quaternion.LookRotation(forward);
            Vector3 directionPos = rootPosition;
            Quaternion pivotRot = rootRotation;
            this.PositionPreviewObjects(pivotRot, pivotPosition, bodyRotation, bodyPosition, directionRot, rootRotation, rootPosition, directionPos, this.m_AvatarScale);
            bool flag2 = Mathf.Abs((float) (this.m_NextFloorHeight - this.m_PrevFloorHeight)) > (this.m_ZoomFactor * 0.01f);
            if (flag2)
            {
                float num3 = (this.m_NextFloorHeight >= this.m_PrevFloorHeight) ? 0.8f : 0.2f;
                prevFloorHeight = (this.timeControl.normalizedTime >= num3) ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                num2 = Mathf.Clamp01(Mathf.Abs((float) (this.timeControl.normalizedTime - num3)) / 0.2f);
            }
            else
            {
                prevFloorHeight = this.m_PrevFloorHeight;
                num2 = 1f;
            }
            Quaternion identity = Quaternion.identity;
            Vector3 floorPos = new Vector3(0f, 0f, 0f);
            floorPos = this.m_ReferenceInstance.transform.position;
            floorPos.y = prevFloorHeight;
            RenderTexture texture = this.RenderPreviewShadowmap(this.m_PreviewUtility.m_Light[0], this.m_BoundingVolumeScale / 2f, bodyPosition, floorPos, out matrixx);
            this.m_PreviewUtility.m_Camera.nearClipPlane = 0.5f * this.m_ZoomFactor;
            this.m_PreviewUtility.m_Camera.farClipPlane = 100f * this.m_AvatarScale;
            Quaternion quaternion6 = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0f);
            Vector3 vector7 = (((Vector3) (quaternion6 * ((Vector3.forward * -5.5f) * this.m_ZoomFactor))) + bodyPosition) + this.m_PivotPositionOffset;
            this.m_PreviewUtility.m_Camera.transform.position = vector7;
            this.m_PreviewUtility.m_Camera.transform.rotation = quaternion6;
            floorPos.y = prevFloorHeight;
            Material floorMaterial = this.m_FloorMaterial;
            Matrix4x4 matrix = Matrix4x4.TRS(floorPos, identity, (Vector3) ((Vector3.one * 5f) * this.m_AvatarScale));
            floorMaterial.mainTextureOffset = (Vector2) (((-new Vector2(floorPos.x, floorPos.z) * 5f) * 0.08f) * (1f / this.m_AvatarScale));
            floorMaterial.SetTexture("_ShadowTexture", texture);
            floorMaterial.SetMatrix("_ShadowTextureMatrix", matrixx);
            floorMaterial.SetVector("_Alphas", new Vector4(0.5f * num2, 0.3f * num2, 0f, 0f));
            Graphics.DrawMesh(this.m_FloorPlane, matrix, floorMaterial, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            if (flag2)
            {
                bool flag3 = this.m_NextFloorHeight > this.m_PrevFloorHeight;
                float b = !flag3 ? this.m_PrevFloorHeight : this.m_NextFloorHeight;
                float a = !flag3 ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                float num6 = ((b != prevFloorHeight) ? 1f : (1f - num2)) * Mathf.InverseLerp(a, b, rootPosition.y);
                floorPos.y = b;
                Material floorMaterialSmall = this.m_FloorMaterialSmall;
                floorMaterialSmall.mainTextureOffset = (Vector2) ((-new Vector2(floorPos.x, floorPos.z) * 0.2f) * 0.08f);
                floorMaterialSmall.SetTexture("_ShadowTexture", texture);
                floorMaterialSmall.SetMatrix("_ShadowTextureMatrix", matrixx);
                floorMaterialSmall.SetVector("_Alphas", new Vector4(0.5f * num6, 0f, 0f, 0f));
                Matrix4x4 matrixx3 = Matrix4x4.TRS(floorPos, identity, (Vector3) ((Vector3.one * 0.2f) * this.m_AvatarScale));
                Graphics.DrawMesh(this.m_FloorPlane, matrixx3, floorMaterialSmall, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            }
            this.SetPreviewCharacterEnabled(true, this.m_ShowReference);
            this.m_PreviewUtility.m_Camera.Render();
            this.SetPreviewCharacterEnabled(false, false);
            TeardownPreviewLightingAndFx(oldFog);
            RenderTexture.ReleaseTemporary(texture);
        }