1 #include "shapes.h"
2 
3 // Billboard
4 //============================================================================
rect(float _x,float _y,float _w,float _h)5 Mesh rect (float _x, float _y, float _w, float _h) {
6     float x = _x-1.0f;
7     float y = _y-1.0f;
8     float w = _w*2.0f;
9     float h = _h*2.0f;
10 
11     Mesh mesh;
12     mesh.addVertex(glm::vec3(x, y, 0.0));
13     mesh.addColor(glm::vec4(1.0));
14     mesh.addNormal(glm::vec3(0.0, 0.0, 1.0));
15     mesh.addTexCoord(glm::vec2(0.0, 0.0));
16 
17     mesh.addVertex(glm::vec3(x+w, y, 0.0));
18     mesh.addColor(glm::vec4(1.0));
19     mesh.addNormal(glm::vec3(0.0, 0.0, 1.0));
20     mesh.addTexCoord(glm::vec2(1.0, 0.0));
21 
22     mesh.addVertex(glm::vec3(x+w, y+h, 0.0));
23     mesh.addColor(glm::vec4(1.0));
24     mesh.addNormal(glm::vec3(0.0, 0.0, 1.0));
25     mesh.addTexCoord(glm::vec2(1.0, 1.0));
26 
27     mesh.addVertex(glm::vec3(x, y+h, 0.0));
28     mesh.addColor(glm::vec4(1.0));
29     mesh.addNormal(glm::vec3(0.0, 0.0, 1.0));
30     mesh.addTexCoord(glm::vec2(0.0, 1.0));
31 
32     mesh.addIndex(0);   mesh.addIndex(1);   mesh.addIndex(2);
33     mesh.addIndex(2);   mesh.addIndex(3);   mesh.addIndex(0);
34 
35     return mesh;
36 }
37