1#include "ProfileGenerator.h"
7 namespace ProfileGenerator
10 generateConnector(std::vector<float> & depths,
11 std::vector<glm::vec2> & profile,
12 const float startDepth,
14 const float startRadius,
15 const float outerRadius,
16 const float endRadius,
17 const float depthAnchor)
19 profile.push_back(glm::vec2(startRadius, startDepth - depthAnchor)); depths.push_back(depthAnchor);
20 profile.push_back(glm::vec2(outerRadius, startDepth - depthAnchor)); depths.push_back(depthAnchor);
22 profile.push_back(glm::vec2(outerRadius, endDepth - depthAnchor)); depths.push_back(depthAnchor);
23 profile.push_back(glm::vec2(endRadius, endDepth - depthAnchor)); depths.push_back(depthAnchor);
27 generateCurvedProfile(std::vector<float> & depths,
28 std::vector<glm::vec2> & profile,
29 const float startDepth,
31 const float startRadius,
32 const float endRadius,
33 const float numSections)
35 float scaledOuterRadius = startRadius;
36 float flexStart = startDepth;
37 float flexBulgeScaleRange = endRadius - startRadius;
38 float flexBulgeLength = endDepth - startDepth;
40 for (
int i = 0; i <= numSections; ++i) {
41 const float increment = (float) i / (
float) numSections;
42 const float value = increment < 0.5 ? increment * increment * 2 : 1 - (1 - increment) * (1 - increment) * 2;
44 profile.push_back(glm::vec2(scaledOuterRadius + flexBulgeScaleRange * value, 0)); depths.push_back(flexStart + flexBulgeLength * increment);
49 insertPoints(std::vector<float> & depths,
50 std::vector<glm::vec2> & profile,
52 const float startDepth,
54 std::vector<float>::const_iterator it,
55 std::vector<float>::const_iterator end)
57 while (it != end && *it <= startDepth) {
61 while (it != end && *it < endDepth) {
62 profile.push_back(glm::vec2(radius, 0)); depths.push_back(*it++);
67 insertPointsReverse(std::vector<float> & depths,
68 std::vector<glm::vec2> & profile,
70 const float startDepth,
72 std::vector<float>::const_iterator it)
76 while (*it >= endDepth) {
80 while (*it > startDepth) {
81 profile.push_back(glm::vec2(radius, 0)); depths.push_back(*it--);
89 reverseProfile(std::vector<float> & depths, std::vector<glm::vec2> & profile,
const float startDepth,
const float endDepth)
91 for (
size_t i = 0; i < profile.size(); ++i) {
92 depths[i] = endDepth - (depths[i] - startDepth);
95 profile[i][1] = -profile[i][1];
98 std::reverse(depths.begin(), depths.end());
99 std::reverse(profile.begin(), profile.end());
@ Geometry
Store entity vector fields (vector<vec3>, vector<vec2>, vector<int>, vector<float>).
void reverseProfile(std::vector< float > &depths, std::vector< glm::vec2 > &profile, const float startDepth, const float endDepth)
Reverses the given profile.
Contains all Cogs related functionality.