private void WriteAnimationEvents(List <CRAnimationEvData> listAnimationEventData, MemoryStream ms, BinaryWriter bw, Dictionary <string, int> dictionaryEmitterNameIdInBake, Dictionary <GameObject, int> dictionaryGameObjectIdInBake) { bw.Write(listAnimationEventData.Count); foreach (CRAnimationEvData evData in listAnimationEventData) { int idEmitterInBkae = dictionaryEmitterNameIdInBake[evData.emitterName_]; bw.Write(idEmitterInBkae); if (evData.type_ == CRAnimationEvData.EEventDataType.Contact) { bw.Write((int)CRAnimationEvData.EEventDataType.Contact); CRContactEvData ceData = (CRContactEvData)evData; int idGameObjectInFileA = dictionaryGameObjectIdInBake[ceData.GameObjectA]; int idGameObjectInFileB = dictionaryGameObjectIdInBake[ceData.GameObjectB]; bw.Write(idGameObjectInFileA); bw.Write(idGameObjectInFileB); bw.Write(ceData.position_.x); bw.Write(ceData.position_.y); bw.Write(ceData.position_.z); bw.Write(ceData.velocityA_.x); bw.Write(ceData.velocityA_.y); bw.Write(ceData.velocityA_.z); bw.Write(ceData.velocityB_.x); bw.Write(ceData.velocityB_.y); bw.Write(ceData.velocityB_.z); bw.Write(ceData.relativeSpeed_N_); bw.Write(ceData.relativeSpeed_T_); bw.Write(ceData.relativeP_N_); bw.Write(ceData.relativeP_T_); } } }
public override void ProcessAnimationEvent(CRAnimationEvData aeData) { if (enabled) { CRContactEvData ceData = (CRContactEvData) aeData; #if UNITY_5_4_OR_NEWER emitParams_.position = ceData.position_; #endif float numParticles = 0; //emit particles based on the selected magnitude of the contact switch (magnitude_) { case EMagnitude.RelativeVeloctiyN: numParticles = (int)(ceData.relativeSpeed_N_ * emitfactor_); break; case EMagnitude.RelativeVelocityT: numParticles = (int)(ceData.relativeSpeed_T_ * emitfactor_); break; case EMagnitude.RelativeMomentumN: numParticles = (int)(ceData.relativeP_N_ * emitfactor_); break; case EMagnitude.RelativeMomentumT: numParticles = (int)(ceData.relativeP_T_ * emitfactor_); break; } #if UNITY_5_4_OR_NEWER particleSystem_.Emit(emitParams_, (int)numParticles); #else particleSystem_.transform.localPosition = ceData.position_; particleSystem_.Emit((int)numParticles); #endif } }