예제 #1
0
        /// <summary>
        /// Deep copy all of the Particle properties
        /// </summary>
        /// <param name="ParticleToCopy">The Particle to Copy the properties from</param>
        public override void CopyFrom(DPSFParticle ParticleToCopy)
        {
            // Cast the Particle to the type it really is
            DefaultSprite3DBillboardTextureCoordinatesParticle cParticleToCopy = (DefaultSprite3DBillboardTextureCoordinatesParticle)ParticleToCopy;

            base.CopyFrom(cParticleToCopy);
            this.TextureCoordinates = cParticleToCopy.TextureCoordinates;
        }
예제 #2
0
        //===========================================================
        // Draw Sprite and Overridden Particle System Functions
        //===========================================================

        /// <summary>
        /// Function to draw a Sprite Particle. This function should be used to draw the given
        /// Particle with the provided SpriteBatch.
        /// </summary>
        /// <param name="Particle">The Particle Sprite to Draw</param>
        /// <param name="cSpriteBatch">The SpriteBatch to use to doing the Drawing</param>
        protected override void DrawSprite(DPSFParticle Particle, SpriteBatch cSpriteBatch)
        {
            // Cast the Particle to the type it really is
            DefaultSprite3DBillboardTextureCoordinatesParticle particle = (DefaultSprite3DBillboardTextureCoordinatesParticle)Particle;

            // Calculate the sprites position in 3D space, and flip it vertically so that it is not upside-down.
            Vector3 viewSpacePosition = Vector3.Transform(particle.Position, this.View);

            // Get the Position of the Particle relative to the camera
            Vector2 destination = new Vector2(viewSpacePosition.X, viewSpacePosition.Y);

            // Get the Position and Dimensions from the Texture to use for this Sprite
            Rectangle sourceFromTexture = particle.TextureCoordinates;

            // Calculate how much to scale the sprite to get it to the desired Width and Height.
            // Use negative height in order to flip the texture to be right-side up.
            Vector2 scale = new Vector2(particle.Width / sourceFromTexture.Width, -particle.Height / sourceFromTexture.Height);

            // Make the Sprite rotate about its center
            Vector2 origin = new Vector2(sourceFromTexture.Width / 2, sourceFromTexture.Height / 2);

            // Draw the Sprite
            cSpriteBatch.Draw(Texture, destination, sourceFromTexture, particle.ColorAsPremultiplied, particle.Rotation, origin, scale, particle.FlipMode, viewSpacePosition.Z);
        }