Stencil shadows failing on .3ds

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
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Stencil shadows failing on .3ds

Post by Will Piovano »

Hey,

I'm not sure if it's been said somewhere, but are .3ds meshes not subject to casting shadows? When I load an md2, it shadows fine, but when I add a ShadowNode to the .3ds mesh, the whole program hangs (this by changing only the path to the mesh being loaded, nothing else).

Any ideas?
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

You will have to show some code if you want help, mate.

Show us the section where you add the mesh, and then how you add the shadow.
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Post by Will Piovano »

Cool yeah. I was just wondering if there was a bug with .3ds initially since some ppl have told me there are some between irrlicht and the format. Here's the code:

Code: Select all

diceArray = new IAnimatedMeshSceneNode[8];

            Random random = new Random();

            for (int i = 0; i < 8; i++)
            {
                diceArray[i] = device.SceneManager.AddAnimatedMeshSceneNode(diceMesh, null, i);
                diceArray[i].SetMaterialFlag(MaterialFlag.LIGHTING, true);
                diceArray[i].Rotation = new Vector3D(0, 0, random.Next(8) * 90);
            }

            // Initialize the dice positions here

            for (int i = 0; i < 8; i++)
            {
                diceArray[i].ID = -(i + 1);
                diceArray[i].AddShadowVolumeSceneNode();
                diceArray[i].SetMaterialFlag(MaterialFlag.NORMALIZE_NORMALS, true);
            }
             smgr.ShadowColor.Set(220, 0, 220, 0);

That's it as far as the dice. The md2 model I load casts shadows and is pretty much identical in creation:

Code: Select all

            IAnimatedMesh mesh = smgr.GetMesh(@"C:/Irrlicht/irrlicht-1.1/media/faerie.md2");
            IAnimatedMeshSceneNode anode = smgr.AddAnimatedMeshSceneNode(mesh, null, 0);
            anode.Position = new Vector3D(0, 30, 0);
            anode.SetMD2Animation(MD2AnimationType.STAND);
            anode.SetMaterialTexture(0,
                driver.GetTexture("C:/Irrlicht/irrlicht-1.1/media/Faerie5.BMP"));

            // add shadow
            anode.AddShadowVolumeSceneNode();
            smgr.ShadowColor.Set(220, 0, 0, 0);
            anode.SetMaterialFlag(MaterialFlag.NORMALIZE_NORMALS, true);
The only difference is the md2 animation really. When I comment out the addShadowNode for the dice, everything works, but that single line makes it hang completely.

I'm a bit perplexed.

Thanks for the help.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

hmm can I have a copy of the 3ds file please? there may be something wrong with the 3ds loader. are you using Irrlicht from svn or 1.1?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Post by Will Piovano »

bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

wow, thats a monster of a mesh!
I've been sat here for the last 5 mins trying to load it.. for such a simple shape you might want to try something a bit more optimized. also, you should triangulate your mesh before exporting it, that way irrlicht won't have to.
if you insist on using such a large mesh, you should use a different mesh for shadow generation (use setMeshToRenderFrom)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Post by Will Piovano »

So are you saying that the mesh is effectively hanging cause it takes too long to do the shadow calculation? It seems to be running fine with normal dynamic lights, strange...

Anyway, as far as setting a different mesh for the shadow, do I have do have that mesh loaded at a node, or do I just specify a different node and irrlicht sort of "replaces" it for the shadow calculation? (The Irrlicht doc didn't say much about it)

Thanks again for the help!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Code: Select all

IShadowVolumeSceneNode *shadow = node->createShadowVolumeSceneNode();
shadow->setMeshToRenderFrom(simple_mesh);
you should really use something much smaller for your die mesh though, you'll get instant loading times and much better fps, and you'll be able to support older computers. 25k triangles is a lot for a simple cube, and most of them are a waste. i bet a polygon reducer would get rid of 90% of them)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Post by Will Piovano »

Yes my mate did the die in max, I saw it and it's quite ridiculous lol. We have another low-poly version, I'll see if that works. Thnx bit.
Will Piovano
Posts: 22
Joined: Sun Oct 15, 2006 10:02 pm

Post by Will Piovano »

Do you know if C# has the ability to carry out that function? It doesn't have a shadowvolume node type, and neither iscenenode nor IAnimatedMeshSceneNode have functions to set the shadow rendering to a different mesh. And there's no createshadow function, only the addShadow, which returns IsceneNode. The documentation only mentions addShadow, too.

It is a problem of performance, I'm sure of that now, just need to get that shadow to be rendered by a simple 6-poly cube, but C# doesn't have that ability it seems...
Post Reply