Feature/arrow renderable (#2219)

* Create a RenderableNodeLine example asset

* First version of node direction hint renderable (arrow)

* Add possibility to set length as a multiplier of the bounding sphere

* Draw arrow cylinder using index array

* Update exponents and min max values for lengths

* Draw arrow head

* Only update arrow geometry when positions change

* Add some properties to control visuals of arrow

* Implement invert option

* Add normals and shading

* Set arrow head size by length percentage instead of angle

* Add bottom circle to cone

* Cleanup and update examples

* Remove non-existing property from example asset

* Fix vertices not updating if anchor node was changed

And some missing updates on property change

* Start cleaning up some shape rendering helper functions

* Cleanup code and move cylinder function to helper class

* Refactor cylinder creation code (fewer loops over same vector)

* Update transformations to correctly scale and place arrow

* Add the cone to make the arrowhead

* Update faulty triangle normals

* Add property visibilities

* Rename NodeDirectionHint to NodeArrow

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>


---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Emma Broman
2023-09-11 11:04:46 +02:00
committed by GitHub
parent 7bfedbdf12
commit d77836d910
11 changed files with 1176 additions and 58 deletions

View File

@@ -89,6 +89,22 @@ struct VertexObjects {
int nElements = 64;
} sphere;
struct {
GLuint vao = 0;
GLuint vbo = 0;
GLuint ibo = 0;
int nElements = 64;
} cylinder;
struct {
GLuint vao = 0;
GLuint vbo = 0;
GLuint ibo = 0;
int nElements = 64;
} cone;
struct {
GLuint vao = 0;
} empty;
@@ -119,6 +135,12 @@ struct VertexXYZNormal {
GLfloat normal[3];
};
template <typename V>
struct VertexIndexListCombo {
std::vector<V> vertices;
std::vector<GLushort> indices;
};
VertexXYZ convertToXYZ(const Vertex& v);
std::vector<VertexXYZ> convert(std::vector<Vertex> v);
@@ -126,9 +148,17 @@ std::vector<VertexXYZ> convert(std::vector<Vertex> v);
std::vector<Vertex> createRing(int nSegments, float radius,
glm::vec4 colors = glm::vec4(1.f));
std::pair<std::vector<Vertex>, std::vector<GLushort>>
std::vector<VertexXYZ> createRingXYZ(int nSegments, float radius);
VertexIndexListCombo<Vertex>
createSphere(int nSegments, glm::vec3 radii, glm::vec4 colors = glm::vec4(1.f));
VertexIndexListCombo<VertexXYZNormal> createCylinder(unsigned int nSegments,
float radius, float height);
VertexIndexListCombo<VertexXYZNormal> createCone(unsigned int nSegments, float radius,
float height);
/**
* Data structure that can be used for rendering using multiple light directions
*/