dev #12

Merged
Persson-dev merged 44 commits from dev into main 2025-05-17 15:05:24 +00:00
2 changed files with 2 additions and 16 deletions
Showing only changes of commit 1b61eca58b - Show all commits

View File

@@ -24,10 +24,8 @@ import chess.view.DDDrender.opengl.VertexBuffer;
public class ModelLoader {
private static final int VERTEX_SIZE = 3;
private static final int UV_SIZE = 2;
private static final int VERTEX_POSITION_INDEX = 0;
private static final int VERTEX_UV_INDEX = 1;
private static final int VERTEX_NORMAL_INDEX = 2;
private static final int VERTEX_NORMAL_INDEX = 1;
private static float[] toFloatArray(List<Float> list) {
float[] result = new float[list.size()];
@@ -47,7 +45,6 @@ public class ModelLoader {
private static VertexArray processMesh(AIMesh mesh, AIScene scene) {
List<Float> positions = new ArrayList<>();
List<Float> textureCoords = new ArrayList<>();
List<Float> normals = new ArrayList<>();
List<Integer> indicies = new ArrayList<>();
@@ -79,24 +76,14 @@ public class ModelLoader {
normals.add(normal.z());
}
// PointerBuffer vertexTexture = mesh.mTextureCoords();
// for (int i = 0; i < vertNumber; i++) {
// PointerBuffer buff = mesh.mTextureCoords();
// textureCoords.add(buff.get(i).x());
// textureCoords.add(buff.get(i).y());
// }
VertexBuffer positionVBO = new VertexBuffer(toFloatArray(positions), VERTEX_SIZE);
positionVBO.AddVertexAttribPointer(VERTEX_POSITION_INDEX, VERTEX_SIZE, 0);
VertexBuffer textureVBO = new VertexBuffer(toFloatArray(textureCoords), UV_SIZE);
textureVBO.AddVertexAttribPointer(VERTEX_UV_INDEX, UV_SIZE, 0);
VertexBuffer normalVBO = new VertexBuffer(toFloatArray(normals), VERTEX_SIZE);
normalVBO.AddVertexAttribPointer(VERTEX_NORMAL_INDEX, VERTEX_SIZE, 0);
VertexArray vao = new VertexArray(new ElementBuffer(toIntArray(indicies)));
vao.Bind();
vao.BindVertexBuffer(positionVBO);
vao.BindVertexBuffer(textureVBO);
vao.BindVertexBuffer(normalVBO);
vao.Unbind();
return vao;

View File

@@ -11,8 +11,7 @@ public class PieceShader extends ShaderProgram {
#version 330
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 uv;
layout(location = 2) in vec3 normal;
layout(location = 1) in vec3 normal;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;