SkyDome and GameState

I'm trying to add a SkyDome in a standardagme.



Here is the code of a gameState with only the skydome.



package druidus.client.game.state;

import java.util.concurrent.Callable;
import java.util.concurrent.Future;

import com.jme.bounding.BoundingSphere;
import com.jme.math.Vector3f;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
import com.jme.util.GameTaskQueueManager;
import com.jmex.game.state.GameState;

import druidus.client.data.land.SkyDome;
import druidus.client.game.GSET;

public class SkyState extends GameState {
   
private Node            rootNode      = new Node("sky_rootnode");
   
private SkyDome            ciel;



   public SkyState(){
      
      initSky();
      
      rootNode.attachChild(ciel);
      
      
      rootNode.updateRenderState();
      rootNode.updateGeometricState(0.0f, true);
      rootNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
      rootNode.updateGeometricState(0.0f, true);
      rootNode.updateRenderState();
   }
   
   
   private void initSky(){
      
            Future<SkyDome> future = GameTaskQueueManager.getManager().update(new Callable<SkyDome>(){

               public SkyDome call() throws Exception{
                  LightState ls = GSET.GAME.getDisplay().getRenderer().createLightState();
                  ls.detachAll();
                  ls.setTwoSidedLighting(true);
                  ciel = new SkyDome("skyDome", new Vector3f(0.0f, 0.0f, 0.0f), 11, 18, 850.0f);
                  ciel.setModelBound(new BoundingSphere());
                  ciel.updateModelBound();
                  ciel.updateRenderState();
                  ciel.setUpdateTime(0.1f); // initial 5f
                  ciel.setTimeWarp(500.0f);
                  ciel.setDay(264);
                  ciel.setLatitude(-22.9f);
                  ciel.setLongitude(-47.083f);
                  ciel.setStandardMeridian(-45.0f);
                  ciel.setSunPosition(5.75f); // initial 5.75f 5:45 am
                  ciel.setTurbidity(2f); // initial 1f
                  ciel.setSunEnabled(true);
                  ciel.setExposure(true, 18.0f);
                  ciel.setOvercastFactor(0.0f);
                  ciel.setGammaCorrection(2.5f); // initial 2.5f
                  ciel.setRootNode(rootNode);
                  ciel.setIntensity(0.75f);
                  // setup a target to LightNode, if you dont want terrain with
                  // light's
                  // effect remove it.
                  ciel.setTarget(rootNode);
                  ciel.setLocalTranslation(new Vector3f(0f, -50f, 0f));
                  ciel.updateGeometricState(0f, true);
                  ciel.updateRenderState();
                  rootNode.attachChild(ciel);
                  return ciel;

               }
            });

            try{
               ciel = future.get();
            }
            catch( Exception e ){
               System.out.println(e);
            }

      
         }
   
   
   
   
   @Override
   public void cleanup() {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void render(float tpf) {
      // TODO Auto-generated method stub
      //ciel.render();
      DisplaySystem.getDisplaySystem().getRenderer().draw(rootNode);
      //DisplaySystem.getDisplaySystem().getRenderer().draw(ciel);
      
   }

   @Override
   public void update(float tpf) {
      // TODO Auto-generated method stub
      ciel.updateGeometricState(tpf, true);
      rootNode.updateGeometricState(tpf, true);
   }

}




we can only see a thin line on the right.

testik8.jpg



I certainly AGAIN forgot a little something......
help, 2days allready i'm searching why

Hello from Lyon my french brother  ;),



It's difficult to give to you an answer, because SkyDome is not a jME class, but I have tried to understand what you want to do and I think that your problem comes from your "call()" function :



A sky dome must not be lighted.

I think you understand that because you create a lightstate from which you detach all lights even if you never set this state to your SkyDome ?!

If you do that, you switch off all lights and your dome become black.

Thats why It's not the right way to avoid the lighting computation.



After the creation your SkyDome, add this line of code :


ciel.setLightCombineMode(LightState.OFF);


It could solve your problem by setting to the dome only the color of the sky texture.


For now, I want to give to you another piece of advice :
Try to avoid french name for your variables/functions/classes for 2 reasons :

  • First, it could be difficult to non french person to understand your code, especially on a an english forum;

  • Second, Java keywords, and jme code were written in english. The use of french language in an english language could confuse people that work with you on this project.



I'll try this.

For the french,
I'm trying to avoid it.

and also, i work with only french people in my team, some off them don't understand english (or only a little).

Did anyone managed to do a skydome in standardgame?

I tried to put skydome as a node and in the  gamestate


        SkyDome dome = new SkyDome();
        dome.defaultSetup(); // The lazy mans way of clean code.
        gameState.getRootNode().attachChild(dome);


I also tried the way Eclesia is doing it. (making new gamestate)
both ways result in a black dome.
Somehow the dome colors are not updated but I can't seem to find why...

All i have in the scene it's just a box with random colors attached to (DebugGameState)gameState
The box is fine the skybox is not....

Can anyone help?

Hi Eclesia and kamimark,

Try to change your code:


public class SkyState extends GameState {
   
   private Node rootNode = new Node("sky_rootnode");
   private SkyDome   ciel;

   public SkyState(){

      initSky();
//      rootNode.attachChild(ciel);
//      rootNode.updateRenderState();
//      rootNode.updateGeometricState(0.0f, true);
//      rootNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
      rootNode.updateGeometricState(0.0f, true);
      rootNode.updateRenderState();
   }


   private void initSky(){

      Future<SkyDome> future = GameTaskQueueManager.getManager().update(new Callable<SkyDome>(){

         public SkyDome call() throws Exception{
            LightState ls = GSET.GAME.getDisplay().getRenderer().createLightState();
//            ls.detachAll();
            ls.setEnabled(false);
            ls.setTwoSidedLighting(true);
            ciel = new SkyDome("skyDome", new Vector3f(0.0f, 0.0f, 0.0f), 11, 18, 850.0f);
            ciel.setModelBound(new BoundingSphere());
            ciel.updateModelBound();
            ciel.updateRenderState();
            ciel.setUpdateTime(0.1f); // initial 5f
            ciel.setTimeWarp(500.0f);
            ciel.setDay(264);
            ciel.setLatitude(-22.9f);
            ciel.setLongitude(-47.083f);
            ciel.setStandardMeridian(-45.0f);
            ciel.setSunPosition(5.75f); // initial 5.75f 5:45 am
            ciel.setTurbidity(2f); // initial 1f
            ciel.setSunEnabled(true);
            ciel.setExposure(true, 18.0f);
            ciel.setOvercastFactor(0.0f);
            ciel.setGammaCorrection(2.5f); // initial 2.5f
            ciel.setRootNode(rootNode);
            ciel.setIntensity(0.75f);
            // setup a target to LightNode, if you dont want terrain with
            // light's
            // effect remove it.
            //ciel.setTarget(rootNode);
            ciel.setLocalTranslation(new Vector3f(0f, -50f, 0f));
            ciel.updateGeometricState(0f, true);
            ciel.updateRenderState();
            rootNode.attachChild(ciel);
            return ciel;

         }
      });

      try{
         ciel = future.get();
      }
      catch( Exception e ){
         System.out.println(e);
      }

   }




   @Override
   public void cleanup() {
      // TODO Auto-generated method stub

   }

   @Override
   public void render(float tpf) {
      ciel.render();
      DisplaySystem.getDisplaySystem().getRenderer().draw(rootNode);
   }

   @Override
   public void update(float tpf) {
      ciel.update();
      rootNode.updateGeometricState(tpf, true);
   }

}



1) SkyDome doesn't support Light

ls.setEnabled(false);



2) Must be invoked .update() and .render() methods


ciel.update();
ciel.render();




I tryied you code in my game and it is working fine.

I hope to help you.
Sorry my English.

Highnik


thanks man.

That was quite helpful. :slight_smile: