public bool Initialize(String behaveXml, String sceneXml, String model) { if (MengeWrapper.InitSimulator(behaveXml, sceneXml, model, null)) { uint count = MengeWrapper.AgentCount(); for (uint i = 0; i < count; ++i) { Agent agt = new Agent(); float x = 0; float y = 0; float z = 0; MengeWrapper.GetAgentPosition(i, ref x, ref y, ref z); agt._pos = new Vector3(x, y, z); MengeWrapper.GetAgentOrient(i, ref x, ref y); agt._orient = new Vector2(x, y); agt._class = MengeWrapper.GetAgentClass(i); agt._radius = MengeWrapper.GetAgentRadius(i); _agents.Add(agt); } return(true); } else { System.Console.WriteLine("Failed to initialize simulator."); } return(false); }
/// <summary> /// Populates the trigger list from the simulator. /// </summary> private void FindTriggers() { _triggers = new List <ExternalTrigger>(); int triggerCount = MengeWrapper.ExternalTriggerCount(); for (int i = 0; i < triggerCount; ++i) { string s = Marshal.PtrToStringAnsi(MengeWrapper.ExternalTriggerName(i)); _triggers.Add(new ExternalTrigger(s)); } }
/// <summary> /// Advances the simulation by the current time step. /// </summary> /// <returns>True if evaluation is successful and the simulation can proceed.</returns> public bool DoStep() { bool running = MengeWrapper.DoStep(); for (int i = 0; i < _agents.Count; ++i) { float x = 0, y = 0, z = 0; MengeWrapper.GetAgentPosition((uint)i, ref x, ref y, ref z); _agents[i].Position.Set(x, y, z); } return(true); }
/// <summary> /// Fires this external trigger in the simulator. /// </summary> public void Fire() { MengeWrapper.FireExternalTrigger(_name); }