public Texture DoRenderPreview(Rect previewRect, GUIStyle background)
{
this.m_PreviewUtility.BeginPreview(previewRect, background);
Vector3 bodyPosition = this.bodyPosition;
Quaternion quaternion;
Vector3 vector;
Quaternion quaternion2;
Vector3 pivotPos;
if (this.Animator && this.Animator.isHuman)
{
quaternion = this.Animator.rootRotation;
vector = this.Animator.rootPosition;
quaternion2 = this.Animator.bodyRotation;
pivotPos = this.Animator.pivotPosition;
}
else
{
if (this.Animator && this.Animator.hasRootMotion)
{
quaternion = this.Animator.rootRotation;
vector = this.Animator.rootPosition;
quaternion2 = Quaternion.identity;
pivotPos = Vector3.zero;
}
else
{
quaternion = Quaternion.identity;
vector = Vector3.zero;
quaternion2 = Quaternion.identity;
pivotPos = Vector3.zero;
}
}
bool oldFog = this.SetupPreviewLightingAndFx();
Vector3 forward = quaternion2 * Vector3.forward;
forward[1] = 0f;
Quaternion directionRot = Quaternion.LookRotation(forward);
Vector3 directionPos = vector;
Quaternion pivotRot = quaternion;
this.PositionPreviewObjects(pivotRot, pivotPos, quaternion2, bodyPosition, directionRot, quaternion, vector, directionPos, this.m_AvatarScale);
bool flag = Mathf.Abs(this.m_NextFloorHeight - this.m_PrevFloorHeight) > this.m_ZoomFactor * 0.01f;
float num2;
float num3;
if (flag)
{
float num = (this.m_NextFloorHeight >= this.m_PrevFloorHeight) ? 0.8f : 0.2f;
num2 = ((this.timeControl.normalizedTime >= num) ? this.m_NextFloorHeight : this.m_PrevFloorHeight);
num3 = Mathf.Clamp01(Mathf.Abs(this.timeControl.normalizedTime - num) / 0.2f);
}
else
{
num2 = this.m_PrevFloorHeight;
num3 = 1f;
}
Quaternion identity = Quaternion.identity;
Vector3 position = new Vector3(0f, 0f, 0f);
position = this.m_ReferenceInstance.transform.position;
position.y = num2;
Matrix4x4 matrix;
RenderTexture renderTexture = this.RenderPreviewShadowmap(this.m_PreviewUtility.m_Light[0], this.m_BoundingVolumeScale / 2f, bodyPosition, position, out matrix);
this.m_PreviewUtility.m_Camera.nearClipPlane = 0.5f * this.m_ZoomFactor;
this.m_PreviewUtility.m_Camera.farClipPlane = 100f * this.m_AvatarScale;
Quaternion rotation = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0f);
Vector3 position2 = rotation * (Vector3.forward * -5.5f * this.m_ZoomFactor) + bodyPosition + this.m_PivotPositionOffset;
this.m_PreviewUtility.m_Camera.transform.position = position2;
this.m_PreviewUtility.m_Camera.transform.rotation = rotation;
position.y = num2;
Material floorMaterial = this.m_FloorMaterial;
Matrix4x4 matrix2 = Matrix4x4.TRS(position, identity, Vector3.one * 5f * this.m_AvatarScale);
floorMaterial.mainTextureOffset = -new Vector2(position.x, position.z) * 5f * 0.08f * (1f / this.m_AvatarScale);
floorMaterial.SetTexture("_ShadowTexture", renderTexture);
floorMaterial.SetMatrix("_ShadowTextureMatrix", matrix);
floorMaterial.SetVector("_Alphas", new Vector4(0.5f * num3, 0.3f * num3, 0f, 0f));
Graphics.DrawMesh(this.m_FloorPlane, matrix2, floorMaterial, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
if (flag)
{
bool flag2 = this.m_NextFloorHeight > this.m_PrevFloorHeight;
float num4 = (!flag2) ? this.m_PrevFloorHeight : this.m_NextFloorHeight;
float from = (!flag2) ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
float num5 = ((num4 != num2) ? 1f : (1f - num3)) * Mathf.InverseLerp(from, num4, vector.y);
position.y = num4;
Material floorMaterialSmall = this.m_FloorMaterialSmall;
floorMaterialSmall.mainTextureOffset = -new Vector2(position.x, position.z) * 0.2f * 0.08f;
floorMaterialSmall.SetTexture("_ShadowTexture", renderTexture);
floorMaterialSmall.SetMatrix("_ShadowTextureMatrix", matrix);
floorMaterialSmall.SetVector("_Alphas", new Vector4(0.5f * num5, 0f, 0f, 0f));
Matrix4x4 matrix3 = Matrix4x4.TRS(position, identity, Vector3.one * 0.2f * this.m_AvatarScale);
Graphics.DrawMesh(this.m_FloorPlane, matrix3, 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);
AvatarPreview.TeardownPreviewLightingAndFx(oldFog);
RenderTexture.ReleaseTemporary(renderTexture);
return(this.m_PreviewUtility.EndPreview());
}