glviewvol
annotate src/renderer.cc @ 12:773f89037a35
added copyright headers
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 31 Dec 2014 07:57:04 +0200 |
parents | 89efc666105c |
children |
rev | line source |
---|---|
nuclear@12 | 1 /* |
nuclear@12 | 2 glviewvol is an OpenGL 3D volume data viewer |
nuclear@12 | 3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org> |
nuclear@12 | 4 |
nuclear@12 | 5 This program is free software: you can redistribute it and/or modify |
nuclear@12 | 6 it under the terms of the GNU General Public License as published by |
nuclear@12 | 7 the Free Software Foundation, either version 3 of the License, or |
nuclear@12 | 8 (at your option) any later version. |
nuclear@12 | 9 |
nuclear@12 | 10 This program is distributed in the hope that it will be useful, |
nuclear@12 | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
nuclear@12 | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
nuclear@12 | 13 GNU General Public License for more details. |
nuclear@12 | 14 |
nuclear@12 | 15 You should have received a copy of the GNU General Public License |
nuclear@12 | 16 along with this program. If not, see <http://www.gnu.org/licenses/>. |
nuclear@12 | 17 */ |
nuclear@4 | 18 #include <math.h> |
nuclear@0 | 19 #include "renderer.h" |
nuclear@0 | 20 |
nuclear@0 | 21 Renderer::Renderer() |
nuclear@0 | 22 { |
nuclear@0 | 23 vol = 0; |
nuclear@0 | 24 view_width = 512; |
nuclear@0 | 25 view_height = 512; |
nuclear@4 | 26 |
nuclear@4 | 27 for(int i=0; i<MAX_CLIP_PLANES; i++) { |
nuclear@4 | 28 disable_clipping_plane(i); |
nuclear@4 | 29 } |
nuclear@10 | 30 |
nuclear@10 | 31 zscale = 1.0; |
nuclear@0 | 32 } |
nuclear@0 | 33 |
nuclear@0 | 34 Renderer::~Renderer() |
nuclear@0 | 35 { |
nuclear@0 | 36 destroy(); |
nuclear@0 | 37 } |
nuclear@0 | 38 |
nuclear@0 | 39 bool Renderer::init() |
nuclear@0 | 40 { |
nuclear@0 | 41 return true; |
nuclear@0 | 42 } |
nuclear@0 | 43 |
nuclear@0 | 44 void Renderer::destroy() |
nuclear@0 | 45 { |
nuclear@0 | 46 } |
nuclear@0 | 47 |
nuclear@0 | 48 void Renderer::set_volume(Volume *vol) |
nuclear@0 | 49 { |
nuclear@0 | 50 this->vol = vol; |
nuclear@0 | 51 } |
nuclear@0 | 52 |
nuclear@0 | 53 Volume *Renderer::get_volume() const |
nuclear@0 | 54 { |
nuclear@0 | 55 return vol; |
nuclear@0 | 56 } |
nuclear@0 | 57 |
nuclear@10 | 58 void Renderer::set_zscale(float zs) |
nuclear@10 | 59 { |
nuclear@10 | 60 zscale = zs; |
nuclear@10 | 61 } |
nuclear@10 | 62 |
nuclear@10 | 63 float Renderer::get_zscale() const |
nuclear@10 | 64 { |
nuclear@10 | 65 return zscale; |
nuclear@10 | 66 } |
nuclear@10 | 67 |
nuclear@6 | 68 void Renderer::set_transfer_function(TransferFunc *xfer) |
nuclear@4 | 69 { |
nuclear@6 | 70 this->xfer = xfer; |
nuclear@4 | 71 } |
nuclear@4 | 72 |
nuclear@6 | 73 TransferFunc *Renderer::get_transfer_function() const |
nuclear@4 | 74 { |
nuclear@6 | 75 return xfer; |
nuclear@5 | 76 } |
nuclear@5 | 77 |
nuclear@4 | 78 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist) |
nuclear@4 | 79 { |
nuclear@4 | 80 float len = sqrt(nx * nx + ny * ny + nz * nz); |
nuclear@4 | 81 if(len != 0.0) { |
nuclear@4 | 82 nx /= len; |
nuclear@4 | 83 ny /= len; |
nuclear@4 | 84 nz /= len; |
nuclear@4 | 85 } |
nuclear@4 | 86 clip_plane[idx][0] = nx; |
nuclear@4 | 87 clip_plane[idx][1] = ny; |
nuclear@4 | 88 clip_plane[idx][2] = nz; |
nuclear@4 | 89 clip_plane[idx][3] = dist; |
nuclear@4 | 90 } |
nuclear@4 | 91 |
nuclear@4 | 92 void Renderer::disable_clipping_plane(int idx) |
nuclear@4 | 93 { |
nuclear@4 | 94 clip_plane[idx][0] = clip_plane[idx][2] = 0; |
nuclear@4 | 95 clip_plane[idx][1] = 1; |
nuclear@4 | 96 clip_plane[idx][3] = -1; |
nuclear@4 | 97 } |
nuclear@4 | 98 |
nuclear@0 | 99 void Renderer::reshape(int x, int y) |
nuclear@0 | 100 { |
nuclear@0 | 101 view_width = x; |
nuclear@0 | 102 view_height = y; |
nuclear@0 | 103 } |
nuclear@0 | 104 |
nuclear@0 | 105 void Renderer::update(unsigned int msec) |
nuclear@0 | 106 { |
nuclear@0 | 107 } |