diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/scene/SceneRenderer.java b/GUI/src/main/java/cz/fidentis/analyst/gui/scene/SceneRenderer.java index 176987cfab5680899d67a0aa98e407159a43872a..ebd53fd749690d1dea6be31b57d180646afde2a2 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/scene/SceneRenderer.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/scene/SceneRenderer.java @@ -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. */