.. | .. |
---|
123 | 123 | JOINT_COUNT |
---|
124 | 124 | } |
---|
125 | 125 | |
---|
| 126 | + float scale; |
---|
| 127 | + |
---|
126 | 128 | //DynamicsWorld ownerWorld; |
---|
127 | 129 | CollisionShape[] shapes = new CollisionShape[BodyPart.BODYPART_COUNT.ordinal()]; |
---|
128 | 130 | RigidBody/*Serial*/[] bodies = new RigidBody/*Serial*/[BodyPart.BODYPART_COUNT.ordinal()]; |
---|
.. | .. |
---|
140 | 142 | |
---|
141 | 143 | public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk) |
---|
142 | 144 | { |
---|
| 145 | + scale = scale_ragdoll; |
---|
| 146 | + |
---|
143 | 147 | this.walkmotion = walk; |
---|
144 | 148 | |
---|
145 | 149 | boolean hasbodies = (bodies[BodyPart.BODYPART_SPINE.ordinal()] != null); |
---|
.. | .. |
---|
149 | 153 | Transform tmpTrans = new Transform(); |
---|
150 | 154 | Vector3f tmp = new Vector3f(); |
---|
151 | 155 | |
---|
152 | | - boolean node = true; |
---|
| 156 | + boolean node = false; // true; |
---|
| 157 | + |
---|
| 158 | + // KIDS4 |
---|
| 159 | + float upperarmlength = 0.3f; // 0.25 |
---|
| 160 | + float lowerarmlength = 0.25f; // 0.2 |
---|
| 161 | + float handlength = 0.1f; // 0.1 |
---|
| 162 | + float upperarmdist = 0.15f; |
---|
153 | 163 | |
---|
154 | 164 | // Setup the geometry |
---|
155 | 165 | //shapes[BodyPart.BODYPART_GROUND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.125f, scale_ragdoll * 0.20f); |
---|
156 | 166 | //scale_ragdoll /= 1.25; |
---|
157 | 167 | if (!hasbodies) |
---|
158 | 168 | { |
---|
159 | | - shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.35f,false); |
---|
160 | | - shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(scale_ragdoll * 0.2f, scale_ragdoll * 0.5f,false); |
---|
161 | | - shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.15f,false); |
---|
| 169 | + float thin = 0.1f; |
---|
| 170 | + |
---|
| 171 | + shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.35f, false); |
---|
| 172 | + shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(scale_ragdoll * 0.2f, scale_ragdoll * 0.5f, false); |
---|
| 173 | + shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.15f, false); |
---|
162 | 174 | |
---|
163 | | - shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f, scale_ragdoll * 0.4f,false); |
---|
164 | | - shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.37f,node); |
---|
165 | | - shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node); |
---|
| 175 | + shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.4f * thin, scale_ragdoll * 0.4f, node); |
---|
| 176 | + shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.37f * thin, scale_ragdoll * 0.37f, node); |
---|
| 177 | + shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f * thin, scale_ragdoll * 0.1f, node); |
---|
166 | 178 | |
---|
167 | | - shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f, scale_ragdoll * 0.4f,false); |
---|
168 | | - shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.37f,node); |
---|
169 | | - shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node); |
---|
| 179 | + shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.4f * thin, scale_ragdoll * 0.4f, node); |
---|
| 180 | + shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.37f * thin, scale_ragdoll * 0.37f, node); |
---|
| 181 | + shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f * thin, scale_ragdoll * 0.1f, node); |
---|
170 | 182 | |
---|
171 | | - shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.08f, scale_ragdoll * 0.25f,node); |
---|
172 | | - shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.2f,node); |
---|
173 | | - shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node); |
---|
| 183 | + shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * upperarmlength * thin, scale_ragdoll * upperarmlength, node); |
---|
| 184 | + shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * lowerarmlength * thin, scale_ragdoll * lowerarmlength, node); |
---|
| 185 | + shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * handlength * thin, scale_ragdoll * handlength, node); |
---|
174 | 186 | |
---|
175 | | - shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.08f, scale_ragdoll * 0.25f,node); |
---|
176 | | - shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.2f,node); |
---|
177 | | - shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node); |
---|
| 187 | + shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * upperarmlength * thin, scale_ragdoll * upperarmlength, node); |
---|
| 188 | + shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * lowerarmlength * thin, scale_ragdoll * lowerarmlength, node); |
---|
| 189 | + shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * handlength * thin, scale_ragdoll * handlength, node); |
---|
178 | 190 | } |
---|
179 | 191 | //scale_ragdoll *= 1.25; |
---|
180 | 192 | |
---|
.. | .. |
---|
185 | 197 | |
---|
186 | 198 | Transform transform = new Transform(); |
---|
187 | 199 | |
---|
188 | | - float depth = -0.02f; // .02f; |
---|
| 200 | + float depth = -0.01f; // .02f; |
---|
189 | 201 | |
---|
190 | 202 | // transform.setIdentity(); |
---|
191 | 203 | // transform.origin.set(0f, scale_ragdoll * 1f, 0f); |
---|
.. | .. |
---|
242 | 254 | transform.setIdentity(); |
---|
243 | 255 | if ((body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]) == null) |
---|
244 | 256 | body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()]); |
---|
245 | | - transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.025f); |
---|
| 257 | + transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f); |
---|
246 | 258 | MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0); |
---|
247 | 259 | tmpTrans.mul(offset, transform); |
---|
248 | 260 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
252 | 264 | transform.setIdentity(); |
---|
253 | 265 | if ((body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]) == null) |
---|
254 | 266 | body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]); |
---|
255 | | - transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.025f); |
---|
| 267 | + transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f); |
---|
256 | 268 | MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0); |
---|
257 | 269 | tmpTrans.mul(offset, transform); |
---|
258 | 270 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
300 | 312 | transform.setIdentity(); |
---|
301 | 313 | if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]) == null) |
---|
302 | 314 | body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]); |
---|
303 | | - transform.origin.set(-0.275f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 315 | + transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
304 | 316 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI); |
---|
305 | 317 | tmpTrans.mul(offset, transform); |
---|
306 | 318 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
310 | 322 | transform.setIdentity(); |
---|
311 | 323 | if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]) == null) |
---|
312 | 324 | body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]); |
---|
313 | | - transform.origin.set(-0.5f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 325 | + transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
314 | 326 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI); |
---|
315 | 327 | tmpTrans.mul(offset, transform); |
---|
316 | 328 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
320 | 332 | transform.setIdentity(); |
---|
321 | 333 | if ((body = bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()]) == null) |
---|
322 | 334 | body = bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()]); |
---|
323 | | - transform.origin.set(-0.65f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 335 | + transform.origin.set(-(handlength/2 + lowerarmlength + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
324 | 336 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI); |
---|
325 | 337 | tmpTrans.mul(offset, transform); |
---|
326 | 338 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
330 | 342 | transform.setIdentity(); |
---|
331 | 343 | if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]) == null) |
---|
332 | 344 | body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]); |
---|
333 | | - transform.origin.set(0.275f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 345 | + transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
334 | 346 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI); |
---|
335 | 347 | tmpTrans.mul(offset, transform); |
---|
336 | 348 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
340 | 352 | transform.setIdentity(); |
---|
341 | 353 | if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]) == null) |
---|
342 | 354 | body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]); |
---|
343 | | - transform.origin.set(0.50f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 355 | + transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
344 | 356 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI); |
---|
345 | 357 | tmpTrans.mul(offset, transform); |
---|
346 | 358 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
350 | 362 | transform.setIdentity(); |
---|
351 | 363 | if ((body = bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()]) == null) |
---|
352 | 364 | body = bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()]); |
---|
353 | | - transform.origin.set(0.65f * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
| 365 | + transform.origin.set((handlength/2 + lowerarmlength + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth); |
---|
354 | 366 | MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI); |
---|
355 | 367 | tmpTrans.mul(offset, transform); |
---|
356 | 368 | body.worldTransform.set(tmpTrans); |
---|
.. | .. |
---|
418 | 430 | localA.setIdentity(); |
---|
419 | 431 | localB.setIdentity(); |
---|
420 | 432 | |
---|
421 | | - localA.origin.set(-0.15f * scale_ragdoll, 0.125f * scale_ragdoll, depth); |
---|
| 433 | + localA.origin.set(-upperarmdist * scale_ragdoll, 0.125f * scale_ragdoll, depth); |
---|
422 | 434 | |
---|
423 | 435 | MatrixUtil.setEulerZYX(localB.basis, 0/*BulletGlobals.SIMD_HALF_PI*/, 0, -BulletGlobals.SIMD_HALF_PI); |
---|
424 | | - localB.origin.set(0f, -0.125f * scale_ragdoll, 0); |
---|
| 436 | + localB.origin.set(0f, -upperarmlength/2 * scale_ragdoll, 0); |
---|
425 | 437 | |
---|
426 | 438 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
427 | 439 | |
---|
.. | .. |
---|
447 | 459 | localA.setIdentity(); |
---|
448 | 460 | localB.setIdentity(); |
---|
449 | 461 | |
---|
450 | | - localA.origin.set(0.15f * scale_ragdoll, 0.125f * scale_ragdoll, depth); |
---|
| 462 | + localA.origin.set(upperarmdist * scale_ragdoll, 0.125f * scale_ragdoll, depth); |
---|
451 | 463 | MatrixUtil.setEulerZYX(localB.basis, 0, 0, BulletGlobals.SIMD_HALF_PI); |
---|
452 | | - localB.origin.set(0f, -0.125f * scale_ragdoll, 0); |
---|
| 464 | + localB.origin.set(0f, -upperarmlength/2 * scale_ragdoll, 0); |
---|
453 | 465 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
454 | 466 | |
---|
455 | 467 | //#ifdef RIGID |
---|
.. | .. |
---|
474 | 486 | localA.setIdentity(); |
---|
475 | 487 | localB.setIdentity(); |
---|
476 | 488 | |
---|
477 | | - localA.origin.set(0f, 0.125f * scale_ragdoll, 0f); |
---|
478 | | - localB.origin.set(0f, -0.1f * scale_ragdoll, 0f); |
---|
| 489 | + localA.origin.set(0f, upperarmlength/2 * scale_ragdoll, 0f); |
---|
| 490 | + localB.origin.set(0f, -lowerarmlength/2 * scale_ragdoll, 0f); |
---|
479 | 491 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
480 | 492 | |
---|
481 | 493 | //#ifdef RIGID |
---|
.. | .. |
---|
500 | 512 | localA.setIdentity(); |
---|
501 | 513 | localB.setIdentity(); |
---|
502 | 514 | |
---|
503 | | - localA.origin.set(0f, 0.125f * scale_ragdoll, 0f); |
---|
504 | | - localB.origin.set(0f, -0.1f * scale_ragdoll, 0f); |
---|
| 515 | + localA.origin.set(0f, upperarmlength/2 * scale_ragdoll, 0f); |
---|
| 516 | + localB.origin.set(0f, -lowerarmlength/2 * scale_ragdoll, 0f); |
---|
505 | 517 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
506 | 518 | |
---|
507 | 519 | //#ifdef RIGID |
---|
.. | .. |
---|
526 | 538 | localA.setIdentity(); |
---|
527 | 539 | localB.setIdentity(); |
---|
528 | 540 | |
---|
529 | | - localA.origin.set(0f, 0.1f * scale_ragdoll, 0f); |
---|
530 | | - localB.origin.set(0f, -0.05f * scale_ragdoll, 0f); |
---|
| 541 | + localA.origin.set(0f, lowerarmlength/2 * scale_ragdoll, 0f); |
---|
| 542 | + localB.origin.set(0f, -handlength/2 * scale_ragdoll, 0f); |
---|
531 | 543 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()], bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
532 | 544 | |
---|
533 | 545 | //#ifdef RIGID |
---|
.. | .. |
---|
552 | 564 | localA.setIdentity(); |
---|
553 | 565 | localB.setIdentity(); |
---|
554 | 566 | |
---|
555 | | - localA.origin.set(0f, 0.1f * scale_ragdoll, 0f); |
---|
556 | | - localB.origin.set(0f, -0.05f * scale_ragdoll, 0f); |
---|
| 567 | + localA.origin.set(0f, lowerarmlength/2 * scale_ragdoll, 0f); |
---|
| 568 | + localB.origin.set(0f, -handlength/2 * scale_ragdoll, 0f); |
---|
557 | 569 | joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()], bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()], localA, localB, useLinearReferenceFrameA); |
---|
558 | 570 | |
---|
559 | 571 | //#ifdef RIGID |
---|