Пример #1
0
        public override void Draw(RenderContext context, EffectApplication material, Matrix transform)
        {
            material.SetEffectParams(context, transform);
            for (int p = 0; p < material.Effect.CurrentTechnique.Passes.Count; ++p)
            {
                material.Effect.CurrentTechnique.Passes[p].Apply();
                if (mParticleData.FirstActiveParticleIndex < mParticleData.FirstFreeParticleIndex)
                {
                    // If the active particles are all in one consecutive range, we can draw them all in a single call.
                    if (SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            mParticleData.FirstActiveParticleIndex * 4,
                            (mParticleData.FirstFreeParticleIndex - mParticleData.FirstActiveParticleIndex) * 4,
                            mParticleData.FirstActiveParticleIndex * 6,
                            (mParticleData.FirstFreeParticleIndex - mParticleData.FirstActiveParticleIndex) * 2);
                    }
                }
                else
                {
                    // If the active particle range wraps past the end of the queue back to the start, we must split them over two draw calls.
                    if (SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            mParticleData.FirstActiveParticleIndex * 4,
                            (mParticleData.MaxParticles - mParticleData.FirstActiveParticleIndex) * 4,
                            mParticleData.FirstActiveParticleIndex * 6,
                            (mParticleData.MaxParticles - mParticleData.FirstActiveParticleIndex) * 2);
                    }

                    if (mParticleData.FirstFreeParticleIndex > 0 && SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            0,
                            mParticleData.FirstFreeParticleIndex * 4,
                            0,
                            mParticleData.FirstFreeParticleIndex * 2);
                    }
                }
            }

            mIncrementDrawCounter();
        }
        public override void Draw(RenderContext context, EffectApplication material, Matrix transform)
        {
            material.SetEffectParams(context, transform);
            for (int p = 0; p < material.Effect.CurrentTechnique.Passes.Count; ++p)
            {
                material.Effect.CurrentTechnique.Passes[p].Apply();
                if (mParticleData.FirstActiveParticleIndex < mParticleData.FirstFreeParticleIndex)
                {
                    // If the active particles are all in one consecutive range, we can draw them all in a single call.
                    if (SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            mParticleData.FirstActiveParticleIndex * 4,
                            (mParticleData.FirstFreeParticleIndex - mParticleData.FirstActiveParticleIndex) * 4,
                            mParticleData.FirstActiveParticleIndex * 6,
                            (mParticleData.FirstFreeParticleIndex - mParticleData.FirstActiveParticleIndex) * 2);
                    }
                }
                else
                {
                    // If the active particle range wraps past the end of the queue back to the start, we must split them over two draw calls.
                    if (SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            mParticleData.FirstActiveParticleIndex * 4,
                            (mParticleData.MaxParticles - mParticleData.FirstActiveParticleIndex) * 4,
                            mParticleData.FirstActiveParticleIndex * 6,
                            (mParticleData.MaxParticles - mParticleData.FirstActiveParticleIndex) * 2);
                    }

                    if (mParticleData.FirstFreeParticleIndex > 0 && SharedResources.GraphicsDeviceReady)
                    {
                        SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            0,
                            mParticleData.FirstFreeParticleIndex * 4,
                            0,
                            mParticleData.FirstFreeParticleIndex * 2);
                    }
                }
            }

            mIncrementDrawCounter();
        }
Пример #3
0
 public virtual void Draw(RenderContext context, EffectApplication material, Matrix transform)
 {
     material.SetEffectParams(context, transform);
     for (int p = 0; p < material.Effect.CurrentTechnique.Passes.Count; ++p)
     {
         material.Effect.CurrentTechnique.Passes[p].Apply();
         if (SharedResources.GraphicsDeviceReady)
         {
             SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                 PrimitiveType.TriangleList,
                 mVertexOffset,
                 0,
                 mNumVertices,
                 mStartIndex,
                 mPrimitiveCount);
         }
     }
 }
Пример #4
0
 public virtual void Draw(RenderContext context, EffectApplication material, Matrix transform)
 {
     material.SetEffectParams(context, transform);
     for (int p = 0; p < material.Effect.CurrentTechnique.Passes.Count; ++p)
     {
         material.Effect.CurrentTechnique.Passes[p].Apply();
         if (SharedResources.GraphicsDeviceReady)
             SharedResources.Game.GraphicsDevice.DrawIndexedPrimitives(
                 PrimitiveType.TriangleList,
                 mVertexOffset,
                 0,
                 mNumVertices,
                 mStartIndex,
                 mPrimitiveCount);
     }
 }