glviewvol
diff src/renderer.cc @ 4:04330eb80b36
lots of stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 29 Dec 2014 05:41:36 +0200 |
parents | 7bdf40403b9c |
children | 5417c25cb238 |
line diff
1.1 --- a/src/renderer.cc Sun Dec 28 21:48:15 2014 +0200 1.2 +++ b/src/renderer.cc Mon Dec 29 05:41:36 2014 +0200 1.3 @@ -1,3 +1,4 @@ 1.4 +#include <math.h> 1.5 #include "renderer.h" 1.6 1.7 Renderer::Renderer() 1.8 @@ -5,6 +6,15 @@ 1.9 vol = 0; 1.10 view_width = 512; 1.11 view_height = 512; 1.12 + 1.13 + for(int i=0; i<3; i++) { 1.14 + xfer[i].set_point(0, 0); 1.15 + xfer[i].set_point(1, 1); 1.16 + } 1.17 + 1.18 + for(int i=0; i<MAX_CLIP_PLANES; i++) { 1.19 + disable_clipping_plane(i); 1.20 + } 1.21 } 1.22 1.23 Renderer::~Renderer() 1.24 @@ -31,6 +41,37 @@ 1.25 return vol; 1.26 } 1.27 1.28 +Curve &Renderer::transfer_curve(int color) 1.29 +{ 1.30 + return xfer[color]; 1.31 +} 1.32 + 1.33 +const Curve &Renderer::transfer_curve(int color) const 1.34 +{ 1.35 + return xfer[color]; 1.36 +} 1.37 + 1.38 +void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist) 1.39 +{ 1.40 + float len = sqrt(nx * nx + ny * ny + nz * nz); 1.41 + if(len != 0.0) { 1.42 + nx /= len; 1.43 + ny /= len; 1.44 + nz /= len; 1.45 + } 1.46 + clip_plane[idx][0] = nx; 1.47 + clip_plane[idx][1] = ny; 1.48 + clip_plane[idx][2] = nz; 1.49 + clip_plane[idx][3] = dist; 1.50 +} 1.51 + 1.52 +void Renderer::disable_clipping_plane(int idx) 1.53 +{ 1.54 + clip_plane[idx][0] = clip_plane[idx][2] = 0; 1.55 + clip_plane[idx][1] = 1; 1.56 + clip_plane[idx][3] = -1; 1.57 +} 1.58 + 1.59 void Renderer::reshape(int x, int y) 1.60 { 1.61 view_width = x;