本文整理匯總了Java中com.badlogic.gdx.graphics.VertexAttributes.Usage.Normal方法的典型用法代碼示例。如果您正苦於以下問題:Java Usage.Normal方法的具體用法?Java Usage.Normal怎麽用?Java Usage.Normal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.VertexAttributes.Usage
的用法示例。
在下文中一共展示了Usage.Normal方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAttributes
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
* TextureCoordinates is supported. */
public static VertexAttributes createAttributes (long usage) {
final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
if ((usage & Usage.Position) == Usage.Position)
attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
if ((usage & Usage.Color) == Usage.Color) attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.Normal) == Usage.Normal)
attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
for (int i = 0; i < attributes.length; i++)
attributes[i] = attrs.get(i);
return new VertexAttributes(attributes);
}
示例2: setupScene
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
public void setupScene () {
plane = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
plane.setVertices(new float[] {-10, -1, 10, 0, 1, 0, 10, -1, 10, 0, 1, 0, 10, -1, -10, 0, 1, 0, -10, -1, -10, 0, 1, 0});
plane.setIndices(new short[] {3, 2, 1, 1, 0, 3});
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0, 5, 10);
cam.lookAt(0, 0, 0);
cam.update();
controller = new PerspectiveCamController(cam);
projector = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
projector.position.set(2, 3, 2);
projector.lookAt(0, 0, 0);
projector.normalizeUp();
projector.update();
}
示例3: createAttributes
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
* TextureCoordinates is supported. */
public static VertexAttributes createAttributes(long usage) {
final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
if ((usage & Usage.Position) == Usage.Position)
attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
if ((usage & Usage.ColorUnpacked) == Usage.ColorUnpacked)
attrs.add(new VertexAttribute(Usage.ColorUnpacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.Normal) == Usage.Normal)
attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
for (int i = 0; i < attributes.length; i++)
attributes[i] = attrs.get(i);
return new VertexAttributes(attributes);
}
示例4: create
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的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);
}
示例5: Normal
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
public static VertexAttribute Normal () {
return new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE);
}
示例6: create
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
@Override
public void create () {
super.create();
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);
float x0 = -2f, y0 = 6f, z0 = -2f;
float x1 = 8f, y1 = 6f, z1 = 8f;
Vector3 patch00 = new Vector3(x0, y0, z0);
Vector3 patch10 = new Vector3(x1, y1, z0);
Vector3 patch01 = new Vector3(x0, y0, z1);
Vector3 patch11 = new Vector3(x1, y1, z1);
softBody = btSoftBodyHelpers.CreatePatch(worldInfo, patch00, patch10, patch01, patch11, 15, 15, 15, false);
softBody.takeOwnership();
softBody.setTotalMass(100f);
// softBody.setConfig_kDP(0.2f);
// softBody.setConfig_kCHR(0.99f);
// softBody.setConfig_kKHR(0.99f);
// softBody.setConfig_kSHR(0.99f);
((btSoftRigidDynamicsWorld)(world.collisionWorld)).addSoftBody(softBody);
final int vertCount = softBody.getNodeCount();
final int faceCount = softBody.getFaceCount();
mesh = new Mesh(false, vertCount, faceCount * 3, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2,
ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
final int vertSize = mesh.getVertexSize() / 4;
mesh.getVerticesBuffer().position(0);
mesh.getVerticesBuffer().limit(vertCount * vertSize);
mesh.getIndicesBuffer().position(0);
mesh.getIndicesBuffer().limit(faceCount * 3);
softBody.getVertices(mesh.getVerticesBuffer(), vertCount, mesh.getVertexSize(), 0);
softBody.getIndices(mesh.getIndicesBuffer(), faceCount);
final float[] verts = new float[vertCount * vertSize];
final int uvOffset = mesh.getVertexAttribute(Usage.TextureCoordinates).offset / 4;
final int normalOffset = mesh.getVertexAttribute(Usage.Normal).offset / 4;
mesh.getVertices(verts);
for (int i = 0; i < vertCount; i++) {
verts[i * vertSize + normalOffset] = 0f;
verts[i * vertSize + normalOffset + 1] = 1f;
verts[i * vertSize + normalOffset + 2] = 0f;
verts[i * vertSize + uvOffset] = (verts[i * vertSize] - x0) / (x1 - x0);
verts[i * vertSize + uvOffset + 1] = (verts[i * vertSize + 2] - z0) / (z1 - z0);
}
mesh.setVertices(verts);
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
model = ModelBuilder.createFromMesh(mesh, GL20.GL_TRIANGLES, new Material(TextureAttribute.createDiffuse(texture),
ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f), IntAttribute.createCullFace(0)));
instance = new ModelInstance(model);
world.add(new BulletEntity(instance, null));
shoot(320f, 240f, 20f);
}
示例7: create
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的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);
}
}
}
}
示例8: create
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
@Override
public void create () {
super.create();
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);
float x0 = -2f, y0 = 6f, z0 = -2f;
float x1 = 8f, y1 = 6f, z1 = 8f;
Vector3 patch00 = new Vector3(x0, y0, z0);
Vector3 patch10 = new Vector3(x1, y1, z0);
Vector3 patch01 = new Vector3(x0, y0, z1);
Vector3 patch11 = new Vector3(x1, y1, z1);
softBody = btSoftBodyHelpers.CreatePatch(worldInfo, patch00, patch10, patch01, patch11, 15, 15, 15, false);
softBody.takeOwnership();
softBody.setTotalMass(100f);
((btSoftRigidDynamicsWorld)(world.collisionWorld)).addSoftBody(softBody);
final int vertCount = softBody.getNodeCount();
final int faceCount = softBody.getFaceCount();
mesh = new Mesh(false, vertCount, faceCount * 3, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2,
ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
final int vertSize = mesh.getVertexSize() / 4;
mesh.getVerticesBuffer().position(0);
mesh.getVerticesBuffer().limit(vertCount * vertSize);
mesh.getIndicesBuffer().position(0);
mesh.getIndicesBuffer().limit(faceCount * 3);
softBody.getVertices(mesh.getVerticesBuffer(), vertCount, mesh.getVertexSize(), 0);
softBody.getIndices(mesh.getIndicesBuffer(), faceCount);
final float[] verts = new float[vertCount * vertSize];
final int uvOffset = mesh.getVertexAttribute(Usage.TextureCoordinates).offset / 4;
final int normalOffset = mesh.getVertexAttribute(Usage.Normal).offset / 4;
mesh.getVertices(verts);
for (int i = 0; i < vertCount; i++) {
verts[i * vertSize + normalOffset] = 0f;
verts[i * vertSize + normalOffset + 1] = 1f;
verts[i * vertSize + normalOffset + 2] = 0f;
verts[i * vertSize + uvOffset] = (verts[i * vertSize] - x0) / (x1 - x0);
verts[i * vertSize + uvOffset + 1] = (verts[i * vertSize + 2] - z0) / (z1 - z0);
}
mesh.setVertices(verts);
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
model = ModelBuilder.createFromMesh(mesh, GL20.GL_TRIANGLES, new Material(TextureAttribute.createDiffuse(texture),
ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f), IntAttribute.createCullFace(0)));
instance = new ModelInstance(model);
world.add(new BulletEntity(instance, null));
}
示例9: genCube
import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
public static Mesh genCube () {
Mesh mesh = new Mesh(true, 24, 36, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.Normal,
3, "a_normal"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texcoords"));
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.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,};
float[] vertices = new float[24 * 8];
int pIdx = 0;
int nIdx = 0;
int tIdx = 0;
for (int i = 0; i < vertices.length;) {
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = cubeTex[tIdx++];
vertices[i++] = cubeTex[tIdx++];
}
short[] indices = {0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 15, 14, 12, 14, 13, 16, 17, 18, 16, 18, 19,
20, 23, 22, 20, 22, 21};
mesh.setVertices(vertices);
mesh.setIndices(indices);
return mesh;
}