fixed model loading maybe

This commit is contained in:
JISAUAY committed 2024-09-26 13:30:01 -05:00
1 parent 60457309ae
commit 719e6993df
3 files changed
+6 -4

No files matched your search

+2 -2
View File
@@ -83,7 +83,7 @@ public class Obj {
// look for vertex // look for vertex
for (int b = 0; b < 3; b++) for (int b = 0; b < 3; b++)
if (temp_n_vbo.get(a + b) != v.get(vertex_index + b)) { if (temp_v_vbo.get(a + b) != v.get(vertex_index + b)) {
vertex_found = false; vertex_found = false;
break; break;
} }
@@ -97,7 +97,7 @@ public class Obj {
if (vertex_found && normal_found) if (vertex_found && normal_found)
{ {
i.add(a / 6); i.add(a / 3);
vbo_el_found = true; vbo_el_found = true;
} }
} }
@@ -69,6 +69,7 @@ public class Mesh {
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0); glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
// Bind Normals into a VBO // Bind Normals into a VBO
System.out.println(this.normals.length);
FloatBuffer normals_buffer = stack.callocFloat(this.normals.length); FloatBuffer normals_buffer = stack.callocFloat(this.normals.length);
normals_buffer.put(0, this.normals); normals_buffer.put(0, this.normals);
vbo_id = glGenBuffers(); vbo_id = glGenBuffers();
+3 -2
View File
@@ -22,7 +22,7 @@ public class Main implements GameLogic {
@Override @Override
public void init(Window window, World world, Render render) { public void init(Window window, World world, Render render) {
Entity cube = new Entity("resources/objs/cube.obj", "resources/shaders/shader.frag", "resources/shaders/shader.vert"); Entity cube = new Entity("resources/objs/sphere.obj", "resources/shaders/shader.frag", "resources/shaders/shader.vert");
cube.model = new Matrix4f().identity().translate(0, 0, -10); cube.model = new Matrix4f().identity().translate(0, 0, -10);
System.out.println(cube.model.toString()); System.out.println(cube.model.toString());
@@ -39,7 +39,8 @@ public class Main implements GameLogic {
world.entities.get(0).model = new Matrix4f() world.entities.get(0).model = new Matrix4f()
.identity() .identity()
.translate(0, 0, -5) .translate(0, 0, -5)
.rotate(ang, 0,1, 0); .rotate(ang, 0,1, 0)
.rotate(ang * 2, 0, 0, 1);
ang += 1.0f/100.0f; ang += 1.0f/100.0f;
} }
} }