grid.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2014 Google Inc. All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "tango-gl/grid.h"
00018 
00019 namespace tango_gl {
00020 
00021 // Initialize Grid with x and y grid count,
00022 // qx, quantity in x
00023 // qy, quantity in y.
00024 Grid::Grid(float density, int qx, int qy) : Line(1.0f, GL_LINES) {
00025   SetShader();
00026 
00027   // 3 float in 1 vertex, 2 vertices form a line.
00028   // Horizontal line and vertical line forms the grid.
00029   float width = density * qx / 2;
00030   float height = density * qy / 2;
00031 
00032   // Horizontal line.
00033   for (int i = 0; i < (qy + 1); i++) {
00034     vec_vertices_.push_back(glm::vec3(-width, 0.0f, -height + i * density));
00035     vec_vertices_.push_back(glm::vec3(width, 0.0f, -height + i * density));
00036   }
00037 
00038   for (int i = 0; i < (qx + 1); i++) {
00039     vec_vertices_.push_back(glm::vec3(-width + i * density, 0.0f, -height));
00040     vec_vertices_.push_back(glm::vec3(-width + i * density, 0.0f, height));
00041   }
00042 }
00043 }  // namespace tango_gl


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:20