2D IGUIImage dynamic shadow casting

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

2D IGUIImage dynamic shadow casting

Post by LunaRebirth »

Hi,

I am trying to create a light source that casts a shadow for 2D images.
My first thought was that I would be able to use IBillboardSceneNode to create a 3D image and then cast a shadow from there, but IBillboardSceneNode inherits ISceneNode, which doesn't contain addShadowVolumeSceneNode(). Casting to an IAnimatedMeshSceneNode and then trying to add a shadow causes a crash.

Preferably, I'd like to cast shadows on IGUIImages. But is there any easy way to do this, whether it be for IGUIImage or IBillboardSceneNode?
CuteAlien
Admin
Posts: 9645
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 2D IGUIImage dynamic shadow casting

Post by CuteAlien »

Maybe create a mesh with 2 triangles and use that as base. Have to admit I never worked much with the build-in shadows from Irrlicht.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: 2D IGUIImage dynamic shadow casting

Post by LunaRebirth »

Will that work if I have a texture with transparent pixels?
I'm making a 2D player (so would need to make it a sprite) with a dynamic shadow
CuteAlien
Admin
Posts: 9645
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 2D IGUIImage dynamic shadow casting

Post by CuteAlien »

Good question.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: 2D IGUIImage dynamic shadow casting

Post by LunaRebirth »

Been a while! But this issue recently turned up again.
I'm working with a client who wants to create an IBillboardSceneNode and have the shadow cast.
For now, the solution has been "create your billboard shape as a 3D model in Blender and make it always face the camera," but this is inefficient.

I thought perhaps there could be a way to create a mesh from an image (similar to how a heightmap works, but cuts out any true-black) or something similar.
Is there no way to convert an ISceneNode to an IMeshSceneNode? dynamic_casting does not work (obviously...) for casting shadows.
CuteAlien
Admin
Posts: 9645
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 2D IGUIImage dynamic shadow casting

Post by CuteAlien »

Sorry, can't convert that one.

Easiest is probably to create your own SceneNode for this. Mainly because to make this work correct it has get values of current camera - which is actually slightly tricky. Because if you do it with animators (next best solution) you have the problem that the camera is still one frame behind (it's updated after OnAnimate... ). In your own SceneNode you can do it in render() which is called when the camera is updated already.

Thought you can work around that also manually updating a camera (updateAbsolutionPosition followed by updateMatrices I think - it's a cheap call so don't worry about doing that). Then you can use an animator which will then work with any scenenode.

Creating the shape can be done in Irrlicht with IGeometryCreator::createPlaneMesh with a tilesize of 1,1
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
Post Reply