Hey Grimfate,
Apologies for the long delay. Thanks again for all the help.
I finally got around to seeing if I could tie all of these piece together.
I concluded it’s not really a good or complete solution for my problem, because if the quad is distorted very much, it becomes clear that it’s being rendered as two triangles, with a clear seam at their boundary. There’s probably some way to do a more appropriate texture interpolation–i.e. across both triangles–but I’ll leave that for someone else.
Anyway, I thought I’d leave this here in case it’s somehow useful for folks in the future.
Note that TL are abbreviations for TopLeft, etc.
Also, “top” and “bottom” are, confusingly, really the visible bottom and top, respectively when rendered on a sprite in Cocos.
void DistortSprite(Sprite *spr, Vec3 posTL, Vec3 posTR, Vec3 PosBR, Vec3 posBL)
{
V3F_C4B_T2F_Quad quad;
PolygonInfo polyInfo;
quad.bl.colors = Color4B::WHITE;
quad.br.colors = Color4B::WHITE;
quad.tl.colors = Color4B::WHITE;
quad.tr.colors = Color4B::WHITE;
float texleft = 0;
float texTop = 0;
float texRight = 1;
float texBottom = 1;
quad.tl.texCoords.u = texleft;
quad.tl.texCoords.v = texTop;
quad.tr.texCoords.u = texRight;
quad.tr.texCoords.v = texTop;
quad.bl.texCoords.u = texleft;
quad.bl.texCoords.v = texBottom;
quad.br.texCoords.u = texRight;
quad.br.texCoords.v = texBottom;
quad.tl.vertices = posTL;
quad.tr.vertices = posTR;
quad.bl.vertices = posBL;
quad.br.vertices = PosBR;
polyInfo.setQuad(&quad);
spr->setPolygonInfo(polyInfo);
}
Dan