本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute类的典型用法代码示例。如果您正苦于以下问题:Java FloatAttribute类的具体用法?Java FloatAttribute怎么用?Java FloatAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FloatAttribute类属于com.badlogic.gdx.graphics.g3d.attributes包,在下文中一共展示了FloatAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GameObject
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public GameObject(ScreenBase context, Model model, BoundingBox bounds) {
super(model);
this.context = context;
this.customBounds = bounds;
this.bounds = this.customBounds != null ? this.customBounds : new BoundingBox();
this.center = new Vector3();
this.enabled = true;
updateBox();
this.animations = new AnimationController(this);
this.blending = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
for(Material item : materials){
item.set(new DepthTestAttribute(GL20.GL_LEQUAL, 0.01f, 25f, true));
item.set(FloatAttribute.createAlphaTest(0.01f));
item.set(blending);
}
}
示例2: MaterialInterpreter
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public MaterialInterpreter() {
waterColor = new Color(0.13f, 0.05f, 0.8f, 1);
waterMaterial = new Material(
ColorAttribute.createDiffuse(waterColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
sandColor = new Color(0.9f, 0.733f, 0.58f, 1);
sandMaterial = new Material(ColorAttribute.createDiffuse(sandColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
grassColor = new Color(0f, 1f, 0f, 1f);
grassMaterial = new Material(ColorAttribute.createDiffuse(grassColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
}
示例3: render
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
@Override
public void render (final Renderable renderable) {
if (renderable.material.has(BlendingAttribute.Type)) {
final BlendingAttribute blending = (BlendingAttribute)renderable.material.get(BlendingAttribute.Type);
renderable.material.remove(BlendingAttribute.Type);
final boolean hasAlphaTest = renderable.material.has(FloatAttribute.AlphaTest);
if (!hasAlphaTest)
renderable.material.set(alphaTestAttribute);
if (blending.opacity >= ((FloatAttribute)renderable.material.get(FloatAttribute.AlphaTest)).value)
super.render(renderable);
if (!hasAlphaTest)
renderable.material.remove(FloatAttribute.AlphaTest);
renderable.material.set(blending);
} else
super.render(renderable);
}
示例4: create
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
@Override
public void create () {
super.create();
final Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
disposables.add(texture);
final Material material = new Material(TextureAttribute.createDiffuse(texture), ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
final long attributes = Usage.Position | Usage.Normal | Usage.TextureCoordinates;
final Model sphere = modelBuilder.createSphere(4f, 4f, 4f, 24, 24, material, attributes);
disposables.add(sphere);
world.addConstructor("sphere", new BulletConstructor(sphere, 10f, new btSphereShape(2f)));
final Model cylinder = modelBuilder.createCylinder(4f, 6f, 4f, 16, material, attributes);
disposables.add(cylinder);
world.addConstructor("cylinder", new BulletConstructor(cylinder, 10f, new btCylinderShape(tmpV1.set(2f, 3f, 2f))));
final Model capsule = modelBuilder.createCapsule(2f, 6f, 16, material, attributes);
disposables.add(capsule);
world.addConstructor("capsule", new BulletConstructor(capsule, 10f, new btCapsuleShape(2f, 2f)));
final Model box = modelBuilder.createBox(4f, 4f, 2f, material, attributes);
disposables.add(box);
world.addConstructor("box2", new BulletConstructor(box, 10f, new btBoxShape(tmpV1.set(2f, 2f, 1f))));
final Model cone = modelBuilder.createCone(4f, 6f, 4f, 16, material, attributes);
disposables.add(cone);
world.addConstructor("cone", new BulletConstructor(cone, 10f, new btConeShape(2f, 6f)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
world.add("sphere", 0, 5, 5);
world.add("cylinder", 5, 5, 0);
world.add("box2", 0, 5, 0);
world.add("capsule", 5, 5, 5);
world.add("cone", 10, 5, 0);
}
示例5: drawBlockSelection
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
private void drawBlockSelection() {
int curProgressInt = Math.round(RadixClient.getInstance().getPlayer().getBreakPercent() * 10) - 1;
if ((blockBreakModel == null || blockBreakStage != curProgressInt) && curProgressInt >= 0) {
if (blockBreakModel != null)
blockBreakModel.dispose();
blockBreakStage = curProgressInt;
ModelBuilder builder = new ModelBuilder();
blockBreakModel = builder.createBox(1f, 1f, 1f,
new Material(TextureAttribute.createDiffuse(blockBreakStages[blockBreakStage]),
new BlendingAttribute(),
FloatAttribute.createAlphaTest(0.25f)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates);
blockBreakModelInstance = new ModelInstance(blockBreakModel);
}
Vec3i curBlk = RadixClient.getInstance().getSelectedBlock();
if (curBlk != null && curProgressInt >= 0) {
Gdx.gl.glPolygonOffset(100000, 2000000);
blockOverlayBatch.begin(RadixClient.getInstance().getCamera());
blockBreakModelInstance.transform.translate(curBlk.x + 0.5f, curBlk.y + 0.5f, curBlk.z + 0.5f);
blockOverlayBatch.render(blockBreakModelInstance);
blockBreakModelInstance.transform.translate(-(curBlk.x + 0.5f), -(curBlk.y + 0.5f), -(curBlk.z + 0.5f));
blockOverlayBatch.end();
Gdx.gl.glPolygonOffset(100000, -2000000);
}
}
示例6: render
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
@Override
public void render(Renderable renderable) {
final MundusEnvironment env = (MundusEnvironment) renderable.environment;
setLights(env);
set(UNIFORM_TRANS_MATRIX, renderable.worldTransform);
// texture uniform
TextureAttribute diffuseTexture = ((TextureAttribute) (renderable.material.get(TextureAttribute.Diffuse)));
ColorAttribute diffuseColor = ((ColorAttribute) (renderable.material.get(ColorAttribute.Diffuse)));
if (diffuseTexture != null) {
set(UNIFORM_MATERIAL_DIFFUSE_TEXTURE, diffuseTexture.textureDescription.texture);
set(UNIFORM_MATERIAL_DIFFUSE_USE_TEXTURE, 1);
} else {
set(UNIFORM_MATERIAL_DIFFUSE_COLOR, diffuseColor.color);
set(UNIFORM_MATERIAL_DIFFUSE_USE_TEXTURE, 0);
}
// shininess
float shininess = ((FloatAttribute)renderable.material.get(FloatAttribute.Shininess)).value;
set(UNIFORM_MATERIAL_SHININESS, shininess);
// Fog
final Fog fog = env.getFog();
if (fog == null) {
set(UNIFORM_FOG_DENSITY, 0f);
set(UNIFORM_FOG_GRADIENT, 0f);
} else {
set(UNIFORM_FOG_DENSITY, fog.density);
set(UNIFORM_FOG_GRADIENT, fog.gradient);
set(UNIFORM_FOG_COLOR, fog.color);
}
// bind attributes, bind mesh & render; then unbinds everything
renderable.meshPart.render(program);
}
示例7: applyToMaterial
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
/**
* Applies this material asset to the libGDX material.
*
* @param material
* @return
*/
public Material applyToMaterial(Material material) {
if (diffuseColor != null) {
material.set(new ColorAttribute(ColorAttribute.Diffuse, diffuseColor));
}
if (diffuseTexture != null) {
material.set(new TextureAttribute(TextureAttribute.Diffuse, diffuseTexture.getTexture()));
} else {
material.remove(TextureAttribute.Diffuse);
}
material.set(new FloatAttribute(FloatAttribute.Shininess, shininess));
return material;
}
示例8: DepthShader
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public DepthShader (final Renderable renderable, final Config config, final ShaderProgram shaderProgram) {
super(renderable, config, shaderProgram);
this.numBones = renderable.bones == null ? 0 : config.numBones;
int w = 0;
final int n = renderable.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit);
}
weights = w;
alphaTestAttribute = new FloatAttribute(FloatAttribute.AlphaTest, config.defaultAlphaTest);
}
示例9: bindMaterial
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
protected void bindMaterial (final Renderable renderable) {
if (currentMaterial == renderable.material) return;
int cullFace = config.defaultCullFace == -1 ? defaultCullFace : config.defaultCullFace;
int depthFunc = config.defaultDepthFunc == -1 ? defaultDepthFunc : config.defaultDepthFunc;
float depthRangeNear = 0f;
float depthRangeFar = 1f;
boolean depthMask = true;
currentMaterial = renderable.material;
for (final Attribute attr : currentMaterial) {
final long t = attr.type;
if (BlendingAttribute.is(t)) {
context.setBlending(true, ((BlendingAttribute)attr).sourceFunction, ((BlendingAttribute)attr).destFunction);
set(u_opacity, ((BlendingAttribute)attr).opacity);
} else if ((t & IntAttribute.CullFace) == IntAttribute.CullFace)
cullFace = ((IntAttribute)attr).value;
else if ((t & FloatAttribute.AlphaTest) == FloatAttribute.AlphaTest)
set(u_alphaTest, ((FloatAttribute)attr).value);
else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
DepthTestAttribute dta = (DepthTestAttribute)attr;
depthFunc = dta.depthFunc;
depthRangeNear = dta.depthRangeNear;
depthRangeFar = dta.depthRangeFar;
depthMask = dta.depthMask;
} else if (!config.ignoreUnimplemented) throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
}
context.setCullFace(cullFace);
context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
context.setDepthMask(depthMask);
}
示例10: initModel
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
private static void initModel() {
if (mc == null) {
Texture tex = new Texture(Gdx.files.internal(GlobalConf.TEXTURES_FOLDER + "star.jpg"));
Texture lut = new Texture(Gdx.files.internal(GlobalConf.TEXTURES_FOLDER + "lut.jpg"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Map<String, Object> params = new TreeMap<String, Object>();
params.put("quality", 120l);
params.put("diameter", 1d);
params.put("flip", false);
Pair<Model, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
Model model = pair.getFirst();
Material mat = pair.getSecond().get("base");
mat.clear();
mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
// Only to activate view vector (camera position)
mat.set(new TextureAttribute(TextureAttribute.Specular, lut));
mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
modelTransform = new Matrix4();
mc = new ModelComponent(false);
mc.env = new Environment();
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Shininess, 0f));
mc.instance = new ModelInstance(model, modelTransform);
}
}
示例11: render
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
/**
* Model rendering
*/
@Override
public void render(ModelBatch modelBatch, float alpha, double t) {
mc.touch();
float opct = (float) MathUtilsd.lint(closestDist, modelDist / 50f, modelDist, 1f, 0f);
if (alpha * opct > 0) {
mc.setTransparency(alpha * opct);
float[] col = closestCol;
((ColorAttribute) mc.env.get(ColorAttribute.AmbientLight)).color.set(col[0], col[1], col[2], 1f);
((FloatAttribute) mc.env.get(FloatAttribute.Shininess)).value = (float) t;
// Local transform
mc.instance.transform.idt().translate((float) closestPos.x, (float) closestPos.y, (float) closestPos.z).scl((float) (getRadius(active[0]) * 2d));
modelBatch.render(mc.instance, mc.env);
}
}
示例12: initModel
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public void initModel() {
if (clusterTex == null) {
clusterTex = new Texture(Gdx.files.internal("data/tex/cluster-tex.png"), true);
clusterTex.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear);
}
if (model == null) {
Material mat = new Material(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA), new ColorAttribute(ColorAttribute.Diffuse, col[0], col[1], col[2], col[3]));
ModelBuilder2 modelBuilder = ModelCache.cache.mb;
modelBuilder.begin();
// create part
MeshPartBuilder2 bPartBuilder = modelBuilder.part("sph", GL20.GL_LINES, Usage.Position, mat);
bPartBuilder.icosphere(1, 3, false, true);
model = (modelBuilder.end());
modelTransform = new Matrix4();
}
mc = new ModelComponent(false);
mc.dlight = new DirectionalLight();
mc.dlight.set(1, 1, 1, 1, 1, 1);
mc.env = new Environment();
mc.env.add(mc.dlight);
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Shininess, 0.2f));
mc.instance = new ModelInstance(model, modelTransform);
}
示例13: initModel
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public static void initModel() {
if (mc == null) {
Texture tex = new Texture(Gdx.files.internal(GlobalConf.TEXTURES_FOLDER + "star.jpg"));
Texture lut = new Texture(Gdx.files.internal(GlobalConf.TEXTURES_FOLDER + "lut.jpg"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Map<String, Object> params = new TreeMap<String, Object>();
params.put("quality", 120l);
params.put("diameter", 1d);
params.put("flip", false);
Pair<Model, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
Model model = pair.getFirst();
Material mat = pair.getSecond().get("base");
mat.clear();
mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
// Only to activate view vector (camera position)
mat.set(new TextureAttribute(TextureAttribute.Specular, lut));
mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
modelTransform = new Matrix4();
mc = new ModelComponent(false);
mc.env = new Environment();
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Shininess, 0f));
mc.instance = new ModelInstance(model, modelTransform);
}
}
示例14: render
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
@Override
public void render(ModelBatch modelBatch, float alpha, double t) {
mc.touch();
mc.setTransparency(alpha * (float) MathUtilsd.lint(distToCamera, modelDistance / 50f, modelDistance, 1f, 0f));
float[] col = GlobalConf.scene.STAR_COLOR_TRANSIT ? ccTransit : cc;
((ColorAttribute) mc.env.get(ColorAttribute.AmbientLight)).color.set(col[0], col[1], col[2], 1f);
((FloatAttribute) mc.env.get(FloatAttribute.Shininess)).value = (float) t;
// Local transform
transform.getMatrix(mc.instance.transform).scl((float) (getRadius() * 2d));
modelBatch.render(mc.instance, mc.env);
}
示例15: MikuMaterial
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute; //导入依赖的package包/类
public MikuMaterial(PMD_MATERIAL_RECORD pMaterial) {
this.m_material = pMaterial;
//Gdx material
gdxMaterial = new Material();
gdxMaterial.set(ColorAttribute.createAmbient(pMaterial.ambient.toColor()));
gdxMaterial.set(ColorAttribute.createDiffuse(pMaterial.diffuse.toColor()));
gdxMaterial.set(ColorAttribute.createSpecular(pMaterial.specular.toColor()));
gdxMaterial.set(FloatAttribute.createShininess(pMaterial.shininess));
String texFileName = pMaterial.getTextureFileName();
if(texFileName.length() > 0) {
Texture texture = new Texture(Gdx.files.internal(texFileName));
gdxMaterial.set(TextureAttribute.createDiffuse(texture));
}
}