/** * Create the {@link NodeModel} instances */ private void createNodeModels() { Map<String, Node> nodes = Optionals.of(gltf.getNodes()); for (int i = 0; i < nodes.size(); i++) { nodeModels.add(new DefaultNodeModel()); } }
/** * Compute the mapping from joint names to the ID of the {@link Node} with * the respective {@link Node#getJointName() joint name} * * @param gltf The {@link GlTF} * @return The mapping */ private static Map<String, String> computeJointNameToNodeIdMap(GlTF gltf) { Map<String, String> map = new LinkedHashMap<String, String>(); Map<String, Node> nodes = Optionals.of(gltf.getNodes()); for (Entry<String, Node> entry : nodes.entrySet()) { String nodeId = entry.getKey(); Node node = entry.getValue(); if (node.getJointName() != null) { String oldNodeId = map.put(node.getJointName(), nodeId); if (oldNodeId != null) { logger.warning("Joint name " + node.getJointName() + " is mapped to nodes with IDs " + nodeId + " and " + oldNodeId); } } } return map; }
/** * Validate the {@link GlTF#getNodes()} * * @param currentContext The optional {@link ValidatorContext} of the glTF * @return The {@link ValidatorResult} */ private ValidatorResult validateNodes(ValidatorContext currentContext) { ValidatorContext context = new ValidatorContext(currentContext); ValidatorResult validatorResult = new ValidatorResult(); validatorResult.add(validateElements( getGltf().getNodes(), "nodes", true, context, nodeValidator::validateNode)); if (validatorResult.hasErrors()) { return validatorResult; } return validatorResult; }
Map<String, Node> nodes = Optionals.of(gltf.getNodes()); Map<String, Camera> cameras = Optionals.of(gltf.getCameras()); for (Entry<String, Node> entry : nodes.entrySet())
getGltf().getNodes(), nodes, "nodes", true, context));
getGltf().getNodes(), nodeId, context)); if (validatorResult.hasErrors()) Node node = getGltf().getNodes().get(nodeId); getGltf().getNodes(), children, "children", false, context)); if (validatorResult.hasErrors()) getGltf().getNodes(), skeletons, "skeletons", false, context)); if (validatorResult.hasErrors())
Map<String, Node> nodes = Optionals.of(gltf.getNodes()); for (Entry<String, Node> entry : nodes.entrySet())
String nodeId = GltfIds.generateId("node", gltf.getNodes()); gltf.addNodes(nodeId, node);
/** * Compute the {@link IndexMappingSet} for the given glTF instance. * The {@link IndexMappingSet} will contain index mappings for all * top-level dictionaries of the given glTF. * * @param gltf The glTF * @return The {@link IndexMappingSet} */ static IndexMappingSet create(GlTF gltf) { IndexMappingSet indexMappingSet = new IndexMappingSet(); indexMappingSet.generate("accessors", gltf.getAccessors()); indexMappingSet.generate("animations", gltf.getAnimations()); indexMappingSet.generate("buffers", gltf.getBuffers()); indexMappingSet.generate("bufferViews", gltf.getBufferViews()); indexMappingSet.generate("cameras", gltf.getCameras()); indexMappingSet.generate("images", gltf.getImages()); indexMappingSet.generate("materials", gltf.getMaterials()); indexMappingSet.generate("meshes", gltf.getMeshes()); indexMappingSet.generate("nodes", gltf.getNodes()); indexMappingSet.generate("programs", gltf.getPrograms()); indexMappingSet.generate("samplers", gltf.getSamplers()); indexMappingSet.generate("scenes", gltf.getScenes()); indexMappingSet.generate("shaders", gltf.getShaders()); indexMappingSet.generate("skins", gltf.getSkins()); indexMappingSet.generate("techniques", gltf.getTechniques()); indexMappingSet.generate("textures", gltf.getTextures()); return indexMappingSet; }