hx3d  1
2D/3D Simple Game Framework
origin_geometry.cpp
1 /*
2  Origin models.
3  Used at point (0, 0, 0) to show the origin.
4 
5  Copyright (C) 2015 Denis BOURGE
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  USA
21 */
22 
23 #include "hx3d/graphics/geometries/origin_geometry.hpp"
24 
25 namespace hx3d {
26 namespace graphics {
27 namespace geom {
28 
29 OriginGeometry::OriginGeometry(): Geometry() {
30 
31  setAttribute("Position", std::vector<float> {
32 
33  // Y pyramid (0 - 4)
34  -0.125f, 0.75f, -0.125f,
35  0.125f, 0.75f, -0.125f,
36  0.125f, 0.75f, 0.125f,
37  -0.125f, 0.75f, 0.125f,
38  0, 1, 0,
39 
40  // Y base (5 - 12)
41  -0.0625f, 0.0625f, -0.0625f,
42  0.0625f, 0.0625f, -0.0625f,
43  0.0625f, 0.0625f, 0.0625f,
44  -0.0625f, 0.0625f, 0.0625f,
45  -0.0625f, 0.75f, -0.0625f,
46  0.0625f, 0.75f, -0.0625f,
47  0.0625f, 0.75f, 0.0625f,
48  -0.0625f, 0.75f, 0.0625f,
49 
50  // X pyramid (13 - 17)
51  0.75f, -0.125f, -0.125f,
52  0.75f, -0.125f, 0.125f,
53  0.75f, 0.125f, 0.125f,
54  0.75f, 0.125f, -0.125f,
55  1, 0, 0,
56 
57  // X base (18 - 25)
58  0.0625f, -0.0625f, -0.0625f,
59  0.0625f, -0.0625f, 0.0625f,
60  0.0625f, 0.0625f, 0.0625f,
61  0.0625f, 0.0625f, -0.0625f,
62  0.75f, -0.0625f, -0.0625f,
63  0.75f, -0.0625f, 0.0625f,
64  0.75f, 0.0625f, 0.0625f,
65  0.75f, 0.0625f, -0.0625f,
66 
67  // Z pyramid (26 - 30)
68  -0.125f, -0.125f, -0.75f,
69  0.125f, -0.125f, -0.75f,
70  0.125f, 0.125f, -0.75f,
71  -0.125f, 0.125f, -0.75f,
72  0, 0, -1,
73 
74  // Z base (31 - 38)
75  -0.0625f, -0.0625f, -0.0625f,
76  0.0625f, -0.0625f, -0.0625f,
77  0.0625f, 0.0625f, -0.0625f,
78  -0.0625f, 0.0625f, -0.0625f,
79  -0.0625f, -0.0625f, -0.75f,
80  0.0625f, -0.0625f, -0.75f,
81  0.0625f, 0.0625f, -0.75f,
82  -0.0625f, 0.0625f, -0.75f,
83 
84  // Last point (39)
85  -0.0625f, -0.0625f, 0.0625f
86  });
87 
88  setIndices(std::vector<GLushort> {
89 
90  // Y pyramid
91  0, 1, 2,
92  0, 2, 3,
93  0, 4, 1,
94  1, 4, 2,
95  2, 4, 3,
96  3, 4, 0,
97 
98  // Y base
99  5, 6, 7,
100  5, 7, 8,
101  5, 6, 10,
102  5, 10, 9,
103  6, 7, 11,
104  6, 11, 10,
105  7, 8, 12,
106  7, 12, 11,
107  8, 9, 12,
108  8, 9, 5,
109  9, 10, 11,
110  9, 11, 12,
111 
112  // X pyramid
113  13, 14, 15,
114  13, 15, 16,
115  13, 17, 14,
116  14, 17, 15,
117  15, 17, 16,
118  16, 17, 13,
119 
120  // X base
121  18, 19, 20,
122  18, 20, 21,
123  18, 19, 23,
124  18, 23, 22,
125  19, 20, 24,
126  19, 24, 23,
127  20, 21, 25,
128  20, 25, 24,
129  21, 22, 25,
130  21, 22, 18,
131  22, 23, 24,
132  22, 24, 25,
133 
134  // Z pyramid
135  26, 27, 28,
136  26, 28, 29,
137  26, 30, 27,
138  27, 30, 28,
139  28, 30, 29,
140  29, 30, 26,
141 
142  // Z base
143  31, 32, 33,
144  31, 33, 34,
145  31, 32, 36,
146  31, 36, 35,
147  32, 33, 37,
148  32, 37, 36,
149  33, 34, 38,
150  33, 38, 37,
151  34, 35, 38,
152  34, 35, 31,
153  35, 36, 37,
154  35, 37, 38,
155 
156  // Last 2 faces
157  39, 31, 34,
158  39, 34, 8,
159  39, 19, 20,
160  39, 20, 8
161  });
162 
163  setAttribute("Color", std::vector<float> {
164  1, 0, 0, 1,
165  1, 0, 0, 1,
166  1, 0, 0, 1,
167  1, 0, 0, 1,
168  1, 0, 0, 1,
169 
170  1, 0, 0, 1,
171  1, 0, 0, 1,
172  1, 0, 0, 1,
173  1, 0, 0, 1,
174  1, 0, 0, 1,
175  1, 0, 0, 1,
176  1, 0, 0, 1,
177  1, 0, 0, 1,
178 
179  0, 1, 0, 1,
180  0, 1, 0, 1,
181  0, 1, 0, 1,
182  0, 1, 0, 1,
183  0, 1, 0, 1,
184 
185  0, 1, 0, 1,
186  0, 1, 0, 1,
187  0, 1, 0, 1,
188  0, 1, 0, 1,
189  0, 1, 0, 1,
190  0, 1, 0, 1,
191  0, 1, 0, 1,
192  0, 1, 0, 1,
193 
194  0, 0, 1, 1,
195  0, 0, 1, 1,
196  0, 0, 1, 1,
197  0, 0, 1, 1,
198  0, 0, 1, 1,
199 
200  0, 0, 1, 1,
201  0, 0, 1, 1,
202  0, 0, 1, 1,
203  0, 0, 1, 1,
204  0, 0, 1, 1,
205  0, 0, 1, 1,
206  0, 0, 1, 1,
207  0, 0, 1, 1,
208 
209  1, 1, 1, 1
210  });
211 
212  uploadAll();
213 }
214 
215 } /* geom */
216 } /* graphics */
217 } /* 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.