diff options
Diffstat (limited to 'OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs | 353 |
1 files changed, 353 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs new file mode 100644 index 0000000..92261cd --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs | |||
@@ -0,0 +1,353 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using PhysXWrapper; | ||
34 | using Quaternion=OpenMetaverse.Quaternion; | ||
35 | using System.Reflection; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
40 | { | ||
41 | public class PhysXCharacter : PhysicsActor | ||
42 | { | ||
43 | private Vector3 _position; | ||
44 | private Vector3 _velocity; | ||
45 | private Vector3 m_rotationalVelocity = Vector3.Zero; | ||
46 | private Vector3 _acceleration; | ||
47 | private NxCharacter _character; | ||
48 | private bool flying; | ||
49 | private bool iscolliding = false; | ||
50 | private float gravityAccel; | ||
51 | |||
52 | public PhysXCharacter(NxCharacter character) | ||
53 | { | ||
54 | _character = character; | ||
55 | } | ||
56 | |||
57 | public override int PhysicsActorType | ||
58 | { | ||
59 | get { return (int) ActorTypes.Agent; } | ||
60 | set { return; } | ||
61 | } | ||
62 | |||
63 | public override bool SetAlwaysRun | ||
64 | { | ||
65 | get { return false; } | ||
66 | set { return; } | ||
67 | } | ||
68 | |||
69 | public override uint LocalID | ||
70 | { | ||
71 | set { return; } | ||
72 | } | ||
73 | |||
74 | public override bool Grabbed | ||
75 | { | ||
76 | set { return; } | ||
77 | } | ||
78 | |||
79 | public override bool Selected | ||
80 | { | ||
81 | set { return; } | ||
82 | } | ||
83 | |||
84 | public override float Buoyancy | ||
85 | { | ||
86 | get { return 0f; } | ||
87 | set { return; } | ||
88 | } | ||
89 | |||
90 | public override bool FloatOnWater | ||
91 | { | ||
92 | set { return; } | ||
93 | } | ||
94 | |||
95 | public override bool IsPhysical | ||
96 | { | ||
97 | get { return false; } | ||
98 | set { return; } | ||
99 | } | ||
100 | |||
101 | public override bool ThrottleUpdates | ||
102 | { | ||
103 | get { return false; } | ||
104 | set { return; } | ||
105 | } | ||
106 | |||
107 | public override bool Flying | ||
108 | { | ||
109 | get { return flying; } | ||
110 | set { flying = value; } | ||
111 | } | ||
112 | |||
113 | public override bool IsColliding | ||
114 | { | ||
115 | get { return iscolliding; } | ||
116 | set { iscolliding = value; } | ||
117 | } | ||
118 | |||
119 | public override bool CollidingGround | ||
120 | { | ||
121 | get { return false; } | ||
122 | set { return; } | ||
123 | } | ||
124 | |||
125 | public override bool CollidingObj | ||
126 | { | ||
127 | get { return false; } | ||
128 | set { return; } | ||
129 | } | ||
130 | |||
131 | public override Vector3 RotationalVelocity | ||
132 | { | ||
133 | get { return m_rotationalVelocity; } | ||
134 | set { m_rotationalVelocity = value; } | ||
135 | } | ||
136 | |||
137 | public override bool Stopped | ||
138 | { | ||
139 | get { return false; } | ||
140 | } | ||
141 | |||
142 | public override Vector3 Position | ||
143 | { | ||
144 | get { return _position; } | ||
145 | set | ||
146 | { | ||
147 | _position = value; | ||
148 | Vec3 ps = new Vec3(); | ||
149 | ps.X = value.X; | ||
150 | ps.Y = value.Y; | ||
151 | ps.Z = value.Z; | ||
152 | _character.Position = ps; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public override Vector3 Size | ||
157 | { | ||
158 | get { return Vector3.Zero; } | ||
159 | set { } | ||
160 | } | ||
161 | |||
162 | public override float Mass | ||
163 | { | ||
164 | get { return 0f; } | ||
165 | } | ||
166 | |||
167 | public override Vector3 Force | ||
168 | { | ||
169 | get { return Vector3.Zero; } | ||
170 | set { return; } | ||
171 | } | ||
172 | |||
173 | public override int VehicleType | ||
174 | { | ||
175 | get { return 0; } | ||
176 | set { return; } | ||
177 | } | ||
178 | |||
179 | public override void VehicleFloatParam(int param, float value) | ||
180 | { | ||
181 | } | ||
182 | |||
183 | public override void VehicleVectorParam(int param, Vector3 value) | ||
184 | { | ||
185 | } | ||
186 | |||
187 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
188 | { | ||
189 | } | ||
190 | |||
191 | public override void VehicleFlags(int param, bool remove) | ||
192 | { | ||
193 | } | ||
194 | |||
195 | public override void SetVolumeDetect(int param) | ||
196 | { | ||
197 | } | ||
198 | |||
199 | public override Vector3 CenterOfMass | ||
200 | { | ||
201 | get { return Vector3.Zero; } | ||
202 | } | ||
203 | |||
204 | public override Vector3 GeometricCenter | ||
205 | { | ||
206 | get { return Vector3.Zero; } | ||
207 | } | ||
208 | |||
209 | public override Vector3 Velocity | ||
210 | { | ||
211 | get { return _velocity; } | ||
212 | set { _velocity = value; } | ||
213 | } | ||
214 | |||
215 | public override float CollisionScore | ||
216 | { | ||
217 | get { return 0f; } | ||
218 | set { } | ||
219 | } | ||
220 | |||
221 | public override bool Kinematic | ||
222 | { | ||
223 | get { return false; } | ||
224 | set { } | ||
225 | } | ||
226 | |||
227 | public override Quaternion Orientation | ||
228 | { | ||
229 | get { return Quaternion.Identity; } | ||
230 | set { } | ||
231 | } | ||
232 | |||
233 | public override Vector3 Acceleration | ||
234 | { | ||
235 | get { return _acceleration; } | ||
236 | } | ||
237 | |||
238 | public void SetAcceleration(Vector3 accel) | ||
239 | { | ||
240 | _acceleration = accel; | ||
241 | } | ||
242 | |||
243 | public override void AddForce(Vector3 force, bool pushforce) | ||
244 | { | ||
245 | } | ||
246 | |||
247 | public override Vector3 Torque | ||
248 | { | ||
249 | get { return Vector3.Zero; } | ||
250 | set { return; } | ||
251 | } | ||
252 | |||
253 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
254 | { | ||
255 | } | ||
256 | |||
257 | public override void link(PhysicsActor obj) | ||
258 | { | ||
259 | } | ||
260 | |||
261 | public override void delink() | ||
262 | { | ||
263 | } | ||
264 | |||
265 | public override void LockAngularMotion(Vector3 axis) | ||
266 | { | ||
267 | } | ||
268 | |||
269 | public override void SetMomentum(Vector3 momentum) | ||
270 | { | ||
271 | } | ||
272 | |||
273 | public void Move(float timeStep) | ||
274 | { | ||
275 | Vec3 vec = new Vec3(); | ||
276 | vec.X = _velocity.X*timeStep; | ||
277 | vec.Y = _velocity.Y*timeStep; | ||
278 | if (flying) | ||
279 | { | ||
280 | vec.Z = (_velocity.Z)*timeStep; | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | gravityAccel += -9.8f; | ||
285 | vec.Z = (gravityAccel + _velocity.Z)*timeStep; | ||
286 | } | ||
287 | int res = _character.Move(vec); | ||
288 | if (res == 1) | ||
289 | { | ||
290 | gravityAccel = 0; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | public override PrimitiveBaseShape Shape | ||
295 | { | ||
296 | set { return; } | ||
297 | } | ||
298 | |||
299 | public void UpdatePosition() | ||
300 | { | ||
301 | Vec3 vec = _character.Position; | ||
302 | _position.X = vec.X; | ||
303 | _position.Y = vec.Y; | ||
304 | _position.Z = vec.Z; | ||
305 | } | ||
306 | |||
307 | public override void CrossingFailure() | ||
308 | { | ||
309 | } | ||
310 | |||
311 | public override Vector3 PIDTarget { set { return; } } | ||
312 | public override bool PIDActive { set { return; } } | ||
313 | public override float PIDTau { set { return; } } | ||
314 | |||
315 | public override float PIDHoverHeight { set { return; } } | ||
316 | public override bool PIDHoverActive { set { return; } } | ||
317 | public override PIDHoverType PIDHoverType { set { return; } } | ||
318 | public override float PIDHoverTau { set { return; } } | ||
319 | |||
320 | public override Quaternion APIDTarget | ||
321 | { | ||
322 | set { return; } | ||
323 | } | ||
324 | |||
325 | public override bool APIDActive | ||
326 | { | ||
327 | set { return; } | ||
328 | } | ||
329 | |||
330 | public override float APIDStrength | ||
331 | { | ||
332 | set { return; } | ||
333 | } | ||
334 | |||
335 | public override float APIDDamping | ||
336 | { | ||
337 | set { return; } | ||
338 | } | ||
339 | |||
340 | public override void SubscribeEvents(int ms) | ||
341 | { | ||
342 | |||
343 | } | ||
344 | public override void UnSubscribeEvents() | ||
345 | { | ||
346 | |||
347 | } | ||
348 | public override bool SubscribedEvents() | ||
349 | { | ||
350 | return false; | ||
351 | } | ||
352 | } | ||
353 | } | ||