Shadows on a cube?

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
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Shadows on a cube?

Post by dgrafix »

How do i make a stencil shadow on a cube, it only seems to accept animmeshes?
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
Munger
Posts: 28
Joined: Sun Mar 04, 2007 11:39 am
Location: Tokyo

Post by Munger »

This came up here with no really satisfactory responses:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=32081
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

As i dont whant to create another topic ill post my problem here
I just create light and set materialflag light into true and got such an effect:

Image


Floor is made of cubes.

Is there some flag that i have to change or it is more complex problem ?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

The normals of your cube corners are pointing out from the centre of the cube, so they are lit like a sphere. You need to make them hard edges in your modelling program.
Are they created with addCubeSceneNode?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

I did not create them in any modelling program :| (in fact i hardly ever use thoese programs )

They are just create by smgr->addCubeSceneNode();

So should i replace them with cube mesh ?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Yeah a cube mesh would be better. In fact, making your whole level in a modelling program would give much faster results (draw the whole thing in one call instead of hundreds). If you need to use a tiled world then consider using my batching mesh which will give you a good performance boost.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Post by dgrafix »

Code: Select all

		irr::scene::IAnimatedMeshSceneNode* toAnimMeshSceneNode;
		irr::scene::IMesh * toMesh;
		irr::scene::IAnimatedMesh* toAnimMesh;
irr::scene::IMeshSceneNode*temp = b3d::B3dSmgr->addCubeSceneNode(size) ;                                           
					irr::scene::IMesh*tmesh = temp->getMesh();
					irr::scene::SAnimatedMesh * am=new irr::scene::SAnimatedMesh();
					am->addMesh(tmesh);
					toAnimMesh = am;
					toAnimMeshSceneNode = b3d::B3dSmgr->addAnimatedMeshSceneNode(toAnimMesh,ValidateParent(parent));
					toAnimMeshSceneNode;

					temp->setVisible(false); //TODO// Find a solution to this ugly hide!!



Here is a cube creation from my world entity class i am making up that allows shadows on a cube with using ->addshadowvolumemesh() on it.

This converts the cube into an animated mesh which allows for shadows (shadows are not available on IMesh for some odd reason) as i discovered by a bit of forum scouring.
There is one small problem with this though, the creation leaves the original mesh lying about and will not let me drop it. (i suspect the geometry is linked with the new one somehow).

Howevwer, i have fixed it with a bit of a hide hack, but its still there :( It would be nice if someone with more experience could clean this method up for me,[/code]
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I took a look at Xefects but i would prefer an engine-native solution (plus im too much of a noob to fully understand it :D ).
You made this yet you can't do simple shadow maps, wow. Not saying you should use them or anything, I don't care but I am still amazed you can do all that and not use shadow maps. Infact even a static lightmap would work here, you already wrote a lightmapper yourself!
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

bitplane wrote:Yeah a cube mesh would be better. In fact, making your whole level in a modelling program would give much faster results (draw the whole thing in one call instead of hundreds). If you need to use a tiled world then consider using my batching mesh which will give you a good performance boost.

Well my point in making this program is tu create some generator of dungeon (random or reading from txt file) so i think that i cant use any world creater.

But i'll check your class :)

There is one small problem with this though, the creation leaves the original mesh lying about and will not let me drop it. (i suspect the geometry is linked with the new one somehow).
Well i am afraid that this will end with a big memory slick


P.S.

So does anyone have some cube mesh wich i could use :) ?
Last edited by MarcinS on Sun Mar 01, 2009 2:04 pm, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Code: Select all

cube->getMaterial(0).GouraudShading = false;
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Post by dgrafix »

You made this yet you can't do simple shadow maps, wow. Not saying you should use them or anything, I don't care but I am still amazed you can do all that and not use shadow maps. Infact even a static lightmap would work here, you already wrote a lightmapper yourself!
:oops: hehe, lets say i can understand when its in a language i understand. I have been using c++ for a very little time, and irrlicht for a lot less (i started learning it ages ago and then got attracted away by C# but am now disenchanted at my options there and am back.) The Language and b3d Engine T.Ed was writen in i know well.

I understand the principles behind it but i still have to use the phrase book every 2 seconds when looking at c++/Irrlicht code. (and i do not like simply bolting in code to my project until i understand it implicitly :))

Basically, ive worked out how to use stencil shadows on everything "animated" except cubes and other static meshes. I suppose its more of a mission to learn more about the way Irrlicht behaves internally. I am still a bit confused over SMesh IMesh IAnimMesh SAnimMesh etc..
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

Code: Select all

toAnimMeshSceneNode = b3d::B3dSmgr->addAnimatedMeshSceneNode(toAnimMesh,ValidateParent(parent)); 
what is the reason for setting parent in this case? (it is just for your use ? )
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Post by dgrafix »

there is no parent in this case, it is actually all part of a larger class construct. I put parent there in case i want one. Otherwise its 0.
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

thanks to dgrafix it works..

But i add also

Code: Select all

tmesh->setBoundingBox(temp->getBoundingBox());
becosue i have big problems with

Code: Select all

target = smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(core::position2di(receiver.MouseX(),receiver.MouseY()));
It hardly ever was able to "see" the cube that mouse was pointing at.. with this line it works ok


Well it works when you are near the light but when you get to the edge of it then i again start to act strange

Image


I am going to use BlindSide Xeffects for shadows maby that will work better :)
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Post by dgrafix »

Still got that irritating memory hole though :/

I wish i could find a clean and easy way to convert a static mesh (one that cleans up after itself)
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
Post Reply