glviewvol

annotate 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
rev   line source
nuclear@4 1 #include <math.h>
nuclear@0 2 #include "renderer.h"
nuclear@0 3
nuclear@0 4 Renderer::Renderer()
nuclear@0 5 {
nuclear@0 6 vol = 0;
nuclear@0 7 view_width = 512;
nuclear@0 8 view_height = 512;
nuclear@4 9
nuclear@4 10 for(int i=0; i<MAX_CLIP_PLANES; i++) {
nuclear@4 11 disable_clipping_plane(i);
nuclear@4 12 }
nuclear@0 13 }
nuclear@0 14
nuclear@0 15 Renderer::~Renderer()
nuclear@0 16 {
nuclear@0 17 destroy();
nuclear@0 18 }
nuclear@0 19
nuclear@0 20 bool Renderer::init()
nuclear@0 21 {
nuclear@0 22 return true;
nuclear@0 23 }
nuclear@0 24
nuclear@0 25 void Renderer::destroy()
nuclear@0 26 {
nuclear@0 27 }
nuclear@0 28
nuclear@0 29 void Renderer::set_volume(Volume *vol)
nuclear@0 30 {
nuclear@0 31 this->vol = vol;
nuclear@0 32 }
nuclear@0 33
nuclear@0 34 Volume *Renderer::get_volume() const
nuclear@0 35 {
nuclear@0 36 return vol;
nuclear@0 37 }
nuclear@0 38
nuclear@6 39 void Renderer::set_transfer_function(TransferFunc *xfer)
nuclear@4 40 {
nuclear@6 41 this->xfer = xfer;
nuclear@4 42 }
nuclear@4 43
nuclear@6 44 TransferFunc *Renderer::get_transfer_function() const
nuclear@4 45 {
nuclear@6 46 return xfer;
nuclear@5 47 }
nuclear@5 48
nuclear@4 49 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
nuclear@4 50 {
nuclear@4 51 float len = sqrt(nx * nx + ny * ny + nz * nz);
nuclear@4 52 if(len != 0.0) {
nuclear@4 53 nx /= len;
nuclear@4 54 ny /= len;
nuclear@4 55 nz /= len;
nuclear@4 56 }
nuclear@4 57 clip_plane[idx][0] = nx;
nuclear@4 58 clip_plane[idx][1] = ny;
nuclear@4 59 clip_plane[idx][2] = nz;
nuclear@4 60 clip_plane[idx][3] = dist;
nuclear@4 61 }
nuclear@4 62
nuclear@4 63 void Renderer::disable_clipping_plane(int idx)
nuclear@4 64 {
nuclear@4 65 clip_plane[idx][0] = clip_plane[idx][2] = 0;
nuclear@4 66 clip_plane[idx][1] = 1;
nuclear@4 67 clip_plane[idx][3] = -1;
nuclear@4 68 }
nuclear@4 69
nuclear@0 70 void Renderer::reshape(int x, int y)
nuclear@0 71 {
nuclear@0 72 view_width = x;
nuclear@0 73 view_height = y;
nuclear@0 74 }
nuclear@0 75
nuclear@0 76 void Renderer::update(unsigned int msec)
nuclear@0 77 {
nuclear@0 78 }