Yikes! I don’t like this file… you are a very stoic programmer! X)
Nonetheless, let me point normals in your direction. (HA FUNNY JOKE)
Each object has 3 matrices it uses and 3 3d vectors it uses. Although it is based on one vao and 3 common, but variable amounts of vbos. This is my approach to it. Don’t forget the vertex count or indices count (ibo)!
Since two of these matrices are generated separately from the object, we don’t need to store any references to these, but due render time, pass them through for the shader. This leaves us with one matrix we need to modify. This is a transformation matrix, and you can call it the Model View matrix. The model view matrix determines, from the 3 vectors where the vertices are drawn. The other two matrices are the projection matrix and the camera matrix. This is multiplied after the projection and camera view matrix. The camera matrix has MANY names, but at the end it just transforms the world as a camera.
So the first thing you need is a class that holds everything unique to every single element you render. Then you need a class that holds everything common, static for each model. Finally, you can just store a list of the class that holds everything different. Come render time, you just loop over it.
soo… Pseudo code…
public class Positional {
final Vec3 position = new Vec3(), scale = new Vec3(1,1,1), rotation = new Vec3();
public Mat4 generateMatrix() {
final Matrix4f matrix = new Mat4();
matrix.translate(-position.x, -position.y, -position.z);
matrix.rotate(rotation.x, 1, 0, 0);
matrix.rotate(rotation.y, 0, 1, 0);
matrix.rotate(rotation.z, 0, 0, 1);
matrix.scale(scale);
matrix.finalize(); // this executes calculations at once, a small improvement... cuts down on calls
}
}
public class Model {
private int vao, vertex_count;
private int[] vbos, int[] offshore_vbos;
private ArrayList<Positional> models;
public Model(int vao, int[] vbos, int[] offshore_vbos) {
this.vao = vao;
this.vbos = vbos;
this.offshore_vbos = offshore_vbos;
models = new ArrayList<Positional>();
}
public void addModel(Positional model) {
models.add(model);
}
public void removeModel(Positional model) {
models.remove(model);
}
public ArrayList<Positional> getModels() {
return models;
}
}
Now you can see from here you don’t need any “batch” stuff anymore. You just need to loop through once you bind your vao. I STRONGLY suggest that you create a class that takes in a model and renders it. You only need 1-3 render methods, which is a great thing.
Also, I want you to check out my ModelLoader class… or something that generates VAO and VBOS.
http://www.java-gaming.org/index.php?action=pastebin&hex=11db92c574115
If you need help on the render method I’d love to help <3
Anyone: If you have anything to suggest to me, I’m all ears.
Edit:
Checked the posts in more depth. RIP I don’t use quaternions… RIP I think I misunderstood the context of what OP was trying to do.