示例#1
0
 /// <summary>Renders a series of particles</summary>
 /// <param name="particles">Particles that will be rendered</param>
 /// <param name="primitiveBatch">
 ///   Primitive batch that will receive the vertices generated by the particles
 /// </param>
 public void Render(
     ArraySegment <ParticleType> particles,
     PrimitiveBatch <ParticleType> primitiveBatch
     )
 {
     primitiveBatch.Draw(
         particles.Array, particles.Offset, particles.Count,
         PrimitiveType.PointList,
         this.drawContext
         );
 }
示例#2
0
 public static void Draw(VoxelEngine.Primitives.GeometricPrimitive primitive)
 {
     primitive.Update();
     if (primitive is VoxelChunk)
     {
         batch.Draw(PrimitiveType.TriangleList, primitive.VerticeArray);
     }
     else
     {
         batch.DrawIndexed(PrimitiveType.TriangleList, primitive.IndiceArray, primitive.VerticeArray);
     }
 }
示例#3
0
        /// <summary>Renders a series of particles</summary>
        /// <param name="particles">Particles that will be rendered</param>
        /// <param name="primitiveBatch">
        ///   Primitive batch that will receive the vertices generated by the particles
        /// </param>
        public void Render(
            ArraySegment <ParticleType> particles,
            PrimitiveBatch <ParticleType> primitiveBatch
            )
        {
            Vector3 cameraPosition = this.Camera.Translation;
            Vector3 cameraUp       = this.Camera.Up;
            Vector3 cameraForward  = this.Camera.Forward;
            Matrix  billboard;

            ParticleType tl, tr, bl, br;
            int          end = particles.Offset + particles.Count;

            for (int index = particles.Offset; index < end; ++index)
            {
                tl = particles.Array[index];
                tr = tl;
                bl = tl;
                br = tl;

                Vector3 position;
                this.accessor.GetPosition(ref tl, out position);

                Matrix.CreateBillboard(
                    ref position, ref cameraPosition, ref cameraUp, cameraForward, out billboard
                    );

                Vector3 corner;
                corner.X = position.X + billboard.M11 + billboard.M21;
                corner.Y = position.Y + billboard.M12 + billboard.M22;
                corner.Z = position.Z + billboard.M13 + billboard.M23;
                this.accessor.SetPosition(ref tl, ref corner);
                corner.X = position.X - billboard.M11 + billboard.M21;
                corner.Y = position.Y - billboard.M12 + billboard.M22;
                corner.Z = position.Z - billboard.M13 + billboard.M23;
                this.accessor.SetPosition(ref tr, ref corner);
                corner.X = position.X + billboard.M11 - billboard.M21;
                corner.Y = position.Y + billboard.M12 - billboard.M22;
                corner.Z = position.Z + billboard.M13 - billboard.M23;
                this.accessor.SetPosition(ref bl, ref corner);
                corner.X = position.X - billboard.M11 - billboard.M21;
                corner.Y = position.Y - billboard.M12 - billboard.M22;
                corner.Z = position.Z - billboard.M13 - billboard.M23;
                this.accessor.SetPosition(ref br, ref corner);
            }
            primitiveBatch.Draw(
                particles.Array, particles.Offset, particles.Count,
                PrimitiveType.PointList,
                this.drawContext
                );
        }
示例#4
0
        public void Draw(TextureNode node, float width, float height)
        {
            for (int index = 0; index < 4; index++)
            {
                Vector2 vec  = GameMode.ModePoints[index] * new Vector2(node.Destination.Width, node.Destination.Height);
                Vector4 pos  = Vector2.Transform(vec, node.Transform);
                Vector3 pos2 = new Vector3(2 * pos.X / width - 1.0f, 2 * pos.Y / -height + 1.0f, 0);
                vertices[index * 2].Position = pos2;
            }
            for (int index = 0; index < 4; index++)
            {
                vertices[index * 2 + 1].Position = (vertices[index * 2].Position + vertices[index * 2 + 2].Position) / 2;
            }


            vertices[8] = vertices[0];

            effect.CurrentTechnique.Passes[0].Apply();
            batch.Begin();
            batch.Draw(PrimitiveType.LineStrip, vertices);
            batch.End();
        }