I'm trying to integrate spriter into my home grown engine that uses a 3D rendering system on the back end. I'm using SpriterPlusPlus and I've overridden SpriterEngine::AtlasFile to render the actual images, but things don't seem to be in the right place. I'm basing my code off this file in the sample: https://github.com/lucidspriter/SpriterPlusPlus/blob/master/example/override/sfmlimagefile.cpp
For the time being, everything is essentially being rendered with a unit square centered at 0, 0 (instead of the top left corner at 0, 0).
Things I'm not sure about are that initial translation by atlasData.spriteSourcePosition, and the move of the pivot by -0.5. I think putting the top left corner at 0, 0 might solve the pivot problem, but I'm not sure what the spriteSourcePosition translation is doing.
Here's the psuedo code for rendering (in AtlasFile::renderSprite)
transform = identity()
if(atlasData.rotated) {
transform = scale(atlasData.frameSize.y, atlasData.frameSize.x)
transform *= translate(atlasData.spriteSourcePosition.y, atlasData.spriteSourcePosition.x)
transform *= rotateZ(PI / 2)
} else {
transform = scale(atlasData.frameSize.x, atlasData.frameSize.y)
transform *= translate(atlasData.spriteSourcePosition.x, atlasData.spriteSourcePosition.y)
}
transform *= translate(-(pivot.x - 0.5) * atlasData.sourceSize.x, -(pivot.y - 0.5f) * atlasData.sourceSize.y)
transform *= spriteInfo->scale
transform *= rotateZ(-spriteInfo->getAngle())
transform *= translate(spriteInfo->getPosition())
Anyone see anything obvious?