diff options
author | gareth | 2007-05-21 19:05:09 +0000 |
---|---|---|
committer | gareth | 2007-05-21 19:05:09 +0000 |
commit | b253f3db48022cead7755eaabbb217c7ed60e213 (patch) | |
tree | d22252b28c36057fc54b1a16b653186a29734089 | |
parent | Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim ,... (diff) | |
download | opensim-SC-b253f3db48022cead7755eaabbb217c7ed60e213.zip opensim-SC-b253f3db48022cead7755eaabbb217c7ed60e213.tar.gz opensim-SC-b253f3db48022cead7755eaabbb217c7ed60e213.tar.bz2 opensim-SC-b253f3db48022cead7755eaabbb217c7ed60e213.tar.xz |
Merged the new ODE stuff
-rw-r--r-- | OpenSim.Physics/OdePlugin/OdePlugin.cs | 908 |
1 files changed, 456 insertions, 452 deletions
diff --git a/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim.Physics/OdePlugin/OdePlugin.cs index 599dea8..137e44d 100644 --- a/OpenSim.Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim.Physics/OdePlugin/OdePlugin.cs | |||
@@ -1,452 +1,456 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | 2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are met: | 5 | * modification, are permitted provided that the following conditions are met: |
6 | * * Redistributions of source code must retain the above copyright | 6 | * * Redistributions of source code must retain the above copyright |
7 | * notice, this list of conditions and the following disclaimer. | 7 | * notice, this list of conditions and the following disclaimer. |
8 | * * Redistributions in binary form must reproduce the above copyright | 8 | * * Redistributions in binary form must reproduce the above copyright |
9 | * notice, this list of conditions and the following disclaimer in the | 9 | * notice, this list of conditions and the following disclaimer in the |
10 | * documentation and/or other materials provided with the distribution. | 10 | * documentation and/or other materials provided with the distribution. |
11 | * * Neither the name of the <organization> nor the | 11 | * * Neither the name of the <organization> nor the |
12 | * names of its contributors may be used to endorse or promote products | 12 | * names of its contributors may be used to endorse or promote products |
13 | * derived from this software without specific prior written permission. | 13 | * derived from this software without specific prior written permission. |
14 | * | 14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | 15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY |
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | 18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY |
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenSim.Physics.Manager; | 29 | using OpenSim.Physics.Manager; |
30 | using Ode.NET; | 30 | using Ode.NET; |
31 | 31 | ||
32 | namespace OpenSim.Physics.OdePlugin | 32 | namespace OpenSim.Physics.OdePlugin |
33 | { | 33 | { |
34 | /// <summary> | 34 | /// <summary> |
35 | /// ODE plugin | 35 | /// ODE plugin |
36 | /// </summary> | 36 | /// </summary> |
37 | public class OdePlugin : IPhysicsPlugin | 37 | public class OdePlugin : IPhysicsPlugin |
38 | { | 38 | { |
39 | private OdeScene _mScene; | 39 | private OdeScene _mScene; |
40 | 40 | ||
41 | public OdePlugin() | 41 | public OdePlugin() |
42 | { | 42 | { |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | public bool Init() | 46 | public bool Init() |
47 | { | 47 | { |
48 | return true; | 48 | return true; |
49 | } | 49 | } |
50 | 50 | ||
51 | public PhysicsScene GetScene() | 51 | public PhysicsScene GetScene() |
52 | { | 52 | { |
53 | if (_mScene == null) | 53 | if (_mScene == null) |
54 | { | 54 | { |
55 | _mScene = new OdeScene(); | 55 | _mScene = new OdeScene(); |
56 | } | 56 | } |
57 | return (_mScene); | 57 | return (_mScene); |
58 | } | 58 | } |
59 | 59 | ||
60 | public string GetName() | 60 | public string GetName() |
61 | { | 61 | { |
62 | return ("OpenDynamicsEngine"); | 62 | return ("OpenDynamicsEngine"); |
63 | } | 63 | } |
64 | 64 | ||
65 | public void Dispose() | 65 | public void Dispose() |
66 | { | 66 | { |
67 | 67 | ||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | public class OdeScene : PhysicsScene | 71 | public class OdeScene : PhysicsScene |
72 | { | 72 | { |
73 | static public IntPtr world; | 73 | static public IntPtr world; |
74 | static public IntPtr space; | 74 | static public IntPtr space; |
75 | static private IntPtr contactgroup; | 75 | static private IntPtr contactgroup; |
76 | static private IntPtr LandGeom; | 76 | static private IntPtr LandGeom; |
77 | //static private IntPtr Land; | 77 | //static private IntPtr Land; |
78 | private double[] _heightmap; | 78 | private double[] _heightmap; |
79 | static private d.NearCallback nearCallback = near; | 79 | static private d.NearCallback nearCallback = near; |
80 | private List<OdeCharacter> _characters = new List<OdeCharacter>(); | 80 | private List<OdeCharacter> _characters = new List<OdeCharacter>(); |
81 | private static d.ContactGeom[] contacts = new d.ContactGeom[30]; | 81 | private static d.ContactGeom[] contacts = new d.ContactGeom[30]; |
82 | private static d.Contact contact; | 82 | private static d.Contact contact; |
83 | 83 | ||
84 | public OdeScene() | 84 | public OdeScene() |
85 | { | 85 | { |
86 | contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; | 86 | contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; |
87 | contact.surface.mu = d.Infinity; | 87 | contact.surface.mu = d.Infinity; |
88 | contact.surface.mu2 = 0.0f; | 88 | contact.surface.mu2 = 0.0f; |
89 | contact.surface.bounce = 0.1f; | 89 | contact.surface.bounce = 0.1f; |
90 | contact.surface.bounce_vel = 0.1f; | 90 | contact.surface.bounce_vel = 0.1f; |
91 | contact.surface.soft_cfm = 0.01f; | 91 | contact.surface.soft_cfm = 0.01f; |
92 | 92 | ||
93 | world = d.WorldCreate(); | 93 | world = d.WorldCreate(); |
94 | space = d.HashSpaceCreate(IntPtr.Zero); | 94 | space = d.HashSpaceCreate(IntPtr.Zero); |
95 | contactgroup = d.JointGroupCreate(0); | 95 | contactgroup = d.JointGroupCreate(0); |
96 | d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); | 96 | d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); |
97 | //d.WorldSetCFM(world, 1e-5f); | 97 | //d.WorldSetCFM(world, 1e-5f); |
98 | d.WorldSetAutoDisableFlag(world, false); | 98 | d.WorldSetAutoDisableFlag(world, false); |
99 | d.WorldSetContactSurfaceLayer(world, 0.001f); | 99 | d.WorldSetContactSurfaceLayer(world, 0.001f); |
100 | // d.CreatePlane(space, 0, 0, 1, 0); | 100 | // d.CreatePlane(space, 0, 0, 1, 0); |
101 | this._heightmap = new double[65536]; | 101 | this._heightmap = new double[65536]; |
102 | } | 102 | } |
103 | 103 | ||
104 | // This function blatantly ripped off from BoxStack.cs | 104 | // This function blatantly ripped off from BoxStack.cs |
105 | static private void near(IntPtr space, IntPtr g1, IntPtr g2) | 105 | static private void near(IntPtr space, IntPtr g1, IntPtr g2) |
106 | { | 106 | { |
107 | //Console.WriteLine("collision callback"); | 107 | //Console.WriteLine("collision callback"); |
108 | IntPtr b1 = d.GeomGetBody(g1); | 108 | IntPtr b1 = d.GeomGetBody(g1); |
109 | IntPtr b2 = d.GeomGetBody(g2); | 109 | IntPtr b2 = d.GeomGetBody(g2); |
110 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 110 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); | 113 | int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); |
114 | for (int i = 0; i < count; ++i) | 114 | for (int i = 0; i < count; ++i) |
115 | { | 115 | { |
116 | contact.geom = contacts[i]; | 116 | contact.geom = contacts[i]; |
117 | IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); | 117 | IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); |
118 | d.JointAttach(joint, b1, b2); | 118 | d.JointAttach(joint, b1, b2); |
119 | } | 119 | } |
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | public override PhysicsActor AddAvatar(PhysicsVector position) | 123 | public override PhysicsActor AddAvatar(PhysicsVector position) |
124 | { | 124 | { |
125 | PhysicsVector pos = new PhysicsVector(); | 125 | PhysicsVector pos = new PhysicsVector(); |
126 | pos.X = position.X; | 126 | pos.X = position.X; |
127 | pos.Y = position.Y; | 127 | pos.Y = position.Y; |
128 | pos.Z = position.Z + 20; | 128 | pos.Z = position.Z + 20; |
129 | OdeCharacter newAv = new OdeCharacter(this, pos); | 129 | OdeCharacter newAv = new OdeCharacter(this, pos); |
130 | this._characters.Add(newAv); | 130 | this._characters.Add(newAv); |
131 | return newAv; | 131 | return newAv; |
132 | } | 132 | } |
133 | 133 | ||
134 | public override void RemoveAvatar(PhysicsActor actor) | 134 | public override void RemoveAvatar(PhysicsActor actor) |
135 | { | 135 | { |
136 | 136 | ||
137 | } | 137 | } |
138 | 138 | ||
139 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | 139 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) |
140 | { | 140 | { |
141 | PhysicsVector pos = new PhysicsVector(); | 141 | PhysicsVector pos = new PhysicsVector(); |
142 | pos.X = position.X; | 142 | pos.X = position.X; |
143 | pos.Y = position.Y; | 143 | pos.Y = position.Y; |
144 | pos.Z = position.Z; | 144 | pos.Z = position.Z; |
145 | PhysicsVector siz = new PhysicsVector(); | 145 | PhysicsVector siz = new PhysicsVector(); |
146 | siz.X = size.X; | 146 | siz.X = size.X; |
147 | siz.Y = size.Y; | 147 | siz.Y = size.Y; |
148 | siz.Z = size.Z; | 148 | siz.Z = size.Z; |
149 | return new OdePrim(); | 149 | return new OdePrim(); |
150 | } | 150 | } |
151 | 151 | ||
152 | public override void Simulate(float timeStep) | 152 | public override void Simulate(float timeStep) |
153 | { | 153 | { |
154 | foreach (OdeCharacter actor in _characters) | 154 | foreach (OdeCharacter actor in _characters) |
155 | { | 155 | { |
156 | actor.Move(timeStep * 5f); | 156 | actor.Move(timeStep * 5f); |
157 | } | 157 | } |
158 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); | 158 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); |
159 | d.WorldQuickStep(world, timeStep * 5f); | 159 | d.WorldQuickStep(world, timeStep * 5f); |
160 | d.JointGroupEmpty(contactgroup); | 160 | d.JointGroupEmpty(contactgroup); |
161 | foreach (OdeCharacter actor in _characters) | 161 | foreach (OdeCharacter actor in _characters) |
162 | { | 162 | { |
163 | actor.UpdatePosition(); | 163 | actor.UpdatePosition(); |
164 | } | 164 | } |
165 | 165 | ||
166 | } | 166 | } |
167 | 167 | ||
168 | public override void GetResults() | 168 | public override void GetResults() |
169 | { | 169 | { |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | public override bool IsThreaded | 173 | public override bool IsThreaded |
174 | { | 174 | { |
175 | get | 175 | get |
176 | { | 176 | { |
177 | return (false); // for now we won't be multithreaded | 177 | return (false); // for now we won't be multithreaded |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | public override void SetTerrain(float[] heightMap) | 181 | public override void SetTerrain(float[] heightMap) |
182 | { | 182 | { |
183 | for (int i = 0; i < 65536; i++) | 183 | for (int i = 0; i < 65536; i++) |
184 | { | 184 | { |
185 | this._heightmap[i] = (double)heightMap[i]; | 185 | // this._heightmap[i] = (double)heightMap[i]; |
186 | } | 186 | // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...) |
187 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 187 | int x = i & 0xff; |
188 | d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); | 188 | int y = i >> 8; |
189 | d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); | 189 | this._heightmap[i] = (double)heightMap[x * 256 + y]; |
190 | LandGeom = d.CreateHeightfield(space, HeightmapData, 1); | 190 | } |
191 | d.Matrix3 R = new d.Matrix3(); | 191 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
192 | 192 | d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); | |
193 | Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0)); | 193 | d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); |
194 | Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0)); | 194 | LandGeom = d.CreateHeightfield(space, HeightmapData, 1); |
195 | //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1)); | 195 | d.Matrix3 R = new d.Matrix3(); |
196 | 196 | ||
197 | q1 = q1 * q2; | 197 | Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0)); |
198 | //q1 = q1 * q3; | 198 | Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0)); |
199 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(); | 199 | //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1)); |
200 | float angle = 0; | 200 | |
201 | q1.ToAngleAxis(ref angle, ref v3); | 201 | q1 = q1 * q2; |
202 | 202 | //q1 = q1 * q3; | |
203 | d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); | 203 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(); |
204 | d.GeomSetRotation(LandGeom, ref R); | 204 | float angle = 0; |
205 | d.GeomSetPosition(LandGeom, 128, 128, 0); | 205 | q1.ToAngleAxis(ref angle, ref v3); |
206 | } | 206 | |
207 | 207 | d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); | |
208 | public override void DeleteTerrain() | 208 | d.GeomSetRotation(LandGeom, ref R); |
209 | { | 209 | d.GeomSetPosition(LandGeom, 128, 128, 0); |
210 | 210 | } | |
211 | } | 211 | |
212 | } | 212 | public override void DeleteTerrain() |
213 | 213 | { | |
214 | public class OdeCharacter : PhysicsActor | 214 | |
215 | { | 215 | } |
216 | private PhysicsVector _position; | 216 | } |
217 | private PhysicsVector _velocity; | 217 | |
218 | private PhysicsVector _acceleration; | 218 | public class OdeCharacter : PhysicsActor |
219 | private bool flying; | 219 | { |
220 | //private float gravityAccel; | 220 | private PhysicsVector _position; |
221 | private IntPtr BoundingCapsule; | 221 | private PhysicsVector _velocity; |
222 | IntPtr capsule_geom; | 222 | private PhysicsVector _acceleration; |
223 | d.Mass capsule_mass; | 223 | private bool flying; |
224 | 224 | //private float gravityAccel; | |
225 | public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) | 225 | private IntPtr BoundingCapsule; |
226 | { | 226 | IntPtr capsule_geom; |
227 | _velocity = new PhysicsVector(); | 227 | d.Mass capsule_mass; |
228 | _position = pos; | 228 | |
229 | _acceleration = new PhysicsVector(); | 229 | public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) |
230 | d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); | 230 | { |
231 | capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); | 231 | _velocity = new PhysicsVector(); |
232 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); | 232 | _position = pos; |
233 | d.BodySetMass(BoundingCapsule, ref capsule_mass); | 233 | _acceleration = new PhysicsVector(); |
234 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); | 234 | d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); |
235 | d.GeomSetBody(capsule_geom, BoundingCapsule); | 235 | capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); |
236 | } | 236 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); |
237 | 237 | d.BodySetMass(BoundingCapsule, ref capsule_mass); | |
238 | public override bool Flying | 238 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); |
239 | { | 239 | d.GeomSetBody(capsule_geom, BoundingCapsule); |
240 | get | 240 | } |
241 | { | 241 | |
242 | return flying; | 242 | public override bool Flying |
243 | } | 243 | { |
244 | set | 244 | get |
245 | { | 245 | { |
246 | flying = value; | 246 | return flying; |
247 | } | 247 | } |
248 | } | 248 | set |
249 | 249 | { | |
250 | public override PhysicsVector Position | 250 | flying = value; |
251 | { | 251 | } |
252 | get | 252 | } |
253 | { | 253 | |
254 | return _position; | 254 | public override PhysicsVector Position |
255 | } | 255 | { |
256 | set | 256 | get |
257 | { | 257 | { |
258 | _position = value; | 258 | return _position; |
259 | } | 259 | } |
260 | } | 260 | set |
261 | 261 | { | |
262 | public override PhysicsVector Velocity | 262 | _position = value; |
263 | { | 263 | } |
264 | get | 264 | } |
265 | { | 265 | |
266 | return _velocity; | 266 | public override PhysicsVector Velocity |
267 | } | 267 | { |
268 | set | 268 | get |
269 | { | 269 | { |
270 | _velocity = value; | 270 | return _velocity; |
271 | } | 271 | } |
272 | } | 272 | set |
273 | 273 | { | |
274 | public override bool Kinematic | 274 | _velocity = value; |
275 | { | 275 | } |
276 | get | 276 | } |
277 | { | 277 | |
278 | return false; | 278 | public override bool Kinematic |
279 | } | 279 | { |
280 | set | 280 | get |
281 | { | 281 | { |
282 | 282 | return false; | |
283 | } | 283 | } |
284 | } | 284 | set |
285 | 285 | { | |
286 | public override Axiom.MathLib.Quaternion Orientation | 286 | |
287 | { | 287 | } |
288 | get | 288 | } |
289 | { | 289 | |
290 | return Axiom.MathLib.Quaternion.Identity; | 290 | public override Axiom.MathLib.Quaternion Orientation |
291 | } | 291 | { |
292 | set | 292 | get |
293 | { | 293 | { |
294 | 294 | return Axiom.MathLib.Quaternion.Identity; | |
295 | } | 295 | } |
296 | } | 296 | set |
297 | 297 | { | |
298 | public override PhysicsVector Acceleration | 298 | |
299 | { | 299 | } |
300 | get | 300 | } |
301 | { | 301 | |
302 | return _acceleration; | 302 | public override PhysicsVector Acceleration |
303 | } | 303 | { |
304 | 304 | get | |
305 | } | 305 | { |
306 | public void SetAcceleration(PhysicsVector accel) | 306 | return _acceleration; |
307 | { | 307 | } |
308 | this._acceleration = accel; | 308 | |
309 | } | 309 | } |
310 | 310 | public void SetAcceleration(PhysicsVector accel) | |
311 | public override void AddForce(PhysicsVector force) | 311 | { |
312 | { | 312 | this._acceleration = accel; |
313 | 313 | } | |
314 | } | 314 | |
315 | 315 | public override void AddForce(PhysicsVector force) | |
316 | public override void SetMomentum(PhysicsVector momentum) | 316 | { |
317 | { | 317 | |
318 | 318 | } | |
319 | } | 319 | |
320 | 320 | public override void SetMomentum(PhysicsVector momentum) | |
321 | public void Move(float timeStep) | 321 | { |
322 | { | 322 | |
323 | PhysicsVector vec = new PhysicsVector(); | 323 | } |
324 | vec.X = this._velocity.X * timeStep; | 324 | |
325 | vec.Y = this._velocity.Y * timeStep; | 325 | public void Move(float timeStep) |
326 | if (flying) | 326 | { |
327 | { | 327 | PhysicsVector vec = new PhysicsVector(); |
328 | vec.Z = (this._velocity.Z + 0.5f) * timeStep; | 328 | vec.X = this._velocity.X * timeStep; |
329 | } | 329 | vec.Y = this._velocity.Y * timeStep; |
330 | d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); | 330 | if (flying) |
331 | } | 331 | { |
332 | 332 | vec.Z = (this._velocity.Z + 0.5f) * timeStep; | |
333 | public void UpdatePosition() | 333 | } |
334 | { | 334 | d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); |
335 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); | 335 | } |
336 | this._position.X = vec.X; | 336 | |
337 | this._position.Y = vec.Y; | 337 | public void UpdatePosition() |
338 | this._position.Z = vec.Z; | 338 | { |
339 | } | 339 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); |
340 | } | 340 | this._position.X = vec.X; |
341 | 341 | this._position.Y = vec.Y; | |
342 | public class OdePrim : PhysicsActor | 342 | this._position.Z = vec.Z+1.0f; |
343 | { | 343 | } |
344 | private PhysicsVector _position; | 344 | } |
345 | private PhysicsVector _velocity; | 345 | |
346 | private PhysicsVector _acceleration; | 346 | public class OdePrim : PhysicsActor |
347 | 347 | { | |
348 | public OdePrim() | 348 | private PhysicsVector _position; |
349 | { | 349 | private PhysicsVector _velocity; |
350 | _velocity = new PhysicsVector(); | 350 | private PhysicsVector _acceleration; |
351 | _position = new PhysicsVector(); | 351 | |
352 | _acceleration = new PhysicsVector(); | 352 | public OdePrim() |
353 | } | 353 | { |
354 | public override bool Flying | 354 | _velocity = new PhysicsVector(); |
355 | { | 355 | _position = new PhysicsVector(); |
356 | get | 356 | _acceleration = new PhysicsVector(); |
357 | { | 357 | } |
358 | return false; //no flying prims for you | 358 | public override bool Flying |
359 | } | 359 | { |
360 | set | 360 | get |
361 | { | 361 | { |
362 | 362 | return false; //no flying prims for you | |
363 | } | 363 | } |
364 | } | 364 | set |
365 | public override PhysicsVector Position | 365 | { |
366 | { | 366 | |
367 | get | 367 | } |
368 | { | 368 | } |
369 | PhysicsVector pos = new PhysicsVector(); | 369 | public override PhysicsVector Position |
370 | // PhysicsVector vec = this._prim.Position; | 370 | { |
371 | //pos.X = vec.X; | 371 | get |
372 | //pos.Y = vec.Y; | 372 | { |
373 | //pos.Z = vec.Z; | 373 | PhysicsVector pos = new PhysicsVector(); |
374 | return pos; | 374 | // PhysicsVector vec = this._prim.Position; |
375 | 375 | //pos.X = vec.X; | |
376 | } | 376 | //pos.Y = vec.Y; |
377 | set | 377 | //pos.Z = vec.Z; |
378 | { | 378 | return pos; |
379 | /*PhysicsVector vec = value; | 379 | |
380 | PhysicsVector pos = new PhysicsVector(); | 380 | } |
381 | pos.X = vec.X; | 381 | set |
382 | pos.Y = vec.Y; | 382 | { |
383 | pos.Z = vec.Z; | 383 | /*PhysicsVector vec = value; |
384 | this._prim.Position = pos;*/ | 384 | PhysicsVector pos = new PhysicsVector(); |
385 | } | 385 | pos.X = vec.X; |
386 | } | 386 | pos.Y = vec.Y; |
387 | 387 | pos.Z = vec.Z; | |
388 | public override PhysicsVector Velocity | 388 | this._prim.Position = pos;*/ |
389 | { | 389 | } |
390 | get | 390 | } |
391 | { | 391 | |
392 | return _velocity; | 392 | public override PhysicsVector Velocity |
393 | } | 393 | { |
394 | set | 394 | get |
395 | { | 395 | { |
396 | _velocity = value; | 396 | return _velocity; |
397 | } | 397 | } |
398 | } | 398 | set |
399 | 399 | { | |
400 | public override bool Kinematic | 400 | _velocity = value; |
401 | { | 401 | } |
402 | get | 402 | } |
403 | { | 403 | |
404 | return false; | 404 | public override bool Kinematic |
405 | //return this._prim.Kinematic; | 405 | { |
406 | } | 406 | get |
407 | set | 407 | { |
408 | { | 408 | return false; |
409 | //this._prim.Kinematic = value; | 409 | //return this._prim.Kinematic; |
410 | } | 410 | } |
411 | } | 411 | set |
412 | 412 | { | |
413 | public override Axiom.MathLib.Quaternion Orientation | 413 | //this._prim.Kinematic = value; |
414 | { | 414 | } |
415 | get | 415 | } |
416 | { | 416 | |
417 | Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); | 417 | public override Axiom.MathLib.Quaternion Orientation |
418 | return res; | 418 | { |
419 | } | 419 | get |
420 | set | 420 | { |
421 | { | 421 | Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); |
422 | 422 | return res; | |
423 | } | 423 | } |
424 | } | 424 | set |
425 | 425 | { | |
426 | public override PhysicsVector Acceleration | 426 | |
427 | { | 427 | } |
428 | get | 428 | } |
429 | { | 429 | |
430 | return _acceleration; | 430 | public override PhysicsVector Acceleration |
431 | } | 431 | { |
432 | 432 | get | |
433 | } | 433 | { |
434 | public void SetAcceleration(PhysicsVector accel) | 434 | return _acceleration; |
435 | { | 435 | } |
436 | this._acceleration = accel; | 436 | |
437 | } | 437 | } |
438 | 438 | public void SetAcceleration(PhysicsVector accel) | |
439 | public override void AddForce(PhysicsVector force) | 439 | { |
440 | { | 440 | this._acceleration = accel; |
441 | 441 | } | |
442 | } | 442 | |
443 | 443 | public override void AddForce(PhysicsVector force) | |
444 | public override void SetMomentum(PhysicsVector momentum) | 444 | { |
445 | { | 445 | |
446 | 446 | } | |
447 | } | 447 | |
448 | 448 | public override void SetMomentum(PhysicsVector momentum) | |
449 | 449 | { | |
450 | } | 450 | |
451 | 451 | } | |
452 | } | 452 | |
453 | |||
454 | } | ||
455 | |||
456 | } | ||