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 void FireParticles() { int num = FireParticles(FireCountPerTime); if (num < FireCountPerTime) { } for (int i = 0; i < SubStates.Length; i++) { SubStates[i].OnParticleStateBorn(Effector.Get(false), this, i); } }
public unsafe void DealParticleStateCompose(float elaspe) { unsafe { CGfxParticle **ppParticles; int num; GetParticles(&ppParticles, &num); //宏图合成最终粒子姿态 if (num > 0) { Effector.Get(false).OnParticleCompose(this, ppParticles, num, elaspe); } } //if (SubParticleSystems != null) //{ // for (int i = 0; i < SubParticleSystems.Count; i++) // { // SubParticleSystems[i].DealDeathParticles(); // } //} }
public unsafe void DealDeathParticles() { unsafe { CGfxParticle **ppParticles; int num; GetDeathParticles(&ppParticles, &num); //处理粒子死亡 for (int i = 0; i < num; i++) { if (TrailNode != null) { TrailNode.DealDeathParticle(ref *ppParticles[i]); } if (TriggerNodes.Count > 0) { for (int j = 0; j < TriggerNodes.Count; j++) { TriggerNodes[j].TriggerDeathEvent(ref ppParticles[i]->FinalPose); } } Effector.Get(false).DoParticleDead(this, ref *ppParticles[i]); ppParticles[i]->Tag = null; } } //if (SubParticleSystems != null) //{ // for (int i = 0; i < SubParticleSystems.Count; i++) // { // SubParticleSystems[i].DealDeathParticles(); // } //} }