diff --git a/src/geometries/PBDSimulation.cpp b/src/geometries/PBDSimulation.cpp index 3bc81bd79eb2df136c18e56449bdbdb755d24ef8..17b303a57de290bd7fc6a16b775e356a35bbd33f 100644 --- a/src/geometries/PBDSimulation.cpp +++ b/src/geometries/PBDSimulation.cpp @@ -20,11 +20,23 @@ PBDSimulation::PBDSimulation(HeadObject *_head, size_t _nr_sims, size_t _nr_segm } void PBDSimulation::propagateHead() { - vec3 origin(0, 0, 0); + srand(time(nullptr)); + vec3 head(0,0,0); + float step = M_PI / nrStrands; + float currAngle = M_PI; + float r = 0.20f; + + // if there is only one strand, then place it in the middle + if (nrStrands == 1) r = 0.0; + for (size_t i = 0; i < nrStrands; i++) { vec3 color = util::getRandomRGBColorAround(vec3(222.0f, 101.0f, 32.0f), vec3(40.0f, 20.0f, 20.0f)); - strands.emplace_back(CreateStrand(nrSegments, lSeg, origin, color)); + vec3 curr_pos(head.x + cosf(currAngle) * r * 1.2f, head.y + sinf(currAngle) * r * 1.1f, head.z); + + strands.emplace_back(CreateStrand(nrSegments, lSeg, curr_pos, color)); + currAngle -= step; } + } void PBDSimulation::update(float dt) {