Add spark concentration & weight options
Weight does not work great, lines are not the right thing to use.
This commit is contained in:
parent
c83b16b385
commit
ba037a1b2c
@ -34,6 +34,9 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
private double exhaustScale = 1.0;
|
||||
private double flameAspectRatio = 1.0;
|
||||
|
||||
private double sparkConcentration;
|
||||
private double sparkWeight;
|
||||
|
||||
private Sky sky = Mountains.instance;
|
||||
|
||||
public double getRoll() {
|
||||
@ -250,4 +253,22 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
this.sky = sky;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public double getSparkConcentration() {
|
||||
return sparkConcentration;
|
||||
}
|
||||
|
||||
public void setSparkConcentration(double sparkConcentration) {
|
||||
this.sparkConcentration = sparkConcentration;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public double getSparkWeight() {
|
||||
return sparkWeight;
|
||||
}
|
||||
|
||||
public void setSparkWeight(double sparkWeight) {
|
||||
this.sparkWeight = sparkWeight;
|
||||
fireChangeEvent();
|
||||
}
|
||||
}
|
@ -288,10 +288,32 @@ public class PhotoSettingsConfig extends JTabbedPane {
|
||||
fireModel.addEnableComponent(flameAspectSpinner);
|
||||
|
||||
add(new JLabel("Sparks"));
|
||||
JCheckBox sparksCheck = new JCheckBox(new BooleanModel(p, "Sparks"));
|
||||
BooleanModel sparksModel = new BooleanModel(p, "Sparks");
|
||||
JCheckBox sparksCheck = new JCheckBox(sparksModel);
|
||||
add(sparksCheck, "wrap");
|
||||
fireModel.addEnableComponent(sparksCheck);
|
||||
|
||||
add(new JLabel("Spark Concentration"));
|
||||
DoubleModel sparkConcentrationModel = new DoubleModel(p, "SparkConcentration", 100, UnitGroup.UNITS_NONE, 0, 100);
|
||||
JSpinner sparkConcentrationSpinner = new JSpinner(sparkConcentrationModel.getSpinnerModel());
|
||||
add(sparkConcentrationSpinner, "wrap");
|
||||
sparksModel.addEnableComponent(sparkConcentrationSpinner);
|
||||
|
||||
add(new JLabel("Spark Weight"));
|
||||
DoubleModel sparkWeightModel = new DoubleModel(p, "SparkWeight", 100, UnitGroup.UNITS_NONE, 0, 100);
|
||||
JSpinner sparkWeightSpinner = new JSpinner(sparkWeightModel.getSpinnerModel());
|
||||
add(sparkWeightSpinner, "wrap");
|
||||
sparksModel.addEnableComponent(sparkWeightSpinner);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add(new JLabel("Exhaust Scale"));
|
||||
DoubleModel exhaustScaleModel = new DoubleModel(p, "ExhaustScale", 100, UnitGroup.UNITS_NONE, 0, 1000);
|
||||
add(new JSpinner(exhaustScaleModel.getSpinnerModel()), "wrap");
|
||||
|
@ -141,21 +141,25 @@ import com.jogamp.opengl.util.texture.TextureIO;
|
||||
public final class FlameRenderer {
|
||||
|
||||
public interface FlameSettings {
|
||||
public double getExhaustScale();
|
||||
|
||||
public boolean isFlame();
|
||||
|
||||
public boolean isSmoke();
|
||||
|
||||
public Color getFlameColor();
|
||||
|
||||
public boolean isSmoke();
|
||||
|
||||
public Color getSmokeColor();
|
||||
|
||||
public double getSmokeAlpha();
|
||||
|
||||
public boolean isSparks();
|
||||
|
||||
public double getExhaustScale();
|
||||
|
||||
public double getFlameAspectRatio();
|
||||
|
||||
public boolean isSparks();
|
||||
|
||||
public double getSparkConcentration();
|
||||
|
||||
public double getSparkWeight();
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FlameRenderer.class);
|
||||
@ -175,7 +179,7 @@ public final class FlameRenderer {
|
||||
gl.glDisable(GLLightingFunc.GL_LIGHTING);
|
||||
|
||||
if (fs.isSparks() && fs.isFlame()) {
|
||||
sparks(gl, fs.getFlameColor());
|
||||
sparks(gl, fs);
|
||||
}
|
||||
|
||||
gl.glEnable(GL.GL_BLEND);
|
||||
@ -457,13 +461,13 @@ public final class FlameRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sparks(GL2 gl, Color color) {
|
||||
private static void sparks(GL2 gl, FlameSettings fs) {
|
||||
// Use the same seed every time
|
||||
Random r = new Random(0);
|
||||
|
||||
float[] c = new float[4];
|
||||
float[] c2 = new float[4];
|
||||
convertColor(color, c);
|
||||
convertColor(fs.getFlameColor(), c);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
c[i] = c2[i] = c[i] * .2f + .8f;
|
||||
}
|
||||
@ -471,17 +475,17 @@ public final class FlameRenderer {
|
||||
c2[3] = 1;
|
||||
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl.glEnable(GL.GL_BLEND);
|
||||
gl.glLineWidth(1f);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
final float z = 2 * (r.nextFloat() * r.nextFloat() * r.nextFloat());
|
||||
gl.glLineWidth(1 + (float)fs.getSparkWeight() * 1.0f);
|
||||
for (int i = 0; i < 4000 * fs.getSparkConcentration(); i++) {
|
||||
final float z = 0.01f + 2 * (r.nextFloat() * r.nextFloat() * r.nextFloat());
|
||||
final float x = z * (r.nextFloat() - 0.5f);
|
||||
final float y = z * (r.nextFloat() - 0.5f);
|
||||
gl.glPointSize(1);
|
||||
//gl.glPointSize(1);
|
||||
gl.glBegin(GL.GL_LINES);
|
||||
gl.glColor4fv(c, 0);
|
||||
gl.glVertex3f(x, y, z * 2);
|
||||
gl.glColor4fv(c2, 0);
|
||||
gl.glVertex3f(x * 1.02f, y * 1.02f, z * 2 + 0.01f);
|
||||
gl.glVertex3f(x * 1.02f, y * 1.02f, z * 2 + 0.01f + ((float)fs.getSparkWeight() / 20));
|
||||
gl.glEnd();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user