当前位置: 首页>>代码示例>>Java>>正文


Java TextureAttribute类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute的典型用法代码示例。如果您正苦于以下问题:Java TextureAttribute类的具体用法?Java TextureAttribute怎么用?Java TextureAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextureAttribute类属于com.badlogic.gdx.graphics.g3d.attributes包,在下文中一共展示了TextureAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canRender

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
@Override
public boolean canRender (Renderable renderable) {
	if (renderable.material.has(BlendingAttribute.Type)) {
		if ((materialMask & BlendingAttribute.Type) != BlendingAttribute.Type)
			return false;
		if (renderable.material.has(TextureAttribute.Diffuse) != ((materialMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse))
			return false;
	}
	final boolean skinned = ((renderable.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight);
	if (skinned != (numBones > 0)) return false;
	if (!skinned) return true;
	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);
	}
	return w == weights;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:DepthShader.java

示例2: create

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
@Override
public void create () {
	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
	texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
	ObjLoader objLoader = new ObjLoader();
	mesh = objLoader.loadObj(Gdx.files.internal("data/cube.obj"));
	mesh.materials.get(0).set(new TextureAttribute(TextureAttribute.Diffuse, texture));
	modelInstance = new ModelInstance(mesh);
	modelBatch = new ModelBatch();

	cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	cam.position.set(3, 3, 3);
	cam.direction.set(-1, -1, -1);
	batch = new SpriteBatch();
	font = new BitmapFont();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:FramebufferToTextureTest.java

示例3: AreaDisplayable

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的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);
  }
}
 
开发者ID:fauu,项目名称:HelixEngine,代码行数:24,代码来源:AreaDisplayable.java

示例4: Game3d

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
public Game3d(){
   ship = Asset.loadModelObj("ship");//loads an obj model
   ship.scale(3f);
   skydome = Asset.loadModel("skydome"); //loads a g3db model
   builder = new ModelBuilder();
   builder.begin();
   MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | 
        Usage.TextureCoordinates | Usage.Normal, new Material());
   for (float x = -200f; x < 200f; x += 10f) {
       for (float z = -200f; z < 200f; z += 10f) {
           part.rect(x, 0, z + 10f, x + 10f, 0, z + 10f, x + 10f, 0, z, x, 0, z, 0, 1, 0);
       }
   }
   floor = new Actor3d(builder.end());
   floor.materials.get(0).set(TextureAttribute.createDiffuse(Asset.tex("concrete").getTexture()));
   knight = Asset.loadModel("knight");
   knight.setPosition(-20f, 18f, 0f);
   knight.setPitch(-90f);
   addActor3d(floor);
   addActor3d(skydome);
   addActor3d(ship);
   addActor3d(knight);
   stage3d.getCamera().position.set(knight.getX()+ 13f, knight.getY() + 24f, knight.getZ() + 45f);
   //Camera3d.followOffset(20f, 20f, -20f);
  // Camera3d.followActor3d(knight, false);
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:27,代码来源:Game3d.java

示例5: CreateHeightMapChunk

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
/**
 * Return a heightmap chunk
 * TODO NOT IMPLEMENTED! 
 * @param heightmap
 * @param tex
 * @param width
 * @param height
 * @return
 */
public static TerrainChunk CreateHeightMapChunk (FileHandle heightmap, Texture tex, int width, int height) {
	HeightMap hp = new HeightMap(heightmap, 10, 10, false, 3);
	
	HeightMapModel md = new HeightMapModel(hp);
	//Model model = md.ground;
	 md.ground.materials.get(0).set(TextureAttribute.createDiffuse(tex));
	 
	//btCollisionObject obj = new btCollisionObject();
	//btCollisionShape shape = new btBvhTriangleMeshShape(model.meshParts);
	//obj.setCollisionShape(shape);
	////Physics.applyStaticGeometryCollisionFlags(obj);
	//Physics.inst.addStaticGeometryToWorld(obj);
	TerrainChunk ch = new  TerrainChunk();
	ch.setModelInstance(md.ground);
	
	return ch;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:27,代码来源:Terrain.java

示例6: 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();
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:25,代码来源:ModelManager.java

示例7: createSkyBox

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
public static void createSkyBox (Texture xpos, Texture xneg, Texture ypos, Texture yneg, Texture zpos, Texture zneg) {
	modelInstance = new ModelInstance(model, "Skycube");
	
	// Set material textures
	modelInstance.materials.get(0).set(TextureAttribute.createDiffuse(xpos));
	modelInstance.materials.get(1).set(TextureAttribute.createDiffuse(xneg));
	modelInstance.materials.get(2).set(TextureAttribute.createDiffuse(ypos));
	modelInstance.materials.get(3).set(TextureAttribute.createDiffuse(yneg));
	modelInstance.materials.get(5).set(TextureAttribute.createDiffuse(zpos));
	modelInstance.materials.get(4).set(TextureAttribute.createDiffuse(zneg));
	
	//Disable depth test
	modelInstance.materials.get(0).set(new DepthTestAttribute(0));
	modelInstance.materials.get(1).set(new DepthTestAttribute(0));
	modelInstance.materials.get(2).set(new DepthTestAttribute(0));
	modelInstance.materials.get(3).set(new DepthTestAttribute(0));
	modelInstance.materials.get(4).set(new DepthTestAttribute(0));
	modelInstance.materials.get(5).set(new DepthTestAttribute(0));
	
	enabled = true;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:22,代码来源:Sky.java

示例8: 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
	);
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:21,代码来源:Shadow.java

示例9: begin

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
@Override
public void begin(ShaderProgram program, Camera camera, RenderContext context) {
	TextureAttribute textureAttribute = AmbientOcclusion.getTextureAttribute();

	ao_unit = context.textureBinder.bind(textureAttribute.textureDescription);
	program.setUniformi(u_aoTexture, ao_unit);

	program.setUniformf(u_aoUVTransform, textureAttribute.offsetU, textureAttribute.offsetV,
			textureAttribute.scaleU, textureAttribute.scaleV);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:11,代码来源:WorldShaderProvider.java

示例10: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:40,代码来源:Assets.java

示例11: begin

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
@Override
public void begin(ShaderProgram program, Camera camera, RenderContext context) {
  TextureAttribute textureAttribute = AmbientOcclusion.getTextureAttribute();

  ao_unit = context.textureBinder.bind(textureAttribute.textureDescription);
  program.setUniformi(u_aoTexture, ao_unit);

  program.setUniformf(u_aoUVTransform, textureAttribute.offsetU, textureAttribute.offsetV, textureAttribute.scaleU, textureAttribute.scaleV);
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:10,代码来源:WorldShaderProvider.java

示例12: 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));
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:8,代码来源:PointSpriteSoftParticleBatch.java

示例13: loadSync

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:36,代码来源:NhgModelLoader.java

示例14: compareTo

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
@Override
public int compareTo (Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    TextureAttribute other = (TextureAttribute)o;
    final int c = textureDescription.compareTo(other.textureDescription);
    if (c != 0) return c;
    if (uvIndex != other.uvIndex) return uvIndex - other.uvIndex;
    if (!MathUtils.isEqual(scaleU, other.scaleU)) return scaleU > other.scaleU ? 1 : -1;
    if (!MathUtils.isEqual(scaleV, other.scaleV)) return scaleV > other.scaleV ? 1 : -1;
    if (!MathUtils.isEqual(offsetU, other.offsetU)) return offsetU > other.offsetU ? 1 : -1;
    if (!MathUtils.isEqual(offsetV, other.offsetV)) return offsetV > other.offsetV ? 1 : -1;
    return 0;
}
 
开发者ID:PWorlds,项目名称:LibGDX-PBR,代码行数:14,代码来源:PBRTextureAttribute.java

示例15: getAttribute

import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入依赖的package包/类
private <T extends Attribute> T getAttribute(long type, Class<T> cls) {
    String alias = TextureAttribute.getAttributeAlias(type);
    Attribute attr = mtl.get(type);
    if(attr == null)
        return null;
    return cls.cast(attr);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:8,代码来源:MaterialWrapper.java


注:本文中的com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。