24 public static class NEParams
implements Cloneable {
26 public int numRiftsToSpawn = 2;
27 public float fadeIn = 0.1f;
28 public float fadeOut = 0.5f;
29 public float spawnHitGlowAt = 0f;
30 public float hitGlowSizeMult = 0.75f;
31 public float radius = 20f;
32 public float thickness = 25f;
33 public float noiseMag = 1f;
34 public float noiseMult = 1f;
35 public float noisePeriod = 0.1f;
36 public boolean withHitGlow =
true;
37 public boolean withNegativeParticles =
true;
38 public Color color =
new Color(100,100,255);
40 public Color blackColor = Color.black;
41 public Color invertForDarkening =
null;
42 public boolean additiveBlend =
false;
47 public NEParams(
float radius,
float thickness, Color color) {
50 this.thickness = thickness;
55 protected NEParams clone() {
57 return (NEParams) super.clone();
58 }
catch (CloneNotSupportedException e) {
90 return p.radius + 500f;
104 if (
p.noiseMag > 0) {
112 for (
int i = 0; i <
noise.length; i++) {
115 noise[i] = n1 + (n2 - n1) * f;
119 if (!
p.withHitGlow)
return;
121 float glowSpawnAt = 1f;
123 float size = Math.min(
p.radius * 7f,
p.radius + 150f);
124 float coreSize = Math.max(size,
p.radius * 4f);
125 if (coreSize > size) size = coreSize;
127 size *=
p.hitGlowSizeMult;
128 coreSize *=
p.hitGlowSizeMult;
136 engine.
addHitParticle(point, vel, coreSize * 1.5f, 1f, dur, Color.white);
139 Color invert =
p.color;
140 if (
p.invertForDarkening !=
null) invert =
p.invertForDarkening;
141 Color c =
new Color(255 - invert.getRed(),
142 255 - invert.getGreen(),
143 255 - invert.getBlue(), 127);
148 for (
int i = 0; i < 7 &&
p.withNegativeParticles; i++) {
149 dur = 4f + 4f * (float) Math.random();
155 float nSize = size * 1f;
158 v.scale(nSize + nSize * (
float) Math.random() * 0.5f);
160 Vector2f.add(vel, v, v);
173 p.fadeIn / dur, 0f, dur, c);
176 dur = p.fadeIn + p.fadeOut + 2f;
178 float rampUp = (p.fadeIn +
p.fadeOut) / dur;
186 for (
int i = 0; i < 15; i++) {
188 Vector2f loc =
new Vector2f(point);
191 float s = size * 3f * (0.25f + (float) Math.random() * 0.25f);
210 float perSegment = 2f;
211 segments = (int) ((
p.radius * 2f * 3.14f) / perSegment);
234 float tSmall =
p.thickness;
237 r *= 0.75f + Math.sqrt(f) * 0.25f;
239 r *= 0.1f + 0.9f * f;
240 tSmall = Math.min(r * 1f,
p.thickness);
254 float circleAlpha = 1f;
255 if (alphaMult < 0.5f) {
256 circleAlpha = alphaMult * 2f;
258 float tCircleBorder = 1f;
259 renderCircle(x, y, r, circleAlpha,
segments,
p.blackColor);
268 private void renderCircle(
float x,
float y,
float radius,
float alphaMult,
int segments, Color color) {
272 float startRad = (float) Math.toRadians(0);
273 float endRad = (float) Math.toRadians(360);
275 float anglePerSegment = spanRad /
segments;
278 GL11.glTranslatef(x, y, 0);
279 GL11.glRotatef(0, 0, 0, 1);
280 GL11.glDisable(GL11.GL_TEXTURE_2D);
282 GL11.glEnable(GL11.GL_BLEND);
283 if (
p.additiveBlend) {
284 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
286 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
290 GL11.glColor4ub((
byte)color.getRed(),
291 (
byte)color.getGreen(),
292 (
byte)color.getBlue(),
293 (
byte)((
float) color.getAlpha() * alphaMult));
295 GL11.glBegin(GL11.GL_TRIANGLE_FAN);
296 GL11.glVertex2f(0, 0);
297 for (
float i = 0; i <
segments + 1; i++) {
300 float theta = anglePerSegment * i;
301 float cos = (float) Math.cos(theta);
302 float sin = (float) Math.sin(theta);
304 float m1 = 0.75f + 0.65f *
noise[(int)i] *
p.noiseMult;
305 if (
p.noiseMag <= 0) {
309 float x1 = cos * radius * m1;
310 float y1 = sin * radius * m1;
312 GL11.glVertex2f(x1, y1);
324 private void renderAtmosphere(
float x,
float y,
float radius,
float thickness,
float alphaMult,
int segments, SpriteAPI tex,
float []
noise, Color color,
boolean additive) {
326 float startRad = (float) Math.toRadians(0);
327 float endRad = (float) Math.toRadians(360);
328 float spanRad = Misc.normalizeAngle(endRad - startRad);
329 float anglePerSegment = spanRad /
segments;
332 GL11.glTranslatef(x, y, 0);
333 GL11.glRotatef(0, 0, 0, 1);
334 GL11.glEnable(GL11.GL_TEXTURE_2D);
338 GL11.glEnable(GL11.GL_BLEND);
340 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
342 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
345 GL11.glColor4ub((
byte)color.getRed(),
346 (
byte)color.getGreen(),
347 (
byte)color.getBlue(),
348 (
byte)((
float) color.getAlpha() * alphaMult));
351 GL11.glBegin(GL11.GL_QUAD_STRIP);
352 for (
float i = 0; i <
segments + 1; i++) {
355 float theta = anglePerSegment * i;
356 float cos = (float) Math.cos(theta);
357 float sin = (float) Math.sin(theta);
359 float m1 = 0.75f + 0.65f *
noise[(int)i] *
p.noiseMult;
361 if (
p.noiseMag <= 0) {
366 float x1 = cos * radius * m1;
367 float y1 = sin * radius * m1;
368 float x2 = cos * (radius + thickness * m2);
369 float y2 = sin * (radius + thickness * m2);
371 GL11.glTexCoord2f(0.5f, 0.05f);
372 GL11.glVertex2f(x1, y1);
374 GL11.glTexCoord2f(0.5f, 0.95f);
375 GL11.glVertex2f(x2, y2);
void addNegativeNebulaParticle(Vector2f loc, Vector2f vel, float size, float endSizeMult, float rampUpFraction, float fullBrightnessFraction, float totalDuration, Color color)
void addNebulaParticle(Vector2f loc, Vector2f vel, float size, float endSizeMult, float rampUpFraction, float fullBrightnessFraction, float totalDuration, Color color)