List of usage examples for com.badlogic.gdx.graphics.g3d Model getMaterial
public Material getMaterial(final String id)
From source file:com.mygdx.game.scene.GameScene.java
License:Apache License
private void setVColorBlendAttributes() { Array<String> modelsIdsInScene = assets.getPlaceholderIdsByType(BlenderModel.class); Array<BlenderModel> instancesWithId = new Array<BlenderModel>(); for (String id : modelsIdsInScene) { instancesWithId.clear();/*from w w w .j a v a 2s. c om*/ assets.getPlaceholders(id, BlenderModel.class, instancesWithId); for (BlenderModel blenderModel : instancesWithId) { // Maybe check if // renderable.meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.ColorUnpacked) != null if (blenderModel.custom_properties.containsKey("v_color_material_blend")) { Model model = assets.getAsset(id, Model.class); String redMaterialName = blenderModel.custom_properties.get("v_color_material_red"); String greenMaterialName = blenderModel.custom_properties.get("v_color_material_green"); String blueMaterialName = blenderModel.custom_properties.get("v_color_material_blue"); TextureAttribute redTexAttr = (TextureAttribute) model.getMaterial(redMaterialName) .get(TextureAttribute.Diffuse); TextureAttribute greenTexAttr = (TextureAttribute) model.getMaterial(greenMaterialName) .get(TextureAttribute.Diffuse); TextureAttribute blueTexAttr = (TextureAttribute) model.getMaterial(blueMaterialName) .get(TextureAttribute.Diffuse); VertexColorTextureBlend redAttribute = new VertexColorTextureBlend(VertexColorTextureBlend.Red, redTexAttr.textureDescription.texture); VertexColorTextureBlend greenAttribute = new VertexColorTextureBlend( VertexColorTextureBlend.Green, greenTexAttr.textureDescription.texture); VertexColorTextureBlend blueAttribute = new VertexColorTextureBlend( VertexColorTextureBlend.Blue, blueTexAttr.textureDescription.texture); for (Node node : model.nodes) { for (NodePart nodePart : node.parts) { nodePart.material.set(redAttribute, greenAttribute, blueAttribute); } } break; } } } }