Thanks so much Laurent. I have implemented something but I'm not sure that it works. It seems to kind of work, in that the big circle is in the right place, and the little one is in the right place. The big circle spins but the little one does not, and that's because I have no idea what I'm doing
I've tried to simplify the scene graph so it's not really a graph anymore. But I have the "platter":
Platter::Platter(void)
{
m_shape = sf::CircleShape(300.f);
m_shape.setFillColor(sf::Color::Green);
}
void Platter::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
target.draw(m_shape, states);
for (std::size_t i = 0; i < m_children.size(); ++i)
m_children[i]->draw(target, getTransform());
}
void Platter::addChild(Node* n)
{
m_children.push_back(n);
}
And a generic child for this platter:
#pragma once
class Node
{
public:
Node(sf::Shape* s);
~Node(void);
void draw(sf::RenderTarget& target, const sf::Transform& parentTransform) const
{
sf::Transform combined = parentTransform;
target.draw(*m_shape, combined);
}
private:
sf::Shape* m_shape;
};
As you can see I have
sf::Transform combined = parentTransform;
I'm am not actually combining anything because I don't want to for this particular child; I just want it to take the parent's transform. But it doesn't rotate at all. If I move the origin a bit it does rotate around the center, but it doesn't actually spin. So I guess it is following the translations but not the rotation?
Basically in main.cpp I want to call
platter.rotate(.1f);
and the platter rotates as well as the smaller circle in the center. I also want that if I add another child, it will follow the circle around but I will still be able to give it its own relative transforms. Thanks.