Esempio n. 1
0
 public void Initialize()
 {
     // Loading ODEPlugin
     cbt = new OdePlugin();
     // Loading Zero Mesher
     imp = new ZeroMesherPlugin();
     // Getting Physics Scene
     ps = cbt.GetScene("test");
     // Initializing Physics Scene.
     ps.Initialise(imp.GetMesher(), null);
     float[] _heightmap = new float[256 * 256];
     for (int i = 0; i < (256 * 256); i++)
     {
         _heightmap[i] = 21f;
     }
     ps.SetTerrain(_heightmap);
 }
 public void Initialize()
 {
     // Loading ODEPlugin
     cbt = new OdePlugin();
     // Loading Zero Mesher
     imp = new ZeroMesherPlugin();
     // Getting Physics Scene
     ps = cbt.GetScene("test");
     // Initializing Physics Scene.
     ps.Initialise(imp.GetMesher(),null);
     float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
     for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
     {
         _heightmap[i] = 21f;
     }
     ps.SetTerrain(_heightmap);
 }
Esempio n. 3
0
        public void Initialize()
        {
            IConfigSource TopConfig = new IniConfigSource();
            IConfig config = TopConfig.AddConfig("Startup");
            config.Set("DecodedSculptMapPath","j2kDecodeCache");

            // Loading ODEPlugin
            cbt = new OdePlugin();
            // Loading Zero Mesher
            imp = new ZeroMesherPlugin();
            // Getting Physics Scene
            ps = cbt.GetScene("test");
            // Initializing Physics Scene.
            ps.Initialise(imp.GetMesher(TopConfig),null);
            float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
            for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
            {
                _heightmap[i] = 21f;
            }
            ps.SetTerrain(_heightmap);
        }
Esempio n. 4
0
        public void Initialize()
        {
            IConfigSource TopConfig = new IniConfigSource();
            IConfig       config    = TopConfig.AddConfig("Startup");

            config.Set("DecodedSculptMapPath", "j2kDecodeCache");

            // Loading ODEPlugin
            cbt = new OdePlugin();
            // Loading Zero Mesher
            imp = new ZeroMesherPlugin();
            // Getting Physics Scene
            ps = cbt.GetScene("test");
            // Initializing Physics Scene.
            ps.Initialise(imp.GetMesher(TopConfig), null);
            float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
            for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
            {
                _heightmap[i] = 21f;
            }
            ps.SetTerrain(_heightmap);
        }
Esempio n. 5
0
        /// <summary>
        /// Load plugins from an assembly at the given path
        /// </summary>
        /// <param name="assemblyPath"></param>
        public void LoadPluginsFromAssembly(string assemblyPath)
        {
            // TODO / NOTE
            // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from
            // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll'
            // using the LoadFrom context. The use of this context can result in unexpected behavior
            // for serialization, casting and dependency resolution. In almost all cases, it is recommended
            // that the LoadFrom context be avoided. This can be done by installing assemblies in the
            // Global Assembly Cache or in the ApplicationBase directory and using Assembly.
            // Load when explicitly loading assemblies.
            Assembly pluginAssembly = null;

            Type[] types = null;

            try
            {
                pluginAssembly = Assembly.LoadFrom(assemblyPath);
            }
            catch (Exception ex)
            {
                m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex);
            }

            if (pluginAssembly != null)
            {
                try
                {
                    types = pluginAssembly.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " +
                                ex.LoaderExceptions[0].Message, ex);
                }
                catch (Exception ex)
                {
                    m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex);
                }

                if (types != null)
                {
                    foreach (Type pluginType in types)
                    {
                        if (pluginType.IsPublic)
                        {
                            if (!pluginType.IsAbstract)
                            {
                                Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin", true);

                                if (physTypeInterface != null)
                                {
                                    IPhysicsPlugin plug =
                                        (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                                    plug.Init();
                                    if (!_PhysPlugins.ContainsKey(plug.GetName()))
                                    {
                                        _PhysPlugins.Add(plug.GetName(), plug);
                                        m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
                                    }
                                }

                                Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin", true);

                                if (meshTypeInterface != null)
                                {
                                    IMeshingPlugin plug =
                                        (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                                    if (!_MeshPlugins.ContainsKey(plug.GetName()))
                                    {
                                        _MeshPlugins.Add(plug.GetName(), plug);
                                        m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName());
                                    }
                                }

                                physTypeInterface = null;
                                meshTypeInterface = null;
                            }
                        }
                    }
                }
            }

            pluginAssembly = null;
        }