How to flip an iBillboardSceneNode
How to flip an iBillboardSceneNode
Im animating a sprite on an iBillboardSceneNode. Id like to be able to flip it horizontally when moving left. I was hoping for a flip function but I cant seem to find one?
Re: How to flip an iBillboardSceneNode
Yeah, a bit tricky as meshbuffers are mostly rebuild each frame.
In Irrlicht svn trunk you can now go over uv coordinates, like:
In Irrlicht 1.8 getMeshBuffer did not exist yet. So the only clean option there is copying the CBillboardSceneNode code, renaming it and creating your own SceneNode that way. Then give yourself access to the video::S3DVertex vertices[4]; in there. And do as in code above.
edit: Argh, forget all I wrote - it's all horrible, horrible, horrible!!!
The real solution - which works in Irrlicht 1.8 as well:
Yeah... I totally forgot (and not for the first time) we have texture matrices
In Irrlicht svn trunk you can now go over uv coordinates, like:
Code: Select all
// Flip upside-down
scene::IMeshBuffer* mb = billboard->getMeshBuffer(0);
video::S3DVertex* vertices = static_cast<video::S3DVertex*>(mb->getVertices());
u32 vertCount = mb->getVertexCount();
for ( u32 v=0; v < vertCount; ++v )
{
vertices[v].TCoords.Y = 1.f - vertices[v].TCoords.Y;
}
edit: Argh, forget all I wrote - it's all horrible, horrible, horrible!!!
The real solution - which works in Irrlicht 1.8 as well:
Code: Select all
billboard->getMaterial(0).getTextureMatrix(0).setTextureScale(1.f, -1.f);
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: How to flip an iBillboardSceneNode
Thank you so much!