本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute.createDiffuse方法的典型用法代码示例。如果您正苦于以下问题:Java TextureAttribute.createDiffuse方法的具体用法?Java TextureAttribute.createDiffuse怎么用?Java TextureAttribute.createDiffuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
的用法示例。
在下文中一共展示了TextureAttribute.createDiffuse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBillboardTest
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的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();
}
示例2: init
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的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
);
}
示例3: getPackedTextureSheet
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
private static PackedTextureSheet getPackedTextureSheet(AssetType... assetType) {
if (Adapter.isDedicatedServer())
return null;
TexturePacker texturePacker = new TexturePacker(2048, 2048, 1, true);
Pixmap pixmap;
getPacketTextureSheetFor(assetType, texturePacker, pixmap);
FileHandle fileHandle = assetsFolder.child("packed");
fileHandle.mkdirs();
Compatibility.get().nomedia(fileHandle);
fileHandle = fileHandle.child(assetType[0].name() + ".cim");
try {
PixmapIO.writeCIM(fileHandle, texturePacker.getPixmap());
} catch (GdxRuntimeException e) {
Log.error("Failed to write packed image", e);
}
Texture texture = new Texture(fileHandle);
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
PackedTextureSheet packedTextureSheet = new PackedTextureSheet(
new Material(TextureAttribute.createDiffuse(texture)));
packedTextureSheet.getMaterial().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Map<Asset, TexturePacker.PackRectangle> rectangles = texturePacker.getRectangles();
int num = 0;
for (Map.Entry<Asset, TexturePacker.PackRectangle> entry : rectangles.entrySet()) {
num++;
TextureRegion textureRegion = new TextureRegion(texture, entry.getValue().x, entry.getValue().y,
entry.getValue().width, entry.getValue().height);
entry.getKey().setPackedTextureRegion(textureRegion, packedTextureSheet);
packedTextureSheet.getPackedTextures().put(entry.getKey().toString(), textureRegion);
}
for (AssetType type : assetType) {
type.setPackedTextureSheet(packedTextureSheet);
}
return packedTextureSheet;
}
示例4: allocRenderable
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
protected void allocRenderable() {
renderable = new Renderable();
renderable.meshPart.primitiveType = GL20.GL_POINTS;
renderable.meshPart.offset = 0;
renderable.material = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
new DepthTestAttribute(GL20.GL_LEQUAL, false), TextureAttribute.createDiffuse((Texture) null));
}
示例5: create
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的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);
}
示例6: allocRenderable
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
protected Renderable allocRenderable(){
Renderable renderable = new Renderable();
renderable.primitiveType = GL20.GL_TRIANGLES;
renderable.meshPartOffset = 0;
renderable.material = new Material( new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
new DepthTestAttribute(GL20.GL_LEQUAL, false),
TextureAttribute.createDiffuse(texture));
renderable.mesh = new Mesh(false, MAX_VERTICES_PER_MESH, MAX_PARTICLES_PER_MESH*6, currentAttributes);
renderable.mesh.setIndices(indices);
renderable.shader = shader;
return renderable;
}
示例7: allocRenderable
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
protected void allocRenderable(){
renderable = new Renderable();
renderable.primitiveType = GL20.GL_POINTS;
renderable.meshPartOffset = 0;
renderable.material = new Material( new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
new DepthTestAttribute(GL20.GL_LEQUAL, false),
TextureAttribute.createDiffuse((Texture)null));
}
示例8: TilePermissionsGridDisplayable
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public TilePermissionsGridDisplayable(Tile[][] tiles, TextureAtlas atlas) {
this.atlas = atlas;
MeshBuilder meshBuilder = new MeshBuilder();
meshBuilder.begin(VertexAttributes.Usage.Position |
VertexAttributes.Usage.TextureCoordinates,
GL20.GL_TRIANGLES);
for (int y = 0; y < tiles.length; y++) {
for (int x = 0; x < tiles[y].length; x++) {
// TODO: Cache regions
meshBuilder.setUVRange(
atlas.findRegion(tiles[y][x].getPermissions().name()));
meshBuilder.rect(x, y, 0,
x + 1, y, 0,
x + 1, y + 1, 0,
x, y + 1, 0,
0, 0, 1);
}
}
Mesh mesh = meshBuilder.end();
ModelBuilder modelBuilder = new ModelBuilder();
modelBuilder.begin();
TextureAttribute diffuse
= TextureAttribute.createDiffuse(atlas.getTextures().first());
modelBuilder.part("grid", mesh, GL20.GL_TRIANGLES, new Material(diffuse));
instance = new ModelInstance(modelBuilder.end());
instance.transform.translate(0, 0, Z_OFFSET);
}
示例9: Map
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public Map(FileHandle handle) {
this.tileset = new TextureAtlas(Gdx.files.internal("tileset.atlas"));
this.floorEndRegion = this.tileset.findRegion("floor_end");
TextureAttribute textureAttribute = TextureAttribute.createDiffuse(this.tileset.getTextures().first());
this.material = new Material(textureAttribute);
this.primitiveType = GL20.GL_TRIANGLES;
this.robotStartPosition = new Vector3(0, 1.6f, 0);
parse(handle);
build();
}
示例10: World
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public World(int width, int depth) {
this.width = width;
this.depth = depth;
islands = new Island[width * depth];
highlight = new Material(TextureAttribute.createDiffuse(Vloxlands.assets.get("img/transparent.png", Texture.class)), ColorAttribute.createDiffuse(SELECTION));
dataMaps = new Material[Config.dataMaps.length][2];
for (int i = 0; i < dataMaps.length; i++) {
Material trp = new Material(TextureAttribute.createDiffuse(Vloxlands.assets.get("img/datamaps/" + Config.dataMaps[i].toLowerCase() + ".png", Texture.class)), new BlendingAttribute());
Material opq = Config.dataMapFullBlending[i] ? trp : new Material(TextureAttribute.createDiffuse(Vloxlands.assets.get("img/datamaps/" + Config.dataMaps[i].toLowerCase() + ".png", Texture.class)));
dataMaps[i] = new Material[] { opq, trp };
}
}
示例11: HeightMapModel
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public HeightMapModel(HeightMap hm) {
this.heightMap = hm;
String groundTexName = "textures/hm_paint.png";
groundTexture = new Texture(Gdx.files.internal(groundTexName), true);
groundTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
groundTexture.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.Linear);
groundMat = new Material(TextureAttribute.createDiffuse(groundTexture)
, ColorAttribute.createSpecular(specular)
);
createGround();
}
示例12: create
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
@Override
public void create () {
super.create();
instructions = "Tap to shoot\nArrow keys to move\nR to reset\nLong press to toggle debug mode\nSwipe for next test";
// Create a visual representation of the character (note that we don't use the physics part of BulletEntity, we'll do that manually)
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 capsule = modelBuilder.createCapsule(2f, 6f, 16, material, attributes);
disposables.add(capsule);
world.addConstructor("capsule", new BulletConstructor(capsule, null));
character = world.add("capsule", 5f, 3f, 5f);
characterTransform = character.transform; // Set by reference
// Create the physics representation of the character
ghostObject = new btPairCachingGhostObject();
ghostObject.setWorldTransform(characterTransform);
ghostShape = new btCapsuleShape(2f, 2f);
ghostObject.setCollisionShape(ghostShape);
ghostObject.setCollisionFlags(btCollisionObject.CollisionFlags.CF_CHARACTER_OBJECT);
characterController = new btKinematicCharacterController(ghostObject, ghostShape, .35f);
// And add it to the physics world
world.collisionWorld.addCollisionObject(ghostObject,
(short)btBroadphaseProxy.CollisionFilterGroups.CharacterFilter,
(short)(btBroadphaseProxy.CollisionFilterGroups.StaticFilter | btBroadphaseProxy.CollisionFilterGroups.DefaultFilter));
((btDiscreteDynamicsWorld)(world.collisionWorld)).addAction(characterController);
// Add the ground
(ground = 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);
// Create some boxes to play with
for (int x = 0; x < BOXCOUNT_X; x++) {
for (int y = 0; y < BOXCOUNT_Y; y++) {
for (int z = 0; z < BOXCOUNT_Z; z++) {
world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z)
.setColor(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
}
}
}
}
示例13: create
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
@Override
public void create () {
super.create();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
modelsWindow.setVisible(false);
Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
Material material = new Material(TextureAttribute.createDiffuse(texture));
ModelBuilder mb = new ModelBuilder();
mb.begin();
mb.manage(texture);
mb.node().id = "box";
MeshPartBuilder mpb = mb.part("box", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
mpb.setColor(Color.RED);
mpb.box(1f, 1f, 1f);
mb.node().id = "sphere";
mpb = mb.part("sphere", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
mpb.sphere(2f, 2f, 2f, 10, 5);
mb.node().id = "cone";
mpb = mb.part("cone", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
mpb.setVertexTransform(new Matrix4().rotate(Vector3.X, -45f));
mpb.cone(2f, 3f, 1f, 8);
mb.node().id = "cylinder";
mpb = mb.part("cylinder", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
mpb.cylinder(2f, 4f, 3f, 15);
model = mb.end();
instances.add(new ModelInstance(model, new Matrix4().trn(-5f, 0f, -5f), "box", true));
instances.add(new ModelInstance(model, new Matrix4().trn(5f, 0f, -5f), "sphere", true));
instances.add(new ModelInstance(model, new Matrix4().trn(-5f, 0f, 5f), "cone", true));
instances.add(new ModelInstance(model, new Matrix4().trn(5f, 0f, 5f), "cylinder", true));
}
示例14: CreatePlaneChunk
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
/**
* Creates a plane, used for testing
* @param size the size of the plane
* @return
*/
public static TerrainChunk CreatePlaneChunk (float size) {
TerrainChunk chunk = new TerrainChunk();
// graphical representation of the ground
Log.debug("createLevel - create ground");
if (Main.isClient()) {
ModelBuilder mb = new ModelBuilder();
mb.begin();
Vector3 bl = new Vector3();
Vector3 tl = new Vector3();
Vector3 tr = new Vector3();
Vector3 br = new Vector3();
Vector3 norm = new Vector3(0f, 1f, 0f);
// the size of each rect that makes up the ground
Texture groundTex = Assets.manager.get("textures/ground1.jpg", Texture.class);
Material groundMat = new Material(TextureAttribute.createDiffuse(groundTex));
MeshPartBuilder mpb = mb.part("ground", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates,
groundMat);
float u1 = 0f;
float v1 = 0f;
float u2 = size / 5f;
float v2 = size / 5f;
mpb.setUVRange(u1, v1, u2, v2);
bl.set(0, 0, 0);
tl.set(0, 0, size);
tr.set(size, 0, size);
br.set(size, 0, 0);
// mpb.rect(bl, tl, tr, br, norm);
int divisions = ((int)size) / 4;
mpb.patch(bl, tl, tr, br, norm, divisions, divisions);
Model groundModel = mb.end();
chunk.modelInstance = new ModelInstance(groundModel);
}
// physical representation of the ground
btCollisionObject groundObj = new btCollisionObject();
btCollisionShape groundShape = new btStaticPlaneShape(Vector3.Y, 0f);
groundObj.setCollisionShape(groundShape);
Physics.applyStaticGeometryCollisionFlags(groundObj);
Physics.inst.addStaticGeometryToWorld(groundObj);
chunk.body = groundObj;
return chunk;
}
示例15: createLevel
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public static void createLevel() {
// graphical representation of the ground
Log.debug("createLevel - create ground");
if (Main.isClient()) {
ModelBuilder mb = new ModelBuilder();
mb.begin();
Vector3 bl = new Vector3();
Vector3 tl = new Vector3();
Vector3 tr = new Vector3();
Vector3 br = new Vector3();
Vector3 norm = new Vector3(0f, 1f, 0f);
// the size of each rect that makes up the ground
Texture groundTex = Assets.manager.get("textures/ground1.jpg", Texture.class);
Material groundMat = new Material(TextureAttribute.createDiffuse(groundTex));
MeshPartBuilder mpb = mb.part("ground", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates, groundMat);
float u1 = 0f;
float v1 = 0f;
float u2 = groundPieceSize / 5f;
float v2 = groundPieceSize / 5f;
mpb.setUVRange(u1, v1, u2, v2);
bl.set(0, 0, 0);
tl.set(0, 0, groundPieceSize);
tr.set(groundPieceSize, 0, groundPieceSize);
br.set(groundPieceSize, 0, 0);
//mpb.rect(bl, tl, tr, br, norm);
int divisions = ((int) groundPieceSize) / 4;
mpb.patch(bl, tl, tr, br, norm, divisions, divisions);
Model groundModel = mb.end();
models.add(groundModel);
groundPieces.clear();
int count = 0;
for (int x = 0; x < GameWorld.WORLD_WIDTH; x += groundPieceSize) {
for (int z = 0; z < GameWorld.WORLD_DEPTH; z += groundPieceSize) {
count++;
ModelInstance groundPiece = new ModelInstance(groundModel);
groundPiece.transform.setToTranslation(x, 0f, z);
groundPieces.add(groundPiece);
}
}
Log.debug("createLevel - created " + count + " groundPieces");
}
// physical representation of the ground
btCollisionObject groundObj = new btCollisionObject();
btCollisionShape groundShape = new btStaticPlaneShape(Vector3.Y, 0f);
groundObj.setCollisionShape(groundShape);
Physics.applyStaticGeometryCollisionFlags(groundObj);
Physics.inst.addStaticGeometryToWorld(groundObj);
if (Main.isServer()) {
Log.debug("createLevel - create static models");
// server creates static models here, client will create the models when received from server upon connection
createStaticModels(25);
}
Log.debug("createLevel - create boxes");
Box.createBoxes(10);
}