25
24
#include <GL/glu.h>
26
25
#include <GL/glx.h>
29
27
#include "driver.h"
30
#include "impCubeVolume.h"
31
#include "impCrawlPoint.h"
32
#include "impSphere.h"
28
#include "Implicit/impCubeVolume.h"
29
#include "Implicit/impCrawlPoint.h"
30
#include "Implicit/impSphere.h"
33
31
#include "loadTexture.h"
34
32
#include "rgbhsl.h"
35
33
#include "rsDefines.h"
36
34
#include "rsRand.h"
35
#include "rsMath/rsMatrix.h"
36
#include "rsMath/rsQuat.h"
37
#include "rsMath/rsVec.h"
41
39
char *hack_name = (char *)"helios";
154
151
pos = rsVec (0.0f, 0.0f, 0.0f);
155
152
rgb = rsVec (0.0f, 0.0f, 0.0f);
156
temp = myRandf (2.0f) + 0.4f;
153
temp = rsRandf (2.0f) + 0.4f;
157
154
size = float (dSize) * temp;
158
155
speed = float (dSpeed) * 12.0f / temp;
293
290
switch (whichTarget) {
294
291
case 0: // random
295
292
for (i = 0; i < dEmitters; i++)
296
elist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, myRandf (1000.0f) - 500.0f, myRandf (1000.0f) - 500.0f)));
293
elist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, rsRandf (1000.0f) - 500.0f, rsRandf (1000.0f) - 500.0f)));
297
294
for (i = 0; i < dAttracters; i++)
298
alist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, myRandf (1000.0f) - 500.0f, myRandf (1000.0f) - 500.0f)));
295
alist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, rsRandf (1000.0f) - 500.0f, rsRandf (1000.0f) - 500.0f)));
301
298
{ // line (all emitters on one side, all attracters on the other)
378
375
case 5: // random distribution across a plane
379
376
for (i = 0; i < dEmitters; i++)
380
elist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, 0.0f, myRandf (1000.0f) - 500.0f)));
377
elist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, 0.0f, rsRandf (1000.0f) - 500.0f)));
381
378
for (i = 0; i < dAttracters; i++)
382
alist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, 0.0f, myRandf (1000.0f) - 500.0f)));
379
alist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, 0.0f, rsRandf (1000.0f) - 500.0f)));
385
382
{ // random distribution across 2 planes
386
383
float height = -525.0f + float (dEmitters * 25);
388
385
for (i = 0; i < dEmitters; i++)
389
elist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, height, myRandf (1000.0f) - 500.0f)));
386
elist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, height, rsRandf (1000.0f) - 500.0f)));
391
388
height = 525.0f - float (dAttracters * 25);
393
390
for (i = 0; i < dAttracters; i++)
394
alist[i].settargetpos (rsVec (rsVec (myRandf (1000.0f) - 500.0f, height, myRandf (1000.0f) - 500.0f)));
391
alist[i].settargetpos (rsVec (rsVec (rsRandf (1000.0f) - 500.0f, height, rsRandf (1000.0f) - 500.0f)));
553
538
radialVel += radialVelDiff;
555
540
radialVel = targetRadialVel;
557
targetRadialVel = rsVec (myRandf (1.0f), myRandf (1.0f), myRandf (1.0f));
542
targetRadialVel = rsVec (rsRandf (1.0f), rsRandf (1.0f), rsRandf (1.0f));
558
543
targetRadialVel.normalize ();
559
targetRadialVel *= float (dCameraspeed) * myRandf (0.002f);
544
targetRadialVel *= float (dCameraspeed) * rsRandf (0.002f);
561
546
targetRadialVel = rsVec (0.0f, 0.0f, 0.0f);
576
561
rotMat.get (billboardMat);
578
563
// Calculate new color
579
static rsVec oldHsl, newHsl = rsVec (myRandf (1.0f), 1.0f, 1.0f), targetHsl;
564
static rsVec oldHsl, newHsl = rsVec (rsRandf (1.0f), 1.0f, 1.0f), targetHsl;
580
565
static float colorInterp = 1.0f, colorChange;
582
567
colorInterp += elapsedTime * colorChange;
583
568
if (colorInterp >= 1.0f) {
584
if (!myRandi (3) && dIons >= 100) // change color suddenly
585
newHsl = rsVec (myRandf (1.0f), 1.0f - (myRandf (1.0f) * myRandf (1.0f)), 1.0f);
569
if (!rsRandi (3) && dIons >= 100) // change color suddenly
570
newHsl = rsVec (rsRandf (1.0f), 1.0f - (rsRandf (1.0f) * rsRandf (1.0f)), 1.0f);
587
targetHsl = rsVec (myRandf (1.0f), 1.0f - (myRandf (1.0f) * myRandf (1.0f)), 1.0f);
572
targetHsl = rsVec (rsRandf (1.0f), 1.0f - (rsRandf (1.0f) * rsRandf (1.0f)), 1.0f);
588
573
colorInterp = 0.0f;
589
574
// amount by which to change colorInterp each second
590
colorChange = myRandf (0.005f * float (dSpeed)) + (0.002f * float (dSpeed));
575
colorChange = rsRandf (0.005f * float (dSpeed)) + (0.002f * float (dSpeed));
592
577
float diff = targetHsl[0] - oldHsl[0];
659
644
spheres[i].setPosition (elist[i].pos[0], elist[i].pos[1], elist[i].pos[2]);
660
645
for (i = 0; i < dAttracters; i++)
661
646
spheres[dEmitters + i].setPosition (alist[i].pos[0], alist[i].pos[1], alist[i].pos[2]);
662
std::list < impCrawlPoint > crawlpointlist;
665
for (i = 0; i < dEmitters + dAttracters; i++) {
666
spheres[i].center (center);
667
crawlpointlist.push_back (impCrawlPoint (center));
648
impCrawlPointVector cpv;
649
for(i=0; i<dEmitters+dAttracters; i++)
650
spheres[i].addCrawlPoint(cpv);
669
652
surface->reset ();
670
654
static float valuetrig = 0.0f;
672
655
valuetrig += elapsedTime;
673
volume->surfacevalue = 0.45f + 0.05f * cos (valuetrig);
674
volume->make_surface (crawlpointlist);
657
volume->setSurfaceValue(0.45f + 0.05f * cosf(valuetrig));
658
volume->makeSurface(cpv);
677
661
// clear the screen
678
662
if (dBlur) { // partially
679
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
680
glColor4f (0.0f, 0.0f, 0.0f, 0.5f - (float (sqrt (sqrt (double (dBlur)))) * 0.15495f));
663
glMatrixMode (GL_PROJECTION);
684
glBegin (GL_TRIANGLE_STRIP);
685
glVertex3f (-5.0f, -4.0f, -3.0f);
686
glVertex3f (5.0f, -4.0f, -3.0f);
687
glVertex3f (-5.0f, 4.0f, -3.0f);
688
glVertex3f (5.0f, 4.0f, -3.0f);
666
glOrtho(0.0, 1.0, 0.0, 1.0, 1.0, -1.0);
667
glMatrixMode(GL_MODELVIEW);
670
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
671
glColor4f(0.0f, 0.0f, 0.0f, 0.5f - (float(sqrtf(sqrtf(float(dBlur)))) * 0.15495f));
672
glBegin(GL_TRIANGLE_STRIP);
673
glVertex3f(0.0f, 0.0f, 0.0f);
674
glVertex3f(1.0f, 0.0f, 0.0f);
675
glVertex3f(0.0f, 1.0f, 0.0f);
676
glVertex3f(1.0f, 1.0f, 0.0f);
679
glMatrixMode(GL_PROJECTION);
691
681
} else // completely
692
682
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
685
glMatrixMode(GL_MODELVIEW);
695
686
glBlendFunc (GL_ONE, GL_ONE);
696
687
glBindTexture (GL_TEXTURE_2D, 1);
697
688
for (i = 0; i < ionsReleased; i++)
796
787
glMatrixMode (GL_PROJECTION);
797
788
glLoadIdentity ();
798
789
gluPerspective (60.0, float (XStuff->windowWidth) / float (XStuff->windowHeight), 0.1, 10000.0f);
800
glMatrixMode (GL_MODELVIEW);
802
glDisable (GL_DEPTH_TEST);
804
glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
807
792
void hack_init (xstuff_t * XStuff)
813
798
// Window initialization
814
799
hack_reshape (XStuff);
801
glDisable (GL_DEPTH_TEST);
803
glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
816
805
// Clear the buffers and test for type of buffer swapping
817
// glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
818
806
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
819
807
glXSwapBuffers (XStuff->display, XStuff->window); // wglSwapLayerBuffers(hdc, WGL_SWAP_MAIN_PLANE);
820
808
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
893
881
volume = new impCubeVolume;
894
882
volume->init (50, 50, 50, 35.0f);
895
883
volume->function = surfaceFunction;
896
surface = new impSurface;
897
surface->init (6000);
898
volume->surface = surface;
884
surface = volume->getSurface();
899
886
spheres = new impSphere[dEmitters + dAttracters];
900
float sphereScaleFactor = 1.0f / float (sqrt (double (2 * dEmitters + dAttracters)));
888
float sphereScaleFactor = 1.0f / sqrtf (double (2 * dEmitters + dAttracters));
902
889
for (i = 0; i < dEmitters; i++)
903
spheres[i].setScale (400.0f * sphereScaleFactor);
890
spheres[i].setThickness (400.0f * sphereScaleFactor);
904
891
for (i = 0; i < dAttracters; i++)
905
spheres[i + dEmitters].setScale (200.0f * sphereScaleFactor);
892
spheres[i + dEmitters].setThickness (200.0f * sphereScaleFactor);