dont touch vulkan PLEASE
parent
84b4ae2ead
commit
9d9fef3899
|
@ -7,6 +7,7 @@ public class Mesh
|
||||||
private float[] normals;
|
private float[] normals;
|
||||||
private int[] indices;
|
private int[] indices;
|
||||||
private float furthestPoint;
|
private float furthestPoint;
|
||||||
|
public Vertex[] vkVertices;//may not be set only used for vulkan
|
||||||
|
|
||||||
public Mesh(float[] vertices, float[] textureCoords, float[] normals, int[] indices,
|
public Mesh(float[] vertices, float[] textureCoords, float[] normals, int[] indices,
|
||||||
float furthestPoint)
|
float furthestPoint)
|
||||||
|
|
|
@ -74,6 +74,8 @@ public class OBJFileLoader
|
||||||
textureCoords[j * 2 + 1] = 1 - vertex.getTextureIndex().y;
|
textureCoords[j * 2 + 1] = 1 - vertex.getTextureIndex().y;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
return new Mesh(verticies, textureCoords, new float[normals.sizeof()], indicesList, i);
|
Mesh mesh = new Mesh(verticies, textureCoords, new float[normals.sizeof()], indicesList, i);
|
||||||
|
mesh.vkVertices = vertexList;
|
||||||
|
return mesh;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -127,13 +127,26 @@ public class VKModelData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void memcpy(ByteBuffer buffer, float[] indices) {
|
private void memcpy(ByteBuffer buffer, float[] vertices) {
|
||||||
|
|
||||||
for(float index : indices) {
|
// buffer.putFloat(vertex.color.x());
|
||||||
buffer.putFloat(index);
|
// buffer.putFloat(vertex.color.y());
|
||||||
|
// buffer.putFloat(vertex.color.z());
|
||||||
|
//
|
||||||
|
// buffer.putFloat(vertex.texCoords.x());
|
||||||
|
// buffer.putFloat(vertex.texCoords.y());
|
||||||
|
int i = 0;
|
||||||
|
for(float vertex : vertices) {
|
||||||
|
buffer.putFloat(vertex);
|
||||||
|
if(i == 2) {
|
||||||
|
i = 0;
|
||||||
|
buffer.putFloat(1);
|
||||||
|
buffer.putFloat(1);
|
||||||
|
buffer.putFloat(1);
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
buffer.rewind();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createVertexBuffer() {
|
private void createVertexBuffer() {
|
||||||
|
@ -153,12 +166,7 @@ public class VKModelData
|
||||||
long stagingBuffer = pBuffer.get(0);
|
long stagingBuffer = pBuffer.get(0);
|
||||||
long stagingBufferMemory = pBufferMemory.get(0);
|
long stagingBufferMemory = pBufferMemory.get(0);
|
||||||
|
|
||||||
PointerBuffer data = stack.mallocPointer(1);
|
|
||||||
|
|
||||||
VK12.vkMapMemory(VKRegister.device, stagingBufferMemory, 0, bufferSize, 0, data);
|
|
||||||
{
|
|
||||||
memcpy(data.getByteBuffer(0, (int) bufferSize), mesh.getVertices());
|
|
||||||
}
|
|
||||||
VK12.vkUnmapMemory(VKRegister.device, stagingBufferMemory);
|
VK12.vkUnmapMemory(VKRegister.device, stagingBufferMemory);
|
||||||
|
|
||||||
createBuffer(bufferSize,
|
createBuffer(bufferSize,
|
||||||
|
@ -177,7 +185,7 @@ public class VKModelData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void memcpyIndices(ByteBuffer buffer, int[] indices) {
|
private void memcpy(ByteBuffer buffer, int[] indices) {
|
||||||
|
|
||||||
for(int index : indices) {
|
for(int index : indices) {
|
||||||
buffer.putInt(index);
|
buffer.putInt(index);
|
||||||
|
@ -207,7 +215,7 @@ public class VKModelData
|
||||||
|
|
||||||
VK12.vkMapMemory(VKRegister.device, stagingBufferMemory, 0, bufferSize, 0, data);
|
VK12.vkMapMemory(VKRegister.device, stagingBufferMemory, 0, bufferSize, 0, data);
|
||||||
{
|
{
|
||||||
memcpyIndices(data.getByteBuffer(0, (int) bufferSize), mesh.getIndices());
|
memcpy(data.getByteBuffer(0, (int) bufferSize), mesh.getIndices());
|
||||||
}
|
}
|
||||||
VK12.vkUnmapMemory(VKRegister.device, stagingBufferMemory);
|
VK12.vkUnmapMemory(VKRegister.device, stagingBufferMemory);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue