Page 1 of 1

Shadows on a cube?

Posted: Wed Feb 25, 2009 10:28 pm
by dgrafix
How do i make a stencil shadow on a cube, it only seems to accept animmeshes?

Posted: Wed Feb 25, 2009 10:50 pm
by Munger
This came up here with no really satisfactory responses:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=32081

Posted: Sat Feb 28, 2009 11:18 pm
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 ?

Posted: Sun Mar 01, 2009 5:09 am
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?

Posted: Sun Mar 01, 2009 9:19 am
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 ?

Posted: Sun Mar 01, 2009 10:27 am
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.

Posted: Sun Mar 01, 2009 10:44 am
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]

Posted: Sun Mar 01, 2009 11:10 am
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!

Posted: Sun Mar 01, 2009 11:34 am
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 :) ?

Posted: Sun Mar 01, 2009 11:45 am
by BlindSide

Code: Select all

cube->getMaterial(0).GouraudShading = false;

Posted: Sun Mar 01, 2009 1:33 pm
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..

Posted: Sun Mar 01, 2009 2:31 pm
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 ? )

Posted: Sun Mar 01, 2009 2:47 pm
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.

Posted: Sun Mar 01, 2009 9:15 pm
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 :)

Posted: Mon Mar 02, 2009 7:37 pm
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)