-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mesh_R.cpp
42 lines (36 loc) · 1.21 KB
/
Mesh_R.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Mesh_R.h"
#include "MeshObject.h"
std::vector<Vertex> Mesh_R::toVertex()
{
float color = 1.0f;
vector<Vertex> vec;
Vertex vertex;
for (uint i = 0; i < buffersSize[vertices_size]; ++i)
{
if (buffersSize[vertices_size] > 0) {
memcpy(&vertex.Position.x, &_vertices[i * 3], sizeof(float));
memcpy(&vertex.Position.y, &_vertices[i * 3 + 1], sizeof(float));
memcpy(&vertex.Position.z, &_vertices[i * 3 + 2], sizeof(float));
}
if (buffersSize[normals_size] > 0) {
memcpy(&vertex.Normal.x, &_normals[i * 3], sizeof(float));
memcpy(&vertex.Normal.y, &_normals[i * 3 + 1], sizeof(float));
memcpy(&vertex.Normal.z, &_normals[i * 3 + 2], sizeof(float));
}
if (buffersSize[vertices_size] > 0) {
memcpy(&vertex.Colors.x, &color, sizeof(float));
memcpy(&vertex.Colors.y, &color, sizeof(float));
memcpy(&vertex.Colors.z, &color, sizeof(float));
}
if (buffersSize[tex_coords_size] > 0) {
memcpy(&vertex.TexCoords.x, &_tex_coords[i * 2], sizeof(float));
memcpy(&vertex.TexCoords.y, &_tex_coords[i * 2 + 1], sizeof(float));
}
else {
memcpy(&vertex.TexCoords.x, &color, sizeof(float));
memcpy(&vertex.TexCoords.y, &color, sizeof(float));
}
vec.push_back(vertex);
}
return vec;
}