PDA

View Full Version : Rendering problem



andrei.alex
11-13-2015, 03:50 AM
So, I am trying to implement a way to render multiple Gameobjects using one Model with multiple Meshes.
The way I thought this would work is by drawing the Model (with all the Meshes) once and use multiple Gameobjects on that.

Below is the code that I came up with and I think its not the correct way.
Can anyone give me an advice on how I can achieve these?


for (Model model : _entities.keySet()) {

for(Mesh mesh : model.getMeshes()) {
mesh.bind();

for (GameObject entity : _entities.get(model)) {

Matrix4f transformationMatrix = Maths.createTransformMatrix(entity.getPosition(), entity.getRotation(), entity.getScale());
shader.LoadTransformationMatrix(transformationMatr ix);
}

mesh.draw();

mesh.unbind();
}
}