Initial tube & balsa default appearances
This commit is contained in:
parent
88e87d5925
commit
8dd0a6abc1
BIN
core/resources/datafiles/textures/balsa.png
Normal file
BIN
core/resources/datafiles/textures/balsa.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 553 KiB |
BIN
core/resources/datafiles/textures/spiral-wound-alpha.png
Normal file
BIN
core/resources/datafiles/textures/spiral-wound-alpha.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1023 B |
@ -16,13 +16,13 @@ public class Appearance {
|
|||||||
private final double shine;
|
private final double shine;
|
||||||
private final Decal texture;
|
private final Decal texture;
|
||||||
|
|
||||||
Appearance(final Color paint, final double shine, final Decal texture) {
|
public Appearance(final Color paint, final double shine, final Decal texture) {
|
||||||
this.paint = paint;
|
this.paint = paint;
|
||||||
this.shine = MathUtil.clamp(shine, 0, 1);
|
this.shine = MathUtil.clamp(shine, 0, 1);
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Appearance(final Color paint, final double shine) {
|
public Appearance(final Color paint, final double shine) {
|
||||||
this.paint = paint;
|
this.paint = paint;
|
||||||
this.shine = MathUtil.clamp(shine, 0, 1);
|
this.shine = MathUtil.clamp(shine, 0, 1);
|
||||||
this.texture = null;
|
this.texture = null;
|
||||||
|
@ -13,9 +13,11 @@ public class Decal {
|
|||||||
public static enum EdgeMode {
|
public static enum EdgeMode {
|
||||||
REPEAT("TextureWrap.Repeat"), MIRROR("TextureWrap.Mirror"), CLAMP("TextureWrap.Clamp"), STICKER("TextureWrap.Sticker");
|
REPEAT("TextureWrap.Repeat"), MIRROR("TextureWrap.Mirror"), CLAMP("TextureWrap.Clamp"), STICKER("TextureWrap.Sticker");
|
||||||
private final String transName;
|
private final String transName;
|
||||||
|
|
||||||
EdgeMode(final String name) {
|
EdgeMode(final String name) {
|
||||||
this.transName = name;
|
this.transName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Application.getTranslator().get(transName);
|
return Application.getTranslator().get(transName);
|
||||||
@ -27,7 +29,7 @@ public class Decal {
|
|||||||
private final DecalImage image;
|
private final DecalImage image;
|
||||||
private final EdgeMode mode;
|
private final EdgeMode mode;
|
||||||
|
|
||||||
Decal(final Coordinate offset, final Coordinate center, final Coordinate scale, final double rotation,
|
public Decal(final Coordinate offset, final Coordinate center, final Coordinate scale, final double rotation,
|
||||||
final DecalImage image, final EdgeMode mode) {
|
final DecalImage image, final EdgeMode mode) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.center = center;
|
this.center = center;
|
||||||
|
23
core/src/net/sf/openrocket/appearance/defaults/Balsa.java
Normal file
23
core/src/net/sf/openrocket/appearance/defaults/Balsa.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package net.sf.openrocket.appearance.defaults;
|
||||||
|
|
||||||
|
import net.sf.openrocket.appearance.Appearance;
|
||||||
|
import net.sf.openrocket.appearance.Decal;
|
||||||
|
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||||
|
import net.sf.openrocket.util.Color;
|
||||||
|
import net.sf.openrocket.util.Coordinate;
|
||||||
|
|
||||||
|
class Balsa extends Appearance {
|
||||||
|
public static final Balsa INSTANCE = new Balsa();
|
||||||
|
|
||||||
|
private Balsa() {
|
||||||
|
super(
|
||||||
|
new Color(1, 1, 1),
|
||||||
|
0,
|
||||||
|
new Decal(
|
||||||
|
new Coordinate(0, 0),
|
||||||
|
new Coordinate(0, 0),
|
||||||
|
new Coordinate(1, 1),
|
||||||
|
0,
|
||||||
|
new ResourceDecalImage("/datafiles/textures/balsa.png"), EdgeMode.REPEAT));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package net.sf.openrocket.appearance.defaults;
|
||||||
|
|
||||||
|
import net.sf.openrocket.appearance.Appearance;
|
||||||
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
|
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||||
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
|
||||||
|
public class DefaultAppearance {
|
||||||
|
public static Appearance getDefaultAppearance(RocketComponent c) {
|
||||||
|
if (c instanceof BodyTube)
|
||||||
|
return SpiralWound.ESTES_BT;
|
||||||
|
if (c instanceof FinSet)
|
||||||
|
return Balsa.INSTANCE;
|
||||||
|
if (c instanceof LaunchLug)
|
||||||
|
return SpiralWound.WHITE;
|
||||||
|
return Appearance.MISSING;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package net.sf.openrocket.appearance.defaults;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.sf.openrocket.appearance.DecalImage;
|
||||||
|
|
||||||
|
class ResourceDecalImage implements DecalImage {
|
||||||
|
final String resource;
|
||||||
|
|
||||||
|
ResourceDecalImage(final String resource) {
|
||||||
|
this.resource = resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getBytes() throws FileNotFoundException, IOException {
|
||||||
|
return this.getClass().getResourceAsStream(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportImage(File file, boolean watchForChanges) throws IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package net.sf.openrocket.appearance.defaults;
|
||||||
|
|
||||||
|
import net.sf.openrocket.appearance.Appearance;
|
||||||
|
import net.sf.openrocket.appearance.Decal;
|
||||||
|
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||||
|
import net.sf.openrocket.util.Color;
|
||||||
|
import net.sf.openrocket.util.Coordinate;
|
||||||
|
|
||||||
|
class SpiralWound extends Appearance {
|
||||||
|
|
||||||
|
public static final SpiralWound ESTES_BT = new SpiralWound(new Color(212, 185, 145), .3, 45);
|
||||||
|
public static final SpiralWound BLUE = new SpiralWound(new Color(212, 185, 145), .3, 45);
|
||||||
|
public static final SpiralWound WHITE = new SpiralWound(new Color(240, 240, 240), .3, 45);
|
||||||
|
|
||||||
|
public SpiralWound(Color paint, double shine, double angle) {
|
||||||
|
super(
|
||||||
|
paint,
|
||||||
|
shine,
|
||||||
|
new Decal(
|
||||||
|
new Coordinate(0, 0),
|
||||||
|
new Coordinate(0, 0),
|
||||||
|
new Coordinate(1, 1),
|
||||||
|
0,
|
||||||
|
new ResourceDecalImage("/datafiles/textures/spiral-wound-alpha.png"), EdgeMode.REPEAT));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,6 +14,7 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
|
|||||||
|
|
||||||
import net.sf.openrocket.appearance.Appearance;
|
import net.sf.openrocket.appearance.Appearance;
|
||||||
import net.sf.openrocket.appearance.Decal;
|
import net.sf.openrocket.appearance.Decal;
|
||||||
|
import net.sf.openrocket.appearance.defaults.DefaultAppearance;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.util.Color;
|
import net.sf.openrocket.util.Color;
|
||||||
@ -216,7 +217,7 @@ public class RealisticRenderer extends RocketRenderer {
|
|||||||
private Appearance getAppearance(RocketComponent c) {
|
private Appearance getAppearance(RocketComponent c) {
|
||||||
Appearance ret = c.getAppearance();
|
Appearance ret = c.getAppearance();
|
||||||
if (ret == null) {
|
if (ret == null) {
|
||||||
ret = Appearance.MISSING;
|
ret = DefaultAppearance.getDefaultAppearance(c);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user