/** * Initialize the {@link TextureModel} instances */ private void initTextureModels() { Map<String, Texture> textures = Optionals.of(gltf.getTextures()); for (Entry<String, Texture> entry : textures.entrySet()) { String textureId = entry.getKey(); Texture texture = entry.getValue(); DefaultTextureModel textureModel = get("textures", textureId, textureModels); textureModel.setName(texture.getName()); String imageId = texture.getSource(); DefaultImageModel imageModel = get("images", imageId, imageModels); textureModel.setImageModel(imageModel); } }
Texture texture = new Texture(); texture.setFormat(GltfConstants.GL_RGBA); texture.setInternalFormat(GltfConstants.GL_RGBA); texture.setSource(imageId); texture.setTarget(GltfConstants.GL_TEXTURE_2D); texture.setType(GltfConstants.GL_UNSIGNED_BYTE); texture.setSampler(samplerId); textureId = GltfIds.generateId("texture", gltf.getTextures()); gltf.addTextures(textureId, texture);
String imageId = texture.getSource(); validatorResult.add(validateMapEntry( getGltf().getImages(), imageId, String samplerId = texture.getSampler(); validatorResult.add(validateMapEntry( getGltf().getSamplers(), samplerId,
/** * Create the {@link TextureModel} instances */ private void createTextureModels() { Map<String, Texture> textures = Optionals.of(gltf.getTextures()); Map<String, Sampler> samplers = Optionals.of(gltf.getSamplers()); for (Entry<String, Texture> entry : textures.entrySet()) { Texture texture = entry.getValue(); String samplerId = texture.getSampler(); Sampler sampler = samplers.get(samplerId); int magFilter = Optionals.of( sampler.getMagFilter(), sampler.defaultMagFilter()); int minFilter = Optionals.of( sampler.getMinFilter(), sampler.defaultMinFilter()); int wrapS = Optionals.of( sampler.getWrapS(), sampler.defaultWrapS()); int wrapT = Optionals.of( sampler.getWrapT(), sampler.defaultWrapT()); textureModels.add(new DefaultTextureModel( magFilter, minFilter, wrapS, wrapT)); } }