mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:48:38 +02:00
Move constants to macros; increase particle count
This commit is contained in:
parent
4ebcc0cff3
commit
8b720d53df
4 changed files with 16 additions and 9 deletions
|
@ -10,6 +10,8 @@
|
||||||
#include "cloud.h"
|
#include "cloud.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#define COLOR_MIN 0.3f // minimum R/G/B value at 0,0,0 - also needs setting in field.cpp
|
||||||
|
|
||||||
Cloud::Cloud(int num,
|
Cloud::Cloud(int num,
|
||||||
glm::vec3 box,
|
glm::vec3 box,
|
||||||
int wrap) {
|
int wrap) {
|
||||||
|
@ -32,9 +34,10 @@ Cloud::Cloud(int num,
|
||||||
particles[i].velocity.y = 0; //randFloat() - 0.5;
|
particles[i].velocity.y = 0; //randFloat() - 0.5;
|
||||||
particles[i].velocity.z = 0; //randFloat() - 0.5;
|
particles[i].velocity.z = 0; //randFloat() - 0.5;
|
||||||
|
|
||||||
particles[i].color = glm::vec3(x*0.8f/WORLD_SIZE + 0.2f,
|
float color_mult = 1 - COLOR_MIN;
|
||||||
y*0.8f/WORLD_SIZE + 0.2f,
|
particles[i].color = glm::vec3(x*color_mult/WORLD_SIZE + COLOR_MIN,
|
||||||
z*0.8f/WORLD_SIZE + 0.2f);
|
y*color_mult/WORLD_SIZE + COLOR_MIN,
|
||||||
|
z*color_mult/WORLD_SIZE + COLOR_MIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
field.cpp
11
field.cpp
|
@ -9,6 +9,8 @@
|
||||||
#include "field.h"
|
#include "field.h"
|
||||||
#include "glm/glm.hpp"
|
#include "glm/glm.hpp"
|
||||||
#define FIELD_SCALE 0.00050
|
#define FIELD_SCALE 0.00050
|
||||||
|
#define COLOR_DRIFT_RATE 0.001f // per-frame drift of particle color towards field element color
|
||||||
|
#define COLOR_MIN 0.3f // minimum R/G/B value at 0,0,0 - also needs setting in cloud.cpp
|
||||||
|
|
||||||
// A vector-valued field over an array of elements arranged as a 3D lattice
|
// A vector-valued field over an array of elements arranged as a 3D lattice
|
||||||
|
|
||||||
|
@ -39,9 +41,10 @@ void field_init()
|
||||||
field[i].val.y = (randFloat() - 0.5)*FIELD_SCALE;
|
field[i].val.y = (randFloat() - 0.5)*FIELD_SCALE;
|
||||||
field[i].val.z = (randFloat() - 0.5)*FIELD_SCALE;
|
field[i].val.z = (randFloat() - 0.5)*FIELD_SCALE;
|
||||||
// and set up the RGB values for each field element.
|
// and set up the RGB values for each field element.
|
||||||
fieldcolors[i].rgb = glm::vec3(((i%10)*0.08) + 0.2f,
|
float color_mult = 1 - COLOR_MIN;
|
||||||
((i%100)*0.008) + 0.2f,
|
fieldcolors[i].rgb = glm::vec3(((i%10)*(color_mult/10.0f)) + COLOR_MIN,
|
||||||
(i*0.0008) + 0.2f);
|
((i%100)*(color_mult/100.0f)) + COLOR_MIN,
|
||||||
|
(i*(color_mult/1000.0f)) + COLOR_MIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +76,7 @@ void field_interact(glm::vec3 * pos, glm::vec3 * vel, glm::vec3 * color, float c
|
||||||
field[index].val += temp;
|
field[index].val += temp;
|
||||||
|
|
||||||
// add a fraction of the field color to the particle color
|
// add a fraction of the field color to the particle color
|
||||||
*color = (*color * 0.999f) + (fieldcolors[index].rgb * 0.001f);
|
*color = (*color * (1 - COLOR_DRIFT_RATE)) + (fieldcolors[index].rgb * COLOR_DRIFT_RATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
|
08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
|
||||||
8DD76F6C0486A84900D96B5E /* interface */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = interface; sourceTree = BUILT_PRODUCTS_DIR; };
|
8DD76F6C0486A84900D96B5E /* interface */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = interface; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B6BDADD115F4084F002A07DF /* audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio.h; sourceTree = "<group>"; };
|
B6BDADD115F4084F002A07DF /* audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio.h; sourceTree = "<group>"; };
|
||||||
B6BDADD315F4085B002A07DF /* audio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio.cpp; sourceTree = "<group>"; };
|
B6BDADD315F4085B002A07DF /* audio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio.cpp; sourceTree = "<group>"; };
|
||||||
B6BDADD515F40B04002A07DF /* libportaudio.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libportaudio.a; sourceTree = "<group>"; };
|
B6BDADD515F40B04002A07DF /* libportaudio.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libportaudio.a; sourceTree = "<group>"; };
|
||||||
|
@ -321,6 +321,7 @@
|
||||||
/usr/local/lib,
|
/usr/local/lib,
|
||||||
/usr/local/Cellar/libpng/1.5.13/lib,
|
/usr/local/Cellar/libpng/1.5.13/lib,
|
||||||
);
|
);
|
||||||
|
ONLY_ACTIVE_ARCH = NO;
|
||||||
OTHER_CPLUSPLUSFLAGS = (
|
OTHER_CPLUSPLUSFLAGS = (
|
||||||
"-O3",
|
"-O3",
|
||||||
"$(OTHER_CFLAGS)",
|
"$(OTHER_CFLAGS)",
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -92,7 +92,7 @@ ParticleSystem balls(0,
|
||||||
0.0 // Gravity
|
0.0 // Gravity
|
||||||
);
|
);
|
||||||
|
|
||||||
Cloud cloud(100000, // Particles
|
Cloud cloud(200000, // Particles
|
||||||
box, // Bounding Box
|
box, // Bounding Box
|
||||||
false // Wrap
|
false // Wrap
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue