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

Fixed transparency rendering, by reversing rendering order

parent 40cc5fd4
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import cz.fidentis.analyst.gui.scene.DrawableMesh; ...@@ -10,6 +10,7 @@ import cz.fidentis.analyst.gui.scene.DrawableMesh;
import cz.fidentis.analyst.visitors.mesh.BoundingBox; import cz.fidentis.analyst.visitors.mesh.BoundingBox;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import javax.vecmath.Point3d; import javax.vecmath.Point3d;
import javax.vecmath.Vector3d; import javax.vecmath.Vector3d;
......
...@@ -11,6 +11,7 @@ import cz.fidentis.analyst.mesh.core.MeshFacet; ...@@ -11,6 +11,7 @@ import cz.fidentis.analyst.mesh.core.MeshFacet;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.vecmath.Point3d; import javax.vecmath.Point3d;
import javax.vecmath.Point4f; import javax.vecmath.Point4f;
...@@ -133,6 +134,10 @@ public class SceneRenderer { ...@@ -133,6 +134,10 @@ public class SceneRenderer {
gl.glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); gl.glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
} }
if (((DrawableMesh)drawables.toArray()[0]).getTransparency() != 1) {
Collections.reverse((ArrayList)drawables);
}
for (DrawableMesh obj: drawables) { for (DrawableMesh obj: drawables) {
// render color // render color
Color color = obj.getColor(); Color color = obj.getColor();
...@@ -140,7 +145,6 @@ public class SceneRenderer { ...@@ -140,7 +145,6 @@ public class SceneRenderer {
color.getBlue() / 255d , obj.getTransparency()); color.getBlue() / 255d , obj.getTransparency());
for (MeshFacet facet: obj.getFacets()) { for (MeshFacet facet: obj.getFacets()) {
// TO DO - R. Pajersky: add transformation (glPushMatrix, glRotate, ...)
// rotate // rotate
gl.glPushMatrix(); gl.glPushMatrix();
gl.glRotated(obj.getRotation().x, 1, 0, 0); gl.glRotated(obj.getRotation().x, 1, 0, 0);
......
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