Merge pull request #321 from ChrisMickelson/unstable
Alpha value for semi-transparent components saved/loaded and small bug fix
This commit is contained in:
commit
a59aadbf04
@ -51,7 +51,14 @@ class AppearanceHandler extends AbstractElementHandler {
|
||||
int red = Integer.parseInt(attributes.get("red"));
|
||||
int green = Integer.parseInt(attributes.get("green"));
|
||||
int blue = Integer.parseInt(attributes.get("blue"));
|
||||
builder.setPaint(new Color(red, green, blue));
|
||||
int alpha = 255;//set default
|
||||
// add a test if "alpha" was added to the XML / backwards compatibility
|
||||
String a = attributes.get("alpha");
|
||||
if (a != null){
|
||||
// "alpha" string was present so load the value
|
||||
alpha = Integer.parseInt(a);
|
||||
}
|
||||
builder.setPaint(new Color(red, green, blue, alpha));
|
||||
return;
|
||||
}
|
||||
if ("shine".equals(element)) {
|
||||
@ -96,4 +103,4 @@ class AppearanceHandler extends AbstractElementHandler {
|
||||
super.endHandler(element, attributes, content, warnings);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public class RocketComponentSaver {
|
||||
private final static void emitColor(String elementName, List<String> elements, Color color) {
|
||||
if (color != null) {
|
||||
elements.add("<" + elementName + " red=\"" + color.getRed() + "\" green=\"" + color.getGreen()
|
||||
+ "\" blue=\"" + color.getBlue() + "\"/>");
|
||||
+ "\" blue=\"" + color.getBlue() + "\" alpha=\"" + color.getAlpha() + "\"/>");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,8 +112,8 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);
|
||||
|
||||
|
||||
convertColor(a.getPaint(), color);//color now contains alpha value
|
||||
|
||||
convertColor(a.getPaint(), color);
|
||||
color[3] = alpha;//re-set to "alpha" so that Unfinished renderer will show interior parts.
|
||||
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_DIFFUSE, color, 0);
|
||||
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user