File: Grid.cpp

package info (click to toggle)
structure-synth 1.5.0-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,268 kB
  • ctags: 1,966
  • sloc: cpp: 10,209; python: 164; makefile: 71; sh: 15
file content (60 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Grid.h"

#include "SyntopiaCore/Math/Vector3.h"

using namespace SyntopiaCore::Math;

namespace SyntopiaCore {
	namespace GLEngine {

		Grid::Grid(SyntopiaCore::Math::Vector3f base, 
				SyntopiaCore::Math::Vector3f dir1 , 
				 SyntopiaCore::Math::Vector3f dir2, 
				 SyntopiaCore::Math::Vector3f dir3) : base(base), v1(dir1), v2(dir2), v3(dir3) 
		{
			/// Bounding box
			from = base;
			to = base + dir1 + dir2 + dir3;
		};


		Grid::~Grid() { };

		void Grid::draw() const {
			glPushMatrix();
			glTranslatef( base.x(), base.y(), base.z() );
			glLineWidth( 1.0 );

			glDisable (GL_LIGHTING);
			glColor4fv( primaryColor );

			glBegin( GL_LINE_LOOP  );
			Vector3f O(0,0,0);
			vertex(O);
			vertex(v2);
			vertex(v2+v1);
			vertex(v1);
			glEnd();

			glBegin( GL_LINE_LOOP  );
			vertex(v3);
			vertex(v2+v3);
			vertex(v2+v1+v3);
			vertex(v1+v3);
			glEnd();
			
			glBegin( GL_LINES  );
			vertex( v3 );   vertex( O );
			vertex( v2 );   vertex( v2+v3 );
			vertex( v1+v2 );   vertex( v1+v2+v3 );
			vertex( v1 );   vertex( v1+v3 );
			glEnd();

			glEnable (GL_LIGHTING);			

			glPopMatrix();			
		};

	}
}