diff options
author | Adam Frisby | 2007-07-11 08:02:47 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:02:47 +0000 |
commit | 5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |
parent | Who would have known that the only way of specifying utf-8 without preamble, ... (diff) | |
download | opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2 opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz |
* Wiping trunk in prep for Sugilite
Diffstat (limited to 'OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs')
-rw-r--r-- | OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 278 |
1 files changed, 0 insertions, 278 deletions
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs deleted file mode 100644 index 3d8c9aa..0000000 --- a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ /dev/null | |||
@@ -1,278 +0,0 @@ | |||
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.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 | if(_mScene == null) | ||
54 | { | ||
55 | _mScene = new BasicScene(); | ||
56 | } | ||
57 | return(_mScene); | ||
58 | } | ||
59 | |||
60 | public string GetName() | ||
61 | { | ||
62 | return("basicphysics"); | ||
63 | } | ||
64 | |||
65 | public void Dispose() | ||
66 | { | ||
67 | |||
68 | } | ||
69 | } | ||
70 | |||
71 | public class BasicScene :PhysicsScene | ||
72 | { | ||
73 | private List<BasicActor> _actors = new List<BasicActor>(); | ||
74 | private float[] _heightMap; | ||
75 | |||
76 | public BasicScene() | ||
77 | { | ||
78 | |||
79 | } | ||
80 | |||
81 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
82 | { | ||
83 | BasicActor act = new BasicActor(); | ||
84 | act.Position = position; | ||
85 | _actors.Add(act); | ||
86 | return act; | ||
87 | } | ||
88 | |||
89 | public override void RemoveAvatar(PhysicsActor actor) | ||
90 | { | ||
91 | BasicActor act = (BasicActor)actor; | ||
92 | if(_actors.Contains(act)) | ||
93 | { | ||
94 | _actors.Remove(act); | ||
95 | } | ||
96 | |||
97 | } | ||
98 | |||
99 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | ||
100 | { | ||
101 | return null; | ||
102 | } | ||
103 | |||
104 | public override void Simulate(float timeStep) | ||
105 | { | ||
106 | foreach (BasicActor actor in _actors) | ||
107 | { | ||
108 | actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); | ||
109 | actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); | ||
110 | actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); | ||
111 | /*if(actor.Flying) | ||
112 | { | ||
113 | actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep); | ||
118 | } | ||
119 | if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1)) | ||
120 | {*/ | ||
121 | if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256)) | ||
122 | { | ||
123 | actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1; | ||
124 | } | ||
125 | //} | ||
126 | |||
127 | |||
128 | |||
129 | // This code needs sorting out - border crossings etc | ||
130 | /* if(actor.Position.X<0) | ||
131 | { | ||
132 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
133 | actor.Position.X = 0; | ||
134 | actor.Velocity.X = 0; | ||
135 | } | ||
136 | if(actor.Position.Y < 0) | ||
137 | { | ||
138 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
139 | actor.Position.Y = 0; | ||
140 | actor.Velocity.Y = 0; | ||
141 | } | ||
142 | if(actor.Position.X > 255) | ||
143 | { | ||
144 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
145 | actor.Position.X = 255; | ||
146 | actor.Velocity.X = 0; | ||
147 | } | ||
148 | if(actor.Position.Y > 255) | ||
149 | { | ||
150 | ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); | ||
151 | actor.Position.Y = 255; | ||
152 | actor.Velocity.X = 0; | ||
153 | }*/ | ||
154 | } | ||
155 | } | ||
156 | |||
157 | public override void GetResults() | ||
158 | { | ||
159 | |||
160 | } | ||
161 | |||
162 | public override bool IsThreaded | ||
163 | { | ||
164 | get | ||
165 | { | ||
166 | return(false); // for now we won't be multithreaded | ||
167 | } | ||
168 | } | ||
169 | |||
170 | public override void SetTerrain(float[] heightMap) | ||
171 | { | ||
172 | this._heightMap = heightMap; | ||
173 | } | ||
174 | |||
175 | public override void DeleteTerrain() | ||
176 | { | ||
177 | |||
178 | } | ||
179 | } | ||
180 | |||
181 | public class BasicActor : PhysicsActor | ||
182 | { | ||
183 | private PhysicsVector _position; | ||
184 | private PhysicsVector _velocity; | ||
185 | private PhysicsVector _acceleration; | ||
186 | private bool flying; | ||
187 | public BasicActor() | ||
188 | { | ||
189 | _velocity = new PhysicsVector(); | ||
190 | _position = new PhysicsVector(); | ||
191 | _acceleration = new PhysicsVector(); | ||
192 | } | ||
193 | |||
194 | public override bool Flying | ||
195 | { | ||
196 | get | ||
197 | { | ||
198 | return false; | ||
199 | } | ||
200 | set | ||
201 | { | ||
202 | flying= value; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | public override PhysicsVector Position | ||
207 | { | ||
208 | get | ||
209 | { | ||
210 | return _position; | ||
211 | } | ||
212 | set | ||
213 | { | ||
214 | _position = value; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | public override PhysicsVector Velocity | ||
219 | { | ||
220 | get | ||
221 | { | ||
222 | return _velocity; | ||
223 | } | ||
224 | set | ||
225 | { | ||
226 | _velocity = value; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | public override Axiom.MathLib.Quaternion Orientation | ||
231 | { | ||
232 | get | ||
233 | { | ||
234 | return Axiom.MathLib.Quaternion.Identity; | ||
235 | } | ||
236 | set | ||
237 | { | ||
238 | |||
239 | } | ||
240 | } | ||
241 | |||
242 | public override PhysicsVector Acceleration | ||
243 | { | ||
244 | get | ||
245 | { | ||
246 | return _acceleration; | ||
247 | } | ||
248 | |||
249 | } | ||
250 | |||
251 | public override bool Kinematic | ||
252 | { | ||
253 | get | ||
254 | { | ||
255 | return true; | ||
256 | } | ||
257 | set | ||
258 | { | ||
259 | |||
260 | } | ||
261 | } | ||
262 | public void SetAcceleration (PhysicsVector accel) | ||
263 | { | ||
264 | this._acceleration = accel; | ||
265 | } | ||
266 | |||
267 | public override void AddForce(PhysicsVector force) | ||
268 | { | ||
269 | |||
270 | } | ||
271 | |||
272 | public override void SetMomentum(PhysicsVector momentum) | ||
273 | { | ||
274 | |||
275 | } | ||
276 | } | ||
277 | |||
278 | } | ||