glviewvol

view src/renderer.cc @ 5:5417c25cb238

moving to a simpler transfer function
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 29 Dec 2014 15:59:55 +0200
parents 04330eb80b36
children f22be47a3572
line source
1 #include <math.h>
2 #include "renderer.h"
4 Renderer::Renderer()
5 {
6 vol = 0;
7 view_width = 512;
8 view_height = 512;
10 for(int i=0; i<3; i++) {
11 xfer[i].set_point(0, 0);
12 xfer[i].set_point(1, 1);
13 }
15 xfer_low = 0.0;
16 xfer_high = 1.0;
18 for(int i=0; i<MAX_CLIP_PLANES; i++) {
19 disable_clipping_plane(i);
20 }
21 }
23 Renderer::~Renderer()
24 {
25 destroy();
26 }
28 bool Renderer::init()
29 {
30 return true;
31 }
33 void Renderer::destroy()
34 {
35 }
37 void Renderer::set_volume(Volume *vol)
38 {
39 this->vol = vol;
40 }
42 Volume *Renderer::get_volume() const
43 {
44 return vol;
45 }
47 Curve &Renderer::transfer_curve(int color)
48 {
49 return xfer[color];
50 }
52 const Curve &Renderer::transfer_curve(int color) const
53 {
54 return xfer[color];
55 }
57 void Renderer::set_simple_transfer(float low, float high)
58 {
59 xfer_low = std::min(low, high);
60 xfer_high = std::max(low, high);
61 }
63 void Renderer::get_simple_transfer(float *low, float *high) const
64 {
65 *low = xfer_low;
66 *high = xfer_high;
67 }
69 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
70 {
71 float len = sqrt(nx * nx + ny * ny + nz * nz);
72 if(len != 0.0) {
73 nx /= len;
74 ny /= len;
75 nz /= len;
76 }
77 clip_plane[idx][0] = nx;
78 clip_plane[idx][1] = ny;
79 clip_plane[idx][2] = nz;
80 clip_plane[idx][3] = dist;
81 }
83 void Renderer::disable_clipping_plane(int idx)
84 {
85 clip_plane[idx][0] = clip_plane[idx][2] = 0;
86 clip_plane[idx][1] = 1;
87 clip_plane[idx][3] = -1;
88 }
90 void Renderer::reshape(int x, int y)
91 {
92 view_width = x;
93 view_height = y;
94 }
96 void Renderer::update(unsigned int msec)
97 {
98 }