159 if (Keyboard.isKeyDown(Keyboard.KEY_P) ||
true) {
213 TurbulenceParams params =
new TurbulenceParams();
214 params.field =
field;
215 params.effectWidth = 210f;
216 params.effectLength = 410f;
217 params.maxDispersionAngle = 120f;
218 params.energyTransferMult = 5f;
219 params.dampenFactor = 0.2f;
220 params.maxVelocity = 1000f;
224 params.maxDispersionAngle = 0f;
225 params.maxVelocity = 1000f;
226 params.energyTransferMult = 6f;
230 params.propagationAmount = 6f * amount;
242 float facing =
entity.getFacing();
243 float x =
entity.getLocation().x;
244 float y =
entity.getLocation().y;
250 Vector2f loc =
new Vector2f();
252 loc.x = w * 0.4f + w * 0.2f * (float) Math.random() ;
253 loc.y = h * (1f - (float) Math.random()) ;
254 loc = Misc.rotateAroundOrigin(loc,
entity.getFacing());
259 float mass = 0.0001f;
261 mass = (float) Math.random() * 10f;
263 float dur = 0f + 4f * Misc.random.nextFloat();
290 while (iter.hasNext()) {
291 PointParticle p = iter.next();
292 p.remaining -= amount;
294 if (p.remaining <= 0) {
300 Vector2f vel =
field.
getVelocity(p.loc.x, p.loc.y,
new Vector2f(x, y), facing);
301 float accelAmount = 1f / p.mass;
302 if (accelAmount > 1f) accelAmount = 1f;
305 Vector2f diff = Vector2f.sub(vel, p.vel,
new Vector2f());
306 p.vel.x += diff.x * accelAmount * amount;
307 p.vel.y += diff.y * accelAmount * amount;
309 if (p.elapsed > 0.5f) {
310 p.remaining = Math.min(p.remaining, 0.5f);
316 p.loc.x += p.vel.x * amount;
317 p.loc.y += p.vel.y * amount;
321 List<ParticleData>
remove =
new ArrayList<ParticleData>();
323 p.advance(amount,
field, x, y, facing);
324 if (p.elapsed >= p.maxDur) {
330 remove =
new ArrayList<ParticleData>();
332 p.advance(amount,
field, x, y, facing);
333 if (p.elapsed >= p.maxDur) {
340 Vector2f vel =
new Vector2f(0f, Misc.getSpeedForBurnLevel(30f));
341 Vector2f dv =
new Vector2f(vel.x * amount, vel.y * amount);
356 public void render(CampaignEngineLayers layer, ViewportAPI viewport) {
358 float mx = Mouse.getX();
359 float my = Mouse.getY();
361 float wmx =
Global.
getSector().getViewport().convertScreenXToWorldX(mx);
362 float wmy =
Global.
getSector().getViewport().convertScreenYToWorldY(my);
366 float facing =
entity.getFacing();
367 float x =
entity.getLocation().x;
368 float y =
entity.getLocation().y;
370 GL11.glDisable(GL11.GL_TEXTURE_2D);
371 GL11.glEnable(GL11.GL_BLEND);
372 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
374 if (
false || Keyboard.isKeyDown(Keyboard.KEY_O)) {
376 GL11.glTranslatef(x, y, 0);
377 GL11.glRotatef(facing, 0, 0, 1);
379 GL11.glPointSize(20f);
380 GL11.glEnable(GL11.GL_POINT_SMOOTH);
381 GL11.glBegin(GL11.GL_POINTS);
382 GL11.glColor4f(1f,0,0,0.75f);
383 for (
int i = 0; i <
field.
field.length; i++) {
384 for (
int j = 0; j <
field.
field[0].length; j++) {
387 GL11.glVertex2f(cx, cy);
393 GL11.glEnable(GL11.GL_LINE_SMOOTH);
394 GL11.glDisable(GL11.GL_BLEND);
395 GL11.glBegin(GL11.GL_LINES);
397 GL11.glColor4f(1f,1f,0,1f);
399 for (
int i = 0; i <
field.
field.length; i++) {
400 for (
int j = 0; j <
field.
field[0].length; j++) {
408 GL11.glVertex2f(cx, cy);
409 GL11.glVertex2f(cx + vel.x * scale, cy + vel.y * scale);
420 GL11.glPointSize(6f);
421 GL11.glEnable(GL11.GL_POINT_SMOOTH);
422 GL11.glBegin(GL11.GL_POINTS);
423 GL11.glColor4f(1,1,0,1);
424 GL11.glVertex2f(wmx, wmy);
427 GL11.glEnable(GL11.GL_LINE_SMOOTH);
428 GL11.glBegin(GL11.GL_LINES);
430 GL11.glColor4f(1,1,0,1);
432 GL11.glVertex2f(wmx, wmy);
433 GL11.glVertex2f(wmx + vel.x, wmy + vel.y);
440 GL11.glEnable(GL11.GL_POINT_SMOOTH);
441 GL11.glEnable(GL11.GL_BLEND);
442 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
445 GL11.glPointSize(2f / zoom);
446 GL11.glBegin(GL11.GL_POINTS);
449 if (!viewport.isNearViewport(p.loc, 5))
continue;
451 if (p.remaining <= 0.5f) {
452 a = p.remaining / 0.5f;
453 }
else if (p.elapsed < 0.5f) {
454 a = p.elapsed / 0.5f;
457 Misc.setColor(p.color, a);
458 GL11.glVertex2f(p.loc.x, p.loc.y);
461 if (zoom < 1.75f &&
false) {
465 Vector2f dir = Misc.normalise(
new Vector2f(p.vel));
469 Misc.setColor(p.color, a * zf);
470 GL11.glVertex2f(p.loc.x + dir.x * spread, p.loc.y + dir.y * spread);
475 Misc.setColor(p.color, a * zf);
476 GL11.glVertex2f(p.loc.x - dir.x * spread, p.loc.y - dir.y * spread);
485 Misc.setColor(p.color, a * zf);
486 GL11.glVertex2f(p.loc.x + dir.x * spread, p.loc.y + dir.y * spread);
491 Misc.setColor(p.color, a * zf);
492 GL11.glVertex2f(p.loc.x - dir.x * spread, p.loc.y - dir.y * spread);
507 GL11.glLineWidth(3.5f);
508 GL11.glLineWidth(2f);
510 GL11.glEnable(GL11.GL_LINE_SMOOTH);
511 GL11.glBegin(GL11.GL_LINES);
514 if (!viewport.isNearViewport(p.loc, 500))
continue;
516 if (p.remaining <= 0.5f) {
517 a = p.remaining / 0.5f;
518 }
else if (p.elapsed < 0.5f) {
519 a = p.elapsed / 0.5f;
525 Vector2f prev =
new Vector2f(p.loc);
526 float prevAlpha = 0f;
527 float interval = 1/60f;
530 for (
int i = 0; i < iter; i++) {
533 Vector2f vel =
field.
getVelocity(prev.x, prev.y,
new Vector2f(x, y), facing);
535 Vector2f loc =
new Vector2f(prev);
536 loc.x -= vel.x * interval;
537 loc.y -= vel.y * interval;
541 float baseAlpha = 0.5f;
547 float alpha = baseAlpha * a * (iter - i) / iter;
550 Misc.setColor(p.color, prevAlpha);
551 GL11.glVertex2f(prev.x, prev.y);
552 Misc.setColor(p.color, alpha);
553 GL11.glVertex2f(loc.x, loc.y);
576 float b = viewport.getAlphaMult();
578 CampaignEngineLayers normalLayer = layer;
579 CampaignEngineLayers darkLayer = layer;
580 if (layer == normalLayer) {
582 float size = p.baseSize * p.scale;
583 Vector2f loc = p.offset;
585 float alphaMult = 1f;
587 p.sprite.setAngle(p.angle);
588 p.sprite.setSize(size, size);
589 p.sprite.setAlphaMult(b * alphaMult * p.fader.getBrightness());
590 p.sprite.setColor(p.color);
591 p.sprite.renderAtCenter(loc.x, loc.y);
594 if (layer == darkLayer) {
595 GL14.glBlendEquation(GL14.GL_FUNC_REVERSE_SUBTRACT);
599 float size = p.baseSize * p.scale;
601 Vector2f loc = p.offset;
603 float alphaMult = 1f;
605 p.sprite.setAngle(p.angle);
606 p.sprite.setSize(size, size);
607 p.sprite.setAlphaMult(b * alphaMult * p.fader.getBrightness());
608 p.sprite.setColor(p.color);
609 p.sprite.renderAtCenter(loc.x, loc.y);
612 GL14.glBlendEquation(GL14.GL_FUNC_ADD);