mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-08 04:20:14 -05:00
Refactor
This commit is contained in:
@@ -31,8 +31,10 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -353,5 +355,37 @@ void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4
|
||||
shdr.program->deactivate();
|
||||
}
|
||||
|
||||
VertexXYZ convertToXYZ(const Vertex& v) {
|
||||
return VertexXYZ{ v.xyz[0], v.xyz[1], v.xyz[2] };
|
||||
}
|
||||
|
||||
std::vector<VertexXYZ> convert(std::vector<Vertex> v) {
|
||||
std::vector<VertexXYZ> result(v.size());
|
||||
std::transform(v.begin(), v.end(), result.begin(), convertToXYZ);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<Vertex> createRing(int nSegments, float radius, glm::vec4 colors) {
|
||||
const int nVertices = nSegments + 1;
|
||||
std::vector<Vertex> vertices(nVertices);
|
||||
|
||||
const float fsegments = static_cast<float>(nSegments);
|
||||
|
||||
for (int i = 0; i <= nSegments; ++i) {
|
||||
const float fi = static_cast<float>(i);
|
||||
|
||||
const float theta = fi * glm::pi<float>() * 2.0f / fsegments; // 0 -> 2*PI
|
||||
|
||||
const float x = radius * cos(theta);
|
||||
const float y = radius * sin(theta);
|
||||
const float z = 0.0f;
|
||||
|
||||
const float u = cos(theta);
|
||||
const float v = sin(theta);
|
||||
|
||||
vertices[i] = { x, y, z, u, v, colors.r, colors.g, colors.b, colors.a };
|
||||
}
|
||||
return vertices;
|
||||
}
|
||||
|
||||
} // namespace openspace::rendering::helper
|
||||
|
||||
Reference in New Issue
Block a user