本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.Material.set方法的典型用法代码示例。如果您正苦于以下问题:Java Material.set方法的具体用法?Java Material.set怎么用?Java Material.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g3d.Material
的用法示例。
在下文中一共展示了Material.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GameObject
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的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: Terrain
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
private Terrain(int vertexResolution) {
this.transform = new Matrix4();
this.attribs = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
| VertexAttributes.Usage.TextureCoordinates);
this.posPos = attribs.getOffset(VertexAttributes.Usage.Position, -1);
this.norPos = attribs.getOffset(VertexAttributes.Usage.Normal, -1);
this.uvPos = attribs.getOffset(VertexAttributes.Usage.TextureCoordinates, -1);
this.stride = attribs.vertexSize / 4;
this.vertexResolution = vertexResolution;
this.heightData = new float[vertexResolution * vertexResolution];
this.terrainTexture = new TerrainTexture();
this.terrainTexture.setTerrain(this);
material = new Material();
material.set(new TerrainTextureAttribute(TerrainTextureAttribute.ATTRIBUTE_SPLAT0, terrainTexture));
}
示例3: AreaDisplayable
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public AreaDisplayable(Model model) {
instance = new ModelInstance(model);
animationController = new AnimationController(instance);
instance.transform.rotate(new Vector3(1, 0, 0), 90);
for (Material material : instance.materials) {
TextureAttribute ta
= (TextureAttribute) material.get(TextureAttribute.Diffuse);
ta.textureDescription.magFilter = Texture.TextureFilter.Nearest;
ta.textureDescription.minFilter = Texture.TextureFilter.Nearest;
material.set(ta);
material.set(ColorAttribute.createDiffuse(Color.WHITE));
BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA);
material.set(ba);
}
}
示例4: createBillboardTest
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public void createBillboardTest() {
ModelBuilder mb = new ModelBuilder();
mb.begin();
long attr = Usage.TextureCoordinates | Usage.Position | Usage.Normal;
TextureRegion region = Assets.getAtlas().findRegion("sprites/test-guy");
Material mat = new Material(TextureAttribute.createDiffuse(region.getTexture()));
boolean blended = true;
float opacity = 1f;
mat.set(new BlendingAttribute(blended, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, opacity));
MeshPartBuilder mpb = mb.part("rect", GL20.GL_TRIANGLES, attr, mat);
mpb.setUVRange(region);
// the coordinates are offset so that we can easily set the center position to align with the entity's body
float sz = 2f; // size
float b = -sz/2; // base
float max = sz/2; // max
Vector3 bl = new Vector3(b, b, 0f);
Vector3 br = new Vector3(b, max, 0f);
Vector3 tr = new Vector3(max, max, 0f);
Vector3 tl = new Vector3(max, b, 0f);
Vector3 norm = new Vector3(0f, 0f, 1f);
mpb.rect(bl, tl, tr, br, norm);
billboardTestModel = mb.end();
}
示例5: init
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public static void init() {
list = new Array<>();
ModelBuilder mb = new ModelBuilder();
Vector3 norm = new Vector3(0f, 1f, 0f);
Texture texture = Assets.manager.get("textures/shadow.png", Texture.class);
Material material = new Material(TextureAttribute.createDiffuse(texture));
material.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.7f));
//material.set(new DepthTestAttribute(0)); // disable depth testing
long attr = Usage.Position | Usage.TextureCoordinates;
float s = 1f;
model = mb.createRect(
-s, 0f, -s,// bl
-s, 0f, s, // tl
s, 0f, s, // tr
s, 0f, -s, // br
norm.x, norm.y, norm.z,
material,
attr
);
}
示例6: loadSync
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
@Override
public Model loadSync(AssetManager manager, String fileName, FileHandle file, P parameters) {
ModelData data = null;
synchronized (items) {
for (int i = 0; i < items.size; i++) {
if (items.get(i).key.equals(fileName)) {
data = items.get(i).value;
items.removeIndex(i);
}
}
}
if (data == null) return null;
final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
// need to remove the textures from the managed disposables, or else ref counting
// doesn't work!
Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
while (disposables.hasNext()) {
Disposable disposable = disposables.next();
if (disposable instanceof Texture) {
disposables.remove();
}
}
// Automatically convert all materials to PBR
for (Material material : result.materials) {
TextureAttribute textureAttribute = (TextureAttribute) material.get(TextureAttribute.Diffuse);
if (textureAttribute != null) {
material.set(PbrTextureAttribute.createAlbedo(textureAttribute.textureDescription.texture));
}
}
data = null;
return result;
}
示例7: createMaterial
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
Material createMaterial(String materialName){
Material material=new Material();
material.set(PBRTextureAttribute.createAlbedo(new Texture("materials/" + materialName + "_Base_Color.png")));
material.set(PBRTextureAttribute.createMetallic(new Texture("materials/" + materialName + "_Metallic.png")));
material.set(PBRTextureAttribute.createRoughness(new Texture("materials/" + materialName + "_Roughness.png")));
material.set(PBRTextureAttribute.createAmbientOcclusion(new Texture("materials/" + materialName + "_Ambient_Occlusion.png")));
material.set(PBRTextureAttribute.createHeight(new Texture("materials/" + materialName + "_Height.png")));
material.set(PBRTextureAttribute.createNormal(new Texture("materials/" + materialName + "_Normal.png")));
return material;
}
示例8: applyToMaterial
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的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;
}
示例9: createOutlineModel
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public static void createOutlineModel(Model model, Color outlineColor, float fattenAmount) {
fatten(model, fattenAmount);
for (Material m : model.materials) {
m.clear();
m.set(new IntAttribute(IntAttribute.CullFace, Gdx.gl.GL_FRONT));
m.set(ColorAttribute.createDiffuse(outlineColor));
}
}
示例10: buildBillboardModel
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public static Model buildBillboardModel(Texture texture, float width, float height) {
TextureRegion textureRegion = new TextureRegion(texture, texture.getWidth(), texture.getHeight());
Material material = new Material();
material.set(new TextureAttribute(TextureAttribute.Diffuse, textureRegion));
material.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
material.set(new BlendingAttribute());
return ModelFactory.buildPlaneModel(width, height, material, 0, 0, 1, 1);
}
示例11: replace
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
private void replace(Material m, Attribute oldAttribute, Attribute newAttribute) {
Iterator<Attribute> iterator = m.iterator();
while (iterator.hasNext()) {
Attribute next = iterator.next();
if (next.equals(oldAttribute)) {
iterator.remove();
}
}
m.set(newAttribute);
}
示例12: createMaterial
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
public Material createMaterial() {
Material m = new Material(this.id);
for (ColorAttribute colorAttribute : colorAttributes) {
m.set(colorAttribute);
}
return m;
}
示例13: onLoaded
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的package包/类
@Override
protected void onLoaded () {
if (currentlyLoading == null || currentlyLoading.isEmpty()) return;
instances.clear();
animationControllers.clear();
final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
for (Material m : instance.materials)
m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f));
instances.add(instance);
if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance));
currentlyLoading = null;
}
示例14: initModel
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的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);
}
}
示例15: initModel
import com.badlogic.gdx.graphics.g3d.Material; //导入方法依赖的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);
}
}