Blame view

stim/visualization/gl_aabb.h 1.21 KB
9c97e126   David Mayerich   added an axis-ali...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #ifndef STIM_GL_AABB
  #define STIM_GL_AABB
  
  #include "aabb.h"
  #include "GL/gl.h"
  
  namespace stim{
  
  template <typename T>
  class gl_aabb : public aabb<T>{
  
  public:
  
  	//default constructor
  	gl_aabb() : stim::aabb<T>(){}
  
  	//constructor takes an AABB
  	gl_aabb(stim::aabb<T> b) : stim::aabb<T>(b){}
  
  
  	/// Specifies vertices of the bounding box using CW winding. Use GL_LINE_LOOP for wireframe or GL_QUADS for a solid.
c184655c   David Mayerich   fixed bugs in AAB...
22
  	void glWire(){
9c97e126   David Mayerich   added an axis-ali...
23
  
c184655c   David Mayerich   fixed bugs in AAB...
24
25
  		//front plane (in A[2])
  		glBegin(GL_LINE_LOOP);
9c97e126   David Mayerich   added an axis-ali...
26
27
28
29
  			glVertex3f(A[0], A[1], A[2]);
  			glVertex3f(A[0], B[1], A[2]);
  			glVertex3f(B[0], B[1], A[2]);
  			glVertex3f(B[0], A[1], A[2]);
c184655c   David Mayerich   fixed bugs in AAB...
30
  		glEnd();
9c97e126   David Mayerich   added an axis-ali...
31
  
c184655c   David Mayerich   fixed bugs in AAB...
32
33
  		//back plane (in B[2])
  		glBegin(GL_LINE_LOOP);
9c97e126   David Mayerich   added an axis-ali...
34
35
36
37
  			glVertex3f(B[0], B[1], B[2]);
  			glVertex3f(A[0], B[1], B[2]);
  			glVertex3f(A[0], A[1], B[2]);			
  			glVertex3f(B[0], A[1], B[2]);
c184655c   David Mayerich   fixed bugs in AAB...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  		glEnd();
  
  		//fill out the rest of the lines to connect the two faces
  		glBegin(GL_LINES);
  			glVertex3f(A[0], B[1], A[2]);
  			glVertex3f(A[0], B[1], B[2]);
  			glVertex3f(B[0], B[1], B[2]);
  			glVertex3f(B[0], B[1], A[2]);
  			glVertex3f(B[0], A[1], A[2]);
  			glVertex3f(B[0], A[1], B[2]);
  			glVertex3f(A[0], A[1], B[2]);
  			glVertex3f(A[0], A[1], A[2]);
  		glEnd();
  
9c97e126   David Mayerich   added an axis-ali...
52
53
54
55
56
57
58
59
60
  	}
  
  
  };		//end stim::gl_aabb
  
  
  };		//end namespace stim
  
  #endif