Exemplo n.º 1
0
        void ICmpRenderer.Draw(IDrawDevice device)
        {
            if (_inEditor)
            {
                if (FXArea != null)
                {
                    Canvas c = new Canvas(device);
                    FXArea.DrawInEditor(c);
                }
            }
            else
            {
                if (_particlesAlive > 0)
                {
                    Vector3 posTemp   = FXArea.GameObj.Transform.Pos;
                    float   scaleTemp = 1f;
                    device.PreprocessCoords(ref posTemp, ref scaleTemp);

                    int index = 0;

                    foreach (Particle p in _particles)
                    {
                        if (p.IsAlive)
                        {
                            bool toDraw = DrawParticlesOffScreen || device.IsCoordInView(p.Position);

                            if (toDraw)
                            {
                                p.UpdateVertices(device, posTemp, scaleTemp);
                                Array.Copy(p.Vertices, 0, _particleVertices, index * 4, 4);
                            }
                            index++;
                        }
                    }

                    device.AddVertices(_particleMaterial.Material, VertexMode.Quads, _particleVertices, index * 4);
                }
            }
        }