Technically no, although you can pre-transform vertices when you build your vertex array. In theory it could be done a bit like this (untested code):
struct BodyPart final : public sf::Transformable
{
std::array<sf::Vector2f, 4u> quadPoints = {}; //set these to the default positions of a quad used for a body part
};
enum PartID
{
Legs, Body, Head, Count //start with legs because presumably you want to draw from the bottom up
};
class Robot final : public sf::Drawable, public sf::Transformable
{
public:
Robot()
{
//for each body part set the initial quad point positions
//eg {-10.f, -10.f} , {10.f, -10.f}, {10.f, 10.f}, {-10.f, 10.f} for a 20 unit quad that rotates around the centre
}
void update()
{
//update the transform for each body part
m_bodyParts[PartID::Head].setRotation(20.f);
m_bodyParts[PartID::Body].setScale(1.2f, 1.2f);
//...etc
//build the vertex array by creating a transformed quad for each part
m_vertices.clear();
for(const auto& part : m_bodyParts)
{
auto quadPoints = part.quadPoints; //make sure this is a copy so as not to modify the orignal part
const auto& transform = part.getTransform();
for(auto& point : quadPoints)
{
point = transform.transformPoint(point); //the point is now rotated/scaled by the bodypart transform
}
for(auto i = 0; i < SliceCount; ++i) //slice count is number of quads in this body part
{
//create a new slice by using the quadPoints array as positions
//and adding any texture coordinates. Emplace the vertex into m_vertices
//don't forget to decrement the Y value of the position by the thickness of a slice.
for(auto& point : quadPoints)
{
m_vertices.emplace_back(point, someTexCoord);
point.y -= sliceThickness;
}
}
}
private:
std::array<BodyPart, PartID::Count> m_bodyParts;
std::vector<sf::Vertex> m_vertices;
void draw(sf::RenderTarget& rt, sf::RenderStates) const override
{
states.transform *= getTransform(); //this now controls the world transform of the entire robot
rt.draw(m_vertices.data(), m_vertices.size(), sf::Quads, states);
}
};
To summarise:
Keep the positions for each part separate along with their own transform
When rebuilding the vertex array apply the transform of that part directly to *a copy* of the quad base position
Draw the vertex array using a transform which controls the position/rotation/scale of the robot in world coordinates.