Rev 1798 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.bauzoid2.graphics.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.gebauz.bauzoid2.game.Engine;
import com.gebauz.bauzoid2.graphics.font.Font;
import com.gebauz.bauzoid2.graphics.renderstates.CullingStates;
import com.gebauz.bauzoid2.graphics.renderstates.DepthTestStates;
import com.gebauz.bauzoid2.graphics.shader.ShaderProgram;
import com.gebauz.bauzoid2.graphics.shader.ShaderUniform;
import com.gebauz.bauzoid2.math.Matrix4;
import com.gebauz.bauzoid2.util.IAsyncLoadable;
/**
* Created by chris on 14.12.2014.
*/
public class Material
{
// Constants========================================================================================
// Embedded Types===================================================================================
// Fields===========================================================================================
private String mName =
null;
private ShaderProgram mShader =
null;
private Texture mTexture =
null;
private ShaderUniform mTextureHandle =
null;
private ShaderUniform mMatrixPalette =
null;
// Methods==========================================================================================
public Material
(String name, Texture texture
)
{
mName = name
;
mTexture = texture
;
mShader = Engine.
graphics.
shaders.
createShader("standard",
"DIFFUSE");
mTextureHandle = mShader.
getUniform("uDiffuse");
mMatrixPalette = mShader.
getUniform("uBoneMatrices");
}
public void dispose
()
{
if (mTexture
!=
null)
{
mTexture.
dispose();
mTexture =
null;
}
mShader =
null;
mTextureHandle =
null;
}
public void setMatrixPalette
(Matrix4
[] boneMatrices
)
{
if (mMatrixPalette
!=
null)
{
mMatrixPalette.
set(boneMatrices
);
/*mMatrixPalette.set(new Matrix4[] {
Matrix4.createIdentity(),
Matrix4.createIdentity(),
Matrix4.createIdentity(),
});*/
}
}
public void beginRender
()
{
//Engine.graphics.renderStates.depthTest.setDepthTestFunction(DepthTestStates.ComparisonMode.GREATER);*/
mTexture.
setWrap(Texture.
TextureWrap.
Repeat, Texture.
TextureWrap.
Repeat);
Engine.
graphics.
renderStates.
depthTest.
setEnabled(true);
Engine.
graphics.
renderStates.
culling.
setEnabled(false);
Engine.
graphics.
renderStates.
culling.
setVisibleFaces(CullingStates.
VertexWinding.
COUNTERCLOCKWISE);
Engine.
graphics.
renderStates.
activate();
mShader.
activate();
mTextureHandle.
set(0);
Engine.
graphics.
renderStates.
getTextureStage(0).
bindTexture(mTexture
);
//Engine.graphics.renderStates.culling.setVisibleFaces(CullingStates.VertexWinding.COUNTERCLOCKWISE);
}
public void endRender
()
{
mShader.
deactivate();
Engine.
graphics.
renderStates.
deactivate();
}
// Getters/Setters==================================================================================
public final String getName
() { return mName
; }
}