Normand Briere
2019-08-06 b3ae4e889872ca0b9ca76f1d17b2f0b961226729
cJ3D.java
....@@ -360,13 +360,13 @@
360360 toParent[3][3] = m.m33;
361361 }
362362
363
+ Matrix4d m = new Matrix4d();
364
+
363365 Object3D Read(TransformGroup g)
364366 {
365367 Object3D c = new Object3D(GetName(g)); // g.getClass().getName());
366368
367369 Transform3D t = new Transform3D();
368
-
369
- Matrix4d m = new Matrix4d();
370370
371371 g.getTransform(t);
372372
....@@ -375,22 +375,18 @@
375375 c.toParent = LA.newMatrix();
376376 c.fromParent = LA.newMatrix();
377377
378
- c.toParent[0][0] = m.m00;
379
- c.toParent[0][1] = m.m10;
380
- c.toParent[0][2] = m.m20;
381
- c.toParent[0][3] = m.m30;
382
- c.toParent[1][0] = m.m01;
383
- c.toParent[1][1] = m.m11;
384
- c.toParent[1][2] = m.m21;
385
- c.toParent[1][3] = m.m31;
386
- c.toParent[2][0] = m.m02;
387
- c.toParent[2][1] = m.m12;
388
- c.toParent[2][2] = m.m22;
389
- c.toParent[2][3] = m.m32;
390
- c.toParent[3][0] = m.m03;
391
- c.toParent[3][1] = m.m13;
392
- c.toParent[3][2] = m.m23;
393
- c.toParent[3][3] = m.m33;
378
+ if (m.m00 != 0 || m.m10 != 0 || m.m20 != 0 || m.m30 != 0 ||
379
+ m.m01 != 0 || m.m11 != 0 || m.m21 != 0 || m.m31 != 0 ||
380
+ m.m02 != 0 || m.m12 != 0 || m.m22 != 0 || m.m32 != 0 ||
381
+ m.m03 != 0 || m.m13 != 0 || m.m23 != 0 /*|| m.m33 != 0 */)
382
+ {
383
+ SetMatrix(c, m);
384
+ }
385
+ else
386
+ {
387
+ System.err.println("Found zero scale matrix. Hide the object instead.");
388
+ c.count = 1;
389
+ }
394390
395391 // ReadNode(c, g);
396392 LA.matInvert(c.toParent, c.fromParent);
....@@ -402,6 +398,26 @@
402398
403399 return c;
404400 }
401
+
402
+ private void SetMatrix(Object3D c, Matrix4d m)
403
+ {
404
+ c.toParent[0][0] = m.m00;
405
+ c.toParent[0][1] = m.m10;
406
+ c.toParent[0][2] = m.m20;
407
+ c.toParent[0][3] = m.m30;
408
+ c.toParent[1][0] = m.m01;
409
+ c.toParent[1][1] = m.m11;
410
+ c.toParent[1][2] = m.m21;
411
+ c.toParent[1][3] = m.m31;
412
+ c.toParent[2][0] = m.m02;
413
+ c.toParent[2][1] = m.m12;
414
+ c.toParent[2][2] = m.m22;
415
+ c.toParent[2][3] = m.m32;
416
+ c.toParent[3][0] = m.m03;
417
+ c.toParent[3][1] = m.m13;
418
+ c.toParent[3][2] = m.m23;
419
+ c.toParent[3][3] = m.m33;
420
+ }
405421
406422 Object3D Read(Scene s, String fn)
407423 {