コード例 #1
0
ファイル: Simulator.cs プロジェクト: rlugojr/MengeCS
 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);
 }
コード例 #2
0
        /// <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));
            }
        }
コード例 #3
0
ファイル: Simulator.cs プロジェクト: curds01/MengeCS_junk
        /// <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);
        }
コード例 #4
0
 /// <summary>
 /// Fires this external trigger in the simulator.
 /// </summary>
 public void Fire()
 {
     MengeWrapper.FireExternalTrigger(_name);
 }