use of org.joml.Vector2f in project Terasology by MovingBlocks.
the class BlockMeshPart method appendTo.
public void appendTo(ChunkMesh chunk, ChunkView chunkView, int offsetX, int offsetY, int offsetZ, ChunkMesh.RenderType renderType, Colorc colorOffset, ChunkVertexFlag flags) {
ChunkMesh.VertexElements elements = chunk.getVertexElements(renderType);
for (Vector2f texCoord : texCoords) {
elements.uv0.put(texCoord);
}
int nextIndex = elements.vertexCount;
elements.buffer.reserveElements(nextIndex + vertices.length);
Vector3f pos = new Vector3f();
for (int vIdx = 0; vIdx < vertices.length; ++vIdx) {
elements.color.put(colorOffset);
elements.position.put(pos.set(vertices[vIdx]).add(offsetX, offsetY, offsetZ));
elements.normals.put(normals[vIdx]);
elements.flags.put((byte) (flags.getValue()));
elements.frames.put((byte) (texFrames - 1));
float[] lightingData = calcLightingValuesForVertexPos(chunkView, vertices[vIdx].add(offsetX, offsetY, offsetZ, new Vector3f()), normals[vIdx]);
elements.sunlight.put(lightingData[0]);
elements.blockLight.put(lightingData[1]);
elements.ambientOcclusion.put(lightingData[2]);
}
elements.vertexCount += vertices.length;
for (int index : indices) {
elements.indices.put(index + nextIndex);
}
}
use of org.joml.Vector2f in project Terasology by MovingBlocks.
the class BlockMeshPart method mapTexCoords.
public BlockMeshPart mapTexCoords(Vector2f offset, float width, int frames) {
float normalisedBorder = BORDER * width;
Vector2f[] newTexCoords = new Vector2f[texCoords.length];
for (int i = 0; i < newTexCoords.length; ++i) {
newTexCoords[i] = new Vector2f(offset.x + normalisedBorder + texCoords[i].x * (width - 2 * normalisedBorder), offset.y + normalisedBorder + texCoords[i].y * (width - 2 * normalisedBorder));
}
return new BlockMeshPart(vertices, normals, newTexCoords, indices, frames);
}
Aggregations