aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/physics/PhysicsManager.cs
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /src/physics/PhysicsManager.cs
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to '')
-rw-r--r--src/physics/PhysicsManager.cs285
-rw-r--r--src/physics/PhysicsManager.csproj40
2 files changed, 0 insertions, 325 deletions
diff --git a/src/physics/PhysicsManager.cs b/src/physics/PhysicsManager.cs
deleted file mode 100644
index 1fee628..0000000
--- a/src/physics/PhysicsManager.cs
+++ /dev/null
@@ -1,285 +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( String.IsNullOrEmpty( engineName ) )
50 {
51 return new NullPhysicsScene();
52 }
53
54 if(_plugins.ContainsKey(engineName))
55 {
56 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName);
57 return _plugins[engineName].GetScene();
58 }
59 else
60 {
61 string error = String.Format("couldn't find physicsEngine: {0}", engineName);
62 ServerConsole.MainConsole.Instance.WriteLine( error );
63 throw new ArgumentException( error );
64 }
65 }
66
67 public void LoadPlugins()
68 {
69 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
70 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
71
72
73 for(int i= 0; i<pluginFiles.Length; i++)
74 {
75 this.AddPlugin(pluginFiles[i]);
76 }
77 }
78
79 private void AddPlugin(string FileName)
80 {
81 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
82
83 foreach (Type pluginType in pluginAssembly.GetTypes())
84 {
85 if (pluginType.IsPublic)
86 {
87 if (!pluginType.IsAbstract)
88 {
89 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
90
91 if (typeInterface != null)
92 {
93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
94 plug.Init();
95 this._plugins.Add(plug.GetName(),plug);
96
97 }
98
99 typeInterface = null;
100 }
101 }
102 }
103
104 pluginAssembly = null;
105 }
106 }
107 public interface IPhysicsPlugin
108 {
109 bool Init();
110 PhysicsScene GetScene();
111 string GetName();
112 void Dispose();
113 }
114
115 public abstract class PhysicsScene
116 {
117 public static PhysicsScene Null
118 {
119 get
120 {
121 return new NullPhysicsScene();
122 }
123 }
124
125 public abstract PhysicsActor AddAvatar(PhysicsVector position);
126
127 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
128
129 public abstract void Simulate(float timeStep);
130
131 public abstract void GetResults();
132
133 public abstract void SetTerrain(float[] heightMap);
134
135 public abstract bool IsThreaded
136 {
137 get;
138 }
139 }
140
141 public class NullPhysicsScene : PhysicsScene
142 {
143 private static int m_workIndicator;
144
145 public override PhysicsActor AddAvatar(PhysicsVector position)
146 {
147 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position );
148 return PhysicsActor.Null;
149 }
150
151 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
152 {
153 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size );
154 return PhysicsActor.Null;
155 }
156
157 public override void Simulate(float timeStep)
158 {
159 m_workIndicator = ( m_workIndicator + 1 ) % 10;
160
161 ServerConsole.MainConsole.Instance.SetStatus( m_workIndicator.ToString() );
162 }
163
164 public override void GetResults()
165 {
166 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()" );
167 }
168
169 public override void SetTerrain(float[] heightMap)
170 {
171 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length );
172 }
173
174 public override bool IsThreaded
175 {
176 get { return false; }
177 }
178 }
179
180 public abstract class PhysicsActor
181 {
182 public static readonly PhysicsActor Null = new NullPhysicsActor();
183
184 public abstract PhysicsVector Position
185 {
186 get;
187 set;
188 }
189
190 public abstract PhysicsVector Velocity
191 {
192 get;
193 set;
194 }
195
196 public abstract PhysicsVector Acceleration
197 {
198 get;
199 }
200 public abstract bool Flying
201 {
202 get;
203 set;
204 }
205
206 public abstract void AddForce(PhysicsVector force);
207
208 public abstract void SetMomentum(PhysicsVector momentum);
209 }
210
211 public class NullPhysicsActor : PhysicsActor
212 {
213 public override PhysicsVector Position
214 {
215 get
216 {
217 return PhysicsVector.Zero;
218 }
219 set
220 {
221 return;
222 }
223 }
224
225 public override PhysicsVector Velocity
226 {
227 get
228 {
229 return PhysicsVector.Zero;
230 }
231 set
232 {
233 return;
234 }
235 }
236
237 public override PhysicsVector Acceleration
238 {
239 get { return PhysicsVector.Zero; }
240 }
241
242 public override bool Flying
243 {
244 get
245 {
246 return false;
247 }
248 set
249 {
250 return;
251 }
252 }
253
254 public override void AddForce(PhysicsVector force)
255 {
256 return;
257 }
258
259 public override void SetMomentum(PhysicsVector momentum)
260 {
261 return;
262 }
263 }
264
265 public class PhysicsVector
266 {
267 public float X;
268 public float Y;
269 public float Z;
270
271 public PhysicsVector()
272 {
273
274 }
275
276 public PhysicsVector(float x, float y, float z)
277 {
278 X = x;
279 Y = y;
280 Z = z;
281 }
282
283 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
284 }
285}
diff --git a/src/physics/PhysicsManager.csproj b/src/physics/PhysicsManager.csproj
deleted file mode 100644
index 3eadfe7..0000000
--- a/src/physics/PhysicsManager.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <OutputType>Library</OutputType>
4 <RootNamespace>PhysicsManager</RootNamespace>
5 <AssemblyName>PhysicsManager</AssemblyName>
6 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8 <ProjectGuid>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</ProjectGuid>
9 </PropertyGroup>
10 <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
11 <OutputPath>bin\Debug\</OutputPath>
12 <Optimize>False</Optimize>
13 <DefineConstants>DEBUG;TRACE</DefineConstants>
14 <DebugSymbols>True</DebugSymbols>
15 <DebugType>Full</DebugType>
16 <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
17 </PropertyGroup>
18 <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
19 <OutputPath>bin\Release\</OutputPath>
20 <Optimize>True</Optimize>
21 <DefineConstants>TRACE</DefineConstants>
22 <DebugSymbols>False</DebugSymbols>
23 <DebugType>None</DebugType>
24 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
25 </PropertyGroup>
26 <ItemGroup>
27 <Reference Include="System" />
28 <Reference Include="System.Xml" />
29 </ItemGroup>
30 <ItemGroup>
31 <Compile Include="PhysicsManager.cs" />
32 </ItemGroup>
33 <ItemGroup>
34 <ProjectReference Include="..\ServerConsole\ServerConsole\ServerConsole.csproj">
35 <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
36 <Name>ServerConsole</Name>
37 </ProjectReference>
38 </ItemGroup>
39 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
40</Project> \ No newline at end of file