Esempio n. 1
0
        public static Matrix MatrixFromParticle(Particle particle)
        {
            Matrix rot = Matrix.CreateRotationZ(particle.Angle);
            Matrix bill = Matrix.CreateBillboard(particle.Position, _camera.Position, _camera.UpVector, null);
            Matrix noTransBill = bill;
            noTransBill.Translation = Vector3.Zero;

            Matrix worldRot = Matrix.CreateScale(particle.Scale) * rot * noTransBill;
            worldRot.Translation = bill.Translation;
            return worldRot;
        }
Esempio n. 2
0
        public void Trigger(int num, Vector3 origin, Color tint)
        {
            for(int i = 0; i < num; i++)
            {
                if(Particles.Count < Data.MaxParticles)
                {
                    Particle toAdd = new Particle();

                    bool sampleFound = false;

                    Vector3 sample = new Vector3(99999, 99999, 9999);

                    while(!sampleFound)
                    {
                        sample = RandVec(Data.EmissionRadius);

                        if(sample.Length() < Data.EmissionRadius)
                        {
                            sampleFound = true;
                        }
                    }

                    toAdd.Position = sample + origin;
                    toAdd.Velocity = (sample);
                    toAdd.Velocity.Normalize();
                    toAdd.Velocity *= Data.EmissionSpeed;

                    toAdd.Scale = Rand(Data.MinScale, Data.MaxScale);
                    toAdd.Angle = Rand(Data.MinAngle, Data.MaxAngle);
                    toAdd.AngularVelocity = Rand(Data.MinAngular, Data.MaxAngular);
                    toAdd.LifeRemaining = 1.0f;
                    toAdd.Tint = tint;
                    toAdd.InstanceData = new InstanceData(Matrix.Identity, toAdd.Tint, true);

                    Particles.Add(toAdd);

                    if(toAdd.InstanceData != null)
                    {
                        Sprites.Add(toAdd.InstanceData);
                    }
                }
            }
        }
Esempio n. 3
0
        public static int CompareZDepth(Particle A, Particle B)
        {
            if(A == B)
            {
                return 0;
            }

            if((_camera.Position - A.Position).LengthSquared() < (_camera.Position - B.Position).LengthSquared())
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }