Commit 0aa4f36f authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch 'extract-drawable-rendering-functionality' into 'master'

Extract rendering functionality out of drawable objects

See merge request grp-fidentis/analyst2!366
parents 474bf449 b8e671cd
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -90,6 +90,16 @@
            <artifactId>Rendering</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>RenderingData</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>RenderingEngines</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>SpacePartitioningData</artifactId>
+10 −2
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
                    <useOSGiDependencies>true</useOSGiDependencies>
                    <publicPackages> <!-- expose API/packages to other modules -->
                        <publicPackage>cz.fidentis.analyst.canvas</publicPackage>
                        <publicPackage>cz.fidentis.analyst.drawables</publicPackage>
                        <publicPackage>cz.fidentis.analyst.rendering</publicPackage>
                        <publicPackage>cz.fidentis.analyst.landmarks</publicPackage>
                        <publicPackage>cz.fidentis.analyst.toolbar</publicPackage>
                   </publicPackages>
@@ -99,6 +97,16 @@
            <artifactId>FaceEngines</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>RenderingData</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>RenderingEngines</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.vecmath</groupId>
            <artifactId>vecmath</artifactId>

RenderingData/pom.xml

0 → 100644
+88 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>cz.fidentis</groupId>
        <artifactId>FIDENTIS-Analyst-parent</artifactId>
        <version>master-SNAPSHOT</version>
    </parent>
    <artifactId>RenderingData</artifactId>
    <packaging>nbm</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.netbeans.utilities</groupId>
                <artifactId>nbm-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <useOSGiDependencies>true</useOSGiDependencies>
                    <publicPackages> <!-- expose API/packages to other modules -->
                        <publicPackage>cz.fidentis.analyst.drawables</publicPackage>
                        <publicPackage>cz.fidentis.analyst.rendering</publicPackage>
                   </publicPackages>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <!-- Check code style -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${version.maven.plugin.checkstyle}</version>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <configuration>
                            <configLocation>codestyle.xml</configLocation>
                            <consoleOutput>true</consoleOutput>
                            <failOnViolation>${checkstyle.fail}</failOnViolation>
                            <violationSeverity>${checkstyle.severity}</violationSeverity>
                            <includeTestSourceDirectory>false</includeTestSourceDirectory>
                        </configuration>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>LandmarksData</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>GPU</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>FaceData</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>GeometryData</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.vecmath</groupId>
            <artifactId>vecmath</artifactId>
            <version>${version.javax.vecmath}</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>
+1 −47
Original line number Diff line number Diff line
package cz.fidentis.analyst.drawables;

import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.glu.GLU;
import cz.fidentis.analyst.rendering.RenderingMode;
import java.awt.Color;
import java.util.Comparator;
@@ -16,8 +13,6 @@ import java.util.Comparator;
 */
public abstract class Drawable {

    protected static final GLU GLU_CONTEXT = new GLU();
    
    private boolean display = true;
    
    /* material info */
@@ -66,31 +61,6 @@ public abstract class Drawable {
        }
    }

    /**
     * Renders the scene.
     * @param gl OpenGL context
     */
    public void render(GL2 gl) {
        initRendering(gl);
        renderObject(gl);
        finishRendering(gl);
    }
    
    protected void initRendering(GL2 gl) {
        setPolygonMode(gl);
        
        // set color
        float[] rgba = {color.getRed() / 255f, color.getGreen() / 255f, 
            color.getBlue() / 255f , getTransparency()};
        gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, rgba, 0);

    }
    
    protected abstract void renderObject(GL2 gl);

    protected void finishRendering(GL2 gl) {    
    }
        
    /**
     * Shows or hides the drawable.
     * 
@@ -168,20 +138,4 @@ public abstract class Drawable {
        this.renderMode = renderMode;
    }

    protected void setPolygonMode(GL2 gl) {
        gl.glShadeModel(GL2.GL_SMOOTH);
        switch (getRenderMode()) {
            case WIREFRAME:
                gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_LINE);
                break;
            case POINT_CLOUD:
                gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_POINT);
                break;
            default:
            case TEXTURE:
            case SMOOTH:
                gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL);
                break;                
        }
    }
}
+0 −9
Original line number Diff line number Diff line
package cz.fidentis.analyst.drawables;

import com.jogamp.opengl.GL2;
import cz.fidentis.analyst.data.shapes.Box;
import cz.fidentis.analyst.data.shapes.Plane;

@@ -92,12 +91,4 @@ public class DrawableCuttingPlane extends DrawablePlane {
        return this.showMirror;
        //return getModel().getFacets().size() > 1;
    }
    
    @Override
    protected void renderObject(GL2 gl) {
        renderObject(gl, getPlane().getMesh(getBBox()));
        if (showMirror) {
            renderObject(gl, getMirrorPlane().getMesh(getBBox()));
        }
    }
}
Loading