Normand Briere
2019-09-28 57f4646563d6757f65ddc00ca38975c352d76de7
Wireframe, box mode, and ragdoll zoffset.
5 files modified
112 ■■■■■ changed files
CameraPane.java 4 ●●● patch | view | raw | blame | history
GenericJoint.java 13 ●●●●● patch | view | raw | blame | history
Object3D.java 3 ●●●● patch | view | raw | blame | history
PhysicsNode.java 53 ●●●●● patch | view | raw | blame | history
RagDoll.java 39 ●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -17161,7 +17161,7 @@
1716117161 return;
1716217162 }
1716317163
17164
- if (WIREFRAME)
17164
+ //if (WIREFRAME)
1716517165 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1716617166
1716717167 gl.glDisable(gl.GL_CULL_FACE);
....@@ -17261,6 +17261,8 @@
1726117261
1726217262 if (WIREFRAME)
1726317263 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
17264
+ else
17265
+ gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1726417266 }
1726517267
1726617268 private void DrawChecker(GL gl)
GenericJoint.java
....@@ -178,7 +178,8 @@
178178 public void spawnRagdoll(boolean walk) // random)
179179 {
180180 // KIDS4
181
- RagDoll ragDoll = new RagDoll(null, new Vector3f(0f, 0f, 0f), 0.45f/2, walk); // Math.random() > 0.5/*true*/); // true);
181
+ RagDoll ragDoll = new RagDoll(null, new Vector3f(0f, 0f, 0f), 0.45f/2, walk, myzoffset = zoffset); // Math.random() > 0.5/*true*/); // true);
182
+ zoffset += 0.1f;
182183 ragdolls.add(ragDoll);
183184
184185 bRep = null;
....@@ -278,6 +279,8 @@
278279 //
279280 ObjectArrayList<Transform> initialmatrices;
280281
282
+ float myzoffset;
283
+
281284 void Reset()
282285 {
283286 // int numObjects = dynamicsWorld.getNumCollisionObjects();
....@@ -310,10 +313,12 @@
310313 walkdefined = true;
311314 }
312315
313
- ragdolls.get(0).init(/*staticdynamicsWorld,*/ new Vector3f(0f, 0f, 0f), ragdolls.get(0).scale, walk);
316
+ ragdolls.get(0).init(/*staticdynamicsWorld,*/ new Vector3f(0f, 0f, 0f), ragdolls.get(0).scale, walk, myzoffset);
314317
315318 bRep = null;
316319 }
320
+
321
+ static float zoffset = 0;
317322
318323 void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
319324 {
....@@ -487,7 +492,7 @@
487492
488493 tc.getFrameOffsetB(trans);
489494
490
- if (false) // c == 2) // DEBUG
495
+ if (c == 8) // DEBUG
491496 {
492497 gl.glDisable(gl.GL_LIGHTING);
493498
....@@ -516,7 +521,7 @@
516521
517522 gl.glPopMatrix();
518523
519
- tc.getFrameOffsetB(trans);
524
+ //tc.getFrameOffsetB(trans);
520525
521526 gl.glColor3f(0, 1, 0);
522527
Object3D.java
....@@ -6276,7 +6276,8 @@
62766276 bRep.displaylist = 0;
62776277 }
62786278 // usecalllists &= !(parent instanceof RandomNode);
6279
- // usecalllists = false;
6279
+ if (CameraPane.BOXMODE) // Too dynamic
6280
+ usecalllists = false;
62806281
62816282 if (display.DrawMode() == display.SHADOW)
62826283 //GetBRep() != null)
PhysicsNode.java
....@@ -140,6 +140,8 @@
140140 // initPhysics();
141141 //
142142 // assert(dynamicsWorld == staticdynamicsWorld);
143
+ if (groundTransform != null) // marche pas
144
+ groundTransform.origin.set(0f, -floor - 10, 0f);
143145
144146 GetDynamics().stepSimulation(ms / 1000000.f);
145147 }
....@@ -159,10 +161,14 @@
159161
160162 // if (transientDynamicsWorld == null)
161163 // initPhysics();
162
-
164
+
165
+ groundTransform.origin.set(0f, -floor - 10, 0f);
166
+
163167 GetDynamics().stepSimulation(ms / 1000000.f);
164168 }
165169
170
+ transient Transform groundTransform;
171
+
166172 public void initPhysics()
167173 {
168174 //if (dynamicsWorld != null) // && staticdynamicsWorld == null)
....@@ -201,34 +207,35 @@
201207 // Setup a big ground box
202208 // {
203209 CollisionShape groundShape = new BoxShape(new Vector3f(boxsize, 10f, boxsize));
204
- Transform groundTransform = new Transform();
205
- groundTransform.setIdentity();
206
- groundTransform.origin.set(0f, -floor - 10, 0f);
207
- localCreateRigidBody(0f, groundTransform, groundShape);
210
+ Transform transform = new Transform();
211
+ transform.setIdentity();
212
+ transform.origin.set(0f, -floor - 10, 0f);
213
+ localCreateRigidBody(0f, transform, groundShape);
214
+
215
+ groundTransform = transform;
216
+ groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
217
+ transform = new Transform();
218
+ transform.setIdentity();
219
+ transform.origin.set(0f, boxsize/2, -boxsize-1);
220
+ localCreateRigidBody(0f, transform, groundShape);
208221
209222 groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
210
- groundTransform = new Transform();
211
- groundTransform.setIdentity();
212
- groundTransform.origin.set(0f, boxsize/2, -boxsize-1);
213
- localCreateRigidBody(0f, groundTransform, groundShape);
223
+ transform = new Transform();
224
+ transform.setIdentity();
225
+ transform.origin.set(-boxsize-1, boxsize/2, 0f);
226
+ localCreateRigidBody(0f, transform, groundShape);
214227
215228 groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
216
- groundTransform = new Transform();
217
- groundTransform.setIdentity();
218
- groundTransform.origin.set(-boxsize-1, boxsize/2, 0f);
219
- localCreateRigidBody(0f, groundTransform, groundShape);
229
+ transform = new Transform();
230
+ transform.setIdentity();
231
+ transform.origin.set(boxsize+1, boxsize/2, 0f);
232
+ localCreateRigidBody(0f, transform, groundShape);
220233
221234 groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
222
- groundTransform = new Transform();
223
- groundTransform.setIdentity();
224
- groundTransform.origin.set(boxsize+1, boxsize/2, 0f);
225
- localCreateRigidBody(0f, groundTransform, groundShape);
226
-
227
- groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
228
- groundTransform = new Transform();
229
- groundTransform.setIdentity();
230
- groundTransform.origin.set(0f, boxsize/2, boxsize+1);
231
- localCreateRigidBody(0f, groundTransform, groundShape);
235
+ transform = new Transform();
236
+ transform.setIdentity();
237
+ transform.origin.set(0f, boxsize/2, boxsize+1);
238
+ localCreateRigidBody(0f, transform, groundShape);
232239
233240 transientDynamicsWorld.setGravity(new Vector3f(0.075f, -gravity, wind));
234241
RagDoll.java
....@@ -130,17 +130,17 @@
130130 RigidBody/*Serial*/[] bodies = new RigidBody/*Serial*/[BodyPart.BODYPART_COUNT.ordinal()];
131131 TypedConstraint[] joints = new TypedConstraint[JointType.JOINT_COUNT.ordinal()];
132132
133
- public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset)
133
+ public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float zoffset)
134134 {
135
- this(ownerWorld, positionOffset, 1.0f, false);
135
+ this(ownerWorld, positionOffset, 1.0f, false, zoffset);
136136 }
137137
138
- public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float scale_ragdoll, boolean walk)
138
+ public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float scale_ragdoll, boolean walk, float zoffset)
139139 {
140
- init(/*ownerWorld,*/ positionOffset, scale_ragdoll, walk);
140
+ init(/*ownerWorld,*/ positionOffset, scale_ragdoll, walk, zoffset);
141141 }
142142
143
- public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk)
143
+ public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk, float zoffset)
144144 {
145145 scale = scale_ragdoll;
146146
....@@ -210,7 +210,7 @@
210210 transform.setIdentity();
211211 if ((body = bodies[BodyPart.BODYPART_SPINE.ordinal()]) == null)
212212 body = bodies[BodyPart.BODYPART_SPINE.ordinal()] = localCreateRigidBody(1f, 10, transform, shapes[BodyPart.BODYPART_SPINE.ordinal()]);
213
- transform.origin.set(0f, scale_ragdoll * 1.2f, 0f);
213
+ transform.origin.set(0f, scale_ragdoll * 1.2f, zoffset);
214214 tmpTrans.mul(offset, transform);
215215 body.worldTransform.set(tmpTrans);
216216 body.getMotionState().setWorldTransform(tmpTrans);
....@@ -229,7 +229,7 @@
229229 transform.setIdentity();
230230 if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]) == null)
231231 body = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]);
232
- transform.origin.set(-0.09f * scale_ragdoll, 0.275f * scale_ragdoll, 0f);
232
+ transform.origin.set(-0.09f * scale_ragdoll, 0.275f * scale_ragdoll, zoffset);
233233 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
234234 tmpTrans.mul(offset, transform);
235235 body.worldTransform.set(tmpTrans);
....@@ -237,11 +237,10 @@
237237 //body.getMotionState().setStartTransform(tmpTrans);
238238 ((cRigidBody)body).anchor.set(tmpTrans.origin);
239239
240
-
241240 transform.setIdentity();
242241 if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]) == null)
243242 body = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]);
244
- transform.origin.set(0.09f * scale_ragdoll, 0.275f * scale_ragdoll, 0f);
243
+ transform.origin.set(0.09f * scale_ragdoll, 0.275f * scale_ragdoll, zoffset);
245244 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
246245 tmpTrans.mul(offset, transform);
247246 body.worldTransform.set(tmpTrans);
....@@ -254,7 +253,7 @@
254253 transform.setIdentity();
255254 if ((body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]) == null)
256255 body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()]);
257
- transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
256
+ transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f + zoffset);
258257 MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
259258 tmpTrans.mul(offset, transform);
260259 body.worldTransform.set(tmpTrans);
....@@ -264,7 +263,7 @@
264263 transform.setIdentity();
265264 if ((body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]) == null)
266265 body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]);
267
- transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
266
+ transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f + zoffset);
268267 MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
269268 tmpTrans.mul(offset, transform);
270269 body.worldTransform.set(tmpTrans);
....@@ -274,7 +273,7 @@
274273 transform.setIdentity();
275274 if ((body = bodies[BodyPart.BODYPART_PELVIS.ordinal()]) == null)
276275 body = bodies[BodyPart.BODYPART_PELVIS.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_PELVIS.ordinal()]);
277
- transform.origin.set(scale_ragdoll * 0.f, scale_ragdoll * 0.95f, 0f);
276
+ transform.origin.set(scale_ragdoll * 0.f, scale_ragdoll * 0.95f, zoffset);
278277 tmpTrans.mul(offset, transform);
279278 body.worldTransform.set(tmpTrans);
280279 body.getMotionState().setWorldTransform(tmpTrans);
....@@ -283,7 +282,7 @@
283282 transform.setIdentity();
284283 if ((body = bodies[BodyPart.BODYPART_HEAD.ordinal()]) == null)
285284 body = bodies[BodyPart.BODYPART_HEAD.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_HEAD.ordinal()]);
286
- transform.origin.set(0f, scale_ragdoll * 1.55f, 0); // depth/2);
285
+ transform.origin.set(0f, scale_ragdoll * 1.55f, zoffset); // depth/2);
287286 tmpTrans.mul(offset, transform);
288287 body.worldTransform.set(tmpTrans);
289288 body.getMotionState().setWorldTransform(tmpTrans);
....@@ -292,7 +291,7 @@
292291 transform.setIdentity();
293292 if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]) == null)
294293 body = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]);
295
- transform.origin.set(-0.09f * scale_ragdoll, 0.65f * scale_ragdoll, 0f);
294
+ transform.origin.set(-0.09f * scale_ragdoll, 0.65f * scale_ragdoll, zoffset);
296295 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
297296 tmpTrans.mul(offset, transform);
298297 body.worldTransform.set(tmpTrans);
....@@ -302,7 +301,7 @@
302301 transform.setIdentity();
303302 if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]) == null)
304303 body = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]);
305
- transform.origin.set(0.09f * scale_ragdoll, 0.65f * scale_ragdoll, 0f);
304
+ transform.origin.set(0.09f * scale_ragdoll, 0.65f * scale_ragdoll, zoffset);
306305 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_PI);
307306 tmpTrans.mul(offset, transform);
308307 body.worldTransform.set(tmpTrans);
....@@ -312,7 +311,7 @@
312311 transform.setIdentity();
313312 if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]) == null)
314313 body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]);
315
- transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
314
+ transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
316315 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
317316 tmpTrans.mul(offset, transform);
318317 body.worldTransform.set(tmpTrans);
....@@ -322,7 +321,7 @@
322321 transform.setIdentity();
323322 if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]) == null)
324323 body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]);
325
- transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
324
+ transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
326325 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
327326 tmpTrans.mul(offset, transform);
328327 body.worldTransform.set(tmpTrans);
....@@ -342,7 +341,7 @@
342341 transform.setIdentity();
343342 if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]) == null)
344343 body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]);
345
- transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
344
+ transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
346345 MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
347346 tmpTrans.mul(offset, transform);
348347 body.worldTransform.set(tmpTrans);
....@@ -352,7 +351,7 @@
352351 transform.setIdentity();
353352 if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]) == null)
354353 body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]);
355
- transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
354
+ transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth + zoffset);
356355 MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
357356 tmpTrans.mul(offset, transform);
358357 body.worldTransform.set(tmpTrans);
....@@ -812,7 +811,7 @@
812811 // .push(Tween.to(leftleg, 1, 500).target(100).ease(Quad.INOUT))
813812 // .push(Tween.to(leftleg, 1, 500).target(360).ease(Quad.INOUT))
814813 // .repeat(5, 1)
815
-// .end()
814
+// .end() //??
816815 .start(ObjEditor.tweenManager)
817816 ;
818817 }