glviewvol

view 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 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 for(int i=0; i<MAX_CLIP_PLANES; i++) {
16 disable_clipping_plane(i);
17 }
18 }
20 Renderer::~Renderer()
21 {
22 destroy();
23 }
25 bool Renderer::init()
26 {
27 return true;
28 }
30 void Renderer::destroy()
31 {
32 }
34 void Renderer::set_volume(Volume *vol)
35 {
36 this->vol = vol;
37 }
39 Volume *Renderer::get_volume() const
40 {
41 return vol;
42 }
44 Curve &Renderer::transfer_curve(int color)
45 {
46 return xfer[color];
47 }
49 const Curve &Renderer::transfer_curve(int color) const
50 {
51 return xfer[color];
52 }
54 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
55 {
56 float len = sqrt(nx * nx + ny * ny + nz * nz);
57 if(len != 0.0) {
58 nx /= len;
59 ny /= len;
60 nz /= len;
61 }
62 clip_plane[idx][0] = nx;
63 clip_plane[idx][1] = ny;
64 clip_plane[idx][2] = nz;
65 clip_plane[idx][3] = dist;
66 }
68 void Renderer::disable_clipping_plane(int idx)
69 {
70 clip_plane[idx][0] = clip_plane[idx][2] = 0;
71 clip_plane[idx][1] = 1;
72 clip_plane[idx][3] = -1;
73 }
75 void Renderer::reshape(int x, int y)
76 {
77 view_width = x;
78 view_height = y;
79 }
81 void Renderer::update(unsigned int msec)
82 {
83 }