diff --git a/docs/img/pbd_demo/k_0_2.png b/docs/img/pbd_demo/k_0_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a6e1c5bb7a170c8372d166975d2de675e62d2eeb Binary files /dev/null and b/docs/img/pbd_demo/k_0_2.png differ diff --git a/docs/img/pbd_demo/k_0_6.png b/docs/img/pbd_demo/k_0_6.png new file mode 100644 index 0000000000000000000000000000000000000000..431462afc25d6305caa94b9e8dd7556f4c666677 Binary files /dev/null and b/docs/img/pbd_demo/k_0_6.png differ diff --git a/docs/img/pbd_demo/k_0_8.png b/docs/img/pbd_demo/k_0_8.png new file mode 100644 index 0000000000000000000000000000000000000000..82ab12ef563fb8172acaf411c9adf4513b0f5df7 Binary files /dev/null and b/docs/img/pbd_demo/k_0_8.png differ diff --git a/docs/img/pbd_demo/k_1.png b/docs/img/pbd_demo/k_1.png new file mode 100644 index 0000000000000000000000000000000000000000..1123d822bb5054ad75d1f3139e389e1515b9c495 Binary files /dev/null and b/docs/img/pbd_demo/k_1.png differ diff --git a/docs/img/teaser.png b/docs/img/teaser.png new file mode 100644 index 0000000000000000000000000000000000000000..ee0c6c9b28b54c77165670906a834917d2fe7d2e Binary files /dev/null and b/docs/img/teaser.png differ diff --git a/src/geometries/PBDSimulation.cpp b/src/geometries/PBDSimulation.cpp index 195b9418565b7ab05c76c37676cca7cca60db250..d96e6fcf523e4a406687be7d42cec9b7aad296c5 100644 --- a/src/geometries/PBDSimulation.cpp +++ b/src/geometries/PBDSimulation.cpp @@ -11,12 +11,16 @@ PBDSimulation::PBDSimulation(size_t _nr_sims, size_t _nr_segments, float _l_seg) lSeg(_l_seg), externalForces(.0f, .0f, .0f) { + bool red = true; // placing the fibers of the cloth for (size_t i = 0; i < nrStrands; i++) { vec3 currPos(-0.15f, -0.15f, lSeg*0.5f * (float)i - 0.15); vec3 color = vec3(0.9f, 0.3f, 0.3f); - strands.emplace_back(CreateFiber(nrSegments, lSeg, currPos * vec3(1, -1, 1), color)); + + if(i%8 == 4) red = !red; + + strands.emplace_back(CreateFiber(nrSegments, lSeg, currPos * vec3(1, -1, 1), color, red)); } } @@ -123,37 +127,37 @@ void PBDSimulation::Draw() { particlePosAndColor.push_back(strand[i + 1]->pos.x); particlePosAndColor.push_back(strand[i + 1]->pos.y); particlePosAndColor.push_back(strand[i + 1]->pos.z); - particlePosAndColor.push_back(strand[i + 1]->color.x); - particlePosAndColor.push_back(strand[i + 1]->color.y); - particlePosAndColor.push_back(strand[i + 1]->color.z); + particlePosAndColor.push_back(strand[i]->color.x); + particlePosAndColor.push_back(strand[i]->color.y); + particlePosAndColor.push_back(strand[i]->color.z); particlePosAndColor.push_back(next_strand[i]->pos.x); particlePosAndColor.push_back(next_strand[i]->pos.y); particlePosAndColor.push_back(next_strand[i]->pos.z); - particlePosAndColor.push_back(next_strand[i]->color.x); - particlePosAndColor.push_back(next_strand[i]->color.y); - particlePosAndColor.push_back(next_strand[i]->color.z); + particlePosAndColor.push_back(strand[i]->color.x); + particlePosAndColor.push_back(strand[i]->color.y); + particlePosAndColor.push_back(strand[i]->color.z); particlePosAndColor.push_back(next_strand[i]->pos.x); particlePosAndColor.push_back(next_strand[i]->pos.y); particlePosAndColor.push_back(next_strand[i]->pos.z); - particlePosAndColor.push_back(next_strand[i]->color.x); - particlePosAndColor.push_back(next_strand[i]->color.y); - particlePosAndColor.push_back(next_strand[i]->color.z); + particlePosAndColor.push_back(strand[i]->color.x); + particlePosAndColor.push_back(strand[i]->color.y); + particlePosAndColor.push_back(strand[i]->color.z); particlePosAndColor.push_back(strand[i + 1]->pos.x); particlePosAndColor.push_back(strand[i + 1]->pos.y); particlePosAndColor.push_back(strand[i + 1]->pos.z); - particlePosAndColor.push_back(strand[i + 1]->color.x); - particlePosAndColor.push_back(strand[i + 1]->color.y); - particlePosAndColor.push_back(strand[i + 1]->color.z); + particlePosAndColor.push_back(strand[i]->color.x); + particlePosAndColor.push_back(strand[i]->color.y); + particlePosAndColor.push_back(strand[i]->color.z); particlePosAndColor.push_back(next_strand[i+1]->pos.x); particlePosAndColor.push_back(next_strand[i+1]->pos.y); particlePosAndColor.push_back(next_strand[i+1]->pos.z); - particlePosAndColor.push_back(next_strand[i+1]->color.x); - particlePosAndColor.push_back(next_strand[i+1]->color.y); - particlePosAndColor.push_back(next_strand[i+1]->color.z); + particlePosAndColor.push_back(strand[i]->color.x); + particlePosAndColor.push_back(strand[i]->color.y); + particlePosAndColor.push_back(strand[i]->color.z); } } @@ -181,7 +185,7 @@ vec3 PBDSimulation::getExternalForces() const { return externalForces; } -std::vector<Particle *> PBDSimulation::CreateFiber(size_t n, float l, vec3 startPos, vec3 color) { +std::vector<Particle *> PBDSimulation::CreateFiber(size_t n, float l, vec3 startPos, vec3 color, bool red) { vec3 currPos = startPos; std::vector<Particle *> currentStrand; @@ -191,6 +195,14 @@ std::vector<Particle *> PBDSimulation::CreateFiber(size_t n, float l, vec3 start // which is 2.0e-7 kg == 10^(-7) kg float m = util::randomOffsetf(.35f, .15f); + if(red) { + if((i % 8) < 4) color = vec3(0.9f, 0.3f, 0.3f); + else color = vec3(0.9f, 0.9f, 0.9f); + } else { + if((i % 8) >= 4) color = vec3(0.9f, 0.3f, 0.3f); + else color = vec3(0.9f, 0.9f, 0.9f); + } + // first and last particle's position is infinite if (i == 0 || i == n-1) currentStrand.push_back(new Particle(currPos, 0, color)); else currentStrand.push_back(new Particle(currPos, 1 / m, color)); diff --git a/src/geometries/PBDSimulation.h b/src/geometries/PBDSimulation.h index e5906e4e153e63b4ae80a98b0601eb30e99a9388..1db565ccbaa1381f9b2f93d9ce7c1453681dbdd7 100644 --- a/src/geometries/PBDSimulation.h +++ b/src/geometries/PBDSimulation.h @@ -47,7 +47,7 @@ public: void resetExternalForces(); - std::vector<Particle *> CreateFiber(size_t n, float l, vec3 startPos, vec3 color); + std::vector<Particle *> CreateFiber(size_t n, float l, vec3 startPos, vec3 color, bool red); }; diff --git a/src/main.cpp b/src/main.cpp index cdd3eab13f6678f869e0417e052011dc2929ac3a..a36f341709984f8ecca00e88910dc953f665ece3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,7 +139,7 @@ int main(int argc, char **argv) { } glfwInit(); - window = glfwCreateWindow(WIDTH, HEIGHT, "Brave-2", NULL, NULL); + window = glfwCreateWindow(WIDTH, HEIGHT, "mmadid", NULL, NULL); if (!window) { std::cerr << "ERROR: could not open window with GLFW3" << std::endl; glfwTerminate();