kick
|
00001 // 00002 // Created by Morten Nobel-Jørgensen on 25/08/14. 00003 // 00004 00005 00006 00007 #pragma once 00008 00009 #include "component.h" 00010 #include "kick/material/material.h" 00011 #include "component_renderable.h" 00012 #include <vector> 00013 00014 namespace kick { 00015 class Transform; 00016 class Mesh; 00017 class GameObject; 00018 00019 class LineRenderer : public ComponentRenderable { 00020 public: 00021 LineRenderer(GameObject *gameObject); 00022 ~LineRenderer(); 00023 00024 virtual void render(EngineUniforms *engineUniforms, Material* replacementMaterial = nullptr) override; 00025 00026 std::vector<glm::vec3> const &points() const; 00027 std::vector<GLushort> const & indices() const; 00028 00029 // meshType should be MeshType::Lines, MeshType::LineLoop, MeshType::LineStrip 00030 void setPoints(const std::vector<glm::vec3> &points, MeshType meshType = MeshType::Lines, const std::vector<GLushort> &indices = std::vector<GLushort>{}); 00031 00032 // set the material 00033 void setMaterial(Material *material); 00034 // get material 00035 Material*material(); 00036 00037 virtual int renderOrder(); 00038 00039 bool smoothLine() const; 00040 00041 void setSmoothLine(bool smoothLine); 00042 00043 private: 00044 void rebuildMesh(); 00045 MeshType mMeshType; 00046 std::vector<glm::vec3> mPoints; 00047 std::vector<GLushort> mIndices; 00048 std::shared_ptr<Mesh> mMesh; 00049 std::shared_ptr<Transform> mTransform; 00050 Material* mMaterial; 00051 bool mSmoothLine = true; 00052 }; 00053 } 00054 00055 00056