@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()); }
private void doParsing(XMLStreamReader parser) throws XMLStreamException { for (int i = 0; i < parser.getAttributeCount(); i++) { QName attr = parser.getAttributeName(i); if (attr.getLocalPart().equals("source")) { source = XMLIDREFUtils.parse(parser.getAttributeValue(i)); } else { JAGTLog.exception( "Unsupported ", this.getClass().getSimpleName(), " Attr tag: ", attr.getLocalPart()); } } for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { switch (event) { case XMLStreamConstants.START_ELEMENT: { String localName = parser.getLocalName(); if (localName.equals("source")) { XMLSource src = new XMLSource(); src.parse(parser); sources.add(src); } else if (localName.equals("bind_shape_matrix")) { if (bindShapeMatrix != null) { JAGTLog.exception( this.getClass().getSimpleName(), " too many bind_shape_matrix tags."); } bindShapeMatrix = XMLMatrixUtils.readColumnMajor(StAXHelper.parseText(parser)); // bindShapeMatrix = XMLMatrixUtils.readRowMajor( StAXHelper.parseText( parser ) ); } else if (localName.equals("joints")) { jointsInputs = getJointInputs(parser); } else if (localName.equals("vertex_weights")) { vertexWeights = new XMLVertexWeights(); vertexWeights.parse(parser); } else { JAGTLog.exception( "Unsupported ", this.getClass().getSimpleName(), " Start tag: ", parser.getLocalName()); } break; } case XMLStreamConstants.END_ELEMENT: { if (parser.getLocalName().equals("skin")) { return; } break; } } } }
public ArrayList<XMLInput> getJointInputs(XMLStreamReader parser) throws XMLStreamException { ArrayList<XMLInput> inputs = new ArrayList<XMLInput>(); for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { switch (event) { case XMLStreamConstants.START_ELEMENT: { String localName = parser.getLocalName(); if (localName.equals("input")) { XMLInput input = new XMLInput(); input.parse(parser); inputs.add(input); } else { JAGTLog.exception("Unsupported XMLJoint Start tag: ", parser.getLocalName()); } } case XMLStreamConstants.END_ELEMENT: { if (parser.getLocalName().equals("joints")) { return inputs; } break; } } } return (null); }
public void parse(XMLStreamReader parser) throws XMLStreamException { for (int i = 0; i < parser.getAttributeCount(); i++) { QName attr = parser.getAttributeName(i); if (attr.getLocalPart().equals("id")) { id = parser.getAttributeValue(i); } else if (attr.getLocalPart().equals("name")) { name = parser.getAttributeValue(i); } else { JAGTLog.exception( "Unsupported ", this.getClass().getSimpleName(), " Attr tag: ", parser.getLocalName()); } } for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { switch (event) { case XMLStreamConstants.START_ELEMENT: { String localName = parser.getLocalName(); if (localName.equals("geometry")) { parseAttributes(parser); } else if (localName.equals("asset")) { asset = new XMLAsset(); asset.parse(parser); } else if (localName.equals("mesh")) { mesh = new XMLMesh(); mesh.parse(parser); } else { JAGTLog.exception( "Unsupported ", this.getClass().getSimpleName(), " Start tag: ", parser.getLocalName()); } break; } case XMLStreamConstants.END_ELEMENT: { if (parser.getLocalName().equals("geometry")) return; break; } } } }
public void parse(XMLStreamReader parser) throws XMLStreamException { doParsing(parser); if (source == null) { JAGTLog.exception(this.getClass().getSimpleName(), " missing attribute source."); } if (jointsInputs == null) { JAGTLog.exception(this.getClass().getSimpleName(), " missing joint."); } if (vertexWeights == null) { JAGTLog.exception(this.getClass().getSimpleName(), " missing vertex weights."); } if (sources.size() < 3) { JAGTLog.exception(this.getClass().getSimpleName(), " not enough sources."); } }