예제 #1
0
        internal virtual void InitializeParticle(Particle inParticle)
        {
            float movementSpeed = _movementSpeedRange.GetRandom(FrozenCore.FastRandom);
            float rotationSpeed = _rotationSpeedRange.GetRandom(FrozenCore.FastRandom);
            float scaleSpeed    = _scaleSpeedRange.GetRandom(FrozenCore.FastRandom);

            float direction = _initialDirectionRange.GetRandom(FrozenCore.FastRandom);
            float rotation  = _initialRotationRange.GetRandom(FrozenCore.FastRandom);
            float scale     = _initialScaleRange.GetRandom(FrozenCore.FastRandom);

            float ttl = _timeToLiveRange.GetRandom(FrozenCore.FastRandom);

            Vector3 origin = FXArea.GetPoint(FrozenCore.FastRandom);

            inParticle.SetData(_particleMaterial,
                               origin,
                               movementSpeed,
                               rotationSpeed,
                               scaleSpeed,
                               rotation,
                               _emitterDirection + direction,
                               scale,
                               ttl,
                               _colorRange);
        }
예제 #2
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);
                }
            }
        }