Simplified appearance. Is this really what we want?
This commit is contained in:
parent
98db1885c2
commit
cbb78cf095
@ -9,42 +9,30 @@ import net.sf.openrocket.util.Color;
|
|||||||
* @author Bill Kuker <bkuker@billkuker.com>
|
* @author Bill Kuker <bkuker@billkuker.com>
|
||||||
*/
|
*/
|
||||||
public class Appearance {
|
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 Color paint;
|
||||||
private final int shininess;
|
private final int shine;
|
||||||
private final Decal texture;
|
private final Decal texture;
|
||||||
|
|
||||||
Appearance(final Color ambient, final Color diffuse, final Color specular, final int shininess, final Decal texture){
|
Appearance(final Color paint, final int shine, final Decal texture){
|
||||||
this.ambient = ambient;
|
this.paint = paint;
|
||||||
this.diffuse = diffuse;
|
this.shine = shine;
|
||||||
this.specular = specular;
|
|
||||||
this.shininess = shininess;
|
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Appearance(final Color ambient, final Color diffuse, final Color specular, final int shininess){
|
Appearance(final Color paint, final int shine){
|
||||||
this.ambient = ambient;
|
this.paint = paint;
|
||||||
this.diffuse = diffuse;
|
this.shine = shine;
|
||||||
this.specular = specular;
|
|
||||||
this.shininess = shininess;
|
|
||||||
this.texture = null;
|
this.texture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getAmbient() {
|
public Color getPaint() {
|
||||||
return ambient;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getDiffuse() {
|
public int getShine() {
|
||||||
return diffuse;
|
return shine;
|
||||||
}
|
|
||||||
|
|
||||||
public Color getSpecular() {
|
|
||||||
return specular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getShininess() {
|
|
||||||
return shininess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decal getTexture() {
|
public Decal getTexture() {
|
||||||
@ -53,8 +41,8 @@ public class Appearance {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Appearance [ambient=" + ambient + ", diffuse=" + diffuse + ", specular=" + specular + ", shininess="
|
return "Appearance [paint=" + paint + ", shine="
|
||||||
+ shininess + ", texture=" + texture + "]";
|
+ shine + ", texture=" + texture + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ import net.sf.openrocket.util.Coordinate;
|
|||||||
*/
|
*/
|
||||||
public class AppearanceBuilder extends AbstractChangeSource {
|
public class AppearanceBuilder extends AbstractChangeSource {
|
||||||
|
|
||||||
private Color ambient, diffuse, specular;
|
private Color paint;
|
||||||
private int shininess;
|
private int 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;
|
||||||
@ -36,15 +36,12 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
public AppearanceBuilder(Appearance a) {
|
public AppearanceBuilder(Appearance a) {
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
if ( a != null ){
|
if ( a != null ){
|
||||||
setAmbient(a.getAmbient());
|
setPaint(a.getPaint());
|
||||||
setDiffuse(a.getDiffuse());
|
|
||||||
setSpecular(a.getSpecular());
|
|
||||||
setShininess(a.getShininess());
|
|
||||||
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);
|
||||||
setCenter(d.getCenter().x, d.getCenter().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());
|
setRotation(d.getRotation());
|
||||||
setEdgeMode(d.getEdgeMode());
|
setEdgeMode(d.getEdgeMode());
|
||||||
setImage(d.getImage());
|
setImage(d.getImage());
|
||||||
@ -54,10 +51,8 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetToDefaults() {
|
public void resetToDefaults() {
|
||||||
ambient = new Color(0, 0, 0);
|
paint = new Color(0, 0, 0);
|
||||||
diffuse = new Color(128, 128, 128);
|
shine = 0;
|
||||||
specular = new Color(255, 255, 255);
|
|
||||||
shininess = 100;
|
|
||||||
offsetU = offsetV = 0;
|
offsetU = offsetV = 0;
|
||||||
centerU = centerV = 0;
|
centerU = centerV = 0;
|
||||||
scaleU = scaleV = 1;
|
scaleU = scaleV = 1;
|
||||||
@ -80,44 +75,26 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
edgeMode);
|
edgeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Appearance( ambient, diffuse, specular, shininess, t);
|
return new Appearance( paint, shine, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Color getAmbient() {
|
public Color getPaint() {
|
||||||
return ambient;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAmbient(Color ambient) {
|
public void setPaint(Color paint) {
|
||||||
this.ambient = ambient;
|
this.paint = paint;
|
||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getDiffuse() {
|
public int getShine() {
|
||||||
return diffuse;
|
return shine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiffuse(Color diffuse) {
|
public void setShine(int shine) {
|
||||||
this.diffuse = diffuse;
|
this.shine = shine;
|
||||||
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;
|
|
||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +162,26 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
|||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(double u, double v) {
|
public void setScaleUV(double u, double v) {
|
||||||
setScaleU(u);
|
setScaleU(u);
|
||||||
setScaleV(v);
|
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() {
|
public double getRotation() {
|
||||||
return rotation;
|
return rotation;
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,25 +42,11 @@ class AppearanceHandler extends AbstractElementHandler {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void closeElement(String element,HashMap<String, String> attributes, String content, WarningSet warnings) throws SAXException {
|
public void closeElement(String element,HashMap<String, String> attributes, String content, WarningSet warnings) throws SAXException {
|
||||||
if ( "ambient".equals(element) ) {
|
if ( "paint".equals(element) ) {
|
||||||
int red = Integer.parseInt(attributes.get("red"));
|
int red = Integer.parseInt(attributes.get("red"));
|
||||||
int green = Integer.parseInt(attributes.get("green"));
|
int green = Integer.parseInt(attributes.get("green"));
|
||||||
int blue = Integer.parseInt(attributes.get("blue"));
|
int blue = Integer.parseInt(attributes.get("blue"));
|
||||||
builder.setAmbient( new Color(red,green,blue));
|
builder.setPaint( 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));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( isInDecal && "center".equals(element) ) {
|
if ( isInDecal && "center".equals(element) ) {
|
||||||
@ -78,7 +64,7 @@ class AppearanceHandler extends AbstractElementHandler {
|
|||||||
if ( isInDecal && "scale".equals(element) ) {
|
if ( isInDecal && "scale".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"));
|
||||||
builder.setScale(x,y);
|
builder.setScaleUV(x,y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( isInDecal && "decal".equals(element) ) {
|
if( isInDecal && "decal".equals(element) ) {
|
||||||
|
@ -45,12 +45,8 @@ public class RocketComponentSaver {
|
|||||||
Appearance ap = c.getAppearance();
|
Appearance ap = c.getAppearance();
|
||||||
if ( ap != null ) {
|
if ( ap != null ) {
|
||||||
elements.add("<appearance>");
|
elements.add("<appearance>");
|
||||||
Color ambient = ap.getAmbient();
|
Color paint = ap.getPaint();
|
||||||
emitColor("ambient",elements,ambient);
|
emitColor("paint",elements,paint);
|
||||||
Color diffuse = ap.getDiffuse();
|
|
||||||
emitColor("diffuse",elements,diffuse);
|
|
||||||
Color specular = ap.getSpecular();
|
|
||||||
emitColor("specular",elements,specular);
|
|
||||||
Decal decal = ap.getTexture();
|
Decal decal = ap.getTexture();
|
||||||
if ( decal != null ) {
|
if ( decal != null ) {
|
||||||
String name = decal.getImage();
|
String name = decal.getImage();
|
||||||
|
@ -5,55 +5,35 @@ import java.io.FileNotFoundException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||||
import net.sf.openrocket.appearance.Appearance;
|
|
||||||
import net.sf.openrocket.appearance.AppearanceBuilder;
|
import net.sf.openrocket.appearance.AppearanceBuilder;
|
||||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||||
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
|
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
|
||||||
import net.sf.openrocket.util.Color;
|
import net.sf.openrocket.util.Color;
|
||||||
|
|
||||||
public class RockSimAppearanceBuilder extends AppearanceBuilder {
|
public class RockSimAppearanceBuilder extends AppearanceBuilder {
|
||||||
private double specularW = 1, ambientW = 1, diffuseW = 1;
|
|
||||||
private boolean oneColor;
|
|
||||||
boolean preventSeam = false;
|
boolean preventSeam = false;
|
||||||
boolean repeat = 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) {
|
public void processElement(String element, String content, WarningSet warnings) {
|
||||||
try {
|
try {
|
||||||
if (RocksimCommonConstants.TEXTURE.equals(element)) {
|
if (RocksimCommonConstants.TEXTURE.equals(element)) {
|
||||||
parseTexture(content);
|
parseTexture(content);
|
||||||
} else if ("Ambient".equals(element)) {
|
} else if ("Ambient".equals(element)) {
|
||||||
ambientW = Double.parseDouble(content);
|
//ignored
|
||||||
} else if ("Diffuse".equals(element)) {
|
} else if ("Diffuse".equals(element)) {
|
||||||
diffuseW = Double.parseDouble(content);
|
//ignored
|
||||||
} else if ("Specular".equals(element)) {
|
} else if ("Specular".equals(element)) {
|
||||||
specularW = Double.parseDouble(content);
|
//ignored
|
||||||
} else if ("AbientColor".equals(element)) {
|
} else if ("AbientColor".equals(element)) {
|
||||||
setAmbient(parseColor(content));
|
setPaint(parseColor(content));
|
||||||
} else if ("DiffuseColor".equals(element)) {
|
} else if ("DiffuseColor".equals(element)) {
|
||||||
setDiffuse(parseColor(content));
|
//ignored
|
||||||
} else if ("SpecularColor".equals(element)) {
|
} else if ("SpecularColor".equals(element)) {
|
||||||
setSpecular(parseColor(content));
|
//Ignored
|
||||||
} else if ("UseSingleColor".equals(element) || "SimpleColorModel".equals(element) ) {
|
} else if ("UseSingleColor".equals(element) || "SimpleColorModel".equals(element) ) {
|
||||||
if ("1".equals(content)) {
|
//Ignored
|
||||||
oneColor = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
warnings.add("Could not convert " + element + " value of " + content + ": " + e.getMessage());
|
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]));
|
setCenter(Double.parseDouble(c[0]), Double.parseDouble(c[1]));
|
||||||
} else if ("scale".equals(name)) {
|
} else if ("scale".equals(name)) {
|
||||||
String[] c = value.split(",");
|
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 ){
|
if ( !flips ){
|
||||||
setScale(getScaleU(), getScaleV() * -1);
|
setScaleUV(getScaleU(), getScaleV() * -1);
|
||||||
setOffset(getOffsetU(), -1 - getOffsetV());
|
setOffset(getOffsetU(), -1 - getOffsetV());
|
||||||
}
|
}
|
||||||
if ( !flipr ){
|
if ( !flipr ){
|
||||||
setScale(getScaleU() * -1, getScaleV());
|
setScaleUV(getScaleU() * -1, getScaleV());
|
||||||
setOffset(-1 - getOffsetU(), getOffsetV());
|
setOffset(-1 - getOffsetU(), getOffsetV());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ 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.Decal.EdgeMode;
|
||||||
import net.sf.openrocket.appearance.SimpleAppearanceBuilder;
|
import net.sf.openrocket.appearance.AppearanceBuilder;
|
||||||
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;
|
||||||
@ -51,7 +51,7 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
public class AppearancePanel extends JPanel {
|
public class AppearancePanel extends JPanel {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private SimpleAppearanceBuilder ab;
|
private AppearanceBuilder ab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A non-unit that adjusts by a small amount, suitable for
|
* 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) {
|
public AppearancePanel(final OpenRocketDocument document, final RocketComponent c) {
|
||||||
super(new MigLayout("fill", "[150][grow][150][grow]"));
|
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();
|
net.sf.openrocket.util.Color figureColor = c.getColor();
|
||||||
if (figureColor == null) {
|
if (figureColor == null) {
|
||||||
@ -125,7 +125,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
final JButton figureColorButton = new JButton(new ColorIcon(figureColor));
|
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));;
|
final JComboBox textureDropDown = new JComboBox( new DecalModel(this,document,ab));;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void stateChanged(EventObject e) {
|
public void stateChanged(EventObject e) {
|
||||||
figureColorButton.setIcon(new ColorIcon(c.getColor()));
|
figureColorButton.setIcon(new ColorIcon(c.getColor()));
|
||||||
colorButton.setIcon(new ColorIcon(ab.getColor()));
|
colorButton.setIcon(new ColorIcon(ab.getPaint()));
|
||||||
c.setAppearance(ab.getAppearance());
|
c.setAppearance(ab.getAppearance());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -150,7 +150,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
figureColorButton.addActionListener(new ColorActionListener(c, "Color"));
|
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);
|
BooleanModel fDefault = new BooleanModel(c.getColor() == null);
|
||||||
|
|
||||||
|
@ -108,20 +108,21 @@ public class RealisticRenderStrategy extends RenderStrategy {
|
|||||||
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL,GL2.GL_SEPARATE_SPECULAR_COLOR);
|
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL,GL2.GL_SEPARATE_SPECULAR_COLOR);
|
||||||
|
|
||||||
|
|
||||||
convertColor(a.getDiffuse(), color);
|
if ( a.getTexture() != null ){
|
||||||
color[3] = alpha;
|
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_FRONT, GLLightingFunc.GL_DIFFUSE, color, 0);
|
||||||
gl.glMaterialfv(GL.GL_BACK, 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_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);
|
||||||
|
|
||||||
convertColor(a.getSpecular(), color);
|
color[0] = color[1] = color[2] = (int)(a.getShine()*2.55);
|
||||||
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.getShininess());
|
gl.glMateriali(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 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