glviewvol

view src/renderer.cc @ 10:89efc666105c

mostly done
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 31 Dec 2014 05:21:47 +0200
parents f22be47a3572
children 773f89037a35
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 }
14 zscale = 1.0;
15 }
17 Renderer::~Renderer()
18 {
19 destroy();
20 }
22 bool Renderer::init()
23 {
24 return true;
25 }
27 void Renderer::destroy()
28 {
29 }
31 void Renderer::set_volume(Volume *vol)
32 {
33 this->vol = vol;
34 }
36 Volume *Renderer::get_volume() const
37 {
38 return vol;
39 }
41 void Renderer::set_zscale(float zs)
42 {
43 zscale = zs;
44 }
46 float Renderer::get_zscale() const
47 {
48 return zscale;
49 }
51 void Renderer::set_transfer_function(TransferFunc *xfer)
52 {
53 this->xfer = xfer;
54 }
56 TransferFunc *Renderer::get_transfer_function() const
57 {
58 return xfer;
59 }
61 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
62 {
63 float len = sqrt(nx * nx + ny * ny + nz * nz);
64 if(len != 0.0) {
65 nx /= len;
66 ny /= len;
67 nz /= len;
68 }
69 clip_plane[idx][0] = nx;
70 clip_plane[idx][1] = ny;
71 clip_plane[idx][2] = nz;
72 clip_plane[idx][3] = dist;
73 }
75 void Renderer::disable_clipping_plane(int idx)
76 {
77 clip_plane[idx][0] = clip_plane[idx][2] = 0;
78 clip_plane[idx][1] = 1;
79 clip_plane[idx][3] = -1;
80 }
82 void Renderer::reshape(int x, int y)
83 {
84 view_width = x;
85 view_height = y;
86 }
88 void Renderer::update(unsigned int msec)
89 {
90 }