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 #ifndef TANGO_GL_BAND_H_ 00018 #define TANGO_GL_BAND_H_ 00019 00020 #include <stdlib.h> 00021 #include <vector> 00022 00023 #include "tango-gl/drawable_object.h" 00024 00025 namespace tango_gl { 00026 class Band : public DrawableObject { 00027 public: 00028 enum BandMode { 00029 kNormal = 0, 00030 kKeepLeft = 1, 00031 kKeepRight = 2 00032 }; 00033 00034 Band(const unsigned int max_legnth); 00035 00036 void SetWidth(const float width); 00037 // Render a Band with arrow head, pass in the mode for rendering, 00038 // kKeepLeft is left turn, kKeepRight is right turn, 00039 // when making a turn, vertices only get updated in one side to avoid overlapping. 00040 void UpdateVertexArray(const glm::mat4 m, BandMode mode); 00041 void UpdateVertexArray(const glm::mat4 m); 00042 void SetVertexArray(const std::vector<glm::vec3>& v, const glm::vec3& up); 00043 void ClearVertexArray(); 00044 void Render(const glm::mat4& projection_mat, const glm::mat4& view_mat) const; 00045 00046 private: 00047 float band_width_; 00048 unsigned int max_length_; 00049 std::vector<glm::vec3> vertices_v_; 00050 // Current band head's left and right position in world frame. 00051 glm::vec3 pivot_left; 00052 glm::vec3 pivot_right; 00053 }; 00054 } // namespace tango_gl 00055 #endif // TANGO_GL_BAND_H_