Пример #1
0
        public unsafe void InitParticle(McParticleEffector effector, CGfxParticleSystem sys, CGfxParticle *p)
        {
            if (sys.TrailNode != null)
            {
                sys.TrailNode.CreateTrail(ref (*p));
            }

            if (sys.TextureCutNode != null)
            {
                sys.TextureCutNode.GetStartValue(ref (*p));
            }

            p->SetParticleLife(sys.MinLife, sys.MaxLife);
            if (sys.EnableEventReceiver)
            {
                sys.BindTriggerEvent(ref (*p));
            }

            //if (sys.TriggerNodes.Count > 0)
            //{
            //    for (int i = 0; i < sys.TriggerNodes.Count; i++)
            //    {
            //        sys.TriggerNodes[i].TriggerBornEvent(ref p->FinalPose);
            //    }
            //}
        }
Пример #2
0
        internal unsafe void OnParticleBorn(McParticleEffector effector, CGfxParticleSystem sys)
        {
            CGfxParticleState **pStates;
            int num = 0;

            ScopeTickGetNewBorns.Begin();
            SDK_GfxParticleSubState_GetNewBorns(CoreObject, &pStates, &num);
            ScopeTickGetNewBorns.End();
            ScopeTickDoParticleBorn.Begin();
            for (int i = 0; i < num; i++)
            {
                var particle = pStates[i]->Host;
                if ((IntPtr)particle == IntPtr.Zero)
                {
                    effector.DoParticleBorn(sys, ref CGfxParticle.Empty);
                }
                else
                {
                    effector.DoParticleBorn(sys, ref (*particle));
                }
            }
            ScopeTickDoParticleBorn.End();
        }
Пример #3
0
        internal unsafe void OnParticleStateBorn(McParticleEffector effector, CGfxParticleSystem sys, int stateIndex)
        {
            CGfxParticleState **pStates;
            int num = 0;

            ScopeTickGetNewBorns2.Begin();
            //这里处理每个substate发射出来的粒子,如果num的预期超过粒子数目最大值就有可能...
            SDK_GfxParticleSubState_GetNewBorns(CoreObject, &pStates, &num);

            ScopeTickGetNewBorns2.End();
            ScopeTickDoParticleStateBorn.Begin();

            effector.DoParticleStateBorn(sys, pStates, this, stateIndex, num);

            ScopeTickDoParticleStateBorn.End();
            SDK_GfxParticleSubState_PushNewBorns(CoreObject);
            if (sys.IsBind == true)
            {
                return;
            }

            if (sys.HostActorPlacement == null)
            {
                return;
            }

            var placement = sys.HostActorPlacement as GParticlePlacementComponent;

            if (placement == null)
            {
                return;
            }

            Vector3    pos;
            Vector3    scale;
            Quaternion rot;
            Vector4    temppos;

            bool IsIgnore = placement.IsIgnore;

            placement.IsIgnore = false;
            placement.WorldMatrix.Decompose(out scale, out rot, out pos);
            placement.IsIgnore = IsIgnore;

            for (int i = 0; i < num; i++)
            {
                //pStates[i]->SyncStartToPose();
                pStates[i]->mStartPose.mPosition *= scale;
                Vector3.Transform(ref pStates[i]->mStartPose.mPosition, ref rot, out temppos);
                pStates[i]->mStartPose.mPosition.X += temppos.X;
                pStates[i]->mStartPose.mPosition.Y += temppos.Y;
                pStates[i]->mStartPose.mPosition.Z += temppos.Z;
                pStates[i]->mStartPose.mPosition   += pos;

                if (rot.IsValid)
                {
                    pStates[i]->mStartPose.mRotation *= rot;
                }

                pStates[i]->mStartPose.mScale *= scale;

                Vector3.Transform(ref pStates[i]->mStartPose.mVelocity, ref rot, out temppos);
                pStates[i]->mStartPose.mVelocity.X = temppos.X;
                pStates[i]->mStartPose.mVelocity.Y = temppos.Y;
                pStates[i]->mStartPose.mVelocity.Z = temppos.Z;
                pStates[i]->mStartPose.mVelocity.Normalize();

                //mPose
                pStates[i]->mPose.mPosition *= scale;
                Vector3.Transform(ref pStates[i]->mPose.mPosition, ref rot, out temppos);
                pStates[i]->mPose.mPosition.X += temppos.X;
                pStates[i]->mPose.mPosition.Y += temppos.Y;
                pStates[i]->mPose.mPosition.Z += temppos.Z;
                pStates[i]->mPose.mPosition   += pos;

                if (rot.IsValid)
                {
                    pStates[i]->mPose.mRotation *= rot;
                }

                pStates[i]->mPose.mScale *= scale;

                Vector3.Transform(ref pStates[i]->mPose.mVelocity, ref rot, out temppos);
                pStates[i]->mPose.mVelocity.X = temppos.X;
                pStates[i]->mPose.mVelocity.Y = temppos.Y;
                pStates[i]->mPose.mVelocity.Z = temppos.Z;
                pStates[i]->mPose.mVelocity.Normalize();
            }
        }
Пример #4
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);
            }
        }
Пример #5
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;
            }
        }
Пример #6
0
 public unsafe void UpdateParticle(McParticleEffector effector, float e, CGfxParticleSystem sys, CGfxParticle *p)
 {
 }