Change "Shine" to a double in [0,1]
Add shine to OR import & export
This commit is contained in:
parent
cbb78cf095
commit
c7ffc442a5
@ -12,16 +12,16 @@ public class Appearance {
|
|||||||
public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null);
|
public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null);
|
||||||
|
|
||||||
private final Color paint;
|
private final Color paint;
|
||||||
private final int shine;
|
private final double shine;
|
||||||
private final Decal texture;
|
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.paint = paint;
|
||||||
this.shine = shine;
|
this.shine = shine;
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Appearance(final Color paint, final int shine){
|
Appearance(final Color paint, final double shine){
|
||||||
this.paint = paint;
|
this.paint = paint;
|
||||||
this.shine = shine;
|
this.shine = shine;
|
||||||
this.texture = null;
|
this.texture = null;
|
||||||
@ -31,7 +31,7 @@ public class Appearance {
|
|||||||
return paint;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getShine() {
|
public double getShine() {
|
||||||
return shine;
|
return shine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import net.sf.openrocket.util.Coordinate;
|
|||||||
public class AppearanceBuilder extends AbstractChangeSource {
|
public class AppearanceBuilder extends AbstractChangeSource {
|
||||||
|
|
||||||
private Color paint;
|
private Color paint;
|
||||||
private int shine;
|
private double shine;
|
||||||
private double offsetU, offsetV;
|
private double offsetU, offsetV;
|
||||||
private double centerU, centerV;
|
private double centerU, centerV;
|
||||||
private double scaleU, scaleV;
|
private double scaleU, scaleV;
|
||||||
@ -37,6 +37,7 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
if ( a != null ){
|
if ( a != null ){
|
||||||
setPaint(a.getPaint());
|
setPaint(a.getPaint());
|
||||||
|
setShine(a.getShine());
|
||||||
Decal d = a.getTexture();
|
Decal d = a.getTexture();
|
||||||
if ( d != null ){
|
if ( d != null ){
|
||||||
setOffset(d.getOffset().x, d.getOffset().y);
|
setOffset(d.getOffset().x, d.getOffset().y);
|
||||||
@ -46,7 +47,6 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
setEdgeMode(d.getEdgeMode());
|
setEdgeMode(d.getEdgeMode());
|
||||||
setImage(d.getImage());
|
setImage(d.getImage());
|
||||||
}
|
}
|
||||||
// TODO Critical the rest of this!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getShine() {
|
public double getShine() {
|
||||||
return shine;
|
return shine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShine(int shine) {
|
public void setShine(double shine) {
|
||||||
this.shine = shine;
|
this.shine = shine;
|
||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,11 @@ class AppearanceHandler extends AbstractElementHandler {
|
|||||||
builder.setPaint( new Color(red,green,blue));
|
builder.setPaint( new Color(red,green,blue));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( "shine".equals(element) ){
|
||||||
|
double shine = Double.parseDouble(content);
|
||||||
|
builder.setShine(shine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( isInDecal && "center".equals(element) ) {
|
if ( isInDecal && "center".equals(element) ) {
|
||||||
double x = Double.parseDouble(attributes.get("x"));
|
double x = Double.parseDouble(attributes.get("x"));
|
||||||
double y = Double.parseDouble(attributes.get("y"));
|
double y = Double.parseDouble(attributes.get("y"));
|
||||||
|
@ -47,6 +47,7 @@ public class RocketComponentSaver {
|
|||||||
elements.add("<appearance>");
|
elements.add("<appearance>");
|
||||||
Color paint = ap.getPaint();
|
Color paint = ap.getPaint();
|
||||||
emitColor("paint",elements,paint);
|
emitColor("paint",elements,paint);
|
||||||
|
elements.add("<shine>" + ap.getShine() + "</shine>");
|
||||||
Decal decal = ap.getTexture();
|
Decal decal = ap.getTexture();
|
||||||
if ( decal != null ) {
|
if ( decal != null ) {
|
||||||
String name = decal.getImage();
|
String name = decal.getImage();
|
||||||
|
@ -21,15 +21,14 @@ import javax.swing.SwingConstants;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
|
||||||
import net.sf.openrocket.appearance.AppearanceBuilder;
|
import net.sf.openrocket.appearance.AppearanceBuilder;
|
||||||
|
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.gui.SpinnerEditor;
|
import net.sf.openrocket.gui.SpinnerEditor;
|
||||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||||
import net.sf.openrocket.gui.adaptors.DecalModel;
|
import net.sf.openrocket.gui.adaptors.DecalModel;
|
||||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||||
import net.sf.openrocket.gui.adaptors.EnumModel;
|
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.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.ColorIcon;
|
import net.sf.openrocket.gui.components.ColorIcon;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
@ -276,9 +275,10 @@ public class AppearancePanel extends JPanel {
|
|||||||
|
|
||||||
{// Shine
|
{// Shine
|
||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.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());
|
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(spin, "split 2, w 50");
|
||||||
add(slide, "w 50");
|
add(slide, "w 50");
|
||||||
|
@ -119,10 +119,10 @@ public class RealisticRenderStrategy extends RenderStrategy {
|
|||||||
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0);
|
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0);
|
||||||
gl.glMaterialfv(GL.GL_BACK, 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;
|
color[3] = alpha;
|
||||||
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, color, 0);
|
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.glMaterialfv(GL.GL_BACK, GLLightingFunc.GL_SPECULAR, colorBlack, 0);
|
||||||
gl.glMateriali(GL.GL_BACK, GLLightingFunc.GL_SHININESS, 0);
|
gl.glMateriali(GL.GL_BACK, GLLightingFunc.GL_SHININESS, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user