volmetrics
changeset 26:5ee081af59b8
volume rendering
author | Eleni Maria Stea <elene.mst@gmail.com> |
---|---|
date | Sun, 27 Apr 2014 18:25:40 +0300 |
parents | 4b6c952a83bd |
children | 069fae435a1d |
files | src/main.cc |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line diff
1.1 --- a/src/main.cc Sun Apr 27 18:13:44 2014 +0300 1.2 +++ b/src/main.cc Sun Apr 27 18:25:40 2014 +0300 1.3 @@ -53,6 +53,7 @@ 1.4 1.5 static int use_orig_vol_res = 1; 1.6 static int vol_res[3]; // volume sampling resolution x/y/z 1.7 +static float bound_scale = 1.42; 1.8 1.9 static GLUI *ui; 1.10 1.11 @@ -124,6 +125,8 @@ 1.12 vol_res[1] = vol->get_slice(0)->get_height(); 1.13 vol_res[2] = vol->get_slice_count(); 1.14 1.15 + num_poly = std::max(vol_res[0], std::max(vol_res[1], vol_res[2])) * bound_scale; 1.16 + 1.17 if(!(ui = create_ui())) { 1.18 return false; 1.19 } 1.20 @@ -296,13 +299,9 @@ 1.21 if(tmax_loc != -1) 1.22 glUniform1f(tmax_loc, std::max(thres, thres2)); 1.23 1.24 - const Image *img = vol->get_slice(0); 1.25 - int res_x = img->get_width(); 1.26 - int res_y = img->get_height(); 1.27 - int res_z = vol->get_slice_count(); 1.28 int res_loc = glGetUniformLocation(sprog_vol, "res"); 1.29 if(res_loc != -1) 1.30 - glUniform3f(res_loc, (float)res_x, (float)res_y, (float)res_z); 1.31 + glUniform3f(res_loc, (float)vol_res[0], (float)vol_res[1], (float)vol_res[2]); 1.32 1.33 glDisable(GL_DEPTH_TEST); 1.34 glBindTexture(GL_TEXTURE_3D, vol->get_texture()); 1.35 @@ -314,10 +313,10 @@ 1.36 float tex_z = (float)i / (float)num_poly; 1.37 float z = 2 * tex_z - 1; 1.38 1.39 - glTexCoord3f(0, 0, tex_z); glVertex3f(-2, -2, z * 2); 1.40 - glTexCoord3f(0, 1, tex_z); glVertex3f(-2, 2, z * 2); 1.41 - glTexCoord3f(1, 1, tex_z); glVertex3f(2, 2, z * 2); 1.42 - glTexCoord3f(1, 0, tex_z); glVertex3f(2, -2, z * 2); 1.43 + glTexCoord3f(0, 0, tex_z); glVertex3f(-bound_scale, -bound_scale, z * bound_scale); 1.44 + glTexCoord3f(0, 1, tex_z); glVertex3f(-bound_scale, bound_scale, z * bound_scale); 1.45 + glTexCoord3f(1, 1, tex_z); glVertex3f(bound_scale, bound_scale, z * bound_scale); 1.46 + glTexCoord3f(1, 0, tex_z); glVertex3f(bound_scale, -bound_scale, z * bound_scale); 1.47 } 1.48 glEnd(); 1.49 glDisable(GL_BLEND);