本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.Renderable类的典型用法代码示例。如果您正苦于以下问题:Java Renderable类的具体用法?Java Renderable怎么用?Java Renderable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Renderable类属于com.badlogic.gdx.graphics.g3d包,在下文中一共展示了Renderable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: obtain
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public Renderable obtain() {
Renderable renderable = super.obtain();
// super.obtain resets the following
// renderable.environment = null;
// renderable.material = null;
// renderable.meshPart.set("", null, 0, 0, 0);
// renderable.shader = null;
// renderable.userData = null;
// built in as of libgdx 1.9.6
// https://github.com/libgdx/libgdx/pull/4550
// custom
renderable.worldTransform.idt();
return renderable;
}
示例2: draw
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
public static Renderable draw() {
Player player = Cubes.getClient().player;
ItemTool.MiningTarget currentlyMining = player.getCurrentlyMining();
if (currentlyMining == null)
return null;
BlockReference position = currentlyMining.target;
float percent = currentlyMining.time / currentlyMining.totalTime;
percent -= 1f / (1f + num);
if (percent <= 0f)
return null;
int n = (int) Math.floor(percent * num);
float f = 1f / 128f;
Renderable renderable = new Renderable();
renderable.worldTransform.translate(position.blockX - f, position.blockY - f, position.blockZ - f);
renderable.worldTransform.scl(1f + f + f);
renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
renderable.meshPart.offset = n * (6 * 6);
renderable.meshPart.size = 6 * 6;
renderable.meshPart.mesh = mesh;
renderable.material = material;
return renderable;
}
示例3: getShaderIf
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
private void getShaderIf(int shader, Renderable renderable, boolean fogFlag, boolean aoFlag) {
if (shaders[shader] == null) {
if (shader == 0) {
shaders[shader] = new CubesShader(renderable);
} else {
ArrayList<Feature> f = new ArrayList<Feature>();
if (fogFlag)
f.add(new FogFeature());
if (aoFlag)
f.add(new AmbientOcclusionFeature());
shaders[shader] = new FeatureShader(renderable, f);
}
ShaderProgram program = shaders[shader].program;
if (!program.isCompiled()) {
Log.error("Failed to compile shader");
Log.error("Shader log: \n" + program.getLog());
Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
throw new CubesException("Failed to compile shader");
}
shaders[shader].init();
}
}
示例4: getShader
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public Shader getShader(Renderable renderable) {
int shader = 0;
boolean fogFlag = Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG);
if (renderable.userData instanceof RenderingSettings)
fogFlag &= ((RenderingSettings) renderable.userData).fogEnabled;
if (fogFlag)
shader |= FEATURE_FOG;
boolean aoFlag = renderable.meshPart.mesh.getVertexAttributes() == CubesVertexAttributes.VERTEX_ATTRIBUTES_AO;
if (aoFlag)
shader |= FEATURE_AO;
getShaderIf(shader, renderable, fogFlag, aoFlag);
return shaders[shader];
}
示例5: setWorldTransform
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
public static void setWorldTransform(Renderable renderable, boolean isMoon) {
Vector3 pos = Cubes.getClient().player.position;
int r = 512;
float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME;
if (isMoon)
f += 0.5f;
f %= 1;
float x = (pos.x + (r * Math.cos(f * 2 * Math.PI)));
float y = (pos.y + (r * Math.sin(f * 2 * Math.PI)));
float z = pos.z;
renderable.worldTransform.setToTranslation(x, y, z);
renderable.worldTransform.scl(75f);
renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360);
}
示例6: obtain
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public Renderable obtain () {
Renderable renderable = super.obtain();
// super.obtain resets the following
//renderable.environment = null;
//renderable.material = null;
//renderable.meshPart.set("", null, 0, 0, 0);
//renderable.shader = null;
// renderable.userData = null;
// built in as of libgdx 1.9.6
// https://github.com/libgdx/libgdx/pull/4550
// custom
renderable.worldTransform.idt();
return renderable;
}
示例7: draw
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
public static Renderable draw() {
Player player = Cubes.getClient().player;
ItemTool.MiningTarget currentlyMining = player.getCurrentlyMining();
if (currentlyMining == null) return null;
BlockReference position = currentlyMining.target;
float percent = currentlyMining.time / currentlyMining.totalTime;
percent -= 1f / (1f + num);
if (percent <= 0f) return null;
int n = (int) Math.floor(percent * num);
float f = 1f / 128f;
Renderable renderable = new Renderable();
renderable.worldTransform.translate(position.blockX - f, position.blockY - f, position.blockZ - f);
renderable.worldTransform.scl(1f + f + f);
renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
renderable.meshPart.offset = n * (6 * 6);
renderable.meshPart.size = 6 * 6;
renderable.meshPart.mesh = mesh;
renderable.material = material;
return renderable;
}
示例8: createPrefix
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
private String createPrefix(Renderable renderable) {
String prefix = "";
if (params.useBones) {
prefix += "#define numBones " + 12 + "\n";
final int n = renderable.meshPart.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i);
if (attr.usage == VertexAttributes.Usage.BoneWeight) {
prefix += "#define boneWeight" + attr.unit + "Flag\n";
}
}
}
return prefix;
}
示例9: getAttributeLocations
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
protected final int[] getAttributeLocations(Renderable renderable) {
final IntIntMap attributes = new IntIntMap();
final VertexAttributes attrs = renderable.meshPart.mesh.getVertexAttributes();
final int c = attrs.size();
for (int i = 0; i < c; i++) {
final VertexAttribute attr = attrs.get(i);
final int location = program.getAttributeLocation(attr.alias);
if (location >= 0)
attributes.put(attr.getKey(), location);
}
tempArray.clear();
final int n = attrs.size();
for (int i = 0; i < n; i++) {
tempArray.add(attributes.get(attrs.get(i).getKey(), -1));
}
return tempArray.items;
}
示例10: render
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public void render(Renderable renderable) {
program.setUniformMatrix(u_worldTrans, renderable.worldTransform);
program.setUniformf(albedo, albedoColor);
program.setUniformf(metallic, metallicValue);
program.setUniformf(ambientOcclusion, ambientOcclusionValue);
program.setUniformf(vLight0, new Vector3(2.00f,-2.00f,-2.00f));
ref.bind(0);
program.setUniformi(sCubemapTexture, 0);
program.setUniformf(vRoughness, new Vector2(rougness,5));
if (currentMesh != renderable.meshPart.mesh) {
if (currentMesh != null)
currentMesh.unbind(program, tempArray.items);
currentMesh = renderable.meshPart.mesh;
currentMesh.bind(program, getAttributeLocations(renderable));
}
renderable.meshPart.mesh.render(program,
renderable.meshPart.primitiveType,
renderable.meshPart.offset,
renderable.meshPart.size,false);
}
示例11: render
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public void render(final Renderable renderable, final Attributes combinedAttributes) {
boolean firstCall = true;
for(final LightWrapper light : lights) {
light.applyToShader(program);
if(firstCall){
context.setDepthTest(GL20.GL_LEQUAL);
context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
super.render(renderable, combinedAttributes);
firstCall = false;
}else{
context.setDepthTest(GL20.GL_EQUAL);
context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
renderable.meshPart.render(program, false);
}
}
}
示例12: render
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public void render(final Renderable renderable, final Attributes combinedAttributes) {
renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
final boolean[] firstCall = {true};
lights.forEach(l -> {
l.applyToShader(program);
if(Gdx.input.isKeyJustPressed(Input.Keys.L))
for (String s : program.getUniforms()) {
System.out.println(s);
}
if(true) {
context.setDepthTest(GL20.GL_LEQUAL);
context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
super.render(renderable, combinedAttributes);
firstCall[0] = false;
}else{
context.setDepthTest(GL20.GL_EQUAL);
context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
MeshPart part = renderable.meshPart;
part.mesh.render(program, part.primitiveType, part.offset, part.size, false);
}
});
}
示例13: render
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public void render(Renderable renderable, Attributes combinedAttributes)
{
// context.setCullFace(GL_BACK);
// Classic depth test
context.setDepthTest(GL20.GL_LEQUAL);
// Deactivate blending on first pass
context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
context.setDepthMask(true);
if (!combinedAttributes.has(BlendingAttribute.Type))
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
super.render(renderable, combinedAttributes);
// program.begin();
// super.render(renderable, combinedAttributes);
// program.end();
}
示例14: getShader
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public Shader getShader(Renderable renderable)
{
// небольшой такой КОСТЫЛЬ из за убогости LibGDX
// явно укажем версию шейдеров. и немного поправим совместимость...
ShaderProgram.prependVertexCode = SHADER_VERSION + "\n";
ShaderProgram.prependFragmentCode = SHADER_VERSION + "\n";
Shader shader = super.getShader(renderable);
ShaderProgram.prependVertexCode = null;
ShaderProgram.prependFragmentCode = null;
return shader;
}
示例15: render
import com.badlogic.gdx.graphics.g3d.Renderable; //导入依赖的package包/类
@Override
public void render(final Renderable renderable)
{
// if (!renderable.material.has(BlendingAttribute.Type))
// {
// context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
// }
// else
// {
// context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
// }
// if (!renderable.material.has(BlendingAttribute.Type))
// {
// context.setDepthTest(GL20.GL_LEQUAL);
// context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
// }
// else
// {
// context.setDepthTest(GL20.GL_EQUAL);
// context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
// }
super.render(renderable);
}