本文整理匯總了Java中com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute.Diffuse方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorAttribute.Diffuse方法的具體用法?Java ColorAttribute.Diffuse怎麽用?Java ColorAttribute.Diffuse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute
的用法示例。
在下文中一共展示了ColorAttribute.Diffuse方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的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);
}
示例2: initModel
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的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);
}
示例3: doneLoading
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的package包/類
@Override
public void doneLoading(AssetManager manager) {
Material material = new Material(new BlendingAttribute(cc[3]), new ColorAttribute(ColorAttribute.Diffuse, cc[0], cc[1], cc[2], cc[3]));
// Load model
ModelBuilder2 modelBuilder = ModelCache.cache.mb;
modelBuilder.begin();
// create part
MeshPartBuilder2 bPartBuilder = modelBuilder.part("sph", GL20.GL_LINES, Usage.Position, material);
bPartBuilder.sphere(1, 1, 1, divisionsU, divisionsV);
Model model = (modelBuilder.end());
// Initialize transform
localTransform.scl(size);
if (transformName != null) {
Class<Coordinates> c = Coordinates.class;
try {
Method m = ClassReflection.getMethod(c, transformName);
Matrix4d trf = (Matrix4d) m.invoke(null);
Matrix4 aux = new Matrix4();
trf.putIn(aux);
localTransform.mul(aux);
} catch (ReflectionException e) {
Logger.error(Grid.class.getName(), "Error getting/invoking method Coordinates." + transformName + "()");
}
} else {
// Equatorial, nothing
}
mc.instance = new ModelInstance(model, this.localTransform);
float pl = .5f;
labelColor = new float[] { Math.min(1, cc[0] + pl), Math.min(1, cc[1] + pl), Math.min(1, cc[2] + pl), Math.min(1, cc[3] + pl) };
font = GlobalResources.skin.getFont("grid-annotation");
}
示例4: setColor
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的package包/類
public void setColor(Color color){
ColorAttribute ca = new ColorAttribute(ColorAttribute.Diffuse, color);
if(getMaterial("Color") != null)
getMaterial("Color").set(ca);
else
materials.add(new Material("Color", ca));
model.materials.add(new Material("Color", ca));
}
示例5: getAttributeType
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的package包/類
@Override
public long getAttributeType() {
return ColorAttribute.Diffuse;
}
示例6: createPrefix
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的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;
}
示例7: VoxelWorld
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入方法依賴的package包/類
public VoxelWorld (TextureRegion[] tiles, int chunksX, int chunksY, int chunksZ) {
this.tiles = tiles;
this.chunks = new VoxelChunk[chunksX * chunksY * chunksZ];
this.chunksX = chunksX;
this.chunksY = chunksY;
this.chunksZ = chunksZ;
this.numChunks = chunksX * chunksY * chunksZ;
this.voxelsX = chunksX * CHUNK_SIZE_X;
this.voxelsY = chunksY * CHUNK_SIZE_Y;
this.voxelsZ = chunksZ * CHUNK_SIZE_Z;
int i = 0;
for (int y = 0; y < chunksY; y++) {
for (int z = 0; z < chunksZ; z++) {
for (int x = 0; x < chunksX; x++) {
VoxelChunk chunk = new VoxelChunk(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
chunk.offset.set(x * CHUNK_SIZE_X, y * CHUNK_SIZE_Y, z * CHUNK_SIZE_Z);
chunks[i++] = chunk;
}
}
}
int len = CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z * 6 * 6 / 3;
short[] indices = new short[len];
short j = 0;
for (i = 0; i < len; i += 6, j += 4) {
indices[i + 0] = (short)(j + 0);
indices[i + 1] = (short)(j + 1);
indices[i + 2] = (short)(j + 2);
indices[i + 3] = (short)(j + 2);
indices[i + 4] = (short)(j + 3);
indices[i + 5] = (short)(j + 0);
}
this.meshes = new Mesh[chunksX * chunksY * chunksZ];
for (i = 0; i < meshes.length; i++) {
meshes[i] = new Mesh(true, CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z * 6 * 4, CHUNK_SIZE_X * CHUNK_SIZE_Y
* CHUNK_SIZE_Z * 36 / 3, VertexAttribute.Position(), VertexAttribute.Normal());
meshes[i].setIndices(indices);
}
this.dirty = new boolean[chunksX * chunksY * chunksZ];
for (i = 0; i < dirty.length; i++)
dirty[i] = true;
this.numVertices = new int[chunksX * chunksY * chunksZ];
for (i = 0; i < numVertices.length; i++)
numVertices[i] = 0;
this.vertices = new float[VoxelChunk.VERTEX_SIZE * 6 * CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
this.materials = new Material[chunksX * chunksY * chunksZ];
for (i = 0; i < materials.length; i++) {
materials[i] = new Material(new ColorAttribute(ColorAttribute.Diffuse, MathUtils.random(0.5f, 1f), MathUtils.random(
0.5f, 1f), MathUtils.random(0.5f, 1f), 1));
}
}