GroundPlane.cpp
Go to the documentation of this file.
1 
28  /*
29  * GroundPlane.cpp
30  *
31  * Created on: 27.08.2008
32  * Author: Thomas Wiemann
33  */
34 
36 
37 namespace lvr2
38 {
39 
41  m_listIndex = -1;
42  drawGrid(10, 100);
43 }
44 
45 GroundPlane::GroundPlane(int increment, int count) : Renderable("Ground Plane"){
46  m_listIndex = -1;
47  drawGrid(increment, count);
48 }
49 
51 
52 }
53 
54 void GroundPlane::drawGrid(int increment, int count){
55 
56  m_listIndex = glGenLists(1);
57 
58  glNewList(m_listIndex, GL_COMPILE);
59  glPushMatrix();
60  glPushAttrib ( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_LINE_BIT ); // save colors and polygon offsets state to later restore.
61  glRotatef(-90, 1.0, 0.0, 0.0);
62  glBegin ( GL_LINES );
63  glEnable ( GL_POLYGON_OFFSET_LINE );
64  glEnable ( GL_LINE_SMOOTH );
65  glPolygonOffset ( .5,.5 );
66  glColor3f ( 0.8f, 0.8f, 1.0f );
67  glLineWidth ( 1 );
68  for ( int temp = -count; temp <= count; temp +=1 )
69  {
70  glVertex3i ( temp * increment, -increment * count, 0 );
71  glVertex3i ( temp * increment, increment * count, 0 );
72  glVertex3i ( -increment * count, temp * increment, 0 );
73  glVertex3i ( increment * count, temp * increment, 0 );
74  }
75  glLineWidth ( 1.5 );
76  glColor3f ( 0.8f, 0.8f, 0.8f);
77  for ( int temp = -count; temp <= count; temp +=5 )
78  {
79  glVertex3i ( temp * increment, -increment * count, 0 );
80  glVertex3i ( temp * increment, increment * count, 0 );
81  glVertex3i ( -increment*count, temp * increment, 0 );
82  glVertex3i ( increment*count, temp * increment, 0 );
83  }
84  glDisable ( GL_POLYGON_OFFSET_LINE );
85  glEnd();
86  glLineWidth ( 1 );
87  glDisable ( GL_LINE_SMOOTH );
88  glPopMatrix();
89  glPopAttrib();
90  glEndList();
91 
92 }
93 
95  if(m_visible){
96  glDisable(GL_LIGHTING);
97  glCallList(m_listIndex);
98  glEnable(GL_LIGHTING);
99  }
100 
101 }
102 
104  //To Do: Write transformation code
105 }
106 
107 } // namespace lvr2
virtual void render()
Definition: GroundPlane.cpp:94
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
void drawGrid(int increment, int count)
Definition: GroundPlane.cpp:54
virtual void transform()
Definition: Renderable.cpp:373
virtual ~GroundPlane()
Definition: GroundPlane.cpp:50


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06