grid.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "tango-gl/grid.h"
18 
19 namespace tango_gl {
20 
21 // Initialize Grid with x and y grid count,
22 // qx, quantity in x
23 // qy, quantity in y.
24 Grid::Grid(float density, int qx, int qy) : Line(1.0f, GL_LINES) {
25  SetShader();
26 
27  // 3 float in 1 vertex, 2 vertices form a line.
28  // Horizontal line and vertical line forms the grid.
29  float width = density * qx / 2;
30  float height = density * qy / 2;
31 
32  // Horizontal line.
33  for (int i = 0; i < (qy + 1); i++) {
34  for (int j = 0; j < (qx + 1); j++) {
35  vec_vertices_.push_back(glm::vec3(-width + j*density, 0.0f, -height + i * density));
36  vec_vertices_.push_back(glm::vec3(-width+ + (j+1)*density, 0.0f, -height + i * density));
37  }
38  }
39 
40  for (int i = 0; i < (qx + 1); i++) {
41  for (int j = 0; j < (qy + 1); j++) {
42  vec_vertices_.push_back(glm::vec3(-width + i * density, 0.0f, -height + j*density));
43  vec_vertices_.push_back(glm::vec3(-width + i * density, 0.0f, -height + (j+1)*density));
44  }
45  }
46 }
47 } // namespace tango_gl
tango_gl::Line
Definition: line.h:23
grid.h
glm::detail::tvec3
Definition: type_mat.hpp:37
tango_gl::Grid::Grid
Grid(float density=1.0f, int qx=50, int qy=50)
Definition: grid.cpp:24
j
std::ptrdiff_t j
density
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
tango_gl::DrawableObject::SetShader
void SetShader()
Definition: drawable_object.cpp:22
tango_gl
Definition: axis.cpp:20
tango_gl::Line::vec_vertices_
std::vector< glm::vec3 > vec_vertices_
Definition: line.h:34
i
int i


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11