Change "Shine" to a double in [0,1]

Add shine to OR import & export
This commit is contained in:
bkuker 2013-01-06 09:58:08 -05:00
parent cbb78cf095
commit c7ffc442a5
6 changed files with 20 additions and 14 deletions

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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"));

View File

@ -47,6 +47,7 @@ public class RocketComponentSaver {
elements.add("<appearance>");
Color paint = ap.getPaint();
emitColor("paint",elements,paint);
elements.add("<shine>" + ap.getShine() + "</shine>");
Decal decal = ap.getTexture();
if ( decal != null ) {
String name = decal.getImage();

View File

@ -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");

View File

@ -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);