Cleanup
This commit is contained in:
parent
c613d00511
commit
bdef3aca47
BIN
assets/pimgpsh.jpg
Executable file
BIN
assets/pimgpsh.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
@ -54,8 +54,8 @@ void TMyApplication::InnerInit()
|
|||||||
|
|
||||||
#ifdef TARGET_WIN32
|
#ifdef TARGET_WIN32
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
ST::PathToResources = "resources/";
|
//ST::PathToResources = "resources/";
|
||||||
//ST::PathToResources = "../../../assets/";
|
ST::PathToResources = "../../../assets/";
|
||||||
#else
|
#else
|
||||||
ST::PathToResources = "../../../assets/";
|
ST::PathToResources = "../../../assets/";
|
||||||
#endif
|
#endif
|
||||||
@ -134,60 +134,61 @@ void TMyApplication::InnerInit()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto findPlaneBasis = [] (const Vector3f &normal) {
|
||||||
|
std::vector<Vector3f> result;
|
||||||
|
|
||||||
|
Vector3f e0 = Vector3f(1, 0, -normal.x() / normal.z()).normalized();
|
||||||
|
Vector3f e1 = Vector3f(0, 1, -normal.y() / normal.z());
|
||||||
|
e1 = (e1 - (e1.dot(e0) / e0.dot(e0)) * e0).normalized();
|
||||||
|
|
||||||
|
result.push_back(e0);
|
||||||
|
result.push_back(e1);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
//resolution of linesAll.png
|
|
||||||
float const texW = 900;
|
|
||||||
float const texH = 900;
|
|
||||||
|
|
||||||
float const step = 12;
|
|
||||||
float const thick = 10;
|
|
||||||
|
|
||||||
|
|
||||||
float const R = 5;
|
float const R = 5;
|
||||||
float const r = 6;
|
float const r = 6;
|
||||||
size_t const threadsCount = 5;
|
size_t const threadsCount = 5;
|
||||||
size_t const verticesCount = 6;
|
size_t const edgesCount = 6;
|
||||||
//float const angle = pi / 18;
|
|
||||||
float const angle = pi / 6;
|
float const angle = pi / 6;
|
||||||
size_t const iterationsCount = 20;
|
size_t const iterationsCount = 20;
|
||||||
auto g = [this, R, r, threadsCount, verticesCount, angle, iterationsCount, texW, texH, thick, H, W] (const Vector3f &start, const Vector3f &end) {
|
Vector3f up(0, 1, 0);
|
||||||
|
auto g = [this, findPlaneBasis, R, r, threadsCount, edgesCount, up, angle, iterationsCount] (const Vector3f &start, const Vector3f &end) {
|
||||||
Vector3f translate = (end - start) / iterationsCount;
|
Vector3f translate = (end - start) / iterationsCount;
|
||||||
|
auto e = findPlaneBasis(translate);
|
||||||
|
|
||||||
Vector3f e0 = Vector3f(1, 0, -translate.x() / translate.z()).normalized();
|
// create thread edges
|
||||||
Vector3f e1 = Vector3f(0, 1, -translate.y() / translate.z());
|
|
||||||
e1 = (e1 - (e1.dot(e0) / e0.dot(e0)) * e0).normalized();
|
|
||||||
|
|
||||||
std::vector<Vector3f> threadCenters;
|
std::vector<Vector3f> threadCenters;
|
||||||
std::vector<std::vector<Vector4f>> threads;
|
std::vector<std::vector<Vector4f>> threads;
|
||||||
for(auto i = 0; i < threadsCount; i++) {
|
for(auto i = 0; i < threadsCount; i++) {
|
||||||
std::vector<Vector4f> vertices;
|
std::vector<Vector4f> edges;
|
||||||
Vector3f threadCenter = R * (e0 * cosf(i * 2 * pi / threadsCount) + e1 * sinf(i * 2 * pi / threadsCount));
|
Vector3f threadCenter = R * (e[0] * cosf(i * 2 * pi / threadsCount) + e[1] * sinf(i * 2 * pi / threadsCount));
|
||||||
threadCenters.push_back(threadCenter);
|
threadCenters.push_back(threadCenter);
|
||||||
|
|
||||||
for(auto j = 0; j < verticesCount; j++) {
|
for(auto j = 0; j < edgesCount; j++) {
|
||||||
auto verticeCenter = threadCenter + r * (e0 * cosf(j * 2 * pi / verticesCount) + e1 * sinf(j * 2 * pi / verticesCount));
|
auto verticeCenter = threadCenter + r * (e[0] * cosf(j * 2 * pi / edgesCount) + e[1] * sinf(j * 2 * pi / edgesCount));
|
||||||
vertices.push_back(Vector4f(verticeCenter.x(), verticeCenter.y(), verticeCenter.z(), 1));
|
edges.push_back(Vector4f(verticeCenter.x(), verticeCenter.y(), verticeCenter.z(), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
threads.push_back(vertices);
|
threads.push_back(edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto transform = Translation3f(translate) * AngleAxis<float>(angle, translate.normalized());
|
auto matrix = (Translation3f(translate) * AngleAxis<float>(angle, translate.normalized())).matrix();
|
||||||
auto matrix = transform.matrix();
|
|
||||||
|
|
||||||
for(auto i = 0; i < iterationsCount; i++) {
|
for(auto i = 0; i < iterationsCount; i++) {
|
||||||
std::vector<std::vector<Vector4f>> newThreads;
|
std::vector<std::vector<Vector4f>> newThreads;
|
||||||
|
|
||||||
for(auto j = 0; j < threadsCount; j++) {
|
for(auto j = 0; j < threadsCount; j++) {
|
||||||
auto vertices = threads[j];
|
auto edges = threads[j];
|
||||||
std::vector<Vector4f> newVertices;
|
std::vector<Vector4f> newEdges;
|
||||||
|
|
||||||
for(auto k = 0; k < verticesCount; k++) {
|
for(auto k = 0; k < edgesCount; k++) {
|
||||||
newVertices.push_back(matrix * vertices[k]);
|
newEdges.push_back(matrix * edges[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
newThreads.push_back(newVertices);
|
newThreads.push_back(newEdges);
|
||||||
|
|
||||||
|
|
||||||
auto threadCenter_ = Vector4f(threadCenters[j].x(), threadCenters[j].y(), threadCenters[j].z(), 1);
|
auto threadCenter_ = Vector4f(threadCenters[j].x(), threadCenters[j].y(), threadCenters[j].z(), 1);
|
||||||
auto threadCenter = threadCenter_.head(3);
|
auto threadCenter = threadCenter_.head(3);
|
||||||
@ -195,22 +196,11 @@ void TMyApplication::InnerInit()
|
|||||||
|
|
||||||
threadCenters[j] = newThreadCenter;
|
threadCenters[j] = newThreadCenter;
|
||||||
|
|
||||||
/*
|
for(auto k = 0; k < edgesCount; k++) {
|
||||||
|
auto vk = edges[k].head(3);
|
||||||
Vector3f threadCenter;
|
auto vk1 = edges[(k + 1) % edgesCount].head(3);
|
||||||
Vector3f newThreadCenter;
|
auto nvk = newEdges[k].head(3);
|
||||||
for(auto k = 0; k < verticesCount; k++) {
|
auto nvk1 = newEdges[(k + 1) % edgesCount].head(3);
|
||||||
threadCenter += vertices[k].head(3);
|
|
||||||
newThreadCenter += newVertices[k].head(3);
|
|
||||||
}
|
|
||||||
threadCenter = threadCenter / verticesCount;
|
|
||||||
newThreadCenter = newThreadCenter / verticesCount;
|
|
||||||
*/
|
|
||||||
for(auto k = 0; k < verticesCount; k++) {
|
|
||||||
auto vk = vertices[k].head(3);
|
|
||||||
auto vk1 = vertices[(k + 1) % verticesCount].head(3);
|
|
||||||
auto nvk = newVertices[k].head(3);
|
|
||||||
auto nvk1 = newVertices[(k + 1) % verticesCount].head(3);
|
|
||||||
|
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk);
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk);
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk1);
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk1);
|
||||||
@ -220,11 +210,6 @@ void TMyApplication::InnerInit()
|
|||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk1);
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk1);
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk);
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk);
|
||||||
|
|
||||||
*Console << "k=" + boost::lexical_cast<std::string>(k) + "\n";
|
|
||||||
|
|
||||||
*Console << "tc=" + boost::lexical_cast<std::string>(threadCenter(0))+ " " + boost::lexical_cast<std::string>(threadCenter(1)) + " " + boost::lexical_cast<std::string>(threadCenter(2)) +"\n";
|
|
||||||
*Console << "ntc="+ boost::lexical_cast<std::string>(newThreadCenter(0)) + " "+ boost::lexical_cast<std::string>(newThreadCenter(1))+ " " + boost::lexical_cast<std::string>(newThreadCenter(2))+"\n";
|
|
||||||
|
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((vk - threadCenter));
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((vk - threadCenter));
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((vk1 - threadCenter));
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((vk1 - threadCenter));
|
||||||
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((nvk - newThreadCenter));
|
fabricRender.second.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB].push_back((nvk - newThreadCenter));
|
||||||
@ -248,7 +233,7 @@ void TMyApplication::InnerInit()
|
|||||||
};
|
};
|
||||||
|
|
||||||
Vector3f const stepDirection(18, 0, 0);
|
Vector3f const stepDirection(18, 0, 0);
|
||||||
Vector3f p1(bottomLeft[0], 0, -bottomLeft[1]);
|
Vector3f p1(bottomLeft[0], 100, -bottomLeft[1]);
|
||||||
Vector3f p2 = p1 - Vector3f(0, 0, W);
|
Vector3f p2 = p1 - Vector3f(0, 0, W);
|
||||||
|
|
||||||
while(p1[0] < bottomLeft[0] + W)
|
while(p1[0] < bottomLeft[0] + W)
|
||||||
|
Loading…
Reference in New Issue
Block a user