(int type, float... args)
| 1348 | |
| 1349 | |
| 1350 | protected void transform(int type, float... args) { |
| 1351 | int dimensions = is3D ? 3 : 2; |
| 1352 | boolean invertible = true; |
| 1353 | checkMatrix(dimensions); |
| 1354 | if (transform == null) { |
| 1355 | if (dimensions == 2) { |
| 1356 | transform = new PMatrix2D(); |
| 1357 | transformInv = new PMatrix2D(); |
| 1358 | } else { |
| 1359 | transform = new PMatrix3D(); |
| 1360 | transformInv = new PMatrix3D(); |
| 1361 | } |
| 1362 | } else { |
| 1363 | transform.reset(); |
| 1364 | transformInv.reset(); |
| 1365 | } |
| 1366 | |
| 1367 | int ncoords = args.length; |
| 1368 | if (type == ROTATE) { |
| 1369 | ncoords = args.length == 1 ? 2 : 3; |
| 1370 | } else if (type == MATRIX) { |
| 1371 | ncoords = args.length == 6 ? 2 : 3; |
| 1372 | } |
| 1373 | |
| 1374 | switch (type) { |
| 1375 | case TRANSLATE: |
| 1376 | if (ncoords == 3) { |
| 1377 | transform.translate(args[0], args[1], args[2]); |
| 1378 | PGraphicsOpenGL.invTranslate((PMatrix3D)transformInv, args[0], args[1], args[2]); |
| 1379 | } else { |
| 1380 | transform.translate(args[0], args[1]); |
| 1381 | PGraphicsOpenGL.invTranslate((PMatrix2D)transformInv, args[0], args[1]); |
| 1382 | } |
| 1383 | break; |
| 1384 | case ROTATE: |
| 1385 | if (ncoords == 3) { |
| 1386 | transform.rotate(args[0], args[1], args[2], args[3]); |
| 1387 | PGraphicsOpenGL.invRotate((PMatrix3D)transformInv, args[0], args[1], args[2], args[3]); |
| 1388 | } else { |
| 1389 | transform.rotate(args[0]); |
| 1390 | PGraphicsOpenGL.invRotate((PMatrix2D)transformInv, -args[0]); |
| 1391 | } |
| 1392 | break; |
| 1393 | case SCALE: |
| 1394 | if (ncoords == 3) { |
| 1395 | transform.scale(args[0], args[1], args[2]); |
| 1396 | PGraphicsOpenGL.invScale((PMatrix3D)transformInv, args[0], args[1], args[2]); |
| 1397 | } else { |
| 1398 | transform.scale(args[0], args[1]); |
| 1399 | PGraphicsOpenGL.invScale((PMatrix2D)transformInv, args[0], args[1]); |
| 1400 | } |
| 1401 | break; |
| 1402 | case MATRIX: |
| 1403 | if (ncoords == 3) { |
| 1404 | transform.set(args[ 0], args[ 1], args[ 2], args[ 3], |
| 1405 | args[ 4], args[ 5], args[ 6], args[ 7], |
| 1406 | args[ 8], args[ 9], args[10], args[11], |
| 1407 | args[12], args[13], args[14], args[15]); |
no test coverage detected