private Transform3D applyMatrixTransformGroup( Transform3D transformation, TransformGroup tg ) { Transform3D tmpTrans = new Transform3D(); tg.getTransform( tmpTrans ); if ( tmpTrans.getBestType() != Transform3D.IDENTITY && tmpTrans.getBestType() != Transform3D.ZERO ) { LOG.debug( "A transform group with transform:\n" + tmpTrans ); // Matrix3d mat = new Matrix3d(); // tmpTrans.getRotationScale( mat ); // transformation.set( mat ); transformation.mul( tmpTrans ); LOG.debug( "Resulting transform:\n" + transformation ); } return tmpTrans; }
doUserTransform = ( userMatrix != null && userMatrix.getBestType() != Transform3D.IDENTITY ); doUserRotation = ( userRotationMatrix != null && userRotationMatrix.getBestType() != Transform3D.IDENTITY );
private float[] exportCoords( GeometryArray ga, Transform3D transformation, double[] lower, double[] upper ) { float[] coords = new float[ga.getVertexCount() * 3]; ga.getCoordinates( ga.getInitialVertexIndex(), coords ); boolean doSceneTransform = ( transformation != null && transformation.getBestType() != Transform3D.IDENTITY ); for ( int i = 0; ( i + 2 ) < coords.length; i += 3 ) { Point3d coord = new Point3d( coords[i], coords[i + 1], coords[i + 2] ); // if ( doUserRotation ) { // userRotationMatrix.transform( coord ); // } if ( doSceneTransform ) { transformation.transform( coord ); } if ( doUserTransform ) { userMatrix.transform( coord ); } coords[i] = (float) coord.x; coords[i + 1] = (float) coord.y; coords[i + 2] = (float) coord.z; upper[0] = max( coords[i], upper[0] ); upper[1] = max( coords[i + 1], upper[1] ); upper[2] = max( coords[i + 2], upper[2] ); lower[0] = min( coords[i], lower[0] ); lower[1] = min( coords[i + 1], lower[1] ); lower[2] = min( coords[i + 2], lower[2] ); } return coords; }
boolean userTransform = doUserTransform; Matrix3d rot = new Matrix3d(); boolean doSceneTransform = ( transformation != null && transformation.getBestType() != Transform3D.IDENTITY ); Transform3D transScene = new Transform3D(); if ( doSceneTransform ) { transformation.getRotationScale( rot ); transScene.set( rot ); doSceneTransform = ( transScene.getBestType() != Transform3D.IDENTITY ); userMatrix.getRotationScale( rot ); transUser.set( rot ); userTransform = ( transUser.getBestType() != Transform3D.IDENTITY );