[Fixed] Loading simple Dome

Hi,

newbie to JME here so still grasping the basics. I’m trying to load a simple Dome into my scene to use as a basic sky dome, however it doesn’t appear in my scene and I have no idea why.

[java]public class Main extends SimpleApplication {

private TerrainQuad terrain;

private Material mat_terrain;

private Node skyDomeNode = new Node(“skyDomeNode”);

private Geometry sky;

@Override

public void simpleInitApp() {

flyCam.setMoveSpeed(50);

initTerrain();

initSkyDome();

DirectionalLight sun = new DirectionalLight();

Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);

sun.setDirection(lightDir);

sun.setColor(ColorRGBA.White.clone().multLocal(2));

rootNode.addLight(sun);

}

private void initTerrain() {

// create terrain & camera

// removed code for post, problem shouldn’t lie here

}

public void initSkyDome() {

Dome skyDome = new Dome(new Vector3f(0,0,0), 12, 20, 40000,true);

sky = new Geometry(“Dome”,skyDome);

sky.setCullHint(Spatial.CullHint.Never);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);

sky.setMaterial(mat);

skyDomeNode.attachChild(sky);

rootNode.attachChild(skyDomeNode);

}

// Entry point

public static void main(String[] args) {

Main app = new Main();

app.start();

}

}[/java]

The terrain loads fine and I’m able to fly about, but the Dome just doesn’t appear. I’m hoping this is a basic mistake and that its an easy fix. Thanks in advance for any help :slight_smile:

aaronds said:
The terrain loads fine and I'm able to fly about, but the Dome just doesn't appea....


Yeah, the dome wasn't rendered because you didn't attach it to scene graph.
I can't see anything in your code like :
[java]

rootNode.attachChild("skyDomeNode");
[/java]

I don’t see where you attach skyDomeNode to the rootNode?

Ah sorry about that, I had changed it while trying to create a fix. Even when using rootNode.attachChild(sky); the dome still doesn’t appear.

I just tried using rootNode.attachChild(“skyDomeNode”); which to me would make sense, but apparently attachChild() doesn’t accept a string as a parameter.



Thanks

aaronds said:
I just tried using rootNode.attachChild("skyDomeNode"); which to me would make sense, but apparently attachChild() doesn't accept a string as a parameter.
Thanks


Sorry, i wrote wrong. I wanted to write:
[java]
rootNode.attachChild(skyDomeNode);
[/java]

Did you already use the SkyFactory? https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:sky

Hi,



I tried rootNode.attachChild(skyDomeNode) but I still haven’t solved the issue. I’ve looked at SkyFactory but it’s not quite what I’m trying to play with. Getting the dome to appear shouldn’t be too difficult, I’m just not sure what I’m doing wrong.



Thanks

The radius for your dome is too high, 40,000 world units is too much. The camera by default has its far plane set to 1,000 world units so you won’t see your dome.

also worth noting, and i could be wrong here, but i believe the last parameter in the Dome() constructor is the boolean variable outsideView which (i think) needs to be set to false in order face the normals inward toward the center.

from the JavaDoc:


Parameters:
center - Center of the dome.
planes - The number of planes along the Z-axis.
radialSamples - The number of samples along the radial.
radius - The radius of the dome.
outsideView - If true, the triangles will be connected for a view outside of the dome.

Thanks both for your replies!



I lowered the radius etc and tried changing the boolean value, and I’ve managed to make some progress. I believe the problem is that the dome simply isn’t viewable from the outside. I thought that changing the boolean value would change this, but it doesn’t seem to have any effect at all. At the moment, I’m able to fly outside the dome and view it, but as soon as I’m back inside there is nothing to see, just the terrain and black background.



Anyone know why this might be happening?

Thanks

You could try it:

[java]

sky.getMaterial().getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);

[/java]



try with others face cull modes also.

glaucomardano said:
You could try it:
[java]
sky.getMaterial().getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
[/java]
try with others face cull modes also.

Thanks! That worked and the dome now appears as it should. However, (what I assume is) the 1000 limit on the render distance hinders the dome. With it being the sky and all it needs to be visible all the time, and for larger scenes this could become a problem. Is there any way I can have the dome rendered at all times?
Cheers

Did you already try to do what @Mamoko_Fan said? By setting the camera far plane? I can be wrong, but i think it can be done so (because i never tried to do it before) :



[java]

cam.setFrustumFar(frustumFar);

[/java]

glaucomardano said:
Did you already try to do what @Mamoko_Fan said? By setting the camera far plane? I can be wrong, but i think it can be done so (because i never tried to do it before) :

[java]
cam.setFrustumFar(frustumFar);
[/java]


That worked great, thanks! All working, thanks very much everyone!