Neakor's SkyDome

Hey,



I've set up some terrain, a chase camera, all that good stuff and so I decided to integrate neakor's SkyDome into my StandardGame as well.

I added the code for buildSkyDome into my GameState, etc but the sky is always black :frowning:

Any ideas?



Also, where can I get the textures/required files that are used in SkyDome?



Thanks!

LordOfChaos said:

I've set up some terrain, a chase camera, all that good stuff and so I decided to integrate neakor's SkyDome into my StandardGame as well.
I added the code for buildSkyDome into my GameState, etc but the sky is always black :(
Any ideas?
Source code please?  Ideally at the part where you create the dome and attach it to your scene.  If everything's black you probably forgot a renderstate or lighting.
Quote:
Also, where can I get the textures/required files that are used in SkyDome?
I made my own.  It's way cooler that way ;)

I've decided to update to jME 2.0, so I will try it again soon.



Thanks

I noticed that when I run the program I get

Apr 9, 2009 10:31:10 AM com.jme.scene.Node attachChild
INFO: Child (SunNode) attached to this node (SunNode)
Apr 9, 2009 10:31:10 AM com.jme.scene.Node attachChild
INFO: Child (null) attached to this node (RootNode)


at the end of the ouput

Ill show the whole code b/c im not really sure which part is wrong
my code is kinda long:


public class jmectfGameState extends DebugGameState {

   TerrainPage tp;
   CameraNode camNode;
   Vector3f normal;
   StandardGame g;
   Vehicle player;
   ChaseCamera chaser;
   Node model;
   private float agl;
   SkyDome dome;

   public jmectfGameState(StandardGame g) {
      this.g = g;
      getRootNode().setRenderQueueMode(Renderer.QUEUE_OPAQUE);
      
      buildLighting();
      
      g.getCamera().setFrustum(1.0f, 1000.0f, -0.55f, 0.55f, 0.4125f, -0.4125f);
      g.getCamera().update();
      camNode = new CameraNode("Camera Node", g.getCamera());
      camNode.setLocalTranslation(new Vector3f(0, 250, -20));
      camNode.updateWorldData(0);
      normal = new Vector3f();
      getRootNode().attachChild(camNode);
      CullState cs = g.getDisplay().getRenderer().createCullState();
      getRootNode().setCullHint(CullHint.Never);
      cs.setEnabled(true);
      getRootNode().setRenderState(cs);
      FaultFractalHeightMap heightMap = new FaultFractalHeightMap(129, 32, 0, 127,
            0.75f);
      Vector3f terrainScale = new Vector3f(10,1,10);
      heightMap.setHeightScale( 0.001f);
      tp = new TerrainPage("Terrain", 33, heightMap.getSize(), terrainScale,
            heightMap.getHeightMap());
      tp.setDetailTexture(1, 128);
      getRootNode().attachChild(tp);
      ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
      pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource(
      "jmetest/data/texture/grassb.png")), -128, 0, 128);
      pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource(
      "jmetest/data/texture/dirt.jpg")), 0, 128, 255);
      pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource(
      "jmetest/data/texture/highest.jpg")), 128, 255, 384);
      pt.createTexture(512);
      TextureState ts = g.getDisplay().getRenderer().createTextureState();
      ts.setEnabled(true);
      Texture t1 = TextureManager.loadTexture(
            pt.getImageIcon().getImage(),
            Texture.MinificationFilter.Trilinear,
            Texture.MagnificationFilter.Bilinear,
            true);
      ts.setTexture(t1, 0);
      Texture t2 = TextureManager.loadTexture(TestTerrain.class.getClassLoader().
            getResource(
            "jmetest/data/texture/Detail.jpg"),
            Texture.MinificationFilter.Trilinear,
            Texture.MagnificationFilter.Bilinear);
      ts.setTexture(t2, 1);
      t2.setWrap(Texture.WrapMode.Repeat);
      t1.setApply(Texture.ApplyMode.Combine);
      t1.setCombineFuncRGB(Texture.CombinerFunctionRGB.Modulate);
      t1.setCombineSrc0RGB(Texture.CombinerSource.CurrentTexture);
      t1.setCombineOp0RGB(Texture.CombinerOperandRGB.SourceColor);
      t1.setCombineSrc1RGB(Texture.CombinerSource.PrimaryColor);
      t1.setCombineOp1RGB(Texture.CombinerOperandRGB.SourceColor);
      t1.setCombineScaleRGB(CombinerScale.One);
      t2.setApply(Texture.ApplyMode.Combine);
      t2.setCombineFuncRGB(Texture.CombinerFunctionRGB.AddSigned);
      t2.setCombineSrc0RGB(Texture.CombinerSource.CurrentTexture);
      t2.setCombineOp0RGB(Texture.CombinerOperandRGB.SourceColor);
      t2.setCombineSrc1RGB(Texture.CombinerSource.Previous);
      t2.setCombineOp1RGB(Texture.CombinerOperandRGB.SourceColor);
      t2.setCombineScaleRGB(CombinerScale.One);
      // fog!
      /*FogState fs = g.getDisplay().getRenderer().createFogState();
      fs.setDensity(0.3f);
      fs.setEnabled(true);
      fs.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f));
      fs.setEnd(1000);
      fs.setStart(500);
      fs.setDensityFunction(FogState.DF_LINEAR);
      fs.setApplyFunction(FogState.AF_PER_VERTEX);
      getRootNode().setRenderState(fs);
      */
      tp.setRenderState(ts);
      tp.updateRenderState();
      tp.updateModelBound();
      
      buildPlayer();
      
      buildChaseCamera();
      
      buildSkyDome();
      
      getRootNode().updateRenderState();
      getRootNode().updateGeometricState(0, true);
      
      input = new jmectfHandler(player, g.getSettings().getRenderer());
   }

   public void update(float interpolation) {
      super.update(interpolation);
      chaser.update(interpolation);
      Vector3f loc = g.getCamera().getLocation();
      g.getCamera().setLocation(new Vector3f(loc.x, tp.getHeight(new Vector2f(loc.x,loc.z))+5, loc.z));
      tp.getSurfaceNormal(g.getDisplay().getRenderer().getCamera().getLocation(), normal);
      if(normal != null) {
         camNode.rotateUpTo(normal);
         camNode.updateRenderState();
         camNode.updateFromCamera();
      }
      float characterMinHeight = tp.getHeight(player
            .getLocalTranslation())+agl;
      if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {
         player.getLocalTranslation().y = characterMinHeight;
      }

      tp.getSurfaceNormal(player.getLocalTranslation(), normal);
      if(normal != null) {
         player.rotateUpTo(normal);
      }
      getRootNode().updateGeometricState(interpolation, true);
      dome.update();
      getRootNode().updateRenderState();
   }

   private void buildLighting() {
      /*DirectionalLight dl = new DirectionalLight();
      dl.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dl.setDirection(new Vector3f(1, -0.5f, 1));
      dl.setEnabled(true);
      getLightState().attach(dl);
      DirectionalLight dr = new DirectionalLight();
      dr.setEnabled(true);
      dr.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dr.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
      dr.setDirection(new Vector3f(0.5f, -0.5f, 0).normalizeLocal());
      getLightState().attach(dr);*/
      getLightState().setTwoSidedLighting(true);
   }
   
   private void buildPlayer() {
      Spatial model = null;
      try {
         File file = new File("data/tank.jme");
         URL path = file.toURI().toURL();
         BinaryImporter importer = new BinaryImporter();
         model = (Spatial)importer.load(path.openStream());
         model.setModelBound(new BoundingBox());
         model.updateModelBound();
         model.setLocalScale(2.0f);
         model.rotateUpTo(new Vector3f(0.0f, 0.0f, -1.0f));
         model.rotateUpTo(new Vector3f(.5f , 0.0f, 0.0f));
      } catch (IOException e) {
         System.out.println("Could not load model.");
         e.printStackTrace();
         System.exit(0);
      }
      player = new Vehicle("Player Node", model);
      player.setAcceleration(15);
      player.setBraking(15);
      player.setTurnSpeed(2.5f);
      player.setWeight(25);
      player.setMaxSpeed(25);
      player.setMinSpeed(15);
      player.setLocalTranslation(new Vector3f(100,0, 100));
      getRootNode().attachChild(player);
      getRootNode().updateGeometricState(0, true);
      agl = ((BoundingBox)player.getWorldBound()).yExtent;
      player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
   }

   private void buildChaseCamera() {
      HashMap<String, Object> props = new HashMap<String, Object>();
      props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "6");
      props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "3");
      props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+45 * FastMath.DEG_TO_RAD);
      props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(5, 0, 30 * FastMath.DEG_TO_RAD));
      props.put(ChaseCamera.PROP_DAMPINGK, "4");
      props.put(ChaseCamera.PROP_SPRINGK, "9");
      chaser = new ChaseCamera(g.getCamera(), player, props);
      chaser.setMaxDistance(40);
      chaser.setMinDistance(20);
   }
   
   private void buildSkyDome() {
        dome = new SkyDome("skyDome", new Vector3f(0.0f,0.0f,0.0f), 11, 18, 850.0f);
        dome.setModelBound(new BoundingSphere());
        dome.updateModelBound();
        dome.updateRenderState();
        dome.setUpdateTime(5.0f);
        dome.setTimeWarp(180.0f);
        dome.setDay(267);
        dome.setLatitude(-22.9f);
        dome.setLongitude(-47.083f);
        dome.setStandardMeridian(-45.0f);
        dome.setSunPosition(9.0f); // 9 A.M.
        dome.setTurbidity(2.0f);
        dome.setSunEnabled(true);
        dome.setExposure(true, 18.0f);
        dome.setOvercastFactor(0.0f);
        dome.setGammaCorrection(2.5f);
        dome.setRootNode(rootNode);
        dome.setIntensity(1.0f);
        dome.setTarget(tp);
        getRootNode().attachChild(dome);
        getRootNode().updateRenderState();
    }

}



Also, how do I incorporate my textures into SkyDome?

thanks