List<MeshModel> meshModels = nodeModel.getMeshModels(); for (MeshModel meshModel : meshModels) List<NodeModel> children = nodeModel.getChildren(); for (NodeModel childNode : children)
/** * Creates an {@link AnimationListener} that writes the animation data * into the {@link NodeModel#getWeights() weights} of the * {@link NodeModel}. * * @param nodeModel The {@link NodeModel} * @return The {@link AnimationListener} */ private static AnimationListener createWeightsAnimationListener( NodeModel nodeModel) { return (animation, timeS, values) -> { float weights[] = nodeModel.getWeights(); if (weights == null) { weights = values.clone(); nodeModel.setWeights(weights); } else { System.arraycopy(values, 0, weights, 0, values.length); } }; }
/** * Compute the global transform for the given {@link NodeModel}, * and store it in the given result. If the given result is * <code>null</code> or does not have a length of 16, then * a new array will be created and returned. * * @param nodeModel The {@link NodeModel} * @param result The result * @return The result */ private static float[] computeGlobalTransform( NodeModel nodeModel, float result[]) { float localResult[] = Utils.validate(result, 16); float tempLocalTransform[] = TEMP_MATRIX_4x4_IN_GLOBAL.get(); NodeModel currentNode = nodeModel; MathUtils.setIdentity4x4(localResult); while (currentNode != null) { currentNode.computeLocalTransform(tempLocalTransform); MathUtils.mul4x4( tempLocalTransform, localResult, localResult); currentNode = currentNode.getParent(); } return localResult; }
/** * Creates an {@link AnimationListener} that writes the animation data * into the {@link NodeModel#getRotation() rotation} of the * {@link NodeModel}. * * @param nodeModel The {@link NodeModel} * @return The {@link AnimationListener} */ private static AnimationListener createRotationAnimationListener( NodeModel nodeModel) { return (animation, timeS, values) -> { float rotation[] = nodeModel.getRotation(); if (rotation == null) { rotation = values.clone(); nodeModel.setRotation(rotation); } else { System.arraycopy(values, 0, rotation, 0, values.length); } }; }
if (nodeModel.getMatrix() != null) float m[] = nodeModel.getMatrix(); System.arraycopy(m, 0, localResult, 0, m.length); return localResult; if (nodeModel.getTranslation() != null) float t[] = nodeModel.getTranslation(); localResult[12] = t[0]; localResult[13] = t[1]; localResult[14] = t[2]; if (nodeModel.getRotation() != null) float q[] = nodeModel.getRotation(); float m[] = TEMP_MATRIX_4x4_IN_LOCAL.get(); MathUtils.quaternionToMatrix4x4(q, m); MathUtils.mul4x4(localResult, m, localResult); if (nodeModel.getScale() != null) float s[] = nodeModel.getScale(); float m[] = TEMP_MATRIX_4x4_IN_LOCAL.get(); MathUtils.setIdentity4x4(m);
float[] localTransform = nodeModel.computeLocalTransform(null); float[] transform = new float[16]; MathUtils.mul4x4(parentTransform, localTransform, transform); List<MeshModel> meshModels = nodeModel.getMeshModels(); for (MeshModel meshModel : meshModels) List<NodeModel> children = nodeModel.getChildren(); for (NodeModel child : children)
@Override public void run() { // Update the weights based on the weights from the node // or the mesh if (nodeModel.getWeights() != null) { System.arraycopy( nodeModel.getWeights(), 0, weights, 0, weights.length); } else if (meshModel.getWeights() != null) { System.arraycopy( meshModel.getWeights(), 0, weights, 0, weights.length); } // Perform the update, and pass the updated buffer to GL morphableAttribute.updateMorphedAccessorData(weights); glContext.updateVertexAttribute(glVertexArray, GltfConstants.GL_ARRAY_BUFFER, glBufferView, 0, bufferSize, morphedBufferViewData); } };
NodeModel nodeModel) SkinModel skinModel = nodeModel.getSkinModel(); .create4x4(nodeModel.createGlobalTransformSupplier()) .invert4x4() .multiply4x4(jointNodeModel.createGlobalTransformSupplier()) .multiply4x4(inverseBindMatrixSupplier) .multiply4x4(bindShapeMatrixSupplier)
return nodeModel.createLocalTransformSupplier(); return nodeModel.createGlobalTransformSupplier(); nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(viewMatrixSupplier) nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(projectionMatrixSupplier) nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(modelMatrixSupplier) nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(viewMatrixSupplier) nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(projectionMatrixSupplier) nodeModel.createGlobalTransformSupplier(); return MatrixOps .create4x4(modelMatrixSupplier) nodeModel.createGlobalTransformSupplier();
nodeModel.computeGlobalTransform(localResult); MathUtils.invert4x4(localResult, localResult); return localResult;
nodeModel.computeGlobalTransform(localResult); MathUtils.invert4x4(localResult, localResult); return localResult;