aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Physics/Manager/PhysicsManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.Physics/Manager/PhysicsManager.cs')
-rw-r--r--OpenSim.Physics/Manager/PhysicsManager.cs116
1 files changed, 0 insertions, 116 deletions
diff --git a/OpenSim.Physics/Manager/PhysicsManager.cs b/OpenSim.Physics/Manager/PhysicsManager.cs
deleted file mode 100644
index 291fc7e..0000000
--- a/OpenSim.Physics/Manager/PhysicsManager.cs
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using System.Collections;
30using System.IO;
31using System.Reflection;
32using Axiom.MathLib;
33using OpenSim.Framework.Console;
34
35namespace OpenSim.Physics.Manager
36{
37 /// <summary>
38 /// Description of MyClass.
39 /// </summary>
40 public class PhysicsManager
41 {
42 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
43
44 public PhysicsManager()
45 {
46
47 }
48
49 public PhysicsScene GetPhysicsScene(string engineName)
50 {
51 if (String.IsNullOrEmpty(engineName))
52 {
53 return new NullPhysicsScene();
54 }
55
56 if(_plugins.ContainsKey(engineName))
57 {
58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
59 return _plugins[engineName].GetScene();
60 }
61 else
62 {
63 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
64 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
65 }
66 }
67
68 public void LoadPlugins()
69 {
70 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
71 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
72
73
74 for(int i= 0; i<pluginFiles.Length; i++)
75 {
76 this.AddPlugin(pluginFiles[i]);
77 }
78 }
79
80 private void AddPlugin(string FileName)
81 {
82 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
83
84 foreach (Type pluginType in pluginAssembly.GetTypes())
85 {
86 if (pluginType.IsPublic)
87 {
88 if (!pluginType.IsAbstract)
89 {
90 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
91
92 if (typeInterface != null)
93 {
94 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
95 plug.Init();
96 this._plugins.Add(plug.GetName(),plug);
97
98 }
99
100 typeInterface = null;
101 }
102 }
103 }
104
105 pluginAssembly = null;
106 }
107 }
108
109 public interface IPhysicsPlugin
110 {
111 bool Init();
112 PhysicsScene GetScene();
113 string GetName();
114 void Dispose();
115 }
116}