protected override void LoadContent() { base.LoadContent(); this.shadowEffect = new CloudShadowEffect(); this.shadowMesh = new Mesh() { DepthWrites = false, AlwaysOnTop = true, SamplerState = SamplerState.LinearWrap }; foreach (FaceOrientation faceOrientation in Util.GetValues <FaceOrientation>()) { if (FezMath.IsSide(faceOrientation)) { this.axisPerGroup.Add(this.shadowMesh.AddFace(Vector3.One, Vector3.Zero, faceOrientation, true), FezMath.AsAxis(faceOrientation) == Axis.X ? Axis.Z : Axis.X); } } this.shadowMesh.Effect = (BaseEffect)this.shadowEffect; this.LevelManager.SkyChanged += new Action(this.InitializeShadows); this.InitializeShadows(); this.LightingPostProcess.DrawOnTopLights += new Action(this.DrawLights); }
private void BuildMesh() { Vector3 a = (this.Volume.To - this.Volume.From) / 2f; float num1 = a.Y * 2f; Mesh mesh1 = new Mesh(); Mesh mesh2 = new Mesh(); FaceOrientation[] faceOrientationArray = new FaceOrientation[4] { FaceOrientation.Front, FaceOrientation.Right, FaceOrientation.Back, FaceOrientation.Left }; foreach (FaceOrientation faceOrientation in faceOrientationArray) { Vector3 vector3_1 = FezMath.AsVector(FezMath.IsSide(FezMath.GetTangent(faceOrientation)) ? FezMath.GetTangent(faceOrientation) : FezMath.GetBitangent(faceOrientation)); Vector3 origin = this.Center + FezMath.AsVector(faceOrientation) * a; float num2 = Math.Abs(FezMath.Dot(a, vector3_1)) * 2f; Vector3 vector3_2 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY); Vector3 vector3_3 = origin + (a - new Vector3(0.5f)) * (-vector3_1 + Vector3.UnitY); for (int index = 0; (double)index < (double)num2; ++index) { Vector3 p = vector3_2 + (float)index * vector3_1; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } p = vector3_3 + (float)index * vector3_1; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } } Vector3 vector3_4 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY); Vector3 vector3_5 = origin + (a - new Vector3(0.5f)) * (vector3_1 - Vector3.UnitY); for (int index = 0; (double)index < (double)num1; ++index) { Vector3 p = vector3_4 + (float)index * Vector3.UnitY; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } p = vector3_5 + (float)index * Vector3.UnitY; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } } mesh2.AddFace(num2 * FezMath.Abs(vector3_1) + num1 * Vector3.UnitY, origin, faceOrientation, Color.White, true); } foreach (Group group in mesh1.Groups) { group.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f)); } mesh2.Collapse <VertexPositionNormalColor>(); IndexedUserPrimitives <VertexPositionNormalColor> indexedUserPrimitives1 = mesh2.FirstGroup.Geometry as IndexedUserPrimitives <VertexPositionNormalColor>; mesh1.CollapseWithNormalTexture <FezVertexPositionNormalTexture>(); IndexedUserPrimitives <FezVertexPositionNormalTexture> indexedUserPrimitives2 = mesh1.FirstGroup.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>; this.instanceIndex = this.Host.HolesBodyMesh.Groups.Count; this.Host.HolesBodyMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionInstance>(Enumerable.ToArray <VertexPositionInstance>(Enumerable.Select <VertexPositionNormalColor, VertexPositionInstance>((IEnumerable <VertexPositionNormalColor>)indexedUserPrimitives1.Vertices, (Func <VertexPositionNormalColor, VertexPositionInstance>)(x => new VertexPositionInstance(x.Position) { InstanceIndex = (float)this.instanceIndex }))), indexedUserPrimitives1.Indices, PrimitiveType.TriangleList); this.Host.HolesFringeMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTextureInstance>(Enumerable.ToArray <VertexPositionTextureInstance>(Enumerable.Select <FezVertexPositionNormalTexture, VertexPositionTextureInstance>((IEnumerable <FezVertexPositionNormalTexture>)indexedUserPrimitives2.Vertices, (Func <FezVertexPositionNormalTexture, VertexPositionTextureInstance>)(x => new VertexPositionTextureInstance(x.Position, x.TextureCoordinate) { InstanceIndex = (float)this.instanceIndex }))), indexedUserPrimitives2.Indices, PrimitiveType.TriangleList); }