Skip to content
Snippets Groups Projects
Commit c1dd8f84 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Resolve "Fix material serialization"

parent 16c9fcaa
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
}
......
......@@ -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,
......@@ -53,7 +54,7 @@ public class HumanFaceUtils {
samplingStrategy
);
transformedFace.getMeshModel().compute(icp, true); // superimpose face towards the static face
// update k-d of transformed face:
if (transformedFace.hasKdTree()) {
if (recomputeKdTree) {
......
......@@ -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,28 +81,28 @@ 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);
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)) {
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);
try{
texture = TextureIO.newTexture(new File(model.getMaterial().getTexturePath()), true);
texture.bind(gl);
textureHandle = texture.getTextureObject();
} catch (Exception ex){
ex.printStackTrace();
}
}
}
}
@Override
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);
......
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
......
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