@Override public void process( TDSFile file, AppearanceFactory appFactory, GeometryFactory geomFactory, NodeFactory nodeFactory, AnimationFactory animFactory, SpecialItemsHandler siHandler, ModelContext context, int length) throws IOException { /*int flags = */ file.readUnsignedShort(); // int animType = flags & 0x03; // should be one of 0, 2, 3. // boolean lockX = ( ( flags & 8 ) != 0 ); // boolean lockY = ( ( flags & 16 ) != 0 ); // boolean lockZ = ( ( flags & 32 ) != 0 ); // boolean unlinkX = ( ( flags & 64 ) != 0 ); // boolean unlinkY = ( ( flags & 128 ) != 0 ); // boolean unlinkZ = ( ( flags & 256 ) != 0 ); // System.out.println( "flags: " + Integer.toBinaryString( flags ) ); file.skipBytes(8); // four unknown ushorts. int numKeys = file.readUnsignedInt(); context.translation = new PosTransform(); JAGTLog.debug("Translation key frames: ", numKeys); for (int i = 0; i < numKeys; i++) { int frameNumber = file.readUnsignedInt(); int accelerationData = file.readUnsignedShort(); getSplineTerms(accelerationData, file); float x = file.readFloat(); float y = file.readFloat(); float z = file.readFloat(); Vector3f translation; if ((numKeys == 1) && (x == 0f) && (y == 0f) && (z == 0f)) translation = null; else translation = new Vector3f(x, y, z); // translation = new Vector3f( x, z, -y ); if (context.pivot == null) { context.pivot = new Point3f(0f, 0f, 0f); } JAGTLog.debug("\tTranslation key frame: ", frameNumber + " : ", translation); context.translation.addKeyFrame( frameNumber, (float) frameNumber / (float) context.framesCount, translation); } checkAndApplyTransform( context, false, nodeFactory, animFactory, siHandler, file.convertZup2Yup()); }
/** * This only reads the spline data and should be part of the track header when it gets invented. * * <p>The possible spline values are are * * <ol> * <li>Tension * <li>Continuity * <li>Bias * <li>EaseTo * <li>EaseFrom * </ol> * * @param accelerationData an integer representing the bits that determine which of the five * possible spline terms are present in the data and should be read. * @param file */ private void getSplineTerms(final int accelerationData, TDSFile file) throws IOException { if (accelerationData == 0) return; int bits = accelerationData; for (int i = 0; i < 5; i++) { bits = bits >>> i; if ((bits & 1) == 1) { file.readFloat(); } } }