/** * Create the {@link MeshModel} instances */ private void createMeshModels() { Map<String, Mesh> meshes = Optionals.of(gltf.getMeshes()); for (int i = 0; i < meshes.size(); i++) { meshModels.add(new DefaultMeshModel()); } }
/** * Initialize the {@link MeshModel} instances */ private void initMeshModels() { Map<String, Mesh> meshes = Optionals.of(gltf.getMeshes()); for (Entry<String, Mesh> entry : meshes.entrySet()) { String meshId = entry.getKey(); Mesh mesh = entry.getValue(); List<MeshPrimitive> primitives = Optionals.of(mesh.getPrimitives()); DefaultMeshModel meshModel = get("meshes", meshId, meshModels); meshModel.setName(mesh.getName()); for (MeshPrimitive meshPrimitive : primitives) { MeshPrimitiveModel meshPrimitiveModel = createMeshPrimitiveModel(meshPrimitive); meshModel.addMeshPrimitiveModel(meshPrimitiveModel); } } }
/** * Validate the {@link GlTF#getMeshes()} * * @param currentContext The optional {@link ValidatorContext} of the glTF * @return The {@link ValidatorResult} */ private ValidatorResult validateMeshes(ValidatorContext currentContext) { ValidatorContext context = new ValidatorContext(currentContext); ValidatorResult validatorResult = new ValidatorResult(); validatorResult.add(validateElements( getGltf().getMeshes(), "meshes", true, context, meshValidator::validateMesh)); if (validatorResult.hasErrors()) { return validatorResult; } return validatorResult; }
String meshId = GltfIds.generateId("mesh", gltf.getMeshes()); gltf.addMeshes(meshId, mesh);
getGltf().getMeshes(), meshes, "meshes", false, context)); if (validatorResult.hasErrors())
/** * 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; }