2
2
* drawables.h - Opengl drawable objects header
3
* Copyright (C) 2010, D Haley
3
* Copyright (C) 2011, D Haley
5
5
* This program is free software: you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
19
19
#ifndef DRAWABLES_H
20
20
#define DRAWABLES_H
22
//Do we have the HPMC Real-time on-gpu isosurface library?
23
//Note, this define is repeated in drawables.cpp
24
//to avoid exposing glew.h in this header,
25
//which complains bitterly about header orders.
26
//#define HPMC_GPU_ISOSURFACE
28
22
#include "textures.h"
29
23
#include "cameras.h"
30
24
#include "voxels.h"
99
113
DRAW_SPHERE_BIND_ORIGIN,
100
114
DRAW_SPHERE_BIND_RADIUS,
101
115
DRAW_VECTOR_BIND_ORIENTATION,
116
DRAW_VECTOR_BIND_ORIGIN_ONLY,
102
117
DRAW_VECTOR_BIND_ORIGIN,
118
DRAW_VECTOR_BIND_TARGET,
103
119
DRAW_CYLINDER_BIND_ORIGIN,
104
120
DRAW_CYLINDER_BIND_DIRECTION,
105
121
DRAW_CYLINDER_BIND_RADIUS,
106
122
DRAW_RECT_BIND_TRANSLATE,
107
123
DRAW_RECT_BIND_CORNER_MOVE,
124
DRAW_TEXT_BIND_ORIGIN,
125
//DRAW_TEXT_BIND_TEXTDIR, //FIXME: Implement me for annotation todo.
126
//DRAW_TEXT_BIND_UPDIR,
108
127
DRAW_BIND_ENUM_END
277
301
void setOrigin(const Point3D &);
278
302
//!Sets the location of the poitns
279
303
void setVector(const Point3D &);
280
//!Gets the cylinder axis direction
304
//!Gets the arrow axis direction
281
305
Point3D getVector(){ return vector;};
307
//!Gets the arrow axis direction
308
Point3D getOrigin(){ return origin;};
310
//!Set the arrowhead size
311
void setArrowSize(float size) { arrowSize=size;}
283
313
void getBoundingBox(BoundCube &b) const;
284
316
//!Recompute the internal parameters using the input vector information
285
317
void recomputeParams(const std::vector<Point3D> &vecs,
286
318
const std::vector<float> &scalars, unsigned int mode);
393
430
void getBoundingBox(BoundCube &b) const ;
395
432
//!Recompute the internal parameters using the input vector information
396
void recomputeParams(const vector<Point3D> &vecs, const vector<float> &scalars, unsigned int mode);
433
// i.e. this is used for (eg) mouse interaction
434
void recomputeParams(const vector<Point3D> &vecs,
435
const vector<float> &scalars, unsigned int mode);
663
707
//!Set the text alignment (default is left)
664
708
void setAlignment(unsigned int mode);
710
//Binding parameter recomputation
711
void recomputeParams(const vector<Point3D> &vecs,
712
const vector<float> &scalars, unsigned int mode);
916
973
bool needsDepthSorting() const;
919
#ifdef HPMC_GPU_ISOSURFACE
920
//!A class to use GPU shaders to draw isosurfaces
921
// **********************************************************************
923
// http://www.sintef.no/Projectweb/Heterogeneous-Computing/
924
// Research-Topics/Marching-Cubes-using-Histogram-Pyramids/
927
// High-speed Marching Cubes using Histogram Pyramids
928
// Christopher Dyken, Gernot Ziegler, Christian Theobalt and Hans-Peter Seidel
931
// Original File: texture3d.cpp
933
// Authors: Christopher Dyken <christopher.dyken@sintef.no>
936
// Copyright (C) 2009 by SINTEF. All rights reserved.
938
// This library is free software; you can redistribute it and/or
939
// modify it under the terms of the GNU General Public License
940
// ("GPL") version 2 as published by the Free Software Foundation.
941
// See the file LICENSE.GPL at the root directory of this source
942
// distribution for additional information about the GNU GPL.
944
// SINTEF, Pb 124 Blindern, N-0314 Oslo, Norway
945
// http://www.sintef.no
946
// ********************************************************************/
947
class DrawIsoSurfaceWithShader: public DrawableObj
950
//can we use shaders?
952
//should we draw the thing in wireframe?
958
struct HPMCConstants* hpmc_c;
959
struct HPMCHistoPyramid* hpmc_h;
960
struct HPMCTraversalHandle* hpmc_th_shaded;
969
//On-card volume size
974
struct HPMCTraversalHandle* hpmc_th_flat;
976
//Shader functions, for dynamic compilation
977
std::string shaded_vertex_shader;
978
std::string shaded_fragment_shader;
979
std::string flat_vertex_shader;
984
//Isosurface scalar threshold (true value)
990
//Voxel data Bounding box
993
//Compile shader for video card
994
void compileShader( GLuint shader, const std::string& what );
996
void linkProgram( GLuint program, const std::string& what );
999
DrawIsoSurfaceWithShader();
1000
~DrawIsoSurfaceWithShader();
1002
//initialise dataset and shaders
1003
bool init(const Voxels<float> &v);
1007
//Can the shader run?
1008
bool canRun() const{return shadersOK;};
1010
void setScalarThresh(float thresh) ;
1012
void getBoundingBox(BoundCube &b) const;
1016
977
class DrawAxis : public DrawableObj