glviewvol
view src/renderer.cc @ 6:f22be47a3572
moved to TransferFuncs completely
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 30 Dec 2014 06:22:54 +0200 |
parents | 5417c25cb238 |
children | 89efc666105c |
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<MAX_CLIP_PLANES; i++) {
11 disable_clipping_plane(i);
12 }
13 }
15 Renderer::~Renderer()
16 {
17 destroy();
18 }
20 bool Renderer::init()
21 {
22 return true;
23 }
25 void Renderer::destroy()
26 {
27 }
29 void Renderer::set_volume(Volume *vol)
30 {
31 this->vol = vol;
32 }
34 Volume *Renderer::get_volume() const
35 {
36 return vol;
37 }
39 void Renderer::set_transfer_function(TransferFunc *xfer)
40 {
41 this->xfer = xfer;
42 }
44 TransferFunc *Renderer::get_transfer_function() const
45 {
46 return xfer;
47 }
49 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
50 {
51 float len = sqrt(nx * nx + ny * ny + nz * nz);
52 if(len != 0.0) {
53 nx /= len;
54 ny /= len;
55 nz /= len;
56 }
57 clip_plane[idx][0] = nx;
58 clip_plane[idx][1] = ny;
59 clip_plane[idx][2] = nz;
60 clip_plane[idx][3] = dist;
61 }
63 void Renderer::disable_clipping_plane(int idx)
64 {
65 clip_plane[idx][0] = clip_plane[idx][2] = 0;
66 clip_plane[idx][1] = 1;
67 clip_plane[idx][3] = -1;
68 }
70 void Renderer::reshape(int x, int y)
71 {
72 view_width = x;
73 view_height = y;
74 }
76 void Renderer::update(unsigned int msec)
77 {
78 }