示例#1
0
        /// <summary>
        ///     Get a physics scene for the given physics engine and mesher.
        /// </summary>
        /// <param name="physEngineName"></param>
        /// <param name="meshEngineName"></param>
        /// <param name="config"></param>
        /// <param name="scene"></param>
        /// <returns></returns>
        public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config,
                                            IScene scene)
        {
            if (String.IsNullOrEmpty(physEngineName))
            {
                return(new NullPhysicsScene());
            }

            if (String.IsNullOrEmpty(meshEngineName))
            {
                return(new NullPhysicsScene());
            }

            IMesher meshEngine = null;

            if (_MeshPlugins.ContainsKey(meshEngineName))
            {
                meshEngine = _MeshPlugins[meshEngineName].GetMesher(config, scene);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[Physics]: Couldn't find meshing engine: {0}", meshEngineName);
                throw new ArgumentException(String.Format("couldn't find meshing engine: {0}", meshEngineName));
            }

            if (_PhysPlugins.ContainsKey(physEngineName))
            {
                MainConsole.Instance.Debug("[Physics]: Loading physics engine: " + physEngineName);
                PhysicsScene result = _PhysPlugins[physEngineName].GetScene();
                result.Initialize(meshEngine, scene);
                result.PostInitialize(config);
                return(result);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[Physics]: Couldn't find physics engine: {0}", physEngineName);
                throw new ArgumentException(String.Format("couldn't find physics engine: {0}", physEngineName));
            }
        }