Creating a sun

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
dwe-ax
Posts: 5
Joined: Mon Nov 27, 2006 7:15 pm

Creating a sun

Post by dwe-ax »

Hello.
I'm trying to create a Solar System with Irrlicht and (of course :) ) I have a problem. So, I have a sun object (IAnimatedSceneNode*) in the origin of the coordinates system, which I've textured. The problem is:
I'm using node->setMaterialFlag(EMF_LIGHTING, false) for each planet, but I want to set the light for them in centre of the Solar System( in my sun ). Is it possible to make it?. when I comment the line: node->setMaterialFlag(EMF_LIGHTING, false) and add ILightSceneNode* within my sun, I see nothing because of my sun object overcasts the light.

Thanks a lot for your answers.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, even if the light is completely inside your sun it will still light the objects. But only if you enable lighting in their materials and if the light's radius is large enough.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

even if the light is completely inside your sun it will still light the objects.
It will not light the sun itself though. If a light is 'inside' a mesh, that light will not contribute to the lighting calculations for the mesh. If you want the light that is inside the sun to light the sun itself, you have to flip the normals of the sun mesh. Of course that would break all lights that are outside the sun, but if you're looking at the sun you probably won't notice that I'm shining a flashlight at it.

Travis
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

vitek wrote:
even if the light is completely inside your sun it will still light the objects.
It will not light the sun itself though. If a light is 'inside' a mesh, that light will not contribute to the lighting calculations for the mesh.
Two-sided lighting would do the trick, though I don't think Irrlicht directly supports this OpenGL feature. Then again, I'm sure this could be done as easily in a custom shader.
rayban
Posts: 16
Joined: Thu Nov 30, 2006 8:07 am

Post by rayban »

i will drop my 2-cents in if i understand this correctly, you want the planets
to receive light so you should set EMF_LIGHTING, true

and since the sun has no external light to light it up ( as it should be ) but
you want to see it obviously, you can set its material's emissive colors with

node->getMaterial(0).EmissiveColor.set(255,255,255,255)

well.. not 255,255,255.. that would be a bit annoying, but something not
as bright.


at least i think that should work.. im still new to c++ and irrlicht.
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

or you could implement in irrlicht something like the 3d studio max feature - object self-lighting
but then again... you could use a billboard of some kind that would be the sun and attach a light to it...
you can see how this is made in the tutorial for the Per Pixel Lighting...

Basically you use a sprite that looks like the sun and add a light.

But that is not really efficient if you want it to look realistic when you change the camera possition...
so you could just create your custom light sorrounding the sun (spherical)
and make it light inside and outside... i don't know if that's possible , but it's worth a shot...
dwe-ax
Posts: 5
Joined: Mon Nov 27, 2006 7:15 pm

Post by dwe-ax »

Thanks a lot :) I'll try. One more time: sorry for my poor english, I'm still learning.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Guys guys you are overcomplicating, just set the suns' emf lighting to false and planets to true! Viola!

- Blindside

PS: With something "big" like a solar system maybe it is the radius that is the problem because it is rather small by default..
Post Reply