use of com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute in project libgdx by libgdx.
the class MaterialTest method create.
@Override
public void create() {
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
// Create material attributes. Each material can contain x-number of attributes.
textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
ModelBuilder builder = new ModelBuilder();
model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
model.manageDisposable(texture);
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(Vector3.X, 45);
material = modelInstance.materials.get(0);
builder.begin();
MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(textureAttribute));
mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
backModel = builder.end();
background = new ModelInstance(backModel);
modelBatch = new ModelBatch();
camera = new PerspectiveCamera(45, 4, 4);
camera.position.set(0, 0, 3);
camera.direction.set(0, 0, -1);
camera.update();
Gdx.input.setInputProcessor(this);
}
use of com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute in project bdx by GoranM.
the class BDXShaderProvider method render.
public void render(Renderable renderable, Attributes combinedAttributes) {
if (renderable.material.has(BlendingAttribute.Type)) {
BlendingAttribute ba = (BlendingAttribute) renderable.material.get(BlendingAttribute.Type);
Gdx.gl.glBlendFuncSeparate(ba.sourceFunction, ba.destFunction, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
IntAttribute shadeless = (IntAttribute) renderable.material.get(Scene.BDXIntAttribute.Shadeless);
if (shadeless == null)
set(u_shadeless, 0);
else
set(u_shadeless, shadeless.value);
ColorAttribute tint = (ColorAttribute) renderable.material.get(Scene.BDXColorAttribute.Tint);
if (tint == null)
set(u_tintColor, new Color());
else
set(u_tintColor, tint.color);
ColorAttribute emit = (ColorAttribute) renderable.material.get(Scene.BDXColorAttribute.Emit);
if (emit == null)
set(u_emitColor, new Color());
else
set(u_emitColor, emit.color);
if (shaderProvider.scene != null) {
ColorAttribute fog = (ColorAttribute) renderable.environment.get(ColorAttribute.Fog);
if (fog == null)
set(u_fogRange, 0f, 0f);
else
set(u_fogRange, shaderProvider.scene.fogRange().x, shaderProvider.scene.fogRange().y);
set(u_camRange, shaderProvider.scene.camera.near(), shaderProvider.scene.camera.far());
}
super.render(renderable, combinedAttributes);
}
Aggregations