hx3d  1
2D/3D Simple Game Framework
star_geometry.cpp
1 /*
2  Star model.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #include "hx3d/graphics/geometries/star_geometry.hpp"
22 
23 namespace hx3d {
24 namespace graphics {
25 namespace geom {
26 
27 StarGeometry::StarGeometry(): Geometry() {
28 
29  setAttribute("Position", std::vector<float> {
30  -0.5f, 0.75f, -0.25f,
31  0.5f, 0.75f, -0.25f,
32  0.75f, 0, -0.25f,
33  0, -0.75f, -0.25f,
34  -0.75f, 0, -0.25f,
35 
36  -0.5f, 0.75f, 0.25f,
37  0.5f, 0.75f, 0.25f,
38  0.75f, 0, 0.25f,
39  0, -0.75f, 0.25f,
40  -0.75f, 0, 0.25f,
41 
42  0, 0, -0.5f,
43  0, 0, 0.5f,
44 
45  1.5f, 0.75f, 0,
46  1.25f, -1.25f, 0,
47  -1.25f, -1.25f, 0,
48  -1.5f, 0.75f, 0,
49  0, 1.75f, 0
50  });
51 
52  setIndices(std::vector<GLushort> {
53  0, 1, 10,
54  1, 2, 10,
55  2, 3, 10,
56  3, 4, 10,
57  4, 0, 10,
58 
59  5, 6, 11,
60  6, 7, 11,
61  7, 8, 11,
62  8, 9, 11,
63  9, 5, 11,
64 
65  6, 12, 7,
66  7, 12, 2,
67  2, 12, 1,
68  1, 12, 6,
69 
70  7, 13, 8,
71  8, 13, 3,
72  3, 13, 2,
73  2, 13, 7,
74 
75  8, 14, 9,
76  9, 14, 4,
77  4, 14, 3,
78  3, 14, 8,
79 
80  9, 15, 5,
81  5, 15, 0,
82  0, 15, 4,
83  4, 15, 9,
84 
85  5, 16, 6,
86  6, 16, 1,
87  1, 16, 0,
88  0, 16, 5
89  });
90 
91  setAttribute("Color", std::vector<float> {
92  1, 0, 0, 1,
93  1, 0, 0, 1,
94  1, 0, 0, 1,
95  1, 0, 0, 1,
96  1, 0, 0, 1,
97 
98  0, 1, 0, 1,
99  0, 1, 0, 1,
100  0, 1, 0, 1,
101  0, 1, 0, 1,
102  0, 1, 0, 1,
103 
104  0, 0, 1, 1,
105  0, 0, 1, 1,
106 
107  1, 1, 0, 1,
108  1, 1, 0, 1,
109  1, 1, 0, 1,
110  1, 1, 0, 1,
111  1, 1, 0, 1
112  });
113 
114  uploadAll();
115 }
116 
117 } /* geom */
118 } /* graphics */
119 } /* hx3d */
hx3d framework namespace
Definition: audio.hpp:26
void setIndices(std::vector< GLushort > values)
Set the indices.
void setAttribute(std::string name, std::vector< float > values)
Set an attribute with values.
void uploadAll()
Upload all the buffers to the GPU.