Esempio n. 1
0
        public unsafe void MacrossParticleStateNodeUpdate(McParticleEffector effector, float e, CGfxParticleSystem sys, CGfxParticle *p, CGfxParticleState *pt, int pi)
        {
            var life = (*p).mLife;
            var tick = (*p).mLifeTick;

            if (tick / life >= 1)
            {
                if (ParticleVelocityNodes != null && ParticleVelocityNodes.Count > 1)
                {
                    for (int i = 0; i < ParticleVelocityNodes.Count; i++)
                    {
                        var ParticleVelocityNode = ParticleVelocityNodes[i];
                        if (ParticleVelocityNode != null)
                        {
                            ParticleVelocityNode.StartValues.RemoveAt(pi);
                        }
                    }
                }
                return;
            }

            effector.ParticleData.ParticleSystem       = sys;
            effector.ParticleData.ParticleSubState     = this;
            effector.ParticleData.ParticleEmitterShape = Shape;

            effector.ParticleData.Particle      = p;
            effector.ParticleData.ParticleState = pt;


            if (ParticleScaleNode != null)
            {
                ParticleScaleNode.SetParticleScale2((*p).mLife, (*p).mLifeTick, ref (*pt).mPose);
                ParticleScaleNode.SetParticleScale(life, tick, ref (*pt).mPose);

                pt->mPose.mScale  = ParticleScaleNode.Scale;
                pt->mPose.mScale *= pt->mStartPose.mScale;
            }

            if (VelocityByCenterNode != null)
            {
                VelocityByCenterNode.SetPower(life, tick);
                VelocityByCenterNode.SetPower2((*p).mLife, (*p).mLifeTick);
            }

            if (VelocityByTangentNode != null)
            {
                VelocityByTangentNode.SetAix(life, tick, ref pt->mStartPose.mAxis, pt->mStartPose.mAcceleration.Y);
                VelocityByTangentNode.SetAix2((*p).mLife, (*p).mLifeTick, ref pt->mStartPose.mAxis);
            }

            if (ParticleVelocityNodes != null && ParticleVelocityNodes.Count > 0)
            {
                for (int i = 0; i < ParticleVelocityNodes.Count; i++)
                {
                    var ParticleVelocityNode = ParticleVelocityNodes[i];
                    if (ParticleVelocityNode != null)
                    {
                        ParticleVelocityNode.SetParticleVelocity2((*p).mLife, (*p).mLifeTick, ref (*pt).mPose);
                        ParticleVelocityNode.SetParticleVelocity(life, tick, ref (*pt).mPose);

                        if (ParticleVelocityNodes.Count == 1)
                        {
                            if (i == 0)
                            {
                                pt->mPose.mVelocity = ParticleVelocityNode.Velocity;
                            }
                            else
                            {
                                pt->mPose.mVelocity += ParticleVelocityNode.Velocity;
                            }

                            pt->mPose.mVelocity *= pt->mStartPose.mVelocity;
                        }
                        else
                        {
                            if (i == 0)
                            {
                                pt->mPose.mVelocity = ParticleVelocityNode.Velocity * ParticleVelocityNode.StartValues[pi];
                            }
                            else
                            {
                                pt->mPose.mVelocity += ParticleVelocityNode.Velocity * ParticleVelocityNode.StartValues[pi];
                            }
                        }


                        //ParticleScaleNode.SetParticleScale2((*p).mLife, (*p).mLifeTick, ref (*pt).mPose);
                    }
                }
            }

            if (RotationNodes != null && RotationNodes.Count > 0)
            {
                for (int i = 0; i < RotationNodes.Count; i++)
                {
                    var RotationNode = RotationNodes[i];
                    if (RotationNode != null)
                    {
                        RotationNode.SetYawPitchRoll(life, tick);

                        {
                            RotationNode.Update(e, ref pt->mPose, ref pt->mStartPose);
                        }

                        //ParticleScaleNode.SetParticleScale2((*p).mLife, (*p).mLifeTick, ref (*pt).mPose);
                        if (sys.IsBillBoard)
                        {
                            float Yaw, Pitch, Roll;
                            pt->mPose.mRotation.GetYawPitchRoll(out Yaw, out Pitch, out Roll);
                            pt->mPose.mAngle = Roll;
                        }
                    }
                }
            }

            if (AcceleratedNode != null)
            {
                AcceleratedNode.SetAccelerated(life, tick);
                pt->mPose.mAcceleration.X = AcceleratedNode.Accelerated * pt->mStartPose.mAcceleration.X;
            }
            else
            {
                pt->mPose.mAcceleration.X = 1f;
            }

            if (VelocityByCenterNode != null && VelocityByTangentNode != null)
            {
                VelocityByCenterNode.GetValue(ref (*pt), sys, this, e);
                VelocityByTangentNode.GetValue(ref (*pt), sys, this, e);

                pt->AccelerationEffect(e, ref VelocityByTangentNode.Offset, ref VelocityByCenterNode.Direction);
            }
            else if (VelocityByCenterNode != null)
            {
                VelocityByCenterNode.GetValue(ref (*pt), sys, this, e);

                VelocityByCenterNode.OnlyUseThisNode(e, ref (*pt));
            }
            else if (VelocityByTangentNode != null)
            {
                VelocityByTangentNode.GetValue(ref (*pt), sys, this, e);

                VelocityByTangentNode.OnlyUseThisNode(e, ref (*pt));
            }
            else if (MacrossParticleStateNode != null)
            {
                //if (ParticleVelocityNodes != null && ParticleVelocityNodes.Count > 0)
                {
                    pt->AccelerationEffect(e);
                }
            }

            //粒子状态信息的更新 粒子下面可能有多个状态
            if (MacrossParticleStateNode != null)
            {
                MacrossParticleStateNode.Update(e, effector.ParticleData, ref (*p), ref (*pt));
            }

            if (ColorNode != null)
            {
                ColorNode.SetParticleColor(life, tick, ref (*pt).mPose, ref (*pt).mStartPose);
            }
        }
Esempio n. 2
0
        public unsafe void MacrossParticleStateNodeInit(McParticleEffector effector, CGfxParticleSystem sys, CGfxParticle *p, CGfxParticleState *pt, int pi)
        {
            //粒子状态信息的初始化 粒子下面可能有多个状态
            if (MacrossParticleStateNode != null)
            {
                effector.ParticleData.ParticleSystem       = sys;
                effector.ParticleData.ParticleSubState     = this;
                effector.ParticleData.ParticleEmitterShape = Shape;

                effector.ParticleData.Particle      = p;
                effector.ParticleData.ParticleState = pt;

                MacrossParticleStateNode.Init(effector.ParticleData, ref (*p), ref (*pt));
            }

            //var lifetick = p->mLifeTick / p->mLife;
            if (ColorNode != null)
            {
                ColorNode.GetStartValue();
                pt->mStartPose.SetUserParams_Color4(0, ColorNode.StartValue);
            }

            if (ParticleScaleNode != null)
            {
                ParticleScaleNode.GetStartValue();
                pt->mStartPose.mScale = ParticleScaleNode.StartValue;
            }

            if (ParticleVelocityNodes != null && ParticleVelocityNodes.Count > 0)
            {
                for (int i = 0; i < ParticleVelocityNodes.Count; i++)
                {
                    var ParticleVelocityNode = ParticleVelocityNodes[i];
                    if (ParticleVelocityNode != null)
                    {
                        ParticleVelocityNode.GetStartValue();
                        if (ParticleVelocityNodes.Count == 1)
                        {
                            //ParticleVelocityNode.StartValue.Normalize();
                            if (i == 0)
                            {
                                pt->mStartPose.mVelocity = ParticleVelocityNode.StartValue;
                            }
                            else
                            {
                                pt->mStartPose.mVelocity *= ParticleVelocityNode.StartValue;
                            }
                        }
                        else
                        {
                            ParticleVelocityNode.AddStartValue(pi, ref ParticleVelocityNode.StartValue);
                            //ParticleVelocityNode.AddStartValue(pt, ref ParticleVelocityNode.StartValue);
                        }
                    }
                }
            }

            if (RotationNodes != null && RotationNodes.Count > 0)
            {
                for (int i = 0; i < RotationNodes.Count; i++)
                {
                    var rotationNode = RotationNodes[i];
                    if (rotationNode != null)
                    {
                        rotationNode.GetStartValue2();
                        //ParticleVelocityNode.StartValue.Normalize();
                        if (i == 0)
                        {
                            pt->mStartPose.mRotation = rotationNode.StartValue;
                        }
                        else
                        {
                            pt->mStartPose.mRotation *= rotationNode.StartValue;
                        }
                    }
                }
            }

            if (AcceleratedNode != null)
            {
                AcceleratedNode.GetStartValue();
                pt->mStartPose.mAcceleration.X = AcceleratedNode.StartValue;
            }

            if (VelocityByTangentNode != null)
            {
                VelocityByTangentNode.GetStartValue();
                pt->mStartPose.mAxis = VelocityByTangentNode.StartValue;

                VelocityByTangentNode.Power.GetStartValue();
                pt->mStartPose.mAcceleration.Y = VelocityByTangentNode.Power.StartValue;
            }
        }