Commit 7348d363 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

hexagonal distribution mostly working

parent c95e8d19
......@@ -24,7 +24,7 @@ float random (vec2 uv) {
void
get_color( float u , out vec3 color ) {
// This line turns on the random shading (for structured points)
//u = random( vec2(v_Index,v_Index) ) * (u_nb_points+1);
u = random( vec2(v_Index,v_Index) ) * (u_nb_points+1);
float umin = 0.;
float umax = u_nb_points +1;
......
......@@ -126,18 +126,18 @@ UT_TEST_CASE( test1 )
// *************************************************************************
//generate random seeds desired times 3
int num_points = 1e6;
int num_points = 1e3;
int size = num_points*3;
int DEBUG = 0;
int MODE = 2; // 0 is random, 1 is square, 2 is hexagonal
// *************************************************************************
std::vector<graphics::gl_float> seeds;
srand (time(NULL));
if (DEBUG == 0){
if (MODE == 0){
for (int i = 0; i < size; i ++){
double val = double(rand()) / double(RAND_MAX);
if ((i - 2) % 3 == 0){
......@@ -154,11 +154,12 @@ if (DEBUG == 0){
};
//std::cout << "Test Print!!!!!!!!!!!!!";
}
else{
else if (MODE == 1){
float dx = 1 / (sqrt(num_points) + 1); //delta y is the same if we're going for a grid
std::cout << dx << std::endl;
//std::cout << dx << std::endl;
for (int i = 1; i < sqrt(num_points) +1; i ++ ){
for (int j = 1; j < sqrt(num_points) +1; j ++ ){
float x = j * dx;
float y = i * dx;
seeds.push_back(x);
......@@ -166,9 +167,48 @@ else{
seeds.push_back(0.0);
}
}
num_points = seeds.size()/3;
std::cout << num_points << std:: endl;
}
else if (MODE == 2){
float dx = 1/(sqrt(num_points)-1); // idk what number to put here
float dy = (sqrt(3)/2) * dx;
//std::cout << sqrt(num_points)/dy << std::endl;
for (int i = 0; i < 1/dy; i ++ ){
if ((i % 2) == 0) {
for (int j = 0; j < 1/dx; j ++ ){
float x = (j * dx) + dx/2;
float y = i * dy;
seeds.push_back(x);
seeds.push_back(y);
seeds.push_back(0.0);
}
}
else{
for (int j = 0; j < 1/dx; j ++ ){
float x = j * dx;
float y = i * dy;
seeds.push_back(x);
seeds.push_back(y);
seeds.push_back(0.0);
}
}
}
num_points = seeds.size()/3;
std::cout << num_points << std:: endl;
}
......@@ -245,7 +285,7 @@ else{
//get a colormaps and bind it to the colormap buffer
avro::Colormap colormap;
colormap.change_style("jet");
colormap.change_style("viridis");
index_t ncolor = 256*3;
GL_CALL( glBindBuffer( GL_TEXTURE_BUFFER , colormap_buffer) );
GL_CALL( glBufferData( GL_TEXTURE_BUFFER , sizeof(float) * ncolor , colormap.data() , GL_STATIC_DRAW) );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment