From 57f4646563d6757f65ddc00ca38975c352d76de7 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Fri, 27 Sep 2019 20:06:14 -0400
Subject: [PATCH] Wireframe, box mode, and ragdoll zoffset.

---
 RagDoll.java |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/RagDoll.java b/RagDoll.java
index e22ffb2..a2de06b 100644
--- a/RagDoll.java
+++ b/RagDoll.java
@@ -130,17 +130,17 @@
 	RigidBody/*Serial*/[] bodies = new RigidBody/*Serial*/[BodyPart.BODYPART_COUNT.ordinal()];
 	TypedConstraint[] joints = new TypedConstraint[JointType.JOINT_COUNT.ordinal()];
 
-	public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset)
+	public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float zoffset)
         {
-		this(ownerWorld, positionOffset, 1.0f, false);
+		this(ownerWorld, positionOffset, 1.0f, false, zoffset);
 	}
 
-	public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float scale_ragdoll, boolean walk)
+	public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float scale_ragdoll, boolean walk, float zoffset)
         {
-            init(/*ownerWorld,*/ positionOffset, scale_ragdoll, walk);
+            init(/*ownerWorld,*/ positionOffset, scale_ragdoll, walk, zoffset);
         }
         
-	public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk)
+	public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk, float zoffset)
         {
             scale = scale_ragdoll;
             
@@ -210,7 +210,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_SPINE.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_SPINE.ordinal()] = localCreateRigidBody(1f, 10, transform, shapes[BodyPart.BODYPART_SPINE.ordinal()]);
-		transform.origin.set(0f, scale_ragdoll * 1.2f, 0f);
+		transform.origin.set(0f, scale_ragdoll * 1.2f, zoffset);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
                 body.getMotionState().setWorldTransform(tmpTrans);
@@ -229,7 +229,7 @@
 		transform.setIdentity();
                 if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]);
-		transform.origin.set(-0.09f * scale_ragdoll, 0.275f * scale_ragdoll, 0f);
+		transform.origin.set(-0.09f * scale_ragdoll, 0.275f * scale_ragdoll, zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -237,11 +237,10 @@
                 //body.getMotionState().setStartTransform(tmpTrans);
                 ((cRigidBody)body).anchor.set(tmpTrans.origin);
                 
-
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]);
-		transform.origin.set(0.09f * scale_ragdoll, 0.275f * scale_ragdoll, 0f);
+		transform.origin.set(0.09f * scale_ragdoll, 0.275f * scale_ragdoll, zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -254,7 +253,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()]);
-		transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
+		transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -264,7 +263,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]);
-		transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
+		transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -274,7 +273,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_PELVIS.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_PELVIS.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_PELVIS.ordinal()]);
-		transform.origin.set(scale_ragdoll * 0.f, scale_ragdoll * 0.95f, 0f);
+		transform.origin.set(scale_ragdoll * 0.f, scale_ragdoll * 0.95f, zoffset);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
                 body.getMotionState().setWorldTransform(tmpTrans);
@@ -283,7 +282,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_HEAD.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_HEAD.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_HEAD.ordinal()]);
-		transform.origin.set(0f, scale_ragdoll * 1.55f, 0); // depth/2);
+		transform.origin.set(0f, scale_ragdoll * 1.55f, zoffset); // depth/2);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
                 body.getMotionState().setWorldTransform(tmpTrans);
@@ -292,7 +291,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]);
-		transform.origin.set(-0.09f * scale_ragdoll, 0.65f * scale_ragdoll, 0f);
+		transform.origin.set(-0.09f * scale_ragdoll, 0.65f * scale_ragdoll, zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -302,7 +301,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]);
-		transform.origin.set(0.09f * scale_ragdoll, 0.65f * scale_ragdoll, 0f);
+		transform.origin.set(0.09f * scale_ragdoll, 0.65f * scale_ragdoll, zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -312,7 +311,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]);
-		transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
+		transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -322,7 +321,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]);
-		transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
+		transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -342,7 +341,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]);
-		transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
+		transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -352,7 +351,7 @@
 		transform.setIdentity();
 		if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]) == null)
                     body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]);
-		transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
+		transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
 		MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
 		tmpTrans.mul(offset, transform);
 		body.worldTransform.set(tmpTrans);
@@ -812,7 +811,7 @@
 //                     .push(Tween.to(leftleg, 1, 500).target(100).ease(Quad.INOUT))
 //                     .push(Tween.to(leftleg, 1, 500).target(360).ease(Quad.INOUT))
 //                     .repeat(5, 1)
-//                     .end()
+//                     .end() //??
                      .start(ObjEditor.tweenManager)
                         ;
 	}

--
Gitblit v1.6.2