Hello everyone! I'm currently writing a 2D skeletal animation system. Basically, it just skews and rotates quads to simulate perspective. After getting everything in place and mostly functional, I decided to rewrite the class that handles skewing and rotating quads to allow skewing by section. I started with the convex shape class, since it allows me to have any number of points, but it won't stretch or squash the texture to conform to the shape of the polygon, so it won't work for me.
Since I can't access the texCoords of individual vertecies from the convex shape class, I had to write my own class based on the shape class. I'm not getting any errors, but when I render it, there's just a few white dots on screen. I'm not sure why this is.
My code for the my custom shape class (currently named "sf_sectionedSkewable". Any class that I have inherit from SFML, I put in the sf namespace) is as follows:
sectioned_skewable.hsectioned_skewable.cpp main.cppI'm pretty sure my error lies in the update function of my sectioned_skewable class.
void SectionedSkewable::update()
{
for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i) {
m_vertices[i].position = getPoint(i);
m_vertices[i].texCoords = getTextureCoord(i);
}
}
I've used the debugger to check to make sure each vertex in m_vertices (and their texCoords) were set to what I wanted. So I've no idea why it's just a few white dots. I've been working on this all week, and nothing seems to help. So any advice you can give would be great! I wish the convexShape class just had a setTextureCoord method
That would have simplified things quite a bit. But I doubt that'd be useful in a lot of situations, so I see why it's not a thing.
-edit I've trimmed down the code to make it a minimal and complete example. It's missing the whole point of the class (the skewing of individual sections), but the error is being reproduced with a lot less code.