示例#1
0
        /// <summary></summary>
        /// <param name="onceShaderData"></param>
        /// <param name="onceCloneShaderData"></param>
        /// <param name="frameShaderData"></param>
        /// <param name="frameMoveShaderData"></param>
        public GpuParticleProcessorData(ParticleSystemCompiledShaderData onceShaderData, ParticleSystemCompiledShaderData onceCloneShaderData, ParticleSystemCompiledShaderData frameShaderData, ParticleSystemCompiledShaderData frameMoveShaderData)
        {
            this.OnceShaderData      = onceShaderData;
            this.OnceCloneShaderData = onceCloneShaderData;
            this.FrameShaderData     = frameShaderData;
            this.FrameMoveShaderData = frameMoveShaderData;

            this.onceShader      = new GpuParticleShader(GpuVertexShaderData.VS_ONCE, this.OnceShaderData);
            this.onceCloneShader = new GpuParticleShader(GpuVertexShaderData.VS_ONCE_CLONE, this.OnceCloneShaderData);
            this.frameShader     = new GpuParticleShader(GpuVertexShaderData.VS_FRAME, this.FrameShaderData);
            this.frameMoveShader = new GpuParticleShader(GpuVertexShaderData.VS_ONCE_CLONE, this.FrameMoveShaderData);
        }
示例#2
0
        //draw the particle update data
        void IDraw.Draw(DrawState state)
        {
            int copyIndex = 0;

            //keep an application wide cache of the vertices used
            AllocateVertices(state);


            //special mode, renderig the life / age of particles

            if (renderLifeStoreMode)
            {
                DrawLifeAgeToStore(state);
                return;
            }
            //otherwise, render normal

            //move particles
            if (activeRenderPass.CopyCount > 0)
            {
                while (activeRenderPass.CopyCount > 0)
                {
                    int count = (this.processorData.FrameMoveShader as GpuParticleShader).SetMoveShaderEnabled(state, this, null, activeRenderPass.CopyData, null, activeRenderPass.CopyCount, copyIndex);

                    this.processorData.FrameMoveShader.Bind(state);

                    verticesRenderIndex.Draw(state, null, PrimitiveType.PointList, Math.Min(count, activeRenderPass.CopyCount), 0, 0);

                    activeRenderPass.CopyCount -= count;
                    copyIndex += count;
                }
            }

            //particle are being added?
            for (int i = 0; i < activeRenderPass.AddLists.Length; i++)
            {
                ProcessorAddList list = activeRenderPass.AddLists[i];

                if (list.AddCount > 0)
                {
                    copyIndex = 0;

                    GpuParticleShader shader = this.processorData.OnceShader as GpuParticleShader;

                    //added from a different processor?
                    if (list.processor != null)
                    {
                        shader = this.processorData.OnceCloneShader as GpuParticleShader;

                        Texture2D t0, t1, t2, t3, t4;
                        list.processor.GetLogicTextures(state, out t0, out t1, out t2, out t3, out t4);
                        shader.SetTextures(state, t0, t1, t2, t3, randomTexture.GetTexture(state), t4);
                    }
                    else
                    {
                        shader.SetTextures(state, null, null, null, null, randomTexture.GetTexture(state), null);
                    }

                    while (list.AddCount > 0)
                    {
                        //draw them
                        int count = shader.SetMoveShaderEnabled(state, this, list.processor, list.AddData, list.AddDetails, list.AddCount, copyIndex);

                        shader.Bind(state);

                        verticesRenderIndex.Draw(state, null, PrimitiveType.PointList, Math.Min(count, list.AddCount), 0, 0);

                        list.AddCount -= count;
                        copyIndex     += count;
                    }
                }
            }
        }
		/// <summary></summary>
		/// <param name="onceShaderData"></param>
		/// <param name="onceCloneShaderData"></param>
		/// <param name="frameShaderData"></param>
		/// <param name="frameMoveShaderData"></param>
		public GpuParticleProcessorData(ParticleSystemCompiledShaderData onceShaderData, ParticleSystemCompiledShaderData onceCloneShaderData, ParticleSystemCompiledShaderData frameShaderData, ParticleSystemCompiledShaderData frameMoveShaderData)
		{
			this.OnceShaderData = onceShaderData;
			this.OnceCloneShaderData = onceCloneShaderData;
			this.FrameShaderData = frameShaderData;
			this.FrameMoveShaderData = frameMoveShaderData;

			this.onceShader = new GpuParticleShader(this.OnceShaderData);
			this.onceCloneShader = new GpuParticleShader(this.OnceCloneShaderData);
			this.frameShader = new GpuParticleShader(this.FrameShaderData);
			this.frameMoveShader = new GpuParticleShader(this.FrameMoveShaderData);
		}