burakdogancay Posted August 5, 2019 Share Posted August 5, 2019 Hello everyone , Nowadays I am working on a project that consist of several important movements for objects.But unfortunately I couldn't realize Fibonacci spiral movement.Circular and linear positioınal movements are available on my object.But could you please help me on Fibonacci circular motion.Is there any prepared function for this or how to integrate it in unigine for c++? Basically object should move like below image: Thank you by now, Link to comment
morbid Posted August 5, 2019 Share Posted August 5, 2019 Hello, Spiral movement can be achieved with this code: float angle = 0; void update() { float ifps = Game::get()->getIfps(); angle += 90.0f * ifps; node->setRotation(node->getRotation() * quat(0, 0, angle * ifps)); node->setPosition(node->getPosition() + node->getDirection() * ifps); } If you want exact Fibonacci spiral, you may want to check this implementation: https://www.quora.com/How-Fibonacci-spiral-can-be-drawn-with-a-C-algorithm Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
burakdogancay Posted August 5, 2019 Author Share Posted August 5, 2019 Thank you for information, it moves very well.I think your function will be enough instead of Fibonacci movement.I have one problem, it rotates according to given object orientation and size but I want to rotate it around bigger circle. Sorry for bad drawing :) . For example it moves like this; Link to comment
alexander Posted August 5, 2019 Share Posted August 5, 2019 Hi, Simple decrease the "angular_speed" variable and/or increase the "linear_speed" to rotate it around bigger circle. // public float angular_speed = 45.0f; float linear_speed = 10.0f; // private float angle = 0; void update() { float ifps = Game::get()->getIfps(); angle += angular_speed * ifps; node->setRotation(node->getRotation() * quat(0, 0, angle * ifps)); node->setPosition(node->getPosition() + node->getDirection() * linear_speed * ifps); } Best regards, Alexander Link to comment
burakdogancay Posted August 5, 2019 Author Share Posted August 5, 2019 Thank you so much to all of you, you saved my project :) Link to comment
Recommended Posts