private void SetupGeometry() { lock (TrixelParticleSystem.StaticLock) { if (TrixelParticleSystem.effect == null) TrixelParticleSystem.effect = new TrixelParticleEffect(); } this.mesh = new Mesh() { Effect = (BaseEffect) TrixelParticleSystem.effect, SkipStates = true }; this.mesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) (this.Geometry = new ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Matrix>(PrimitiveType.TriangleList, 60)); Vector3 vector3 = new Vector3(0.0f); this.Geometry.Vertices = new VertexPositionNormalTextureInstance[24] { new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 1f) } }; this.Geometry.Indices = new int[36] { 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 }; this.Geometry.Instances = new Matrix[this.settings.ParticleCount]; this.Geometry.MaximizeBuffers(this.settings.ParticleCount); this.Geometry.InstanceCount = this.settings.ParticleCount; this.mesh.Texture.Set((Texture) this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas); }
private void SetupGeometry() { lock (TrixelParticleSystem.StaticLock) { if (TrixelParticleSystem.effect == null) { TrixelParticleSystem.effect = new TrixelParticleEffect(); } } this.mesh = new Mesh() { Effect = (BaseEffect)TrixelParticleSystem.effect, SkipStates = true }; this.mesh.AddGroup().Geometry = (IIndexedPrimitiveCollection)(this.Geometry = new ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Matrix>(PrimitiveType.TriangleList, 60)); Vector3 vector3 = new Vector3(0.0f); this.Geometry.Vertices = new VertexPositionNormalTextureInstance[24] { new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, Vector3.UnitZ) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitX) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, 1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, -1f, -1f) * 0.5f + vector3, -Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 1f) }, new VertexPositionNormalTextureInstance(new Vector3(-1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.125f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, 1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 0.0f) }, new VertexPositionNormalTextureInstance(new Vector3(1f, 1f, -1f) * 0.5f + vector3, Vector3.UnitY) { TextureCoordinate = new Vector2(0.0f, 1f) } }; this.Geometry.Indices = new int[36] { 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 }; this.Geometry.Instances = new Matrix[this.settings.ParticleCount]; this.Geometry.MaximizeBuffers(this.settings.ParticleCount); this.Geometry.InstanceCount = this.settings.ParticleCount; this.mesh.Texture.Set((Texture)this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas); }