models: remove uv
This commit is contained in:
@@ -24,10 +24,8 @@ import chess.view.DDDrender.opengl.VertexBuffer;
|
|||||||
public class ModelLoader {
|
public class ModelLoader {
|
||||||
|
|
||||||
private static final int VERTEX_SIZE = 3;
|
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_POSITION_INDEX = 0;
|
||||||
private static final int VERTEX_UV_INDEX = 1;
|
private static final int VERTEX_NORMAL_INDEX = 1;
|
||||||
private static final int VERTEX_NORMAL_INDEX = 2;
|
|
||||||
|
|
||||||
private static float[] toFloatArray(List<Float> list) {
|
private static float[] toFloatArray(List<Float> list) {
|
||||||
float[] result = new float[list.size()];
|
float[] result = new float[list.size()];
|
||||||
@@ -47,7 +45,6 @@ public class ModelLoader {
|
|||||||
|
|
||||||
private static VertexArray processMesh(AIMesh mesh, AIScene scene) {
|
private static VertexArray processMesh(AIMesh mesh, AIScene scene) {
|
||||||
List<Float> positions = new ArrayList<>();
|
List<Float> positions = new ArrayList<>();
|
||||||
List<Float> textureCoords = new ArrayList<>();
|
|
||||||
List<Float> normals = new ArrayList<>();
|
List<Float> normals = new ArrayList<>();
|
||||||
|
|
||||||
List<Integer> indicies = new ArrayList<>();
|
List<Integer> indicies = new ArrayList<>();
|
||||||
@@ -79,24 +76,14 @@ public class ModelLoader {
|
|||||||
normals.add(normal.z());
|
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);
|
VertexBuffer positionVBO = new VertexBuffer(toFloatArray(positions), VERTEX_SIZE);
|
||||||
positionVBO.AddVertexAttribPointer(VERTEX_POSITION_INDEX, VERTEX_SIZE, 0);
|
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);
|
VertexBuffer normalVBO = new VertexBuffer(toFloatArray(normals), VERTEX_SIZE);
|
||||||
normalVBO.AddVertexAttribPointer(VERTEX_NORMAL_INDEX, VERTEX_SIZE, 0);
|
normalVBO.AddVertexAttribPointer(VERTEX_NORMAL_INDEX, VERTEX_SIZE, 0);
|
||||||
|
|
||||||
VertexArray vao = new VertexArray(new ElementBuffer(toIntArray(indicies)));
|
VertexArray vao = new VertexArray(new ElementBuffer(toIntArray(indicies)));
|
||||||
vao.Bind();
|
vao.Bind();
|
||||||
vao.BindVertexBuffer(positionVBO);
|
vao.BindVertexBuffer(positionVBO);
|
||||||
vao.BindVertexBuffer(textureVBO);
|
|
||||||
vao.BindVertexBuffer(normalVBO);
|
vao.BindVertexBuffer(normalVBO);
|
||||||
vao.Unbind();
|
vao.Unbind();
|
||||||
return vao;
|
return vao;
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ public class PieceShader extends ShaderProgram {
|
|||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
layout(location = 0) in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
layout(location = 1) in vec2 uv;
|
layout(location = 1) in vec3 normal;
|
||||||
layout(location = 2) in vec3 normal;
|
|
||||||
|
|
||||||
uniform mat4 projectionMatrix;
|
uniform mat4 projectionMatrix;
|
||||||
uniform mat4 viewMatrix;
|
uniform mat4 viewMatrix;
|
||||||
|
|||||||
Reference in New Issue
Block a user