From cbb78cf09584b39ce85798429633ff31b0098b84 Mon Sep 17 00:00:00 2001 From: bkuker Date: Thu, 3 Jan 2013 09:19:58 -0500 Subject: [PATCH 1/5] Simplified appearance. Is this really what we want? --- .../sf/openrocket/appearance/Appearance.java | 42 ++++------ .../appearance/AppearanceBuilder.java | 71 ++++++++--------- .../appearance/SimpleAppearanceBuilder.java | 77 ------------------- .../openrocket/importt/AppearanceHandler.java | 20 +---- .../savers/RocketComponentSaver.java | 8 +- .../importt/RockSimAppearanceBuilder.java | 42 +++------- .../gui/configdialog/AppearancePanel.java | 12 +-- .../gui/figure3d/RealisticRenderStrategy.java | 15 ++-- 8 files changed, 77 insertions(+), 210 deletions(-) delete mode 100644 core/src/net/sf/openrocket/appearance/SimpleAppearanceBuilder.java diff --git a/core/src/net/sf/openrocket/appearance/Appearance.java b/core/src/net/sf/openrocket/appearance/Appearance.java index 43ee54936..ddc190ffd 100644 --- a/core/src/net/sf/openrocket/appearance/Appearance.java +++ b/core/src/net/sf/openrocket/appearance/Appearance.java @@ -9,42 +9,30 @@ import net.sf.openrocket.util.Color; * @author Bill Kuker */ public class Appearance { - public static final Appearance MISSING = new Appearance(new Color(0,0,0), new Color(128,128,128), new Color(255,255,255), 100, null); + public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null); - private final Color ambient, diffuse, specular; - private final int shininess; + private final Color paint; + private final int shine; private final Decal texture; - Appearance(final Color ambient, final Color diffuse, final Color specular, final int shininess, final Decal texture){ - this.ambient = ambient; - this.diffuse = diffuse; - this.specular = specular; - this.shininess = shininess; + Appearance(final Color paint, final int shine, final Decal texture){ + this.paint = paint; + this.shine = shine; this.texture = texture; } - Appearance(final Color ambient, final Color diffuse, final Color specular, final int shininess){ - this.ambient = ambient; - this.diffuse = diffuse; - this.specular = specular; - this.shininess = shininess; + Appearance(final Color paint, final int shine){ + this.paint = paint; + this.shine = shine; this.texture = null; } - public Color getAmbient() { - return ambient; + public Color getPaint() { + return paint; } - public Color getDiffuse() { - return diffuse; - } - - public Color getSpecular() { - return specular; - } - - public int getShininess() { - return shininess; + public int getShine() { + return shine; } public Decal getTexture() { @@ -53,8 +41,8 @@ public class Appearance { @Override public String toString() { - return "Appearance [ambient=" + ambient + ", diffuse=" + diffuse + ", specular=" + specular + ", shininess=" - + shininess + ", texture=" + texture + "]"; + return "Appearance [paint=" + paint + ", shine=" + + shine + ", texture=" + texture + "]"; } } diff --git a/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java b/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java index cfb95f636..790b26800 100644 --- a/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java +++ b/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java @@ -18,8 +18,8 @@ import net.sf.openrocket.util.Coordinate; */ public class AppearanceBuilder extends AbstractChangeSource { - private Color ambient, diffuse, specular; - private int shininess; + private Color paint; + private int shine; private double offsetU, offsetV; private double centerU, centerV; private double scaleU, scaleV; @@ -36,15 +36,12 @@ public class AppearanceBuilder extends AbstractChangeSource { public AppearanceBuilder(Appearance a) { resetToDefaults(); if ( a != null ){ - setAmbient(a.getAmbient()); - setDiffuse(a.getDiffuse()); - setSpecular(a.getSpecular()); - setShininess(a.getShininess()); + setPaint(a.getPaint()); Decal d = a.getTexture(); if ( d != null ){ setOffset(d.getOffset().x, d.getOffset().y); setCenter(d.getCenter().x, d.getCenter().y); - setScale(d.getScale().x, d.getScale().y); + setScaleUV(d.getScale().x, d.getScale().y); setRotation(d.getRotation()); setEdgeMode(d.getEdgeMode()); setImage(d.getImage()); @@ -54,10 +51,8 @@ public class AppearanceBuilder extends AbstractChangeSource { } public void resetToDefaults() { - ambient = new Color(0, 0, 0); - diffuse = new Color(128, 128, 128); - specular = new Color(255, 255, 255); - shininess = 100; + paint = new Color(0, 0, 0); + shine = 0; offsetU = offsetV = 0; centerU = centerV = 0; scaleU = scaleV = 1; @@ -80,44 +75,26 @@ public class AppearanceBuilder extends AbstractChangeSource { edgeMode); } - return new Appearance( ambient, diffuse, specular, shininess, t); + return new Appearance( paint, shine, t); } - public Color getAmbient() { - return ambient; + public Color getPaint() { + return paint; } - public void setAmbient(Color ambient) { - this.ambient = ambient; + public void setPaint(Color paint) { + this.paint = paint; fireChangeEvent(); } - public Color getDiffuse() { - return diffuse; + public int getShine() { + return shine; } - public void setDiffuse(Color diffuse) { - this.diffuse = diffuse; - fireChangeEvent(); - } - - public Color getSpecular() { - return specular; - } - - public void setSpecular(Color specular) { - this.specular = specular; - fireChangeEvent(); - } - - public int getShininess() { - return shininess; - } - - public void setShininess(int shininess) { - this.shininess = shininess; + public void setShine(int shine) { + this.shine = shine; fireChangeEvent(); } @@ -185,10 +162,26 @@ public class AppearanceBuilder extends AbstractChangeSource { fireChangeEvent(); } - public void setScale(double u, double v) { + public void setScaleUV(double u, double v) { setScaleU(u); setScaleV(v); } + + public double getScaleX() { + return 1.0 / getScaleU(); + } + + public void setScaleX(double scaleU) { + setScaleU(1.0 / scaleU); + } + + public double getScaleY() { + return 1.0 / getScaleV(); + } + + public void setScaleY(double scaleV) { + setScaleV(1.0 / scaleV); + } public double getRotation() { return rotation; diff --git a/core/src/net/sf/openrocket/appearance/SimpleAppearanceBuilder.java b/core/src/net/sf/openrocket/appearance/SimpleAppearanceBuilder.java deleted file mode 100644 index 0575069d8..000000000 --- a/core/src/net/sf/openrocket/appearance/SimpleAppearanceBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.sf.openrocket.appearance; - -import net.sf.openrocket.util.Color; - -public class SimpleAppearanceBuilder extends AppearanceBuilder { - - public SimpleAppearanceBuilder() { - super(); - } - - public SimpleAppearanceBuilder(Appearance a) { - super(a); - } - - public Color getColor() { - return getDiffuse(); - } - - public void setColor(final Color c) { - batch(new Runnable() { - @Override - public void run() { - setAmbient(c); - setDiffuse(c); - } - }); - } - - public void setShine(final int s) { - batch(new Runnable() { - @Override - public void run() { - setShininess(s); - int c = (int) (s * 2.55); - setSpecular(new net.sf.openrocket.util.Color(c, c, c)); - } - }); - } - - public int getShine() { - return getShininess(); - } - - private Color oldColor = null; - - @Override - public void setImage(final String image) { - batch(new Runnable() { - @Override - public void run() { - if (getImage() == null && image != null) { - oldColor = getColor(); - setColor(new Color(255, 255, 255)); - } else if (getImage() != null && image == null && oldColor != null) { - setColor(oldColor); - } - SimpleAppearanceBuilder.super.setImage(image); - } - }); - } - - public double getScaleX() { - return 1.0 / super.getScaleU(); - } - - public void setScaleX(double scaleU) { - super.setScaleU(1.0 / scaleU); - } - - public double getScaleY() { - return 1.0 / super.getScaleV(); - } - - public void setScaleY(double scaleV) { - super.setScaleV(1.0 / scaleV); - } -} diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java index caaa561d3..7b7eaa494 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java @@ -42,25 +42,11 @@ class AppearanceHandler extends AbstractElementHandler { } @Override public void closeElement(String element,HashMap attributes, String content, WarningSet warnings) throws SAXException { - if ( "ambient".equals(element) ) { + if ( "paint".equals(element) ) { int red = Integer.parseInt(attributes.get("red")); int green = Integer.parseInt(attributes.get("green")); int blue = Integer.parseInt(attributes.get("blue")); - builder.setAmbient( new Color(red,green,blue)); - return; - } - if ( "diffuse".equals(element) ) { - int red = Integer.parseInt(attributes.get("red")); - int green = Integer.parseInt(attributes.get("green")); - int blue = Integer.parseInt(attributes.get("blue")); - builder.setDiffuse( new Color(red,green,blue)); - return; - } - if ( "specular".equals(element) ) { - int red = Integer.parseInt(attributes.get("red")); - int green = Integer.parseInt(attributes.get("green")); - int blue = Integer.parseInt(attributes.get("blue")); - builder.setSpecular( new Color(red,green,blue)); + builder.setPaint( new Color(red,green,blue)); return; } if ( isInDecal && "center".equals(element) ) { @@ -78,7 +64,7 @@ class AppearanceHandler extends AbstractElementHandler { if ( isInDecal && "scale".equals(element) ) { double x = Double.parseDouble(attributes.get("x")); double y = Double.parseDouble(attributes.get("y")); - builder.setScale(x,y); + builder.setScaleUV(x,y); return; } if( isInDecal && "decal".equals(element) ) { diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index 6429fe3da..db83b879a 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -45,12 +45,8 @@ public class RocketComponentSaver { Appearance ap = c.getAppearance(); if ( ap != null ) { elements.add(""); - Color ambient = ap.getAmbient(); - emitColor("ambient",elements,ambient); - Color diffuse = ap.getDiffuse(); - emitColor("diffuse",elements,diffuse); - Color specular = ap.getSpecular(); - emitColor("specular",elements,specular); + Color paint = ap.getPaint(); + emitColor("paint",elements,paint); Decal decal = ap.getTexture(); if ( decal != null ) { String name = decal.getImage(); diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java index 397e63750..abf584eeb 100644 --- a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java +++ b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java @@ -5,55 +5,35 @@ import java.io.FileNotFoundException; import java.net.MalformedURLException; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.appearance.Appearance; import net.sf.openrocket.appearance.AppearanceBuilder; import net.sf.openrocket.appearance.Decal.EdgeMode; import net.sf.openrocket.file.rocksim.RocksimCommonConstants; import net.sf.openrocket.util.Color; public class RockSimAppearanceBuilder extends AppearanceBuilder { - private double specularW = 1, ambientW = 1, diffuseW = 1; - private boolean oneColor; + boolean preventSeam = false; boolean repeat = false; - @Override - public Appearance getAppearance() { - if (oneColor) { - setDiffuse(weight(getDiffuse(), diffuseW)); - setAmbient(weight(getDiffuse(), diffuseW)); - setSpecular(weight(getDiffuse(), diffuseW)); - } else { - setDiffuse(weight(getDiffuse(), diffuseW)); - setAmbient(weight(getAmbient(), ambientW)); - setSpecular(weight(getSpecular(), specularW)); - } - - - - return super.getAppearance(); - } public void processElement(String element, String content, WarningSet warnings) { try { if (RocksimCommonConstants.TEXTURE.equals(element)) { parseTexture(content); } else if ("Ambient".equals(element)) { - ambientW = Double.parseDouble(content); + //ignored } else if ("Diffuse".equals(element)) { - diffuseW = Double.parseDouble(content); + //ignored } else if ("Specular".equals(element)) { - specularW = Double.parseDouble(content); + //ignored } else if ("AbientColor".equals(element)) { - setAmbient(parseColor(content)); + setPaint(parseColor(content)); } else if ("DiffuseColor".equals(element)) { - setDiffuse(parseColor(content)); + //ignored } else if ("SpecularColor".equals(element)) { - setSpecular(parseColor(content)); + //Ignored } else if ("UseSingleColor".equals(element) || "SimpleColorModel".equals(element) ) { - if ("1".equals(content)) { - oneColor = true; - } + //Ignored } } catch (Exception e) { warnings.add("Could not convert " + element + " value of " + content + ": " + e.getMessage()); @@ -104,7 +84,7 @@ public class RockSimAppearanceBuilder extends AppearanceBuilder { setCenter(Double.parseDouble(c[0]), Double.parseDouble(c[1])); } else if ("scale".equals(name)) { String[] c = value.split(","); - setScale(Double.parseDouble(c[0]), Double.parseDouble(c[1])); + setScaleUV(Double.parseDouble(c[0]), Double.parseDouble(c[1])); } } @@ -117,11 +97,11 @@ public class RockSimAppearanceBuilder extends AppearanceBuilder { } if ( !flips ){ - setScale(getScaleU(), getScaleV() * -1); + setScaleUV(getScaleU(), getScaleV() * -1); setOffset(getOffsetU(), -1 - getOffsetV()); } if ( !flipr ){ - setScale(getScaleU() * -1, getScaleV()); + setScaleUV(getScaleU() * -1, getScaleV()); setOffset(-1 - getOffsetU(), getOffsetV()); } diff --git a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java index ffc989835..c4cffbd69 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java +++ b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java @@ -22,7 +22,7 @@ import javax.swing.SwingUtilities; import net.miginfocom.swing.MigLayout; import net.sf.openrocket.appearance.Decal.EdgeMode; -import net.sf.openrocket.appearance.SimpleAppearanceBuilder; +import net.sf.openrocket.appearance.AppearanceBuilder; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.adaptors.BooleanModel; @@ -51,7 +51,7 @@ import net.sf.openrocket.util.StateChangeListener; public class AppearancePanel extends JPanel { private static final Translator trans = Application.getTranslator(); - private SimpleAppearanceBuilder ab; + private AppearanceBuilder ab; /** * A non-unit that adjusts by a small amount, suitable for @@ -117,7 +117,7 @@ public class AppearancePanel extends JPanel { public AppearancePanel(final OpenRocketDocument document, final RocketComponent c) { super(new MigLayout("fill", "[150][grow][150][grow]")); - ab = new SimpleAppearanceBuilder(c.getAppearance()); + ab = new AppearanceBuilder(c.getAppearance()); net.sf.openrocket.util.Color figureColor = c.getColor(); if (figureColor == null) { @@ -125,7 +125,7 @@ public class AppearancePanel extends JPanel { } final JButton figureColorButton = new JButton(new ColorIcon(figureColor)); - final JButton colorButton = new JButton(new ColorIcon(ab.getColor())); + final JButton colorButton = new JButton(new ColorIcon(ab.getPaint())); final JComboBox textureDropDown = new JComboBox( new DecalModel(this,document,ab));; @@ -133,7 +133,7 @@ public class AppearancePanel extends JPanel { @Override public void stateChanged(EventObject e) { figureColorButton.setIcon(new ColorIcon(c.getColor())); - colorButton.setIcon(new ColorIcon(ab.getColor())); + colorButton.setIcon(new ColorIcon(ab.getPaint())); c.setAppearance(ab.getAppearance()); } }); @@ -150,7 +150,7 @@ public class AppearancePanel extends JPanel { }); figureColorButton.addActionListener(new ColorActionListener(c, "Color")); - colorButton.addActionListener(new ColorActionListener(ab, "Color")); + colorButton.addActionListener(new ColorActionListener(ab, "Paint")); BooleanModel fDefault = new BooleanModel(c.getColor() == null); diff --git a/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java b/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java index 02652288a..3b110bb55 100644 --- a/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java +++ b/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java @@ -108,20 +108,21 @@ public class RealisticRenderStrategy extends RenderStrategy { gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL,GL2.GL_SEPARATE_SPECULAR_COLOR); - convertColor(a.getDiffuse(), color); - color[3] = alpha; + if ( a.getTexture() != null ){ + color[0] = color[1] = color[2] = 1; + } else { + convertColor(a.getPaint(), color); + color[3] = alpha; + } gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_DIFFUSE, color, 0); gl.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_DIFFUSE, color, 0); - - convertColor(a.getAmbient(), color); - color[3] = alpha; gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0); gl.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_AMBIENT, color, 0); - convertColor(a.getSpecular(), color); + color[0] = color[1] = color[2] = (int)(a.getShine()*2.55); color[3] = alpha; gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, color, 0); - gl.glMateriali(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, a.getShininess()); + gl.glMateriali(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, a.getShine()); gl.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_SPECULAR, colorBlack, 0); gl.glMateriali(GL.GL_BACK, GLLightingFunc.GL_SHININESS, 0); From c7ffc442a5ba86c542644d0d6a51d036061806fb Mon Sep 17 00:00:00 2001 From: bkuker Date: Sun, 6 Jan 2013 09:58:08 -0500 Subject: [PATCH 2/5] Change "Shine" to a double in [0,1] Add shine to OR import & export --- core/src/net/sf/openrocket/appearance/Appearance.java | 8 ++++---- .../net/sf/openrocket/appearance/AppearanceBuilder.java | 8 ++++---- .../file/openrocket/importt/AppearanceHandler.java | 5 +++++ .../file/openrocket/savers/RocketComponentSaver.java | 1 + .../sf/openrocket/gui/configdialog/AppearancePanel.java | 8 ++++---- .../openrocket/gui/figure3d/RealisticRenderStrategy.java | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/core/src/net/sf/openrocket/appearance/Appearance.java b/core/src/net/sf/openrocket/appearance/Appearance.java index ddc190ffd..365c81037 100644 --- a/core/src/net/sf/openrocket/appearance/Appearance.java +++ b/core/src/net/sf/openrocket/appearance/Appearance.java @@ -12,16 +12,16 @@ public class Appearance { public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null); private final Color paint; - private final int shine; + private final double shine; private final Decal texture; - Appearance(final Color paint, final int shine, final Decal texture){ + Appearance(final Color paint, final double shine, final Decal texture){ this.paint = paint; this.shine = shine; this.texture = texture; } - Appearance(final Color paint, final int shine){ + Appearance(final Color paint, final double shine){ this.paint = paint; this.shine = shine; this.texture = null; @@ -31,7 +31,7 @@ public class Appearance { return paint; } - public int getShine() { + public double getShine() { return shine; } diff --git a/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java b/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java index 790b26800..2fdea33d9 100644 --- a/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java +++ b/core/src/net/sf/openrocket/appearance/AppearanceBuilder.java @@ -19,7 +19,7 @@ import net.sf.openrocket.util.Coordinate; public class AppearanceBuilder extends AbstractChangeSource { private Color paint; - private int shine; + private double shine; private double offsetU, offsetV; private double centerU, centerV; private double scaleU, scaleV; @@ -37,6 +37,7 @@ public class AppearanceBuilder extends AbstractChangeSource { resetToDefaults(); if ( a != null ){ setPaint(a.getPaint()); + setShine(a.getShine()); Decal d = a.getTexture(); if ( d != null ){ setOffset(d.getOffset().x, d.getOffset().y); @@ -46,7 +47,6 @@ public class AppearanceBuilder extends AbstractChangeSource { setEdgeMode(d.getEdgeMode()); setImage(d.getImage()); } - // TODO Critical the rest of this! } } @@ -89,11 +89,11 @@ public class AppearanceBuilder extends AbstractChangeSource { fireChangeEvent(); } - public int getShine() { + public double getShine() { return shine; } - public void setShine(int shine) { + public void setShine(double shine) { this.shine = shine; fireChangeEvent(); } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java index 7b7eaa494..ae25b8dc2 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/AppearanceHandler.java @@ -49,6 +49,11 @@ class AppearanceHandler extends AbstractElementHandler { builder.setPaint( new Color(red,green,blue)); return; } + if ( "shine".equals(element) ){ + double shine = Double.parseDouble(content); + builder.setShine(shine); + return; + } if ( isInDecal && "center".equals(element) ) { double x = Double.parseDouble(attributes.get("x")); double y = Double.parseDouble(attributes.get("y")); diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index db83b879a..56405a4ed 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -47,6 +47,7 @@ public class RocketComponentSaver { elements.add(""); Color paint = ap.getPaint(); emitColor("paint",elements,paint); + elements.add("" + ap.getShine() + ""); Decal decal = ap.getTexture(); if ( decal != null ) { String name = decal.getImage(); diff --git a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java index c4cffbd69..ab56e91df 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java +++ b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java @@ -21,15 +21,14 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import net.miginfocom.swing.MigLayout; -import net.sf.openrocket.appearance.Decal.EdgeMode; import net.sf.openrocket.appearance.AppearanceBuilder; +import net.sf.openrocket.appearance.Decal.EdgeMode; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.adaptors.BooleanModel; import net.sf.openrocket.gui.adaptors.DecalModel; import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.adaptors.EnumModel; -import net.sf.openrocket.gui.adaptors.IntegerModel; import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.ColorIcon; import net.sf.openrocket.gui.components.StyledLabel; @@ -276,9 +275,10 @@ public class AppearancePanel extends JPanel { {// Shine add(new JLabel(trans.get("AppearanceCfg.lbl.shine"))); - IntegerModel shineModel = new IntegerModel(ab, "Shine", 0, 100); + DoubleModel shineModel = new DoubleModel(ab, "Shine", 0, 1); JSpinner spin = new JSpinner(shineModel.getSpinnerModel()); - JSlider slide = new JSlider(shineModel.getSliderModel()); + spin.setEditor(new SpinnerEditor(spin)); + JSlider slide = new JSlider(shineModel.getSliderModel(0, 1)); add(spin, "split 2, w 50"); add(slide, "w 50"); diff --git a/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java b/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java index 3b110bb55..5be92c5e2 100644 --- a/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java +++ b/core/src/net/sf/openrocket/gui/figure3d/RealisticRenderStrategy.java @@ -119,10 +119,10 @@ public class RealisticRenderStrategy extends RenderStrategy { gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0); gl.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_AMBIENT, color, 0); - color[0] = color[1] = color[2] = (int)(a.getShine()*2.55); + color[0] = color[1] = color[2] = (float)a.getShine(); color[3] = alpha; gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, color, 0); - gl.glMateriali(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, a.getShine()); + gl.glMateriali(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, (int)(100 * a.getShine())); gl.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_SPECULAR, colorBlack, 0); gl.glMateriali(GL.GL_BACK, GLLightingFunc.GL_SHININESS, 0); From ab9dde913cce5cad9e53be832700eb87b05f6ccd Mon Sep 17 00:00:00 2001 From: bkuker Date: Sun, 6 Jan 2013 09:58:43 -0500 Subject: [PATCH 3/5] Update Apocalypse to use Shine & Paint --- .../examples/Apocalypse with decals.ork | Bin 239248 -> 239202 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/core/resources/datafiles/examples/Apocalypse with decals.ork b/core/resources/datafiles/examples/Apocalypse with decals.ork index 9150c47d87c292bf7279c70cf790a878a16c04cb..0b215d31a309142f5a3514c1e52daa503e267e97 100644 GIT binary patch delta 2707 zcmZvec{mj88pg*AhU`nS%aT1~tRW^umO+LrStiRg$X?cop&|PkW6h|@nte~QW#1*s z7+c9_3yBc=e4TT?^L3r`KL0$=_1@2YU+*99b^Q_t>6ZrR*>CED$XNkYXLZ|9SOf6) zNn+>6T3IC!>zIRw%NdW8_w7*0O_9w@R+TCTRLCr z-@cUc18F%Y1F3L_$iYyyL*vAEgjO$euRG7Ng2f+0NRSU6a&EV%qY2xL7;xP_^B2r0 zw0FwIQo*z)#m(|uNA+=f#a`PFHs0tC7bVwVlbyTox>h2>x+RCI^=xZC&&A6d4LTvO zJ79B@JMH+L*(-2qsCy{bJd<+o$8 zha+%U0CLT64g|sjE1*9_wCC-HhD?A4J{j zA4Io@)#V!3($OhTJ@!i9oSY8befakFhXlz32C_&{lsQr%AJPn8+Pd!seh=3oeeS6zgYKrC3p!7BG zFLQSF;PqFY5C0Cg$o5Z^7OGGOQ?f7zTkiU}37SuRF1iq=rF3PW0;9Irzuz1Qyy?^L zfp{d5!DJvt6em|w;Ly>#HU2`sMkrrgWjlP8GHx)N`DmnSqauI4d9e)&Q9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1GR@@WtlJGw2`NCt>+CMr)2YVZu zAQQYI9_nFDZy8n#@qw=D4aV`*->_cM47L?#@|@ksCJJ8DUxjL~1m)!;lr9;-CdsBE zcCz?#r?l{*k2F4|ZiCMJEi`gjL<^PGMW$?%&$K&+fN%VgZ0sGwoE;ovG{c%b9yxg~ zrSKdd$&Cf)62KvP-GpTBmF^=LWN4JgqeJt?kKaS2OeU_xY*%w@eIAxA;ChHHHvgf5(|#OV^vCL&ySJh&hyz)OFW3@HaPc*x2p4kv3|%a~6Z0Wt zC2D8?uJhM}u6G@ylg@jsXyvF>qmpE~nDP>Z?96HjkyMhf+Xf5UT^>i|?KB^GMEwI_|^aC*>~n|6F;;U zTIt_haKaT3gzhUW Date: Sun, 6 Jan 2013 10:32:56 -0500 Subject: [PATCH 4/5] Display shine on 0-100 scale --- .../src/net/sf/openrocket/gui/configdialog/AppearancePanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java index ab56e91df..554d49b9e 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java +++ b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java @@ -275,7 +275,7 @@ public class AppearancePanel extends JPanel { {// Shine add(new JLabel(trans.get("AppearanceCfg.lbl.shine"))); - DoubleModel shineModel = new DoubleModel(ab, "Shine", 0, 1); + DoubleModel shineModel = new DoubleModel(ab, "Shine", UnitGroup.UNITS_RELATIVE); JSpinner spin = new JSpinner(shineModel.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); JSlider slide = new JSlider(shineModel.getSliderModel(0, 1)); From 26e38f80dc8bcd42dfa1ce87918b14c2d163de4d Mon Sep 17 00:00:00 2001 From: bkuker Date: Sun, 6 Jan 2013 10:37:42 -0500 Subject: [PATCH 5/5] Add percent / permille unit selector to shine --- .../net/sf/openrocket/gui/configdialog/AppearancePanel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java index 554d49b9e..5cb71a5bc 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java +++ b/core/src/net/sf/openrocket/gui/configdialog/AppearancePanel.java @@ -279,8 +279,10 @@ public class AppearancePanel extends JPanel { JSpinner spin = new JSpinner(shineModel.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); JSlider slide = new JSlider(shineModel.getSliderModel(0, 1)); + UnitSelector unit = new UnitSelector(shineModel); - add(spin, "split 2, w 50"); + add(spin, "split 3, w 50"); + add(unit, "growx"); add(slide, "w 50"); }