Commit 5b39bd6c authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '183-fix-material-serialization' into 'master'

Resolve "Fix material serialization"

Closes #183

See merge request grp-fidentis/analyst2!198
parents 16c9fcaa c1dd8f84
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import cz.fidentis.analyst.mesh.core.CornerTableRow;
import cz.fidentis.analyst.mesh.core.MeshFacetImpl;
import cz.fidentis.analyst.mesh.core.MeshModel;
import cz.fidentis.analyst.mesh.core.MeshPointImpl;
import cz.fidentis.analyst.mesh.material.Material;
import cz.fidentis.analyst.symmetry.Plane;
import cz.fidentis.analyst.visitors.mesh.BoundingBox.BBox;
import java.io.File;
@@ -118,11 +119,13 @@ public class HumanFaceFactory {
                HumanFaceFactory.kryo.register(CornerTable.class);
                HumanFaceFactory.kryo.register(CornerTableRow.class);
                HumanFaceFactory.kryo.register(BBox.class);
                HumanFaceFactory.kryo.register(Material.class);
                HumanFaceFactory.kryo.register(Plane.class);
                HumanFaceFactory.kryo.register(Point3d.class);
                HumanFaceFactory.kryo.register(Vector3d.class);
                HumanFaceFactory.kryo.register(ArrayList.class);
                HumanFaceFactory.kryo.register(HashMap.class);
                HumanFaceFactory.kryo.register(String.class);
            }
        }
    }
+2 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class HumanFaceUtils {
            boolean recomputeKdTree) {
        
        // transform mesh:
        System.out.println("_AAA " + staticFace.getShortName() + ":" + transformedFace.getShortName());
        IcpTransformer icp = new IcpTransformer(
                staticFace.getMeshModel(), 
                maxIterations, 
+11 −14
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@ import cz.fidentis.analyst.mesh.core.MeshPoint;
import java.awt.Color;
import java.io.File;
import java.util.List;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

/**
 * A drawable triangular mesh, i.e., a mesh model with drawing information like 
@@ -25,7 +23,6 @@ public class DrawableMesh extends Drawable {
    
    private final MeshModel model;
    private Texture texture = null;
    private int textureHandle;
    
    /**
     * Copy constructor. 
@@ -84,15 +81,17 @@ public class DrawableMesh extends Drawable {
        gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 50);  
        gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, highlights, 0);
        
        if (getRenderMode() == RenderingMode.TEXTURE && 
                model.hasMaterial() && 
                model.getMaterial().hasTexture() && 
                (texture == null)) {
            
            gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
            gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
            gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
        
        if (model.hasMaterial() && model.getMaterial().hasTexture() && (texture == null)) {
            try{
                texture = TextureIO.newTexture(new File(model.getMaterial().getTexturePath()), true);
                texture.bind(gl);
                textureHandle = texture.getTextureObject();
            } catch (Exception ex){
                ex.printStackTrace();
            }
@@ -104,8 +103,6 @@ public class DrawableMesh extends Drawable {
    protected void renderObject(GL2 gl) {
        if (getRenderMode() == RenderingMode.TEXTURE){
            gl.glEnable(GL2.GL_TEXTURE_2D);
            // Select the texture object
            gl.glBindTexture(GL2.GL_TEXTURE_2D, textureHandle);
        } else {
            gl.glDisable(GL2.GL_TEXTURE_2D);
        }
@@ -123,7 +120,7 @@ public class DrawableMesh extends Drawable {
                }
                
                // render the vertices
                if (mPoint.getTexCoord() != null) {
                if (getRenderMode() == RenderingMode.TEXTURE && mPoint.getTexCoord() != null) {
                    gl.glTexCoord2d(mPoint.getTexCoord().x, mPoint.getTexCoord().y);
                }
                gl.glVertex3d(mPoint.getPosition().x, mPoint.getPosition().y, mPoint.getPosition().z);
+2 −1
Original line number Diff line number Diff line
package cz.fidentis.analyst.mesh.material;
import java.io.Serializable;
import javax.vecmath.Vector3d;

/**
@@ -7,7 +8,7 @@ import javax.vecmath.Vector3d;
 * @author Matej Lukes
 * @author Katerina Zarska
 */
public class Material {
public class Material implements Serializable {
    
    private final String name;
    // colour info