I’ve been trying to fix this one issue for a long time now, but I always resorted to workarounds. However I’m at a dead end now. That’s why I am asking you for help.
I am currently trying to “simulate” our solar system in OpenGL + GLEW + SDL + ImGUI + Windows. I’ve created my very own framework to work with.
The scene graph contains a root element of the type “Node”. Every object of the class “Node” has a pointer to a parent and a vector of the type “Node”, which are supposed to be the children. Actually everything is working. I am recursively iterating though the scene graph and my planets do what they are supposed to do. However I need the world transform matrix of each planet for ImGui and my Camera Class. But the matrices are not being returned correctly. I even know where the issue is, so the picture below is going to show my function that recursively iterates through my scene graph
In line 97 I am only making a copy when iterating in the for loop. Instead it should be “(Node& itChild : it.getChildrenList())”. This makes it impossible to get the correct world transform matrices since I am not actually using the children but a copy. However if I change it to reference, the sun will spin like crazy and all the other planets are not visible. It seems like the transforms are not being applied to the planets correctly anymore. I want to create a little window where you can press on a button labeled with the planet’s name and then the camera is supposed to follow the planet around the solarsystem. Kind of like a third person camera.
If possible I want you to look at my node.hpp and node.cpp file and tell me what I have to change. I’m going to add the files to this post’s attachments!
Any help is highly appreciated!