Java Code Examples for com.badlogic.gdx.graphics.g3d.Material#get()

The following examples show how to use com.badlogic.gdx.graphics.g3d.Material#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private void addMaterialTextureSwitch(String name, final Material material, long type){
	final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type);
	if(attribute != null){
		final TextButton bt = new TextButton(name, getSkin(), "toggle");
		bt.setChecked(true);
		materialTable.add(bt);
		
		Image pict = new Image(attribute.textureDescription.texture);
		
		pict.setScaling(Scaling.fit);
		
		materialTable.add(pict).size(64);
		
		materialTable.row();
		
		bt.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(bt.isChecked()){
					material.set(attribute);
				}else{
					material.remove(attribute.type);
				}
			}
		});
	}
	
}
 
Example 2
Source File: GLTFMaterialExporter.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private GLTFOcclusionTextureInfo occlusionTexture(PBRTextureAttribute a, Material material) {
	GLTFOcclusionTextureInfo ti = new GLTFOcclusionTextureInfo();
	ti.strength = material.get(PBRFloatAttribute.class, PBRFloatAttribute.OcclusionStrength).value;
	ti.texCoord = a.uvIndex;
	ti.index = getTexture(a);
	return ti;
}
 
Example 3
Source File: GLTFMaterialExporter.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private GLTFNormalTextureInfo normalTexture(PBRTextureAttribute a, Material material) {
	GLTFNormalTextureInfo ti = new GLTFNormalTextureInfo();
	ti.scale = material.get(PBRFloatAttribute.class, PBRFloatAttribute.NormalScale).value;
	ti.texCoord = a.uvIndex;
	ti.index = getTexture(a);
	return ti;
}
 
Example 4
Source File: BaseEntity.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
public void setColor (float r, float g, float b, float a) {
	color.set(r, g, b, a);
	if (modelInstance != null) {
		for (Material m : modelInstance.materials) {
			ColorAttribute ca = (ColorAttribute)m.get(ColorAttribute.Diffuse);
			if (ca != null) ca.color.set(r, g, b, a);
		}
	}
}