//获取绕发射中心的旋转方向
        public void GetRotationByCenter(CGfxParticleSystem sys, CGfxParticleSubState substate, ref Quaternion rotation, out Vector3 result)
        {
            result = new Vector3(sys.Matrix.M41 + substate.Position.X,
                                 sys.Matrix.M42 + substate.Position.Y,
                                 sys.Matrix.M43 + substate.Position.Z);

            result = rotation * (mPose.mPosition - result) + result - mPose.mPosition;
        }
Exemple #2
0
        public void UpdateParticleSubState(float elaspe)
        {
            if (SubStates != null)
            {
                var effector = Effector.Get(false);
                for (int i = 0; i < SubStates.Length; i++)
                {
                    if (CurLiveTime <= FireDelay)
                    {
                        continue;
                    }

                    unsafe
                    {
                        CGfxParticleState **pStates;
                        int num = 0;
                        CGfxParticleSubState.SDK_GfxParticleSubState_GetParticles(SubStates[i].CoreObject, &pStates, &num);
                        if (num > 0)
                        {
                            //宏图处理粒子状态变更
                            effector.OnParticleStateTick(this, pStates, num, i, SubStates[i], elaspe, i);
                        }
                    }

                    //这里处理SubState里面的粒子如果死亡,移除状态
                    CGfxParticleSubState.SDK_GfxParticleSubState_Simulate(SubStates[i].CoreObject, elaspe);

                    if (TrailNode != null)
                    {
                        TrailNode.Clear();
                    }

                    if (SubStates[i].MacrossNode != null)
                    {
                        effector.ParticleData.ParticleSystem       = this;
                        effector.ParticleData.ParticleSubState     = SubStates[i];
                        effector.ParticleData.ParticleEmitterShape = SubStates[i].Shape;
                        SubStates[i].MacrossNode.Update(elaspe, effector.ParticleData);
                    }

                    var TransformNode = SubStates[i].TransformNode;
                    if (TransformNode != null)
                    {
                        float tick = 0;
                        if (TransformNode.Loop)
                        {
                            tick = ((EngineNS.CEngine.Instance.EngineTimeSecond - TransformNode.StartTick) % TransformNode.Duration) / TransformNode.Duration;
                        }
                        else
                        {
                            tick = MathHelper.FClamp((EngineNS.CEngine.Instance.EngineTimeSecond - TransformNode.StartTick) / TransformNode.Duration, 0f, 1f);
                        }
                        SubStates[i].TransformNode.SetMatrix(tick);
                    }
                }
            }
        }
        public Vector3 GetDirectionToCenter([Editor.DisplayParamName("粒子系统对象(CGfxParticleSystem)")] CGfxParticleSystem sys, [Editor.DisplayParamName("粒子发射器状态对象(CGfxParticleSubState)")] CGfxParticleSubState substate)
        {
            Vector3 basepos = new Vector3(sys.Matrix.M41 + substate.Position.X,
                                          sys.Matrix.M42 + substate.Position.Y,
                                          sys.Matrix.M43 + substate.Position.Z);

            Vector3 dir = mPose.mPosition - basepos;

            dir.Normalize();
            return(dir);
        }
        public Vector3 GetRotationByCenter([Editor.DisplayParamName("粒子系统对象(CGfxParticleSystem)")] CGfxParticleSystem sys, [Editor.DisplayParamName("粒子发射器状态对象(CGfxParticleSubState)")] CGfxParticleSubState substate, [Editor.DisplayParamName("转向轴(Vector3)")] Vector3 aix)
        {
            Vector3 basepos = new Vector3(sys.Matrix.M41 + substate.Position.X,
                                          sys.Matrix.M42 + substate.Position.Y,
                                          sys.Matrix.M43 + substate.Position.Z);

            Vector3 dir = mPose.mPosition - basepos;

            Vector3.Cross(ref dir, ref aix, out basepos);
            basepos.Normalize();
            return(basepos);
        }
        //宏图中处理逻辑 工具中提供固定形式
        public unsafe void OnParticleStateTick(CGfxParticleSystem sys, CGfxParticleState **pStates, int num, int stateIndex, CGfxParticleSubState state, float elaspe, int pindex)
        {
            for (int i = num - 1; i >= 0; i--)
            {
                if (pindex == 0)
                {
                    state.UpdateParticle(this, elaspe, sys, pStates[i]->Host);
                }

                state.MacrossParticleStateNodeUpdate(this, elaspe, sys, pStates[i]->Host, pStates[i], i);
            }
        }
        //生成ParticleState时的初始数据 宏图中设置
        public virtual unsafe void DoParticleStateBorn(CGfxParticleSystem sys, CGfxParticleState **pStates, CGfxParticleSubState substate, int stateIndex, int particlenum = 0)
        {
            int nowindex = sys.ParticleNumber - particlenum;

            for (int i = 0; i < particlenum; i++)
            {
                if (stateIndex == 0)
                {
                    substate.InitParticle(this, sys, pStates[i]->Host);
                }
                substate.MacrossParticleStateNodeInit(this, sys, pStates[i]->Host, pStates[i], nowindex + i);
                substate.EffectParticleStatePose(ref *pStates[i]);
            }
        }
 public virtual void DoParticleSubStateTick1([EngineNS.Editor.DisplayParamName("粒子发射器状态对象")] CGfxParticleSubState substate)
 {
 }
 //[EngineNS.Editor.MacrossMember(Editor.MacrossMemberAttribute.enMacrossType.Callable | Editor.MacrossMemberAttribute.enMacrossType.Overrideable)]
 //[Editor.MacrossPanelPathAttribute("粒子系统/粒子系统对象(CGfxParticleSystem)/DoParticleSubState")]
 //[EngineNS.Editor.DisplayParamName("粒子发射器状态对象初始华")]
 public virtual void DoParticleSubStateBorn([EngineNS.Editor.DisplayParamName("粒子发射系统对象")] CGfxParticleSystem sys, [EngineNS.Editor.DisplayParamName("粒子发射器状态对象")] CGfxParticleSubState substate, int index)
 {
     if (substate.MacrossNode != null)
     {
         ParticleData.ParticleSubState     = substate;
         ParticleData.ParticleEmitterShape = substate.Shape;
         substate.MacrossNode.Init(ParticleData);
     }
 }