Skip to content
Snippets Groups Projects
Commit 40432fee authored by Richard Pajerský's avatar Richard Pajerský
Browse files

Moved transformation code into function

parent f9c00ee3
No related branches found
No related tags found
No related merge requests found
......@@ -136,27 +136,21 @@ public class SceneRenderer {
Collections.reverse((ArrayList)drawables);
}
for (DrawableMesh obj: drawables) {
setMaterial(obj);
gl.glPushMatrix();
setTransformation(obj);
for (MeshFacet facet: obj.getFacets()) {
// rotate
gl.glPushMatrix();
gl.glRotated(obj.getRotation().x, 1, 0, 0);
gl.glRotated(obj.getRotation().y, 0, 1, 0);
gl.glRotated(obj.getRotation().z, 0, 0, 1);
// move
gl.glTranslated(obj.getTranslation().x, obj.getTranslation().y, obj.getTranslation().z);
// scale
gl.glScaled(1 + obj.getScale().x, 1 + obj.getScale().y, 1 + obj.getScale().z);
renderFacet(facet);
gl.glPopMatrix();
}
gl.glPopMatrix();
}
gl.glFlush();
}
/**
* Sets up material based on DrawableMesh
* Sets up material based on info from DrawableMesh
*/
private void setMaterial(DrawableMesh obj) {
Color color = obj.getColor();
......@@ -170,6 +164,20 @@ public class SceneRenderer {
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, highlights, 0);*/
}
/**
* Sets up object transformation
*/
private void setTransformation(DrawableMesh obj) {
// rotate
gl.glRotated(obj.getRotation().x, 1, 0, 0);
gl.glRotated(obj.getRotation().y, 0, 1, 0);
gl.glRotated(obj.getRotation().z, 0, 0, 1);
// move
gl.glTranslated(obj.getTranslation().x, obj.getTranslation().y, obj.getTranslation().z);
// scale
gl.glScaled(1 + obj.getScale().x, 1 + obj.getScale().y, 1 + obj.getScale().z);
}
/**
* Clears the scene and prepares it for the re-drawing.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment