diff options
Switched in NameSpaceChanges
Diffstat (limited to 'OpenSim/Region/Physics')
19 files changed, 2425 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs new file mode 100644 index 0000000..177c49d --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System.Reflection; | ||
29 | using System.Runtime.CompilerServices; | ||
30 | using System.Runtime.InteropServices; | ||
31 | |||
32 | // Information about this assembly is defined by the following | ||
33 | // attributes. | ||
34 | // | ||
35 | // change them to the information which is associated with the assembly | ||
36 | // you compile. | ||
37 | |||
38 | [assembly: AssemblyTitle("PhysXplugin")] | ||
39 | [assembly: AssemblyDescription("")] | ||
40 | [assembly: AssemblyConfiguration("")] | ||
41 | [assembly: AssemblyCompany("")] | ||
42 | [assembly: AssemblyProduct("PhysXplugin")] | ||
43 | [assembly: AssemblyCopyright("")] | ||
44 | [assembly: AssemblyTrademark("")] | ||
45 | [assembly: AssemblyCulture("")] | ||
46 | |||
47 | // This sets the default COM visibility of types in the assembly to invisible. | ||
48 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
49 | [assembly: ComVisible(false)] | ||
50 | |||
51 | // The assembly version has following format : | ||
52 | // | ||
53 | // Major.Minor.Build.Revision | ||
54 | // | ||
55 | // You can specify all values by your own or you can build default build and revision | ||
56 | // numbers with the '*' character (the default): | ||
57 | |||
58 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs new file mode 100644 index 0000000..dcb8f3b --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |||
@@ -0,0 +1,294 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Physics.Manager; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Will be the PhysX plugin but for now will be a very basic physics engine | ||
36 | /// </summary> | ||
37 | public class BasicPhysicsPlugin : IPhysicsPlugin | ||
38 | { | ||
39 | private BasicScene _mScene; | ||
40 | |||
41 | public BasicPhysicsPlugin() | ||
42 | { | ||
43 | |||
44 | } | ||
45 | |||
46 | public bool Init() | ||
47 | { | ||
48 | return true; | ||
49 | } | ||
50 | |||
51 | public PhysicsScene GetScene() | ||
52 | { | ||
53 | return new BasicScene(); | ||
54 | } | ||
55 | |||
56 | public string GetName() | ||
57 | { | ||
58 | return("basicphysics"); | ||
59 | } | ||
60 | |||
61 | public void Dispose() | ||
62 | { | ||
63 | |||
64 | } | ||
65 | } | ||
66 | |||
67 | public class BasicScene :PhysicsScene | ||
68 | { | ||
69 | private List<BasicActor> _actors = new List<BasicActor>(); | ||
70 | private float[] _heightMap; | ||
71 | |||
72 | public BasicScene() | ||
73 | { | ||
74 | |||
75 | } | ||
76 | |||
77 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
78 | { | ||
79 | BasicActor act = new BasicActor(); | ||
80 | act.Position = position; | ||
81 | _actors.Add(act); | ||
82 | return act; | ||
83 | } | ||
84 | |||
85 | public override void RemoveAvatar(PhysicsActor actor) | ||
86 | { | ||
87 | BasicActor act = (BasicActor)actor; | ||
88 | if(_actors.Contains(act)) | ||
89 | { | ||
90 | _actors.Remove(act); | ||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | ||
96 | { | ||
97 | return null; | ||
98 | } | ||
99 | |||
100 | public override void Simulate(float timeStep) | ||
101 | { | ||
102 | foreach (BasicActor actor in _actors) | ||
103 | { | ||
104 | actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); | ||
105 | actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); | ||
106 | actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); | ||
107 | /*if(actor.Flying) | ||
108 | { | ||
109 | actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep); | ||
114 | } | ||
115 | if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1)) | ||
116 | {*/ | ||
117 | if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256)) | ||
118 | { | ||
119 | actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | if (actor.Position.Y < 0) | ||
124 | { | ||
125 | actor.Position.Y = 0; | ||
126 | } | ||
127 | else if (actor.Position.Y > 256) | ||
128 | { | ||
129 | actor.Position.Y = 256; | ||
130 | } | ||
131 | |||
132 | if (actor.Position.X < 0) | ||
133 | { | ||
134 | actor.Position.X = 0; | ||
135 | } | ||
136 | if (actor.Position.X > 256) | ||
137 | { | ||
138 | actor.Position.X = 256; | ||
139 | } | ||
140 | } | ||
141 | //} | ||
142 | |||
143 | |||
144 | |||
145 | // This code needs sorting out - border crossings etc | ||
146 | /* if(actor.Position.X<0) | ||
147 | { | ||
148 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
149 | actor.Position.X = 0; | ||
150 | actor.Velocity.X = 0; | ||
151 | } | ||
152 | if(actor.Position.Y < 0) | ||
153 | { | ||
154 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
155 | actor.Position.Y = 0; | ||
156 | actor.Velocity.Y = 0; | ||
157 | } | ||
158 | if(actor.Position.X > 255) | ||
159 | { | ||
160 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
161 | actor.Position.X = 255; | ||
162 | actor.Velocity.X = 0; | ||
163 | } | ||
164 | if(actor.Position.Y > 255) | ||
165 | { | ||
166 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
167 | actor.Position.Y = 255; | ||
168 | actor.Velocity.X = 0; | ||
169 | }*/ | ||
170 | } | ||
171 | } | ||
172 | |||
173 | public override void GetResults() | ||
174 | { | ||
175 | |||
176 | } | ||
177 | |||
178 | public override bool IsThreaded | ||
179 | { | ||
180 | get | ||
181 | { | ||
182 | return(false); // for now we won't be multithreaded | ||
183 | } | ||
184 | } | ||
185 | |||
186 | public override void SetTerrain(float[] heightMap) | ||
187 | { | ||
188 | this._heightMap = heightMap; | ||
189 | } | ||
190 | |||
191 | public override void DeleteTerrain() | ||
192 | { | ||
193 | |||
194 | } | ||
195 | } | ||
196 | |||
197 | public class BasicActor : PhysicsActor | ||
198 | { | ||
199 | private PhysicsVector _position; | ||
200 | private PhysicsVector _velocity; | ||
201 | private PhysicsVector _acceleration; | ||
202 | private bool flying; | ||
203 | public BasicActor() | ||
204 | { | ||
205 | _velocity = new PhysicsVector(); | ||
206 | _position = new PhysicsVector(); | ||
207 | _acceleration = new PhysicsVector(); | ||
208 | } | ||
209 | |||
210 | public override bool Flying | ||
211 | { | ||
212 | get | ||
213 | { | ||
214 | return false; | ||
215 | } | ||
216 | set | ||
217 | { | ||
218 | flying= value; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | public override PhysicsVector Position | ||
223 | { | ||
224 | get | ||
225 | { | ||
226 | return _position; | ||
227 | } | ||
228 | set | ||
229 | { | ||
230 | _position = value; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | public override PhysicsVector Velocity | ||
235 | { | ||
236 | get | ||
237 | { | ||
238 | return _velocity; | ||
239 | } | ||
240 | set | ||
241 | { | ||
242 | _velocity = value; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | public override Axiom.MathLib.Quaternion Orientation | ||
247 | { | ||
248 | get | ||
249 | { | ||
250 | return Axiom.MathLib.Quaternion.Identity; | ||
251 | } | ||
252 | set | ||
253 | { | ||
254 | |||
255 | } | ||
256 | } | ||
257 | |||
258 | public override PhysicsVector Acceleration | ||
259 | { | ||
260 | get | ||
261 | { | ||
262 | return _acceleration; | ||
263 | } | ||
264 | |||
265 | } | ||
266 | |||
267 | public override bool Kinematic | ||
268 | { | ||
269 | get | ||
270 | { | ||
271 | return true; | ||
272 | } | ||
273 | set | ||
274 | { | ||
275 | |||
276 | } | ||
277 | } | ||
278 | public void SetAcceleration (PhysicsVector accel) | ||
279 | { | ||
280 | this._acceleration = accel; | ||
281 | } | ||
282 | |||
283 | public override void AddForce(PhysicsVector force) | ||
284 | { | ||
285 | |||
286 | } | ||
287 | |||
288 | public override void SetMomentum(PhysicsVector momentum) | ||
289 | { | ||
290 | |||
291 | } | ||
292 | } | ||
293 | |||
294 | } | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj new file mode 100644 index 0000000..7dad533 --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj | |||
@@ -0,0 +1,93 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{15B4FEF3-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Region.Physics.BasicPhysicsPlugin</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Region.Physics.BasicPhysicsPlugin</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Axiom.MathLib.dll" > | ||
62 | <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System" > | ||
66 | <HintPath>System.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | </ItemGroup> | ||
70 | <ItemGroup> | ||
71 | <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj"> | ||
72 | <Name>OpenSim.Region.Physics.Manager</Name> | ||
73 | <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project> | ||
74 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
75 | <Private>False</Private> | ||
76 | </ProjectReference> | ||
77 | </ItemGroup> | ||
78 | <ItemGroup> | ||
79 | <Compile Include="AssemblyInfo.cs"> | ||
80 | <SubType>Code</SubType> | ||
81 | </Compile> | ||
82 | <Compile Include="BasicPhysicsPlugin.cs"> | ||
83 | <SubType>Code</SubType> | ||
84 | </Compile> | ||
85 | </ItemGroup> | ||
86 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
87 | <PropertyGroup> | ||
88 | <PreBuildEvent> | ||
89 | </PreBuildEvent> | ||
90 | <PostBuildEvent> | ||
91 | </PostBuildEvent> | ||
92 | </PropertyGroup> | ||
93 | </Project> | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build new file mode 100644 index 0000000..6cf26ca --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build | |||
@@ -0,0 +1,42 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Region.Physics.BasicPhysicsPlugin" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Region.Physics.BasicPhysicsPlugin" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="AssemblyInfo.cs" /> | ||
15 | <include name="BasicPhysicsPlugin.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="../../../../bin/Axiom.MathLib.dll" /> | ||
23 | <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" /> | ||
24 | <include name="System.dll" /> | ||
25 | </references> | ||
26 | </csc> | ||
27 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" /> | ||
28 | <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/> | ||
29 | <copy todir="${project::get-base-directory()}/../../../../bin/Physics/"> | ||
30 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
31 | <include name="*.dll"/> | ||
32 | <include name="*.exe"/> | ||
33 | </fileset> | ||
34 | </copy> | ||
35 | </target> | ||
36 | <target name="clean"> | ||
37 | <delete dir="${bin.dir}" failonerror="false" /> | ||
38 | <delete dir="${obj.dir}" failonerror="false" /> | ||
39 | </target> | ||
40 | <target name="doc" description="Creates documentation."> | ||
41 | </target> | ||
42 | </project> | ||
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs new file mode 100644 index 0000000..132f64a --- /dev/null +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System.Reflection; | ||
29 | using System.Runtime.CompilerServices; | ||
30 | using System.Runtime.InteropServices; | ||
31 | |||
32 | // Information about this assembly is defined by the following | ||
33 | // attributes. | ||
34 | // | ||
35 | // change them to the information which is associated with the assembly | ||
36 | // you compile. | ||
37 | |||
38 | [assembly: AssemblyTitle("PhysicsManager")] | ||
39 | [assembly: AssemblyDescription("")] | ||
40 | [assembly: AssemblyConfiguration("")] | ||
41 | [assembly: AssemblyCompany("")] | ||
42 | [assembly: AssemblyProduct("PhysicsManager")] | ||
43 | [assembly: AssemblyCopyright("")] | ||
44 | [assembly: AssemblyTrademark("")] | ||
45 | [assembly: AssemblyCulture("")] | ||
46 | |||
47 | // This sets the default COM visibility of types in the assembly to invisible. | ||
48 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
49 | [assembly: ComVisible(false)] | ||
50 | |||
51 | // The assembly version has following format : | ||
52 | // | ||
53 | // Major.Minor.Build.Revision | ||
54 | // | ||
55 | // You can specify all values by your own or you can build default build and revision | ||
56 | // numbers with the '*' character (the default): | ||
57 | |||
58 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj new file mode 100644 index 0000000..f340400 --- /dev/null +++ b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj | |||
@@ -0,0 +1,112 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{F4FF31EB-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Region.Physics.Manager</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Region.Physics.Manager</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Axiom.MathLib.dll" > | ||
62 | <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System" > | ||
66 | <HintPath>System.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Xml" > | ||
70 | <HintPath>System.Xml.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | </ItemGroup> | ||
74 | <ItemGroup> | ||
75 | <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj"> | ||
76 | <Name>OpenSim.Framework</Name> | ||
77 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | ||
78 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
79 | <Private>False</Private> | ||
80 | </ProjectReference> | ||
81 | <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj"> | ||
82 | <Name>OpenSim.Framework.Console</Name> | ||
83 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> | ||
84 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
85 | <Private>False</Private> | ||
86 | </ProjectReference> | ||
87 | </ItemGroup> | ||
88 | <ItemGroup> | ||
89 | <Compile Include="AssemblyInfo.cs"> | ||
90 | <SubType>Code</SubType> | ||
91 | </Compile> | ||
92 | <Compile Include="PhysicsActor.cs"> | ||
93 | <SubType>Code</SubType> | ||
94 | </Compile> | ||
95 | <Compile Include="PhysicsManager.cs"> | ||
96 | <SubType>Code</SubType> | ||
97 | </Compile> | ||
98 | <Compile Include="PhysicsScene.cs"> | ||
99 | <SubType>Code</SubType> | ||
100 | </Compile> | ||
101 | <Compile Include="PhysicsVector.cs"> | ||
102 | <SubType>Code</SubType> | ||
103 | </Compile> | ||
104 | </ItemGroup> | ||
105 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
106 | <PropertyGroup> | ||
107 | <PreBuildEvent> | ||
108 | </PreBuildEvent> | ||
109 | <PostBuildEvent> | ||
110 | </PostBuildEvent> | ||
111 | </PropertyGroup> | ||
112 | </Project> | ||
diff --git a/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build new file mode 100644 index 0000000..4b7ce81 --- /dev/null +++ b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build | |||
@@ -0,0 +1,47 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Region.Physics.Manager" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Region.Physics.Manager" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="AssemblyInfo.cs" /> | ||
15 | <include name="PhysicsActor.cs" /> | ||
16 | <include name="PhysicsManager.cs" /> | ||
17 | <include name="PhysicsScene.cs" /> | ||
18 | <include name="PhysicsVector.cs" /> | ||
19 | </sources> | ||
20 | <references basedir="${project::get-base-directory()}"> | ||
21 | <lib> | ||
22 | <include name="${project::get-base-directory()}" /> | ||
23 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
24 | </lib> | ||
25 | <include name="../../../../bin/Axiom.MathLib.dll" /> | ||
26 | <include name="../../../../bin/OpenSim.Framework.dll" /> | ||
27 | <include name="../../../../bin/OpenSim.Framework.Console.dll" /> | ||
28 | <include name="System.dll" /> | ||
29 | <include name="System.Xml.dll" /> | ||
30 | </references> | ||
31 | </csc> | ||
32 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" /> | ||
33 | <mkdir dir="${project::get-base-directory()}/../../../../bin/"/> | ||
34 | <copy todir="${project::get-base-directory()}/../../../../bin/"> | ||
35 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
36 | <include name="*.dll"/> | ||
37 | <include name="*.exe"/> | ||
38 | </fileset> | ||
39 | </copy> | ||
40 | </target> | ||
41 | <target name="clean"> | ||
42 | <delete dir="${bin.dir}" failonerror="false" /> | ||
43 | <delete dir="${obj.dir}" failonerror="false" /> | ||
44 | </target> | ||
45 | <target name="doc" description="Creates documentation."> | ||
46 | </target> | ||
47 | </project> | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs new file mode 100644 index 0000000..6366fb8 --- /dev/null +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Physics.Manager | ||
33 | { | ||
34 | public abstract class PhysicsActor | ||
35 | { | ||
36 | public static PhysicsActor Null | ||
37 | { | ||
38 | get | ||
39 | { | ||
40 | return new NullPhysicsActor(); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public abstract PhysicsVector Position | ||
45 | { | ||
46 | get; | ||
47 | set; | ||
48 | } | ||
49 | |||
50 | public abstract PhysicsVector Velocity | ||
51 | { | ||
52 | get; | ||
53 | set; | ||
54 | } | ||
55 | |||
56 | public abstract PhysicsVector Acceleration | ||
57 | { | ||
58 | get; | ||
59 | } | ||
60 | |||
61 | public abstract Axiom.MathLib.Quaternion Orientation | ||
62 | { | ||
63 | get; | ||
64 | set; | ||
65 | } | ||
66 | |||
67 | public abstract bool Flying | ||
68 | { | ||
69 | get; | ||
70 | set; | ||
71 | } | ||
72 | |||
73 | public abstract bool Kinematic | ||
74 | { | ||
75 | get; | ||
76 | set; | ||
77 | } | ||
78 | |||
79 | public abstract void AddForce(PhysicsVector force); | ||
80 | |||
81 | public abstract void SetMomentum(PhysicsVector momentum); | ||
82 | } | ||
83 | |||
84 | public class NullPhysicsActor : PhysicsActor | ||
85 | { | ||
86 | public override PhysicsVector Position | ||
87 | { | ||
88 | get | ||
89 | { | ||
90 | return PhysicsVector.Zero; | ||
91 | } | ||
92 | set | ||
93 | { | ||
94 | return; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public override PhysicsVector Velocity | ||
99 | { | ||
100 | get | ||
101 | { | ||
102 | return PhysicsVector.Zero; | ||
103 | } | ||
104 | set | ||
105 | { | ||
106 | return; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | public override Axiom.MathLib.Quaternion Orientation | ||
111 | { | ||
112 | get | ||
113 | { | ||
114 | return Axiom.MathLib.Quaternion.Identity; | ||
115 | } | ||
116 | set | ||
117 | { | ||
118 | |||
119 | } | ||
120 | } | ||
121 | |||
122 | public override PhysicsVector Acceleration | ||
123 | { | ||
124 | get { return PhysicsVector.Zero; } | ||
125 | } | ||
126 | |||
127 | public override bool Flying | ||
128 | { | ||
129 | get | ||
130 | { | ||
131 | return false; | ||
132 | } | ||
133 | set | ||
134 | { | ||
135 | return; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | public override bool Kinematic | ||
140 | { | ||
141 | get | ||
142 | { | ||
143 | return true; | ||
144 | } | ||
145 | set | ||
146 | { | ||
147 | return; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | public override void AddForce(PhysicsVector force) | ||
152 | { | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | public override void SetMomentum(PhysicsVector momentum) | ||
157 | { | ||
158 | return; | ||
159 | } | ||
160 | } | ||
161 | } | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsManager.cs b/OpenSim/Region/Physics/Manager/PhysicsManager.cs new file mode 100644 index 0000000..efccb36 --- /dev/null +++ b/OpenSim/Region/Physics/Manager/PhysicsManager.cs | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Collections; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Axiom.MathLib; | ||
34 | using OpenSim.Framework.Console; | ||
35 | |||
36 | namespace OpenSim.Physics.Manager | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Description of MyClass. | ||
40 | /// </summary> | ||
41 | public class PhysicsManager | ||
42 | { | ||
43 | private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>(); | ||
44 | |||
45 | public PhysicsManager() | ||
46 | { | ||
47 | |||
48 | } | ||
49 | |||
50 | public PhysicsScene GetPhysicsScene(string engineName) | ||
51 | { | ||
52 | if (String.IsNullOrEmpty(engineName)) | ||
53 | { | ||
54 | return new NullPhysicsScene(); | ||
55 | } | ||
56 | |||
57 | if(_plugins.ContainsKey(engineName)) | ||
58 | { | ||
59 | OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName); | ||
60 | return _plugins[engineName].GetScene(); | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName); | ||
65 | throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName)); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public void LoadPlugins() | ||
70 | { | ||
71 | string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics"); | ||
72 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); | ||
73 | |||
74 | |||
75 | for(int i= 0; i<pluginFiles.Length; i++) | ||
76 | { | ||
77 | this.AddPlugin(pluginFiles[i]); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | private void AddPlugin(string FileName) | ||
82 | { | ||
83 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
84 | |||
85 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
86 | { | ||
87 | if (pluginType.IsPublic) | ||
88 | { | ||
89 | if (!pluginType.IsAbstract) | ||
90 | { | ||
91 | Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); | ||
92 | |||
93 | if (typeInterface != null) | ||
94 | { | ||
95 | IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
96 | plug.Init(); | ||
97 | this._plugins.Add(plug.GetName(),plug); | ||
98 | |||
99 | } | ||
100 | |||
101 | typeInterface = null; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | |||
106 | pluginAssembly = null; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | public interface IPhysicsPlugin | ||
111 | { | ||
112 | bool Init(); | ||
113 | PhysicsScene GetScene(); | ||
114 | string GetName(); | ||
115 | void Dispose(); | ||
116 | } | ||
117 | } | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs new file mode 100644 index 0000000..0901c2f --- /dev/null +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using OpenSim.Framework.Console; | ||
32 | |||
33 | namespace OpenSim.Physics.Manager | ||
34 | { | ||
35 | public abstract class PhysicsScene | ||
36 | { | ||
37 | public static PhysicsScene Null | ||
38 | { | ||
39 | get | ||
40 | { | ||
41 | return new NullPhysicsScene(); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | public abstract PhysicsActor AddAvatar(PhysicsVector position); | ||
46 | |||
47 | public abstract void RemoveAvatar(PhysicsActor actor); | ||
48 | |||
49 | public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); | ||
50 | |||
51 | public abstract void Simulate(float timeStep); | ||
52 | |||
53 | public abstract void GetResults(); | ||
54 | |||
55 | public abstract void SetTerrain(float[] heightMap); | ||
56 | |||
57 | public abstract void DeleteTerrain(); | ||
58 | |||
59 | public abstract bool IsThreaded | ||
60 | { | ||
61 | get; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public class NullPhysicsScene : PhysicsScene | ||
66 | { | ||
67 | private static int m_workIndicator; | ||
68 | |||
69 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
70 | { | ||
71 | OpenSim.Framework.Console.MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position); | ||
72 | return PhysicsActor.Null; | ||
73 | } | ||
74 | |||
75 | public override void RemoveAvatar(PhysicsActor actor) | ||
76 | { | ||
77 | |||
78 | } | ||
79 | |||
80 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | ||
81 | { | ||
82 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : AddPrim({0},{1})", position, size); | ||
83 | return PhysicsActor.Null; | ||
84 | } | ||
85 | |||
86 | public override void Simulate(float timeStep) | ||
87 | { | ||
88 | m_workIndicator = (m_workIndicator + 1) % 10; | ||
89 | |||
90 | //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString()); | ||
91 | } | ||
92 | |||
93 | public override void GetResults() | ||
94 | { | ||
95 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : GetResults()"); | ||
96 | } | ||
97 | |||
98 | public override void SetTerrain(float[] heightMap) | ||
99 | { | ||
100 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); | ||
101 | } | ||
102 | |||
103 | public override void DeleteTerrain() | ||
104 | { | ||
105 | |||
106 | } | ||
107 | |||
108 | public override bool IsThreaded | ||
109 | { | ||
110 | get { return false; } | ||
111 | } | ||
112 | } | ||
113 | } | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs new file mode 100644 index 0000000..888dbb5 --- /dev/null +++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Physics.Manager | ||
33 | { | ||
34 | public class PhysicsVector | ||
35 | { | ||
36 | public float X; | ||
37 | public float Y; | ||
38 | public float Z; | ||
39 | |||
40 | public PhysicsVector() | ||
41 | { | ||
42 | |||
43 | } | ||
44 | |||
45 | public PhysicsVector(float x, float y, float z) | ||
46 | { | ||
47 | X = x; | ||
48 | Y = y; | ||
49 | Z = z; | ||
50 | } | ||
51 | |||
52 | public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f); | ||
53 | } | ||
54 | } | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs new file mode 100644 index 0000000..b49c8da --- /dev/null +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System.Reflection; | ||
29 | using System.Runtime.CompilerServices; | ||
30 | using System.Runtime.InteropServices; | ||
31 | |||
32 | // Information about this assembly is defined by the following | ||
33 | // attributes. | ||
34 | // | ||
35 | // change them to the information which is associated with the assembly | ||
36 | // you compile. | ||
37 | |||
38 | [assembly: AssemblyTitle("RealPhysXplugin")] | ||
39 | [assembly: AssemblyDescription("")] | ||
40 | [assembly: AssemblyConfiguration("")] | ||
41 | [assembly: AssemblyCompany("")] | ||
42 | [assembly: AssemblyProduct("RealPhysXplugin")] | ||
43 | [assembly: AssemblyCopyright("")] | ||
44 | [assembly: AssemblyTrademark("")] | ||
45 | [assembly: AssemblyCulture("")] | ||
46 | |||
47 | // This sets the default COM visibility of types in the assembly to invisible. | ||
48 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
49 | [assembly: ComVisible(false)] | ||
50 | |||
51 | // The assembly version has following format : | ||
52 | // | ||
53 | // Major.Minor.Build.Revision | ||
54 | // | ||
55 | // You can specify all values by your own or you can build default build and revision | ||
56 | // numbers with the '*' character (the default): | ||
57 | |||
58 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs new file mode 100644 index 0000000..8aca851 --- /dev/null +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -0,0 +1,456 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Physics.Manager; | ||
31 | using Ode.NET; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.OdePlugin | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// ODE plugin | ||
37 | /// </summary> | ||
38 | public class OdePlugin : IPhysicsPlugin | ||
39 | { | ||
40 | private OdeScene _mScene; | ||
41 | |||
42 | public OdePlugin() | ||
43 | { | ||
44 | |||
45 | } | ||
46 | |||
47 | public bool Init() | ||
48 | { | ||
49 | return true; | ||
50 | } | ||
51 | |||
52 | public PhysicsScene GetScene() | ||
53 | { | ||
54 | if (_mScene == null) | ||
55 | { | ||
56 | _mScene = new OdeScene(); | ||
57 | } | ||
58 | return (_mScene); | ||
59 | } | ||
60 | |||
61 | public string GetName() | ||
62 | { | ||
63 | return ("OpenDynamicsEngine"); | ||
64 | } | ||
65 | |||
66 | public void Dispose() | ||
67 | { | ||
68 | |||
69 | } | ||
70 | } | ||
71 | |||
72 | public class OdeScene : PhysicsScene | ||
73 | { | ||
74 | static public IntPtr world; | ||
75 | static public IntPtr space; | ||
76 | static private IntPtr contactgroup; | ||
77 | static private IntPtr LandGeom; | ||
78 | //static private IntPtr Land; | ||
79 | private double[] _heightmap; | ||
80 | static private d.NearCallback nearCallback = near; | ||
81 | private List<OdeCharacter> _characters = new List<OdeCharacter>(); | ||
82 | private static d.ContactGeom[] contacts = new d.ContactGeom[30]; | ||
83 | private static d.Contact contact; | ||
84 | |||
85 | public OdeScene() | ||
86 | { | ||
87 | contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; | ||
88 | contact.surface.mu = d.Infinity; | ||
89 | contact.surface.mu2 = 0.0f; | ||
90 | contact.surface.bounce = 0.1f; | ||
91 | contact.surface.bounce_vel = 0.1f; | ||
92 | contact.surface.soft_cfm = 0.01f; | ||
93 | |||
94 | world = d.WorldCreate(); | ||
95 | space = d.HashSpaceCreate(IntPtr.Zero); | ||
96 | contactgroup = d.JointGroupCreate(0); | ||
97 | d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); | ||
98 | //d.WorldSetCFM(world, 1e-5f); | ||
99 | d.WorldSetAutoDisableFlag(world, false); | ||
100 | d.WorldSetContactSurfaceLayer(world, 0.001f); | ||
101 | // d.CreatePlane(space, 0, 0, 1, 0); | ||
102 | this._heightmap = new double[65536]; | ||
103 | } | ||
104 | |||
105 | // This function blatantly ripped off from BoxStack.cs | ||
106 | static private void near(IntPtr space, IntPtr g1, IntPtr g2) | ||
107 | { | ||
108 | IntPtr b1 = d.GeomGetBody(g1); | ||
109 | IntPtr b2 = d.GeomGetBody(g2); | ||
110 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | ||
111 | return; | ||
112 | |||
113 | int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); | ||
114 | for (int i = 0; i < count; ++i) | ||
115 | { | ||
116 | contact.geom = contacts[i]; | ||
117 | IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); | ||
118 | d.JointAttach(joint, b1, b2); | ||
119 | } | ||
120 | |||
121 | } | ||
122 | |||
123 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
124 | { | ||
125 | PhysicsVector pos = new PhysicsVector(); | ||
126 | pos.X = position.X; | ||
127 | pos.Y = position.Y; | ||
128 | pos.Z = position.Z + 20; | ||
129 | OdeCharacter newAv = new OdeCharacter(this, pos); | ||
130 | this._characters.Add(newAv); | ||
131 | return newAv; | ||
132 | } | ||
133 | |||
134 | public override void RemoveAvatar(PhysicsActor actor) | ||
135 | { | ||
136 | |||
137 | } | ||
138 | |||
139 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | ||
140 | { | ||
141 | PhysicsVector pos = new PhysicsVector(); | ||
142 | pos.X = position.X; | ||
143 | pos.Y = position.Y; | ||
144 | pos.Z = position.Z; | ||
145 | PhysicsVector siz = new PhysicsVector(); | ||
146 | siz.X = size.X; | ||
147 | siz.Y = size.Y; | ||
148 | siz.Z = size.Z; | ||
149 | return new OdePrim(); | ||
150 | } | ||
151 | |||
152 | public override void Simulate(float timeStep) | ||
153 | { | ||
154 | foreach (OdeCharacter actor in _characters) | ||
155 | { | ||
156 | actor.Move(timeStep * 5f); | ||
157 | } | ||
158 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); | ||
159 | d.WorldQuickStep(world, timeStep * 5f); | ||
160 | d.JointGroupEmpty(contactgroup); | ||
161 | foreach (OdeCharacter actor in _characters) | ||
162 | { | ||
163 | actor.UpdatePosition(); | ||
164 | } | ||
165 | |||
166 | } | ||
167 | |||
168 | public override void GetResults() | ||
169 | { | ||
170 | |||
171 | } | ||
172 | |||
173 | public override bool IsThreaded | ||
174 | { | ||
175 | get | ||
176 | { | ||
177 | return (false); // for now we won't be multithreaded | ||
178 | } | ||
179 | } | ||
180 | |||
181 | public override void SetTerrain(float[] heightMap) | ||
182 | { | ||
183 | for (int i = 0; i < 65536; i++) | ||
184 | { | ||
185 | // this._heightmap[i] = (double)heightMap[i]; | ||
186 | // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...) | ||
187 | int x = i & 0xff; | ||
188 | int y = i >> 8; | ||
189 | this._heightmap[i] = (double)heightMap[x * 256 + y]; | ||
190 | } | ||
191 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | ||
192 | d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); | ||
193 | d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); | ||
194 | LandGeom = d.CreateHeightfield(space, HeightmapData, 1); | ||
195 | d.Matrix3 R = new d.Matrix3(); | ||
196 | |||
197 | Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0)); | ||
198 | Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0)); | ||
199 | //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1)); | ||
200 | |||
201 | q1 = q1 * q2; | ||
202 | //q1 = q1 * q3; | ||
203 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(); | ||
204 | float angle = 0; | ||
205 | q1.ToAngleAxis(ref angle, ref v3); | ||
206 | |||
207 | d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); | ||
208 | d.GeomSetRotation(LandGeom, ref R); | ||
209 | d.GeomSetPosition(LandGeom, 128, 128, 0); | ||
210 | } | ||
211 | |||
212 | public override void DeleteTerrain() | ||
213 | { | ||
214 | |||
215 | } | ||
216 | } | ||
217 | |||
218 | public class OdeCharacter : PhysicsActor | ||
219 | { | ||
220 | private PhysicsVector _position; | ||
221 | private PhysicsVector _velocity; | ||
222 | private PhysicsVector _acceleration; | ||
223 | private bool flying; | ||
224 | //private float gravityAccel; | ||
225 | private IntPtr BoundingCapsule; | ||
226 | IntPtr capsule_geom; | ||
227 | d.Mass capsule_mass; | ||
228 | |||
229 | public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) | ||
230 | { | ||
231 | _velocity = new PhysicsVector(); | ||
232 | _position = pos; | ||
233 | _acceleration = new PhysicsVector(); | ||
234 | d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); | ||
235 | capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); | ||
236 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); | ||
237 | d.BodySetMass(BoundingCapsule, ref capsule_mass); | ||
238 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); | ||
239 | d.GeomSetBody(capsule_geom, BoundingCapsule); | ||
240 | } | ||
241 | |||
242 | public override bool Flying | ||
243 | { | ||
244 | get | ||
245 | { | ||
246 | return flying; | ||
247 | } | ||
248 | set | ||
249 | { | ||
250 | flying = value; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | public override PhysicsVector Position | ||
255 | { | ||
256 | get | ||
257 | { | ||
258 | return _position; | ||
259 | } | ||
260 | set | ||
261 | { | ||
262 | _position = value; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | public override PhysicsVector Velocity | ||
267 | { | ||
268 | get | ||
269 | { | ||
270 | return _velocity; | ||
271 | } | ||
272 | set | ||
273 | { | ||
274 | _velocity = value; | ||
275 | } | ||
276 | } | ||
277 | |||
278 | public override bool Kinematic | ||
279 | { | ||
280 | get | ||
281 | { | ||
282 | return false; | ||
283 | } | ||
284 | set | ||
285 | { | ||
286 | |||
287 | } | ||
288 | } | ||
289 | |||
290 | public override Axiom.MathLib.Quaternion Orientation | ||
291 | { | ||
292 | get | ||
293 | { | ||
294 | return Axiom.MathLib.Quaternion.Identity; | ||
295 | } | ||
296 | set | ||
297 | { | ||
298 | |||
299 | } | ||
300 | } | ||
301 | |||
302 | public override PhysicsVector Acceleration | ||
303 | { | ||
304 | get | ||
305 | { | ||
306 | return _acceleration; | ||
307 | } | ||
308 | |||
309 | } | ||
310 | public void SetAcceleration(PhysicsVector accel) | ||
311 | { | ||
312 | this._acceleration = accel; | ||
313 | } | ||
314 | |||
315 | public override void AddForce(PhysicsVector force) | ||
316 | { | ||
317 | |||
318 | } | ||
319 | |||
320 | public override void SetMomentum(PhysicsVector momentum) | ||
321 | { | ||
322 | |||
323 | } | ||
324 | |||
325 | public void Move(float timeStep) | ||
326 | { | ||
327 | PhysicsVector vec = new PhysicsVector(); | ||
328 | vec.X = this._velocity.X * timeStep; | ||
329 | vec.Y = this._velocity.Y * timeStep; | ||
330 | if (flying) | ||
331 | { | ||
332 | vec.Z = (this._velocity.Z + 0.5f) * timeStep; | ||
333 | } | ||
334 | d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); | ||
335 | } | ||
336 | |||
337 | public void UpdatePosition() | ||
338 | { | ||
339 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); | ||
340 | this._position.X = vec.X; | ||
341 | this._position.Y = vec.Y; | ||
342 | this._position.Z = vec.Z+1.0f; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | public class OdePrim : PhysicsActor | ||
347 | { | ||
348 | private PhysicsVector _position; | ||
349 | private PhysicsVector _velocity; | ||
350 | private PhysicsVector _acceleration; | ||
351 | |||
352 | public OdePrim() | ||
353 | { | ||
354 | _velocity = new PhysicsVector(); | ||
355 | _position = new PhysicsVector(); | ||
356 | _acceleration = new PhysicsVector(); | ||
357 | } | ||
358 | public override bool Flying | ||
359 | { | ||
360 | get | ||
361 | { | ||
362 | return false; //no flying prims for you | ||
363 | } | ||
364 | set | ||
365 | { | ||
366 | |||
367 | } | ||
368 | } | ||
369 | public override PhysicsVector Position | ||
370 | { | ||
371 | get | ||
372 | { | ||
373 | PhysicsVector pos = new PhysicsVector(); | ||
374 | // PhysicsVector vec = this._prim.Position; | ||
375 | //pos.X = vec.X; | ||
376 | //pos.Y = vec.Y; | ||
377 | //pos.Z = vec.Z; | ||
378 | return pos; | ||
379 | |||
380 | } | ||
381 | set | ||
382 | { | ||
383 | /*PhysicsVector vec = value; | ||
384 | PhysicsVector pos = new PhysicsVector(); | ||
385 | pos.X = vec.X; | ||
386 | pos.Y = vec.Y; | ||
387 | pos.Z = vec.Z; | ||
388 | this._prim.Position = pos;*/ | ||
389 | } | ||
390 | } | ||
391 | |||
392 | public override PhysicsVector Velocity | ||
393 | { | ||
394 | get | ||
395 | { | ||
396 | return _velocity; | ||
397 | } | ||
398 | set | ||
399 | { | ||
400 | _velocity = value; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | public override bool Kinematic | ||
405 | { | ||
406 | get | ||
407 | { | ||
408 | return false; | ||
409 | //return this._prim.Kinematic; | ||
410 | } | ||
411 | set | ||
412 | { | ||
413 | //this._prim.Kinematic = value; | ||
414 | } | ||
415 | } | ||
416 | |||
417 | public override Axiom.MathLib.Quaternion Orientation | ||
418 | { | ||
419 | get | ||
420 | { | ||
421 | Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); | ||
422 | return res; | ||
423 | } | ||
424 | set | ||
425 | { | ||
426 | |||
427 | } | ||
428 | } | ||
429 | |||
430 | public override PhysicsVector Acceleration | ||
431 | { | ||
432 | get | ||
433 | { | ||
434 | return _acceleration; | ||
435 | } | ||
436 | |||
437 | } | ||
438 | public void SetAcceleration(PhysicsVector accel) | ||
439 | { | ||
440 | this._acceleration = accel; | ||
441 | } | ||
442 | |||
443 | public override void AddForce(PhysicsVector force) | ||
444 | { | ||
445 | |||
446 | } | ||
447 | |||
448 | public override void SetMomentum(PhysicsVector momentum) | ||
449 | { | ||
450 | |||
451 | } | ||
452 | |||
453 | |||
454 | } | ||
455 | |||
456 | } | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj new file mode 100644 index 0000000..490c681 --- /dev/null +++ b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj | |||
@@ -0,0 +1,97 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{90620634-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Region.Physics.OdePlugin</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Region.Physics.OdePlugin</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Axiom.MathLib.dll" > | ||
62 | <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="Ode.NET.dll" > | ||
66 | <HintPath>..\..\..\..\bin\Ode.NET.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System" > | ||
70 | <HintPath>System.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | </ItemGroup> | ||
74 | <ItemGroup> | ||
75 | <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj"> | ||
76 | <Name>OpenSim.Region.Physics.Manager</Name> | ||
77 | <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project> | ||
78 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
79 | <Private>False</Private> | ||
80 | </ProjectReference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <Compile Include="AssemblyInfo.cs"> | ||
84 | <SubType>Code</SubType> | ||
85 | </Compile> | ||
86 | <Compile Include="OdePlugin.cs"> | ||
87 | <SubType>Code</SubType> | ||
88 | </Compile> | ||
89 | </ItemGroup> | ||
90 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
91 | <PropertyGroup> | ||
92 | <PreBuildEvent> | ||
93 | </PreBuildEvent> | ||
94 | <PostBuildEvent> | ||
95 | </PostBuildEvent> | ||
96 | </PropertyGroup> | ||
97 | </Project> | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build new file mode 100644 index 0000000..07b9386 --- /dev/null +++ b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build | |||
@@ -0,0 +1,43 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Region.Physics.OdePlugin" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Region.Physics.OdePlugin" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="AssemblyInfo.cs" /> | ||
15 | <include name="OdePlugin.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="../../../../bin/Axiom.MathLib.dll" /> | ||
23 | <include name="../../../../bin/Ode.NET.dll" /> | ||
24 | <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" /> | ||
25 | <include name="System.dll" /> | ||
26 | </references> | ||
27 | </csc> | ||
28 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" /> | ||
29 | <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/> | ||
30 | <copy todir="${project::get-base-directory()}/../../../../bin/Physics/"> | ||
31 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
32 | <include name="*.dll"/> | ||
33 | <include name="*.exe"/> | ||
34 | </fileset> | ||
35 | </copy> | ||
36 | </target> | ||
37 | <target name="clean"> | ||
38 | <delete dir="${bin.dir}" failonerror="false" /> | ||
39 | <delete dir="${obj.dir}" failonerror="false" /> | ||
40 | </target> | ||
41 | <target name="doc" description="Creates documentation."> | ||
42 | </target> | ||
43 | </project> | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs new file mode 100644 index 0000000..b49c8da --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System.Reflection; | ||
29 | using System.Runtime.CompilerServices; | ||
30 | using System.Runtime.InteropServices; | ||
31 | |||
32 | // Information about this assembly is defined by the following | ||
33 | // attributes. | ||
34 | // | ||
35 | // change them to the information which is associated with the assembly | ||
36 | // you compile. | ||
37 | |||
38 | [assembly: AssemblyTitle("RealPhysXplugin")] | ||
39 | [assembly: AssemblyDescription("")] | ||
40 | [assembly: AssemblyConfiguration("")] | ||
41 | [assembly: AssemblyCompany("")] | ||
42 | [assembly: AssemblyProduct("RealPhysXplugin")] | ||
43 | [assembly: AssemblyCopyright("")] | ||
44 | [assembly: AssemblyTrademark("")] | ||
45 | [assembly: AssemblyCulture("")] | ||
46 | |||
47 | // This sets the default COM visibility of types in the assembly to invisible. | ||
48 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
49 | [assembly: ComVisible(false)] | ||
50 | |||
51 | // The assembly version has following format : | ||
52 | // | ||
53 | // Major.Minor.Build.Revision | ||
54 | // | ||
55 | // You can specify all values by your own or you can build default build and revision | ||
56 | // numbers with the '*' character (the default): | ||
57 | |||
58 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj new file mode 100644 index 0000000..77da908 --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj | |||
@@ -0,0 +1,97 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{A6D191D8-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Region.Physics.PhysXPlugin</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Region.Physics.PhysXPlugin</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\..\..\bin\Physics\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Axiom.MathLib.dll" > | ||
62 | <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="PhysX_Wrapper_Dotnet.dll" > | ||
66 | <HintPath>..\..\..\..\bin\PhysX_Wrapper_Dotnet.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System" > | ||
70 | <HintPath>System.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | </ItemGroup> | ||
74 | <ItemGroup> | ||
75 | <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj"> | ||
76 | <Name>OpenSim.Region.Physics.Manager</Name> | ||
77 | <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project> | ||
78 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
79 | <Private>False</Private> | ||
80 | </ProjectReference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <Compile Include="AssemblyInfo.cs"> | ||
84 | <SubType>Code</SubType> | ||
85 | </Compile> | ||
86 | <Compile Include="PhysXPlugin.cs"> | ||
87 | <SubType>Code</SubType> | ||
88 | </Compile> | ||
89 | </ItemGroup> | ||
90 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
91 | <PropertyGroup> | ||
92 | <PreBuildEvent> | ||
93 | </PreBuildEvent> | ||
94 | <PostBuildEvent> | ||
95 | </PostBuildEvent> | ||
96 | </PropertyGroup> | ||
97 | </Project> | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build new file mode 100644 index 0000000..c1a9608 --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build | |||
@@ -0,0 +1,43 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Region.Physics.PhysXPlugin" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Region.Physics.PhysXPlugin" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="AssemblyInfo.cs" /> | ||
15 | <include name="PhysXPlugin.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="../../../../bin/Axiom.MathLib.dll" /> | ||
23 | <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" /> | ||
24 | <include name="../../../../bin/PhysX_Wrapper_Dotnet.dll" /> | ||
25 | <include name="System.dll" /> | ||
26 | </references> | ||
27 | </csc> | ||
28 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" /> | ||
29 | <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/> | ||
30 | <copy todir="${project::get-base-directory()}/../../../../bin/Physics/"> | ||
31 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
32 | <include name="*.dll"/> | ||
33 | <include name="*.exe"/> | ||
34 | </fileset> | ||
35 | </copy> | ||
36 | </target> | ||
37 | <target name="clean"> | ||
38 | <delete dir="${bin.dir}" failonerror="false" /> | ||
39 | <delete dir="${obj.dir}" failonerror="false" /> | ||
40 | </target> | ||
41 | <target name="doc" description="Creates documentation."> | ||
42 | </target> | ||
43 | </project> | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs new file mode 100644 index 0000000..8bf794b --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | |||
@@ -0,0 +1,424 @@ | |||
1 | /*/* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Physics.Manager; | ||
31 | using PhysXWrapper; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Will be the PhysX plugin but for now will be a very basic physics engine | ||
37 | /// </summary> | ||
38 | public class PhysXPlugin : IPhysicsPlugin | ||
39 | { | ||
40 | private PhysXScene _mScene; | ||
41 | |||
42 | public PhysXPlugin() | ||
43 | { | ||
44 | |||
45 | } | ||
46 | |||
47 | public bool Init() | ||
48 | { | ||
49 | return true; | ||
50 | } | ||
51 | |||
52 | public PhysicsScene GetScene() | ||
53 | { | ||
54 | if(_mScene == null) | ||
55 | { | ||
56 | _mScene = new PhysXScene(); | ||
57 | } | ||
58 | return(_mScene); | ||
59 | } | ||
60 | |||
61 | public string GetName() | ||
62 | { | ||
63 | return("RealPhysX"); | ||
64 | } | ||
65 | |||
66 | public void Dispose() | ||
67 | { | ||
68 | |||
69 | } | ||
70 | } | ||
71 | |||
72 | public class PhysXScene :PhysicsScene | ||
73 | { | ||
74 | private List<PhysXCharacter> _characters = new List<PhysXCharacter>(); | ||
75 | private List<PhysXPrim> _prims = new List<PhysXPrim>(); | ||
76 | private float[] _heightMap = null; | ||
77 | private NxPhysicsSDK mySdk; | ||
78 | private NxScene scene; | ||
79 | |||
80 | public PhysXScene() | ||
81 | { | ||
82 | mySdk = NxPhysicsSDK.CreateSDK(); | ||
83 | Console.WriteLine("Sdk created - now creating scene"); | ||
84 | scene = mySdk.CreateScene(); | ||
85 | |||
86 | } | ||
87 | |||
88 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
89 | { | ||
90 | Vec3 pos = new Vec3(); | ||
91 | pos.X = position.X; | ||
92 | pos.Y = position.Y; | ||
93 | pos.Z = position.Z; | ||
94 | PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos)); | ||
95 | act.Position = position; | ||
96 | _characters.Add(act); | ||
97 | return act; | ||
98 | } | ||
99 | |||
100 | public override void RemoveAvatar(PhysicsActor actor) | ||
101 | { | ||
102 | |||
103 | } | ||
104 | |||
105 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | ||
106 | { | ||
107 | Vec3 pos = new Vec3(); | ||
108 | pos.X = position.X; | ||
109 | pos.Y = position.Y; | ||
110 | pos.Z = position.Z; | ||
111 | Vec3 siz = new Vec3(); | ||
112 | siz.X = size.X; | ||
113 | siz.Y = size.Y; | ||
114 | siz.Z = size.Z; | ||
115 | PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz)); | ||
116 | _prims.Add(act); | ||
117 | return act; | ||
118 | } | ||
119 | public override void Simulate(float timeStep) | ||
120 | { | ||
121 | try | ||
122 | { | ||
123 | foreach (PhysXCharacter actor in _characters) | ||
124 | { | ||
125 | actor.Move(timeStep); | ||
126 | } | ||
127 | scene.Simulate(timeStep); | ||
128 | scene.FetchResults(); | ||
129 | scene.UpdateControllers(); | ||
130 | |||
131 | foreach (PhysXCharacter actor in _characters) | ||
132 | { | ||
133 | actor.UpdatePosition(); | ||
134 | } | ||
135 | } | ||
136 | catch (Exception e) | ||
137 | { | ||
138 | Console.WriteLine(e.Message); | ||
139 | } | ||
140 | |||
141 | } | ||
142 | |||
143 | public override void GetResults() | ||
144 | { | ||
145 | |||
146 | } | ||
147 | |||
148 | public override bool IsThreaded | ||
149 | { | ||
150 | get | ||
151 | { | ||
152 | return(false); // for now we won't be multithreaded | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public override void SetTerrain(float[] heightMap) | ||
157 | { | ||
158 | if (this._heightMap != null) | ||
159 | { | ||
160 | Console.WriteLine("PhysX - deleting old terrain"); | ||
161 | this.scene.DeleteTerrain(); | ||
162 | } | ||
163 | this._heightMap = heightMap; | ||
164 | this.scene.AddTerrain(heightMap); | ||
165 | } | ||
166 | |||
167 | public override void DeleteTerrain() | ||
168 | { | ||
169 | this.scene.DeleteTerrain(); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | public class PhysXCharacter : PhysicsActor | ||
174 | { | ||
175 | private PhysicsVector _position; | ||
176 | private PhysicsVector _velocity; | ||
177 | private PhysicsVector _acceleration; | ||
178 | private NxCharacter _character; | ||
179 | private bool flying; | ||
180 | private float gravityAccel; | ||
181 | |||
182 | public PhysXCharacter(NxCharacter character) | ||
183 | { | ||
184 | _velocity = new PhysicsVector(); | ||
185 | _position = new PhysicsVector(); | ||
186 | _acceleration = new PhysicsVector(); | ||
187 | _character = character; | ||
188 | } | ||
189 | |||
190 | public override bool Flying | ||
191 | { | ||
192 | get | ||
193 | { | ||
194 | return flying; | ||
195 | } | ||
196 | set | ||
197 | { | ||
198 | flying = value; | ||
199 | } | ||
200 | } | ||
201 | |||
202 | public override PhysicsVector Position | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | return _position; | ||
207 | } | ||
208 | set | ||
209 | { | ||
210 | _position = value; | ||
211 | Vec3 ps = new Vec3(); | ||
212 | ps.X = value.X; | ||
213 | ps.Y = value.Y; | ||
214 | ps.Z = value.Z; | ||
215 | this._character.Position = ps; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | public override PhysicsVector Velocity | ||
220 | { | ||
221 | get | ||
222 | { | ||
223 | return _velocity; | ||
224 | } | ||
225 | set | ||
226 | { | ||
227 | _velocity = value; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | public override bool Kinematic | ||
232 | { | ||
233 | get | ||
234 | { | ||
235 | return false; | ||
236 | } | ||
237 | set | ||
238 | { | ||
239 | |||
240 | } | ||
241 | } | ||
242 | |||
243 | public override Axiom.MathLib.Quaternion Orientation | ||
244 | { | ||
245 | get | ||
246 | { | ||
247 | return Axiom.MathLib.Quaternion.Identity; | ||
248 | } | ||
249 | set | ||
250 | { | ||
251 | |||
252 | } | ||
253 | } | ||
254 | |||
255 | public override PhysicsVector Acceleration | ||
256 | { | ||
257 | get | ||
258 | { | ||
259 | return _acceleration; | ||
260 | } | ||
261 | |||
262 | } | ||
263 | public void SetAcceleration (PhysicsVector accel) | ||
264 | { | ||
265 | this._acceleration = accel; | ||
266 | } | ||
267 | |||
268 | public override void AddForce(PhysicsVector force) | ||
269 | { | ||
270 | |||
271 | } | ||
272 | |||
273 | public override void SetMomentum(PhysicsVector momentum) | ||
274 | { | ||
275 | |||
276 | } | ||
277 | |||
278 | public void Move(float timeStep) | ||
279 | { | ||
280 | Vec3 vec = new Vec3(); | ||
281 | vec.X = this._velocity.X * timeStep; | ||
282 | vec.Y = this._velocity.Y * timeStep; | ||
283 | if(flying) | ||
284 | { | ||
285 | vec.Z = ( this._velocity.Z) * timeStep; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | gravityAccel+= -9.8f; | ||
290 | vec.Z = (gravityAccel + this._velocity.Z) * timeStep; | ||
291 | } | ||
292 | int res = this._character.Move(vec); | ||
293 | if(res == 1) | ||
294 | { | ||
295 | gravityAccel = 0; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | public void UpdatePosition() | ||
300 | { | ||
301 | Vec3 vec = this._character.Position; | ||
302 | this._position.X = vec.X; | ||
303 | this._position.Y = vec.Y; | ||
304 | this._position.Z = vec.Z; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | public class PhysXPrim : PhysicsActor | ||
309 | { | ||
310 | private PhysicsVector _position; | ||
311 | private PhysicsVector _velocity; | ||
312 | private PhysicsVector _acceleration; | ||
313 | private NxActor _prim; | ||
314 | |||
315 | public PhysXPrim(NxActor prim) | ||
316 | { | ||
317 | _velocity = new PhysicsVector(); | ||
318 | _position = new PhysicsVector(); | ||
319 | _acceleration = new PhysicsVector(); | ||
320 | _prim = prim; | ||
321 | } | ||
322 | public override bool Flying | ||
323 | { | ||
324 | get | ||
325 | { | ||
326 | return false; //no flying prims for you | ||
327 | } | ||
328 | set | ||
329 | { | ||
330 | |||
331 | } | ||
332 | } | ||
333 | public override PhysicsVector Position | ||
334 | { | ||
335 | get | ||
336 | { | ||
337 | PhysicsVector pos = new PhysicsVector(); | ||
338 | Vec3 vec = this._prim.Position; | ||
339 | pos.X = vec.X; | ||
340 | pos.Y = vec.Y; | ||
341 | pos.Z = vec.Z; | ||
342 | return pos; | ||
343 | |||
344 | } | ||
345 | set | ||
346 | { | ||
347 | PhysicsVector vec = value; | ||
348 | Vec3 pos = new Vec3(); | ||
349 | pos.X = vec.X; | ||
350 | pos.Y = vec.Y; | ||
351 | pos.Z = vec.Z; | ||
352 | this._prim.Position = pos; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | public override PhysicsVector Velocity | ||
357 | { | ||
358 | get | ||
359 | { | ||
360 | return _velocity; | ||
361 | } | ||
362 | set | ||
363 | { | ||
364 | _velocity = value; | ||
365 | } | ||
366 | } | ||
367 | |||
368 | public override bool Kinematic | ||
369 | { | ||
370 | get | ||
371 | { | ||
372 | return this._prim.Kinematic; | ||
373 | } | ||
374 | set | ||
375 | { | ||
376 | this._prim.Kinematic = value; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | public override Axiom.MathLib.Quaternion Orientation | ||
381 | { | ||
382 | get | ||
383 | { | ||
384 | Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); | ||
385 | PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); | ||
386 | res.w = quat.W; | ||
387 | res.x = quat.X; | ||
388 | res.y = quat.Y; | ||
389 | res.z = quat.Z; | ||
390 | return res; | ||
391 | } | ||
392 | set | ||
393 | { | ||
394 | |||
395 | } | ||
396 | } | ||
397 | |||
398 | public override PhysicsVector Acceleration | ||
399 | { | ||
400 | get | ||
401 | { | ||
402 | return _acceleration; | ||
403 | } | ||
404 | |||
405 | } | ||
406 | public void SetAcceleration (PhysicsVector accel) | ||
407 | { | ||
408 | this._acceleration = accel; | ||
409 | } | ||
410 | |||
411 | public override void AddForce(PhysicsVector force) | ||
412 | { | ||
413 | |||
414 | } | ||
415 | |||
416 | public override void SetMomentum(PhysicsVector momentum) | ||
417 | { | ||
418 | |||
419 | } | ||
420 | |||
421 | |||
422 | } | ||
423 | |||
424 | } | ||