本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute.Diffuse方法的典型用法代码示例。如果您正苦于以下问题:Java TextureAttribute.Diffuse方法的具体用法?Java TextureAttribute.Diffuse怎么用?Java TextureAttribute.Diffuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
的用法示例。
在下文中一共展示了TextureAttribute.Diffuse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: create
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
@Override
public void create () {
Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f);
atlas = new TextureAtlas(Gdx.files.internal("data/testpack"));
regions = atlas.getRegions();
modelBatch = new ModelBatch(new DefaultShaderProvider());
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse));
model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
instance = new ModelInstance(model);
attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
示例3: create
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
@Override
public void create () {
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
// Create material attributes. Each material can contain x-number of attributes.
textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
ModelBuilder builder = new ModelBuilder();
model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
model.manageDisposable(texture);
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(Vector3.X, 45);
material = modelInstance.materials.get(0);
builder.begin();
MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(
textureAttribute));
mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
backModel = builder.end();
background = new ModelInstance(backModel);
modelBatch = new ModelBatch();
camera = new PerspectiveCamera(45, 4, 4);
camera.position.set(0, 0, 3);
camera.direction.set(0, 0, -1);
camera.update();
Gdx.input.setInputProcessor(this);
}
示例4: doneLoading
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
/**
* Constructs the interface
*/
public void doneLoading(AssetManager assetManager) {
skin = GlobalResources.skin;
aiTexture = assetManager.get("data/tex/attitudeindicator.png", Texture.class);
aiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
aiPointerTexture = assetManager.get("img/ai-pointer.png", Texture.class);
aiPointerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
aiVelTex = assetManager.get("img/ai-vel.png", Texture.class);
aiVelTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
aiAntivelTex = assetManager.get("img/ai-antivel.png", Texture.class);
aiAntivelTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
aiVelDec = Decal.newDecal(new TextureRegion(aiVelTex));
aiAntivelDec = Decal.newDecal(new TextureRegion(aiAntivelTex));
Material mat = new Material(new TextureAttribute(TextureAttribute.Diffuse, aiTexture), new ColorAttribute(ColorAttribute.Specular, 0.3f, 0.3f, 0.3f, 1f));
aiModel = new ModelBuilder2().createSphere(1 * GlobalConf.SCALE_FACTOR, 30, 30, false, mat, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
aiTransform = new Matrix4();
aiModelInstance = new ModelInstance(aiModel, aiTransform);
aiViewport = new ExtendViewport(indicatorw, indicatorh, aiCam);
buildGui();
EventManager.instance.subscribe(this, Events.SPACECRAFT_STABILISE_CMD, Events.SPACECRAFT_STOP_CMD, Events.SPACECRAFT_INFO, Events.SPACECRAFT_NEAREST_INFO, Events.SPACECRAFT_THRUST_INFO);
EventManager.instance.unsubscribe(this, Events.SPACECRAFT_LOADED);
}
示例5: loadRenderModel
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
private Model loadRenderModel(String name) {
if (models.containsKey(name)) return models.get(name);
// FIXME we load the models synchronously cause we are lazy
int error = 0;
PointerBuffer modelPointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadRenderModel_Async(name, modelPointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) return null;
RenderModel renderModel = new RenderModel(modelPointer.getByteBuffer(RenderModel.SIZEOF));
error = 0;
PointerBuffer texturePointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadTexture_Async(renderModel.diffuseTextureId(), texturePointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) {
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
return null;
}
RenderModelTextureMap renderModelTexture = new RenderModelTextureMap(texturePointer.getByteBuffer(RenderModelTextureMap.SIZEOF));
// convert to a Model
Mesh mesh = new Mesh(true, renderModel.unVertexCount(), renderModel.unTriangleCount() * 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0));
MeshPart meshPart = new MeshPart(name, mesh, 0, renderModel.unTriangleCount() * 3, GL20.GL_TRIANGLES);
RenderModelVertex.Buffer vertices = renderModel.rVertexData();
float[] packedVertices = new float[8 * renderModel.unVertexCount()];
int i = 0;
while(vertices.remaining() > 0) {
RenderModelVertex v = vertices.get();
packedVertices[i++] = v.vPosition().v(0);
packedVertices[i++] = v.vPosition().v(1);
packedVertices[i++] = v.vPosition().v(2);
packedVertices[i++] = v.vNormal().v(0);
packedVertices[i++] = v.vNormal().v(1);
packedVertices[i++] = v.vNormal().v(2);
packedVertices[i++] = v.rfTextureCoord().get(0);
packedVertices[i++] = v.rfTextureCoord().get(1);
}
mesh.setVertices(packedVertices);
short[] indices = new short[renderModel.unTriangleCount() * 3];
renderModel.IndexData().get(indices);
mesh.setIndices(indices);
Pixmap pixmap = new Pixmap(renderModelTexture.unWidth(), renderModelTexture.unHeight(), Format.RGBA8888);
byte[] pixels = new byte[renderModelTexture.unWidth() * renderModelTexture.unHeight() * 4];
renderModelTexture.rubTextureMapData(pixels.length).get(pixels);
pixmap.getPixels().put(pixels);
pixmap.getPixels().position(0);
Texture texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), true, true));
Material material = new Material(new TextureAttribute(TextureAttribute.Diffuse, texture));
Model model = new Model();
model.meshes.add(mesh);
model.meshParts.add(meshPart);
model.materials.add(material);
Node node = new Node();
node.id = name;
node.parts.add(new NodePart(meshPart, material));
model.nodes.add(node);
model.manageDisposable(mesh);
model.manageDisposable(texture);
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
VRRenderModels.VRRenderModels_FreeTexture(renderModelTexture);
models.put(name, model);
return model;
}
示例6: getAttributeType
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
@Override
public long getAttributeType() {
return TextureAttribute.Diffuse;
}
示例7: createPrefix
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; //导入方法依赖的package包/类
public static String createPrefix (final Renderable renderable, final Config config) {
String prefix = "";
final long mask = renderable.material.getMask();
final long attributes = renderable.mesh.getVertexAttributes().getMask();
if (and(attributes, Usage.Position)) prefix += "#define positionFlag\n";
if (or(attributes, Usage.Color | Usage.ColorPacked)) prefix += "#define colorFlag\n";
if (and(attributes, Usage.BiNormal)) prefix += "#define binormalFlag\n";
if (and(attributes, Usage.Tangent)) prefix += "#define tangentFlag\n";
if (and(attributes, Usage.Normal)) prefix += "#define normalFlag\n";
if (and(attributes, Usage.Normal) || and(attributes, Usage.Tangent | Usage.BiNormal)) {
if (renderable.environment != null) {
prefix += "#define lightingFlag\n";
prefix += "#define ambientCubemapFlag\n";
prefix += "#define numDirectionalLights " + config.numDirectionalLights + "\n";
prefix += "#define numPointLights " + config.numPointLights + "\n";
if (renderable.environment.has(ColorAttribute.Fog)) {
prefix += "#define fogFlag\n";
}
if (renderable.environment.shadowMap != null) prefix += "#define shadowMapFlag\n";
if (renderable.material.has(CubemapAttribute.EnvironmentMap)
|| renderable.environment.has(CubemapAttribute.EnvironmentMap)) prefix += "#define environmentCubemapFlag\n";
}
}
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)
prefix += "#define boneWeight" + attr.unit + "Flag\n";
else if (attr.usage == Usage.TextureCoordinates) prefix += "#define texCoord" + attr.unit + "Flag\n";
}
if ((mask & BlendingAttribute.Type) == BlendingAttribute.Type) prefix += "#define " + BlendingAttribute.Alias + "Flag\n";
if ((mask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse) {
prefix += "#define " + TextureAttribute.DiffuseAlias + "Flag\n";
prefix += "#define " + TextureAttribute.DiffuseAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & TextureAttribute.Specular) == TextureAttribute.Specular) {
prefix += "#define " + TextureAttribute.SpecularAlias + "Flag\n";
prefix += "#define " + TextureAttribute.SpecularAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & TextureAttribute.Normal) == TextureAttribute.Normal) {
prefix += "#define " + TextureAttribute.NormalAlias + "Flag\n";
prefix += "#define " + TextureAttribute.NormalAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & TextureAttribute.Emissive) == TextureAttribute.Emissive) {
prefix += "#define " + TextureAttribute.EmissiveAlias + "Flag\n";
prefix += "#define " + TextureAttribute.EmissiveAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & TextureAttribute.Reflection) == TextureAttribute.Reflection) {
prefix += "#define " + TextureAttribute.ReflectionAlias + "Flag\n";
prefix += "#define " + TextureAttribute.ReflectionAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & TextureAttribute.Ambient) == TextureAttribute.Ambient) {
prefix += "#define " + TextureAttribute.AmbientAlias + "Flag\n";
prefix += "#define " + TextureAttribute.AmbientAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
}
if ((mask & ColorAttribute.Diffuse) == ColorAttribute.Diffuse)
prefix += "#define " + ColorAttribute.DiffuseAlias + "Flag\n";
if ((mask & ColorAttribute.Specular) == ColorAttribute.Specular)
prefix += "#define " + ColorAttribute.SpecularAlias + "Flag\n";
if ((mask & ColorAttribute.Emissive) == ColorAttribute.Emissive)
prefix += "#define " + ColorAttribute.EmissiveAlias + "Flag\n";
if ((mask & ColorAttribute.Reflection) == ColorAttribute.Reflection)
prefix += "#define " + ColorAttribute.ReflectionAlias + "Flag\n";
if ((mask & FloatAttribute.Shininess) == FloatAttribute.Shininess)
prefix += "#define " + FloatAttribute.ShininessAlias + "Flag\n";
if ((mask & FloatAttribute.AlphaTest) == FloatAttribute.AlphaTest)
prefix += "#define " + FloatAttribute.AlphaTestAlias + "Flag\n";
if (renderable.bones != null && config.numBones > 0) prefix += "#define numBones " + config.numBones + "\n";
return prefix;
}