protected override void Dispose(bool disposing) { base.Dispose(disposing); this.TargetRenderer.ReturnTarget(this.RtHandle); this.RtHandle = (RenderTargetHandle)null; this.CloneMesh.Dispose(); this.DotMesh.Dispose(); this.CloneMesh = this.DotMesh = (Mesh)null; this.VignetteEffect.Dispose(); this.VignetteEffect = (VignetteEffect)null; this.ScanlineEffect.Dispose(); this.ScanlineEffect = (ScanlineEffect)null; this.DotEffect = (InstancedDotEffect)null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); this.TargetRenderer.ReturnTarget(this.RtHandle); this.RtHandle = (RenderTargetHandle) null; this.CloneMesh.Dispose(); this.DotMesh.Dispose(); this.CloneMesh = this.DotMesh = (Mesh) null; this.VignetteEffect.Dispose(); this.VignetteEffect = (VignetteEffect) null; this.ScanlineEffect.Dispose(); this.ScanlineEffect = (ScanlineEffect) null; this.DotEffect = (InstancedDotEffect) null; }
private void MakeDot() { this.CloneMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), DepthWrites = false, Culling = CullMode.None, AlwaysOnTop = true, SamplerState = SamplerState.PointWrap }; for (int index1 = -10; index1 <= 10; ++index1) { for (int index2 = -10; index2 <= 10; ++index2) this.CloneMesh.AddFace(new Vector3(600f, 337.5f, 1f), Vector3.Zero, FaceOrientation.Front, true).Position = new Vector3((float) (index2 * 575), (float) ((double) (index1 * 575) / 16.0 * 9.0), 0.0f); } this.CloneMesh.CollapseToBuffer<FezVertexPositionNormalTexture>(); this.DotMesh = new Mesh() { Effect = (BaseEffect) (this.DotEffect = new InstancedDotEffect()), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false, Culling = CullMode.None, AlwaysOnTop = true, Material = { Opacity = 0.4f } }; Group group = this.DotMesh.AddGroup(); ShaderInstancedIndexedPrimitives<VertexPosition4ColorInstance, Vector4> indexedPrimitives = new ShaderInstancedIndexedPrimitives<VertexPosition4ColorInstance, Vector4>(PrimitiveType.TriangleList, 100); group.Geometry = (IIndexedPrimitiveCollection) indexedPrimitives; List<Vector4> list = new List<Vector4>() { new Vector4(-1f, -1f, -1f, -1f), new Vector4(1f, -1f, -1f, -1f), new Vector4(-1f, 1f, -1f, -1f), new Vector4(1f, 1f, -1f, -1f), new Vector4(-1f, -1f, 1f, -1f), new Vector4(1f, -1f, 1f, -1f), new Vector4(-1f, 1f, 1f, -1f), new Vector4(1f, 1f, 1f, -1f), new Vector4(-1f, -1f, -1f, 1f), new Vector4(1f, -1f, -1f, 1f), new Vector4(-1f, 1f, -1f, 1f), new Vector4(1f, 1f, -1f, 1f), new Vector4(-1f, -1f, 1f, 1f), new Vector4(1f, -1f, 1f, 1f), new Vector4(-1f, 1f, 1f, 1f), new Vector4(1f, 1f, 1f, 1f) }; int[] numArray = new int[96] { 0, 2, 3, 1, 1, 3, 7, 5, 5, 7, 6, 4, 4, 6, 2, 0, 0, 4, 5, 1, 2, 6, 7, 3, 8, 10, 11, 9, 9, 11, 15, 13, 13, 15, 14, 12, 12, 14, 10, 8, 8, 12, 13, 9, 10, 14, 15, 11, 0, 1, 9, 8, 0, 2, 10, 8, 2, 3, 11, 10, 3, 1, 9, 11, 4, 5, 13, 12, 6, 7, 15, 14, 4, 6, 14, 12, 5, 7, 15, 13, 4, 0, 8, 12, 6, 2, 10, 14, 3, 7, 15, 11, 1, 5, 13, 9 }; indexedPrimitives.Vertices = new VertexPosition4ColorInstance[96]; for (int index1 = 0; index1 < 4; ++index1) { for (int index2 = 0; index2 < 6; ++index2) { Vector3 vector3 = Vector3.Zero; switch ((index2 + index1 * 6) % 6) { case 0: vector3 = new Vector3(0.0f, 1f, 0.75f); break; case 1: vector3 = new Vector3(0.1666667f, 1f, 0.75f); break; case 2: vector3 = new Vector3(0.3333333f, 1f, 0.75f); break; case 3: vector3 = new Vector3(0.5f, 1f, 0.75f); break; case 4: vector3 = new Vector3(0.6666667f, 1f, 0.75f); break; case 5: vector3 = new Vector3(0.8333333f, 1f, 0.75f); break; } for (int index3 = 0; index3 < 4; ++index3) { int index4 = index3 + index2 * 4 + index1 * 24; indexedPrimitives.Vertices[index4].Color = new Color(vector3.X, vector3.Y, vector3.Z); indexedPrimitives.Vertices[index4].Position = list[numArray[index4]]; } } } indexedPrimitives.Indices = new int[144] { 0, 2, 1, 0, 3, 2, 4, 6, 5, 4, 7, 6, 8, 10, 9, 8, 11, 10, 12, 14, 13, 12, 15, 14, 16, 17, 18, 16, 18, 19, 20, 22, 21, 20, 23, 22, 24, 26, 25, 24, 27, 26, 28, 30, 29, 28, 31, 30, 32, 34, 33, 32, 35, 34, 36, 38, 37, 36, 39, 38, 40, 41, 42, 40, 42, 43, 44, 46, 45, 44, 47, 46, 48, 50, 49, 48, 51, 50, 52, 54, 53, 52, 55, 54, 56, 58, 57, 56, 59, 58, 60, 62, 61, 60, 63, 62, 64, 65, 66, 64, 66, 67, 68, 70, 69, 68, 71, 70, 72, 74, 73, 72, 75, 74, 76, 78, 77, 76, 79, 78, 80, 82, 81, 80, 83, 82, 84, 86, 85, 84, 87, 86, 88, 89, 90, 88, 90, 91, 92, 94, 93, 92, 95, 94 }; int num1 = (int) Math.Floor(96.0); int length = 54 * num1; indexedPrimitives.Instances = new Vector4[length]; int num2 = (int) Math.Floor(27.0); int num3 = (int) Math.Floor((double) num1 / 2.0); Random random = RandomHelper.Random; for (int index1 = -num2; index1 < num2; ++index1) { for (int index2 = -num3; index2 < num3; ++index2) { int index3 = (index1 + num2) * num1 + (index2 + num3); indexedPrimitives.Instances[index3] = new Vector4((float) (index2 * 6), (float) (index1 * 6 + (Math.Abs(index2) % 2 == 0 ? 0 : 3)), 0.0f, index2 != 0 || index1 != 0 ? (float) (random.NextDouble() * 3.14159274101257 * 2.0) : 0.0f); } } indexedPrimitives.InstanceCount = length; indexedPrimitives.UpdateBuffers(); }
private void MakeDot() { this.CloneMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), DepthWrites = false, Culling = CullMode.None, AlwaysOnTop = true, SamplerState = SamplerState.PointWrap }; for (int index1 = -10; index1 <= 10; ++index1) { for (int index2 = -10; index2 <= 10; ++index2) { this.CloneMesh.AddFace(new Vector3(600f, 337.5f, 1f), Vector3.Zero, FaceOrientation.Front, true).Position = new Vector3((float)(index2 * 575), (float)((double)(index1 * 575) / 16.0 * 9.0), 0.0f); } } this.CloneMesh.CollapseToBuffer <FezVertexPositionNormalTexture>(); this.DotMesh = new Mesh() { Effect = (BaseEffect)(this.DotEffect = new InstancedDotEffect()), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false, Culling = CullMode.None, AlwaysOnTop = true, Material = { Opacity = 0.4f } }; Group group = this.DotMesh.AddGroup(); ShaderInstancedIndexedPrimitives <VertexPosition4ColorInstance, Vector4> indexedPrimitives = new ShaderInstancedIndexedPrimitives <VertexPosition4ColorInstance, Vector4>(PrimitiveType.TriangleList, 100); group.Geometry = (IIndexedPrimitiveCollection)indexedPrimitives; List <Vector4> list = new List <Vector4>() { new Vector4(-1f, -1f, -1f, -1f), new Vector4(1f, -1f, -1f, -1f), new Vector4(-1f, 1f, -1f, -1f), new Vector4(1f, 1f, -1f, -1f), new Vector4(-1f, -1f, 1f, -1f), new Vector4(1f, -1f, 1f, -1f), new Vector4(-1f, 1f, 1f, -1f), new Vector4(1f, 1f, 1f, -1f), new Vector4(-1f, -1f, -1f, 1f), new Vector4(1f, -1f, -1f, 1f), new Vector4(-1f, 1f, -1f, 1f), new Vector4(1f, 1f, -1f, 1f), new Vector4(-1f, -1f, 1f, 1f), new Vector4(1f, -1f, 1f, 1f), new Vector4(-1f, 1f, 1f, 1f), new Vector4(1f, 1f, 1f, 1f) }; int[] numArray = new int[96] { 0, 2, 3, 1, 1, 3, 7, 5, 5, 7, 6, 4, 4, 6, 2, 0, 0, 4, 5, 1, 2, 6, 7, 3, 8, 10, 11, 9, 9, 11, 15, 13, 13, 15, 14, 12, 12, 14, 10, 8, 8, 12, 13, 9, 10, 14, 15, 11, 0, 1, 9, 8, 0, 2, 10, 8, 2, 3, 11, 10, 3, 1, 9, 11, 4, 5, 13, 12, 6, 7, 15, 14, 4, 6, 14, 12, 5, 7, 15, 13, 4, 0, 8, 12, 6, 2, 10, 14, 3, 7, 15, 11, 1, 5, 13, 9 }; indexedPrimitives.Vertices = new VertexPosition4ColorInstance[96]; for (int index1 = 0; index1 < 4; ++index1) { for (int index2 = 0; index2 < 6; ++index2) { Vector3 vector3 = Vector3.Zero; switch ((index2 + index1 * 6) % 6) { case 0: vector3 = new Vector3(0.0f, 1f, 0.75f); break; case 1: vector3 = new Vector3(0.1666667f, 1f, 0.75f); break; case 2: vector3 = new Vector3(0.3333333f, 1f, 0.75f); break; case 3: vector3 = new Vector3(0.5f, 1f, 0.75f); break; case 4: vector3 = new Vector3(0.6666667f, 1f, 0.75f); break; case 5: vector3 = new Vector3(0.8333333f, 1f, 0.75f); break; } for (int index3 = 0; index3 < 4; ++index3) { int index4 = index3 + index2 * 4 + index1 * 24; indexedPrimitives.Vertices[index4].Color = new Color(vector3.X, vector3.Y, vector3.Z); indexedPrimitives.Vertices[index4].Position = list[numArray[index4]]; } } } indexedPrimitives.Indices = new int[144] { 0, 2, 1, 0, 3, 2, 4, 6, 5, 4, 7, 6, 8, 10, 9, 8, 11, 10, 12, 14, 13, 12, 15, 14, 16, 17, 18, 16, 18, 19, 20, 22, 21, 20, 23, 22, 24, 26, 25, 24, 27, 26, 28, 30, 29, 28, 31, 30, 32, 34, 33, 32, 35, 34, 36, 38, 37, 36, 39, 38, 40, 41, 42, 40, 42, 43, 44, 46, 45, 44, 47, 46, 48, 50, 49, 48, 51, 50, 52, 54, 53, 52, 55, 54, 56, 58, 57, 56, 59, 58, 60, 62, 61, 60, 63, 62, 64, 65, 66, 64, 66, 67, 68, 70, 69, 68, 71, 70, 72, 74, 73, 72, 75, 74, 76, 78, 77, 76, 79, 78, 80, 82, 81, 80, 83, 82, 84, 86, 85, 84, 87, 86, 88, 89, 90, 88, 90, 91, 92, 94, 93, 92, 95, 94 }; int num1 = (int)Math.Floor(96.0); int length = 54 * num1; indexedPrimitives.Instances = new Vector4[length]; int num2 = (int)Math.Floor(27.0); int num3 = (int)Math.Floor((double)num1 / 2.0); Random random = RandomHelper.Random; for (int index1 = -num2; index1 < num2; ++index1) { for (int index2 = -num3; index2 < num3; ++index2) { int index3 = (index1 + num2) * num1 + (index2 + num3); indexedPrimitives.Instances[index3] = new Vector4((float)(index2 * 6), (float)(index1 * 6 + (Math.Abs(index2) % 2 == 0 ? 0 : 3)), 0.0f, index2 != 0 || index1 != 0 ? (float)(random.NextDouble() * 3.14159274101257 * 2.0) : 0.0f); } } indexedPrimitives.InstanceCount = length; indexedPrimitives.UpdateBuffers(); }