aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ConvertToPlugins/src/physics/PhysicsManager.cs
diff options
context:
space:
mode:
authorgareth2007-03-07 19:07:00 +0000
committergareth2007-03-07 19:07:00 +0000
commit2159b3079ec8df2a7337a9d4ea54810b7028c4e1 (patch)
tree5473123011f7a302e63f89ec6ccb4477032fd1db /ConvertToPlugins/src/physics/PhysicsManager.cs
parentImported branch (diff)
downloadopensim-SC_OLD-2159b3079ec8df2a7337a9d4ea54810b7028c4e1.zip
opensim-SC_OLD-2159b3079ec8df2a7337a9d4ea54810b7028c4e1.tar.gz
opensim-SC_OLD-2159b3079ec8df2a7337a9d4ea54810b7028c4e1.tar.bz2
opensim-SC_OLD-2159b3079ec8df2a7337a9d4ea54810b7028c4e1.tar.xz
fixed last screwup
Diffstat (limited to 'ConvertToPlugins/src/physics/PhysicsManager.cs')
-rw-r--r--ConvertToPlugins/src/physics/PhysicsManager.cs167
1 files changed, 0 insertions, 167 deletions
diff --git a/ConvertToPlugins/src/physics/PhysicsManager.cs b/ConvertToPlugins/src/physics/PhysicsManager.cs
deleted file mode 100644
index 0986501..0000000
--- a/ConvertToPlugins/src/physics/PhysicsManager.cs
+++ /dev/null
@@ -1,167 +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;
32
33namespace PhysicsSystem
34{
35 /// <summary>
36 /// Description of MyClass.
37 /// </summary>
38 public class PhysicsManager
39 {
40 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
41
42 public PhysicsManager()
43 {
44
45 }
46
47 public PhysicsScene GetPhysicsScene(string engineName)
48 {
49 if(_plugins.ContainsKey(engineName))
50 {
51 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName);
52 return _plugins[engineName].GetScene();
53 }
54 else
55 {
56 ServerConsole.MainConsole.Instance.WriteLine("couldn't find physicsEngine: "+ engineName);
57 return null;
58 }
59 }
60
61 public void LoadPlugins()
62 {
63 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
64 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
65
66
67 for(int i= 0; i<pluginFiles.Length; i++)
68 {
69 this.AddPlugin(pluginFiles[i]);
70 }
71 }
72
73 private void AddPlugin(string FileName)
74 {
75 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
76
77 foreach (Type pluginType in pluginAssembly.GetTypes())
78 {
79 if (pluginType.IsPublic)
80 {
81 if (!pluginType.IsAbstract)
82 {
83 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
84
85 if (typeInterface != null)
86 {
87 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
88 plug.Init();
89 this._plugins.Add(plug.GetName(),plug);
90
91 }
92
93 typeInterface = null;
94 }
95 }
96 }
97
98 pluginAssembly = null;
99 }
100 }
101 public interface IPhysicsPlugin
102 {
103 bool Init();
104 PhysicsScene GetScene();
105 string GetName();
106 void Dispose();
107 }
108
109 public abstract class PhysicsScene
110 {
111 public abstract PhysicsActor AddAvatar(PhysicsVector position);
112
113 public abstract void Simulate(float timeStep);
114
115 public abstract void GetResults();
116
117 public abstract void SetTerrain(float[] heightMap);
118
119 public abstract bool IsThreaded
120 {
121 get;
122 }
123 }
124
125 public abstract class PhysicsActor
126 {
127 public abstract PhysicsVector Position
128 {
129 get;
130 set;
131 }
132
133 public abstract PhysicsVector Velocity
134 {
135 get;
136 set;
137 }
138
139 public abstract PhysicsVector Acceleration
140 {
141 get;
142 }
143
144 public abstract void AddForce(PhysicsVector force);
145
146 public abstract void SetMomentum(PhysicsVector momentum);
147 }
148
149 public class PhysicsVector
150 {
151 public float X;
152 public float Y;
153 public float Z;
154
155 public PhysicsVector()
156 {
157
158 }
159
160 public PhysicsVector(float x, float y, float z)
161 {
162 X = x;
163 Y = y;
164 Z = z;
165 }
166 }
167}