Main Menu

Atmosphere

Started by osamoelle, October 09, 2013, 12:18:05 AM

Previous topic - Next topic

osamoelle

Hello,
At first, thanks a lot for this very usefull library!
I'm trying to create an atmoshpere around planets.
To do that, I put a sphere around another slightly smaller with a transparent texture. But the largest sphere is not visible on the side of smallest sphere as i was hoping.
I tried different value of transparency, size, culling mode, etc... outside of the smallest sphere, the side of largest still invisible.
Do you have any idea how to do this ? what I'm doing wrong ?

Thanks a lot !

Some code:
        Object3D planet = Loader.loadASC(new FileInputStream("res/meshes/sphere.asc"), (float) planet_radius, true);
        Object3D atmo = Loader.loadASC(new FileInputStream("res/meshes/sphere.asc"), (float) planet_radius, true);
       
        atmo.rotateX((float) (Math.PI/2));
        planet.rotateX((float) (Math.PI/2));
       
        atmo.setOrigin(new SimpleVector( center[X], center[Y], center[Z]));
        planet.setOrigin(new SimpleVector( center[X], center[Y], center[Z]));
       
        atmo.scale((float) atmo_radius);
       
        atmo.setTexture("atmo");
        atmo.setSpecularLighting( true );
        atmo.setCulling(false);
        atmo.setTransparency(0);
        atmo.setTransparencyMode( Object3D.TRANSPARENCY_MODE_ADD);
        //atmo.setAdditionalColor(255,255,255);
        planet.setTexture( textureId );
       
        planet.build();
        atmo.build();
        planet.addChild(atmo);



[attachment deleted by admin]

EgonOlsen

Sorry, but i don't get the problem. The screen shot looks fine to me. What am i missing?

osamoelle

Sorry.
You can find 2 new attachments.
'Atmo_explain.jpg' is what I try to get. With two spheres, 1 is the smallest, 2 is the biggest. I put some texture on the sphere 1 and a transparent one on sphere 2.
Like the sphere 2 is biggest, i was hoping that the texture beyond the perimeter.
I try to draw on the sample that you can see into the file 'atmosphere2.jpg'.
I will certainly make a mistake somewhere.
Thanks a lot for your help.

[attachment deleted by admin]

EgonOlsen

I see....and i don't see what's wrong in your code unless you specify 1 for

atmo.scale((float) atmo_radius);

What's the actual value of atmo_radius?

osamoelle

Today, value is:
double atmo_radius = planet_radius * 2f;

When i removed theses lines:

        atmo.setTransparency(0);
        atmo.setTransparencyMode( Object3D.TRANSPARENCY_MODE_ADD);

I got this (see file)

Maybe my problem come from my skydome ? I have a huge sphere around with disabled culling and texture.

[attachment deleted by admin]

osamoelle

I am awfully sorry I found the source of my error. My sky dome rendered after the rest of the world. Now everything works.
Thank you very much and I apologize for the inconvenience.

EgonOlsen

...Whatever.... ;D I'm glad that you've solved it.