本文整理汇总了Java中com.badlogic.gdx.graphics.VertexAttribute.Normal方法的典型用法代码示例。如果您正苦于以下问题:Java VertexAttribute.Normal方法的具体用法?Java VertexAttribute.Normal怎么用?Java VertexAttribute.Normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.VertexAttribute
的用法示例。
在下文中一共展示了VertexAttribute.Normal方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMeshes
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static void buildMeshes() {
if (indices == null) {
int len = 3 * 6 * 6 / 3;
indices = new short[len];
short j = 0;
for (int 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);
}
}
for (Voxel v : voxels.values()) {
v.mesh = new Mesh(true, 24, indices.length, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1));
v.mesh.setIndices(indices);
verts = new FloatArray();
for (Direction d : Direction.values())
new TextureFace(d, new Vector3(), v.getTextureUV(0, 0, 0, d)).getVertexData(verts);
v.mesh.setVertices(verts.items, 0, verts.size);
}
}
示例2: setupMesh
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
private void setupMesh(Model model, MaterialTileMapping textures) {
int numVertices = countModelVertices(model);
vertices = new Vertices(
numVertices,
VertexAttribute.Position(),
VertexAttribute.ColorUnpacked(),
VertexAttribute.Normal(),
VertexAttribute.TexCoords(0)
);
model.calculateBoundingBox(tmpModelBounds);
if (scaleToSize != null) {
MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
} else {
bounds = new BoundingBox().set(Vector3.Zero, tmpModelBounds.getDimensions());
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
}
for (int i = 0; i < model.nodes.size; ++i)
collectModelNodeVertices(model.nodes.get(i), vertices, textures, color, tmpScaleFactor, positionOffset);
}
示例3: initVertices
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
protected void initVertices() {
/** STARS **/
meshes = new MeshData[1];
curr = new MeshData();
meshes[0] = curr;
aux1 = new Vector3();
maxVertices = 3000000;
VertexAttribute[] attribs = buildVertexAttributes();
curr.mesh = new Mesh(false, maxVertices, 0, attribs);
curr.vertices = new float[maxVertices * (curr.mesh.getVertexAttributes().vertexSize / 4)];
curr.vertexSize = curr.mesh.getVertexAttributes().vertexSize / 4;
curr.colorOffset = curr.mesh.getVertexAttribute(Usage.ColorPacked) != null ? curr.mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0;
pmOffset = curr.mesh.getVertexAttribute(Usage.Tangent) != null ? curr.mesh.getVertexAttribute(Usage.Tangent).offset / 4 : 0;
additionalOffset = curr.mesh.getVertexAttribute(Usage.Generic) != null ? curr.mesh.getVertexAttribute(Usage.Generic).offset / 4 : 0;
/** NEBULA **/
// Max of 5000 nebula clouds
int maxQuads = 5000;
int maxQuadVertices = maxQuads * 4;
int maxQuadIndices = maxQuads * 6;
quad = new MeshData();
quad.mesh = new Mesh(false, maxQuadVertices, maxQuadIndices, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0), new VertexAttribute(Usage.Generic, 2, "a_additional"));
quad.vertices = new float[maxQuadVertices * (quad.mesh.getVertexAttributes().vertexSize / 4)];
quad.vertexSize = quad.mesh.getVertexAttributes().vertexSize / 4;
quad.indices = new short[maxQuadIndices];
}
示例4: load
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public void load() {
if (indices == null) {
int len = SIZE * SIZE * SIZE * 6 * 6 / 3;
indices = new short[len];
short j = 0;
for (int 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);
}
}
opaque = new Mesh(true, SIZE * SIZE * SIZE * 6 * 4, SIZE * SIZE * SIZE * 36 / 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
opaque.setIndices(indices);
transp = new Mesh(true, SIZE * SIZE * SIZE * 6 * 4, SIZE * SIZE * SIZE * 36 / 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
transp.setIndices(indices);
opaqueMeshData = new FloatArray();
transpMeshData = new FloatArray();
loaded = true;
onceLoaded = true;
drawn = false;
}
示例5: genCubeWireframe
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static Mesh genCubeWireframe(float size) {
Mesh mesh = new Mesh(true, 24, 36, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
float[] cubeVerts = { 0, 0, 0, 0, 0, size, 0, 0, size, 0, size, size, 0, size, size, 0, size, 0, 0, size, 0, 0, 0, 0, size, 0, 0, size, 0, size, size, 0, size, size, size, size, size, size, size, size, size, 0, size, size, 0, size, 0, 0, size, 0, 0, 0, 0, 0, size, size, 0, 0, size, 0, size, 0, size, 0, 0, size, size, size, size, 0, size, size, };
float[] vertices = new float[cubeVerts.length / 3 * 10];
int pIdx = 0;
for (int i = 0; i < vertices.length;) {
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = 0;
vertices[i++] = 1;
vertices[i++] = 0;
vertices[i++] = 0;
vertices[i++] = 0;
vertices[i++] = 1;
vertices[i++] = 1;
}
mesh.setVertices(vertices);
return mesh;
}
示例6: loadRenderModel
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的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;
}
示例7: VoxelWorld
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的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));
}
}
示例8: genCube
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static Mesh genCube(float size, float texX, float texY, float texSize) {
Mesh mesh = new Mesh(true, 24, 36, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
float[] cubeVerts = { 0, 0, 0, 0, 0, size, size, 0, size, size, 0, 0, 0, size, 0, 0, size, size, size, size, size, size, size, 0, 0, 0, 0, 0, size, 0, size, size, 0, size, 0, 0, 0, 0, size, 0, size, size, size, size, size, size, 0, size, 0, 0, 0, 0, 0, size, 0, size, size, 0, size, 0, size, 0, 0, size, 0, size, size, size, size, size, size, 0, };
float[] cubeNormals = { 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, };
float[] cubeTex = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.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, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, };
float b = Color.toFloatBits(1f, 1f, 1f, 1f);
float[] vertices = new float[24 * 11];
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++] = b;
vertices[i++] = cubeTex[tIdx++] * texSize + texX;
vertices[i++] = cubeTex[tIdx++] * texSize + texY;
vertices[i++] = 1;
vertices[i++] = 1;
}
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;
}