Blame view

stim/visualization/gl_aaboundingbox.h 1.37 KB
9c97e126   David Mayerich   added an axis-ali...
1
2
3
  #ifndef STIM_GL_AABB
  #define STIM_GL_AABB
  
b3a38641   David Mayerich   added the ability...
4
5
  #include <stim/visualization/aaboundingbox.h>
  #include <GL/gl.h>
9c97e126   David Mayerich   added an axis-ali...
6
7
8
9
  
  namespace stim{
  
  template <typename T>
b3a38641   David Mayerich   added the ability...
10
  class gl_aaboundingbox : public aaboundingbox<T>{
9c97e126   David Mayerich   added an axis-ali...
11
12
13
  
  public:
  
2e0f052a   Pavel Govyadinov   minor changes to ...
14
15
16
  	using stim::aaboundingbox<T>::A;
  	using stim::aaboundingbox<T>::B;
  
9c97e126   David Mayerich   added an axis-ali...
17
  	//default constructor
b3a38641   David Mayerich   added the ability...
18
  	gl_aaboundingbox() : stim::aaboundingbox<T>(){}
9c97e126   David Mayerich   added an axis-ali...
19
20
  
  	//constructor takes an AABB
b3a38641   David Mayerich   added the ability...
21
  	gl_aaboundingbox(stim::aaboundingbox<T> b) : stim::aaboundingbox<T>(b){}
9c97e126   David Mayerich   added an axis-ali...
22
23
24
  
  
  	/// 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...
25
  	void glWire(){
9c97e126   David Mayerich   added an axis-ali...
26
  
c184655c   David Mayerich   fixed bugs in AAB...
27
28
  		//front plane (in A[2])
  		glBegin(GL_LINE_LOOP);
9c97e126   David Mayerich   added an axis-ali...
29
30
31
32
  			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...
33
  		glEnd();
9c97e126   David Mayerich   added an axis-ali...
34
  
c184655c   David Mayerich   fixed bugs in AAB...
35
36
  		//back plane (in B[2])
  		glBegin(GL_LINE_LOOP);
9c97e126   David Mayerich   added an axis-ali...
37
38
39
40
  			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...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  		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...
55
56
57
58
59
60
61
62
  	}
  
  
  };		//end stim::gl_aabb
  
  
  };		//end namespace stim
  
2e0f052a   Pavel Govyadinov   minor changes to ...
63
  #endif