Commit 2a5017b7 authored by Bartosz Borucki's avatar Bartosz Borucki

fixes #83

- added surface offset to visnow config properties
- added surface offset modification GUI to preferences
- modified default surface offset value to 200
- fixed exception on first logging config init
- increased config version
parent b8ca6d75
......@@ -62,6 +62,7 @@ import pl.edu.icm.visnow.geometries.parameters.RegularField3DParams;
import pl.edu.icm.visnow.geometries.parameters.RenderingParams;
import pl.edu.icm.visnow.gui.icons.IconsContainer;
import pl.edu.icm.visnow.lib.utils.SwingInstancer;
import pl.edu.icm.visnow.system.main.VisNow;
/**
*
......@@ -858,7 +859,7 @@ public class RenderingGUI extends javax.swing.JPanel
private void toFrontBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_toFrontBoxActionPerformed
{//GEN-HEADEREND:event_toFrontBoxActionPerformed
renderingParams.setSurfaceOffset(toFrontBox.isSelected() ? -1000000 : 0);
renderingParams.setSurfaceOffset(toFrontBox.isSelected() ? -1000000 : VisNow.get().getMainConfig().getRenderingSurfaceOffset());
}//GEN-LAST:event_toFrontBoxActionPerformed
private void imageBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageBoxActionPerformed
......
......@@ -61,6 +61,7 @@ import pl.edu.icm.visnow.geometries.objects.generics.OpenBranchGroup;
import pl.edu.icm.visnow.geometries.objects.generics.OpenMaterial;
import pl.edu.icm.visnow.geometries.viewer3d.eventslisteners.render.RenderEvent;
import pl.edu.icm.visnow.geometries.viewer3d.eventslisteners.render.RenderEventListener;
import pl.edu.icm.visnow.system.main.VisNow;
/**
*
......@@ -96,7 +97,7 @@ public class RenderingParams
protected int shadingMode = GOURAUD_SHADED;
protected float minEdgeDihedral = 0;
protected byte surfaceOrientation = 1;
protected float surfaceOffset = 500;
protected OpenAppearance appearance = new OpenAppearance();
protected OpenMaterial material = (OpenMaterial) appearance.getMaterial();
protected OpenAppearance lineAppearance = new OpenAppearance();
......@@ -162,7 +163,7 @@ public class RenderingParams
boolean detach = detachUserData(appearance.getUserData());
if (appearance != null && appearance.getPolygonAttributes() != null) {
appearance.getPolygonAttributes().setCullFace(PolygonAttributes.CULL_NONE);
appearance.getPolygonAttributes().setPolygonOffset(surfaceOffset);
appearance.getPolygonAttributes().setPolygonOffset(VisNow.get().getMainConfig().getRenderingSurfaceOffset());
appearance.getPolygonAttributes().setBackFaceNormalFlip(false);
fireStateChanged(RenderEvent.GEOMETRY);
}
......@@ -815,7 +816,7 @@ public class RenderingParams
public float getSurfaceOffset()
{
return surfaceOffset;
return appearance.getPolygonAttributes().getPolygonOffset();
}
/**
......@@ -844,12 +845,10 @@ public class RenderingParams
if (change)
fireStateChanged(RenderEvent.GEOMETRY);
}
public void setSurfaceOffset(float offset)
{
boolean detach = detachUserData(appearance.getUserData());
surfaceOffset = offset;
if (appearance != null && appearance.getPolygonAttributes() != null) {
appearance.getPolygonAttributes().setPolygonOffset(offset);
fireStateChanged(RenderEvent.GEOMETRY);
......@@ -917,7 +916,7 @@ public class RenderingParams
res.add("shadingMode: " + shadingMode);
res.add("minEdgeDihedral: " + minEdgeDihedral);
res.add("surfaceOrientation: " + surfaceOrientation);
res.add("surfaceOffset: " + surfaceOffset);
res.add("surfaceOffset: " + getSurfaceOffset());
res.add("lightedBackground: " + lightedBackground);
if (material != null) {
Color3f specColor = new Color3f();
......@@ -965,7 +964,8 @@ public class RenderingParams
}
if (line.trim().startsWith("surfaceOffset:")) {
try {
surfaceOffset = Float.parseFloat(line.trim().split(" *:* +")[1]);
int surfaceOffset = (int) Float.parseFloat(line.trim().split(" *:* +")[1]);
setSurfaceOffset(surfaceOffset);
}catch (Exception e) {}
continue;
}
......
......@@ -1236,4 +1236,36 @@ public class MainConfig
{
setProperty("visnow.viewer3DWindowBounds", bounds);
}
/**
* Returns the global value of the visnow.rendering.surfaceOffset property.
* This value is used in surface rendering in 3D to slightly offset camera
* related depth position to properly render lines on a surface.
* Should be set to 0 if not using lines on surfaces and the offset causes artifacts.
*
* @return integer value of currently set visnow.rendering.surfaceOffset propoerty
*/
public int getRenderingSurfaceOffset()
{
try {
int k = Integer.parseInt(getProperty("visnow.rendering.surfaceOffset"));
return k;
} catch (NumberFormatException e) {
return 200;
}
}
/**
* Sets the global value of the visnow.rendering.surfaceOffset property.
* This value is used in surface rendering in 3D to slightly offset camera
* related depth position to properly render lines on a surface.
* Should be set to 0 if not using lines on surfaces and the offset causes artifacts.
*
* @param offset value of the surface offset (100-500 is recommended)
*/
public void setRenderingSurfaceOffset(int offset)
{
setProperty("visnow.rendering.surfaceOffset", "" + offset);
}
}
......@@ -196,6 +196,7 @@ public class MainConfigInitializer
props.setProperty("visnow.paths.data.use", "last"); //last/default/home
props.setProperty("visnow.continuousColorAdjustingLimit", "64000");
props.setProperty("visnow.rendering.surfaceOffset", "200");
try {
props.store(new FileOutputStream(file), null);
......
......@@ -66,6 +66,7 @@ import javax.swing.ToolTipManager;
import jcuda.driver.*;
import static jcuda.driver.CUdevice_attribute.*;
import static jcuda.driver.JCudaDriver.*;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
......@@ -97,7 +98,7 @@ public class VisNow {
public final static String TITLE = "VisNow";
public final static String VERSION = "1.3";
public final static String CONFIG_DIR = ".visnow";
public final static String CONFIG_VERSION = "0.75";
public final static String CONFIG_VERSION = "0.76";
public final static String PROJECT_NAME = "VisNow";
public static final String LOG_OUTPUT_DIR = "log"; //subdir of CONFIG_DIR, place for *.log files (has to be equal as path defined in log4j_*.properties)
private static final String LOG_CONFIG_TEMPLATES_DIR = "config_templates"; //directory of config templates which are copied to CONFIG_DIR
......@@ -826,6 +827,8 @@ public class VisNow {
try {
//create log output dir (has to be the same as one specified in log4j*.properties file)
makeConfigDir(LOG_OUTPUT_DIR, false);
//create versioned config dir
makeConfigDir(null, true);
//location of log config templates
File logConfigTemplatesDir = new File(findOperatingFolder() + File.separator + LOG_CONFIG_TEMPLATES_DIR);
//get config dir (place for log config templates)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment