private void ProcessGaze(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.Gaze) == 0x00) { return; } target.gazeFactor = Mathf.Max(target.gazeFactor - sim.gazeCumulativeIntensity, 0f); target.gazeFactor += sim.gazeCollision.EvaluateGazePower(target.headTransform.position); target.gazeFactor = Mathf.Clamp01(target.gazeFactor); if (target.gazeFactor > 0.7f) { target.stateMassFunction[(int)State.Focused] = 1f; target.stateMassFunction[(int)State.Bored] = 0f; target.stateMassFunction[(int)State.Chatting] = 0f; target.lazyUpdateLock = true; if (target.socialGroup != null) { target.socialGroup.shouldChat = false; target.socialGroup.StopAllCoroutines(); } } }
private void ProcessGlobal(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.Global) == 0x00) { return; } float global = sim.globalAttentionAmp * GaussianRandom(sim.globalAttentionMean, sim.globalAttentionStDev) + sim.globalAttentionConstOffset + sim.globalTimeCurve.Evaluate(Mathf.Clamp01((Time.time - PresentationData.in_EnterTime) / PresentationData.in_ExpectedTime)); global = Mathf.Clamp(global, -1f, 1f); target.stateMassFunctionInternal[(int)State.Focused] += global; target.stateMassFunctionInternal[(int)State.Bored] -= global; if (target.stateMassFunctionInternal[(int)State.Focused] < 0f) { target.stateMassFunctionInternal[(int)State.Focused] = 0f; } if (target.stateMassFunctionInternal[(int)State.Bored] < 0f) { target.stateMassFunctionInternal[(int)State.Bored] = 0f; } }
private void ProcessSocialGroup(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.SocialGroup) == 0x00 || target.socialGroup == null) { target.stateMassFunction[(int)State.Chatting] = 0f; return; } if (target.socialGroup.shouldChat) { target.stateMassFunction[(int)State.Chatting] = 1f; if (target.currState != State.Chatting) { target.lazyUpdateLock = true; } } else { target.stateMassFunction[(int)State.Chatting] = 0f; if (target.currState == State.Chatting) { target.lazyUpdateLock = true; } } }
private void ProcessFillerWord(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.FillerWords) == 0x00) { return; } }
protected override NodeStatus Tick(Tick <Audience> tick) { CrowdSimulator sim = CrowdSimulator.currSim; Audience target = tick.target; for (int i = 0; i < target.stateMassFunction.Length; ++i) { target.stateMassFunction[i] = 1f / (float)target.stateMassFunction.Length; } return(NodeStatus.SUCCESS); }
protected override NodeStatus Tick(Tick <Audience> tick) { //#if UNITY_EDITOR // Debug.Log("external sim"); //#endif CrowdSimulator sim = CrowdSimulator.currSim; Audience target = tick.target; ProcessSocialGroup(target); ProcessFillerWord(target); ProcessVoiceVolume(target); ProcessGaze(target); //override float sum = 0f; foreach (var mass in target.stateMassFunction) { sum += mass; } for (int i = 0; i < target.stateMassFunction.Length; ++i) { target.stateMassFunction[i] /= sum; } if (sim.deterministic) { float max = target.stateMassFunction.Max(); bool unique = false; for (int i = 0; i < target.stateMassFunction.Length; ++i) { if (target.stateMassFunction[i] == max && !unique) { target.stateMassFunction[i] = 1f; unique = true; } else { target.stateMassFunction[i] = 0f; } } } return(NodeStatus.SUCCESS); }
private void ProcessVoiceVolume(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.VoiceVolume) == 0x00) { return; } target.stateMassFunction[(int)State.Focused] += sim.recordWrapper.fluencyFactor; target.stateMassFunction[(int)State.Bored] -= sim.recordWrapper.fluencyFactor; if (target.stateMassFunction[(int)State.Focused] < 0f) { target.stateMassFunction[(int)State.Focused] = 0f; } if (target.stateMassFunction[(int)State.Bored] < 0f) { target.stateMassFunction[(int)State.Bored] = 0f; } }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ClipUtils clipUtils = animator.gameObject.GetComponent <ClipUtils>(); clipUtils.SetMonsterMode(false); GameObject crowd = GameObject.Find("Crowd"); CrowdSimulator cs = crowd.GetComponent <CrowdSimulator>(); cs.enabled = true; GameObject tableSet = GameObject.Find("TableSetMain"); Rigidbody rb = tableSet.AddComponent <Rigidbody>(); rb.AddForce(new Vector3(-4.0f, 5.0f, 0.0f), ForceMode.Impulse); clipUtils.StartMoveTable(rb); GameObject player = GameObject.Find("Player"); Vector3 pos = player.transform.position; pos.y = 1.077f; clipUtils.StartMovePlayerTowards(player, pos); }
private void ProcessSeatDistribution(Audience target) { CrowdSimulator sim = CrowdSimulator.currSim; if ((sim.simModule & SimModule.SeatDistribution) == 0x00) { return; } float pos = sim.seatPosAttentionCurve.Evaluate(target.normalizedPos); pos = Mathf.Clamp(pos, -1f, 1f); target.stateMassFunctionInternal[(int)State.Focused] += pos; target.stateMassFunctionInternal[(int)State.Bored] -= pos; if (target.stateMassFunctionInternal[(int)State.Focused] < 0f) { target.stateMassFunctionInternal[(int)State.Focused] = 0f; } if (target.stateMassFunctionInternal[(int)State.Bored] < 0f) { target.stateMassFunctionInternal[(int)State.Bored] = 0f; } }
void Start(){ _crowdSim = crowdSimObj.GetComponent<CrowdSimulator> (); StartCoroutine (StartWebSocket_CR ()); }
void Start() { _crowdSim = crowdSimObj.GetComponent <CrowdSimulator> (); StartCoroutine(StartWebSocket_CR()); }