Skydome

   /**
    * Build the dome as the sky.
    * @param domeTexture The texture used for the sky dome.
    */
   private void buildDome(Texture domeTexture) {
      // Create a dome as the sky.
      Dome dome = new Dome("Sky", new Vector3f(0,0,0), 64, 64, this.radius, true);
      dome.setLocalTranslation(new Vector3f(0,0,0));
      dome.setModelBound(new BoundingBox());
      dome.updateModelBound();
      dome.setIsCollidable(false);
      // Apply the given texture to the dome.
      TextureState ts = this.renderer.createTextureState();
      ts.setTexture(domeTexture);
      ts.setEnabled(true);
      ts.apply();
      dome.setRenderState(ts);
      // Set the modes.
      this.setModes(dome);
      // Build the clouds motion.
      this.buildCloudsAnimation(dome);
      // Attach the dome to the sky dome.
      this.attachChild(dome);
   }

   /**
    * Build the plane under the sky dome.
    * @param planeTexture The texture used for the plane under the sky dome.
    */
   private void buildPlane(Texture planeTexture) {
      // Create a disk as the plane under the sky dome.
      Disk plane = new Disk("Ground", 64, 64, 11*this.radius/10);
      plane.setLocalTranslation(new Vector3f(0,0,0));
      Quaternion rotation = new Quaternion();
      rotation.fromAngleAxis(270*FastMath.DEG_TO_RAD, new Vector3f(1,0,0));
      plane.setLocalRotation(rotation);
      plane.setModelBound(new BoundingBox());
      plane.updateModelBound();
      plane.setIsCollidable(false);
      // Apply the given texture to the plane.
      TextureState ts = this.renderer.createTextureState();
      ts.setTexture(planeTexture);
      ts.setEnabled(true);
      ts.apply();
      plane.setRenderState(ts);
      // Set the modes.
      this.setModes(plane);
      // Attach the plane to the sky dome.
      this.attachChild(plane);
   }
   
   /**
    * Initialize the astronomy system which includes a sun system and a moon system.
    */
   private void initializeAstronomySystem() {
      // Create the astronomy center node.
      Node astronomyNode = new Node("AstronomyCenter");
      astronomyNode.setLocalTranslation(new Vector3f(0,0,0));
      // Create the LightState for both the sun and the moon.
      this.astronomyLightState = this.renderer.createLightState();
      this.astronomyLightState.setTwoSidedLighting(true);
      // Build the sun system.
      this.buildSunSystem(astronomyNode);
      // Build the moon system.
      this.buildMoonSystem(astronomyNode);
      // Build the astronomy rotational animation.
      this.buildAstronomyAnimation(astronomyNode);
      // Attach the astronomy node to the sky dome.
      this.attachChild(astronomyNode);
   }
   
   /**
    * Build the sun system which contains a point light outside the sky dome and a lens
    * flare effect inside the sky dome.
    * @param astronomyNode The astronomy center node.
    */
   private void buildSunSystem(Node astronomyNode) {
      // Create the sun system node.
      Node sunSystem = new Node("SunSystem");
      // Build and attach the sun and the lens flare to the sun system node.
      sunSystem.attachChild(this.buildSun());
      sunSystem.attachChild(this.buildSunLensFlare());
      // Attach the sun system node to the astronomy node.
      astronomyNode.attachChild(sunSystem);
   }

   /**
    * Build the sun.
    * @return The light node contains the sun.
    */
   private SimpleLightNode buildSun() {
      // Create the sunlight which is a PointLight.
      this.sunlight = new PointLight();
      // Initially the time is 0:00, so the sunlight color is black.
      this.sunlight.setEnabled(true);
      this.sunlight.setDiffuse(new ColorRGBA(0,0,0,0));
      this.sunlight.setAmbient(ColorRGBA.gray);
      this.sunlight.setAttenuate(false);
      this.sunlight.setShadowCaster(true);
      // Create the sun which is a LightNode.
      SimpleLightNode sun = new SimpleLightNode("Sun", this.sunlight);
      sun.setLocalTranslation(new Vector3f(0,-20*this.radius,0));
      // Attach the sunlight to the astronomy LightState.
      this.astronomyLightState.attach(this.sunlight);
      // Return the sun LightNode.
      return sun;
   }

   /**
    * Build the sun's lens flare effect.
    * @return The light node contains the sun's lens flare effect.
    */
   private Node buildSunLensFlare() {
      // Create the sun lens flare light node.
      Node sunLensFlare = new Node("SunLensFlare");
      sunLensFlare.setLocalTranslation(new Vector3f(0,-95*this.radius/100,0));
      // Load the textures.
   

alright, i just modified the source code so it only uses the texture manager class to load the textures.



btw, how do i post this on the wiki?

I really think this would be a very good candidate for merge into jME.  Any agreement here? :slight_smile:

heres a simple test


package lightAndDark.test;

import javax.swing.ImageIcon;

import lightAndDark.gameState.scene.universal.SkyDome;
import lightAndDark.utility.loader.ModelLoader;
import lightAndDark.utility.loader.TextureLoader;

import com.jme.app.SimpleGame;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.state.CullState;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jmex.terrain.TerrainPage;
import com.jmex.terrain.util.FaultFractalHeightMap;
import com.jmex.terrain.util.ProceduralTextureGenerator;

/**
 * Messy test for sky dome.
 *
 * @author Yi Wang (Neakor)
 */
public class TestSkyDome extends SimpleGame{
   private SkyDome skydome;
    private TerrainPage terrain;
   
   public static void main(String args[]) {
      TestSkyDome app = new TestSkyDome();
      app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }
   
    protected void simpleUpdate() {
        this.skydome.update(this.cam.getLocation());
    }
   
   @Override
   protected void simpleInitGame() {
      TextureManager.registerHandler(".texture", new TextureLoader());
      float[] dColor = new float[4];
      dColor[0] = 0.9843f;
      dColor[1] = 0.5098f;
      dColor[2] = 0;
      dColor[3] = 1;
      float[] mColor = new float[4];
      mColor[0] = 0.2745f;
      mColor[1] = 0.3961f;
      mColor[2] = 0.6196f;
      mColor[3] = 1;
      Texture dome = TextureLoader.load("dome", 2);
      Texture plane = TextureLoader.load("down", 2);
      skydome = new SkyDome(this.cam.getFrustumFar(), dome, plane, 60, dColor, mColor);
      this.rootNode.attachChild(skydome);
      this.rootNode.attachChild(this.fpsNode);
      
        setupTerrain();
     
        this.rootNode.setRenderState(this.skydome.getLighting());
   }
   
    private void setupTerrain() {
       
        CullState cs = DisplaySystem.getDisplaySystem().getRenderer().createCullState();
        cs.setCullMode(CullState.CS_NONE);
        cs.setEnabled(true);
        rootNode.setRenderState(cs);
       
        FaultFractalHeightMap heightMap = new FaultFractalHeightMap(257, 32, 0, 255, 0.75f);
        Vector3f terrainScale = new Vector3f(2f,0.35f,2f);
        heightMap.setHeightScale( 0.001f);
        terrain = new TerrainPage("Terrain", 33, heightMap.getSize(), terrainScale, heightMap.getHeightMap(), false);
        terrain.setDetailTexture(1, 128);
        terrain.setLocalTranslation(new Vector3f(0,0,0));
        rootNode.attachChild(terrain);
       
        ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
        pt.addTexture(new ImageIcon(TestJMESkyDome.class.getClassLoader().getResource("jmetest/data/texture/grassb.png")), -128, 0, 155);
        pt.addTexture(new ImageIcon(TestJMESkyDome.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg")), 0, 155, 220);
        pt.addTexture(new ImageIcon(TestJMESkyDome.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg")), 155, 220, 512);
        pt.createTexture(512);
       
        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        ts.setEnabled(true);
       
        Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
                Texture.MM_LINEAR_LINEAR,
                Texture.FM_LINEAR,
                true);
        ts.setTexture(t1, 0);
       
        Texture t2 = TextureManager.loadTexture(TestJMESkyDome.class.getClassLoader().getResource("jmetest/data/texture/Detail.jpg"),
                Texture.MM_LINEAR_LINEAR,
                Texture.FM_LINEAR);
        ts.setTexture(t2, 1);
        t2.setWrap(Texture.WM_WRAP_S_WRAP_T);
       
        t1.setApply(Texture.AM_COMBINE);
        t1.setCombineFuncRGB(Texture.ACF_MODULATE);
        t1.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        t1.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        t1.setCombineSrc1RGB(Texture.ACS_PRIMARY_COLOR);
        t1.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        t1.setCombineScaleRGB(1.0f);
       
        t2.setApply(Texture.AM_COMBINE);
        t2.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
        t2.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        t2.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
        t2.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineScaleRGB(1.0f);
        terrain.setRenderState(ts);
    }
}



please post any additional requests here, ill add in the features u guys want asap

Looks good, trying to test it. Problem is that it uses some user classes in the lightAndDark package, which is causing syntax errors.

Great! looks so much better to "contribute" a little bit to my game than going to mess with the GUI's (in other words: now i've got an excuse to wait a little bit longer to start doing my gui's – really boring, you know). Features? Here are some, one maybe easier to implement as others: (you don't have to add them, it's just idea's).

StandardGame compliance – tex.apply without callables?!?

Rain & Snow + Rain & Snow skies (i.e making custom skies instead of only day & night)

I'll post more soon (I'm definitely going to give this a try as soon as it's StandardGame compilant)

SeySayux said:

Great! looks so much better to "contribute" a little bit to my game than going to mess with the GUI's (in other words: now i've got an excuse to wait a little bit longer to start doing my gui's -- really boring, you know). Features? Here are some, one maybe easier to implement as others: (you don't have to add them, it's just idea's).
StandardGame compliance -- tex.apply without callables?!?
Rain & Snow + Rain & Snow skies (i.e making custom skies instead of only day & night)
I'll post more soon (I'm definitely going to give this a try as soon as it's StandardGame compilant)



well u can use it with standard game without any problem i believe. i personally havent tested it out yet. and im in school right now so i cant test it now. but it does use texture.apply() which needs to be excuted in the gl thread. but as long as u r using a game task queue manager. it shouldnt cause any problem.

the sky texures are defined by the user. so if u want custom sky, u just pass them in~ but it is recommanded to use a 3d model created in a 3d modeling tool for better quality.

rain and snow its not a big deal, ill implement them when i got time.

thx for the advices
Momoko_Fan said:

Looks good, trying to test it. Problem is that it uses some user classes in the lightAndDark package, which is causing syntax errors.


those are just for the texture loading. they r my custom texture loading classes since i use converted texture files instead of common .jpg, .bmp files.

u can simply replace those with the jme texture manager class. well, ill change them later when i get home.

thx~

good work!

Agree, but after 1.0…

very awesome, also is there a way to stop the lensflare showing through the terrain?

MrCoder said:

Agree, but after 1.0...


Well OBVIOUSLY.  :P

this will soon be a part of the hamsterengine. }:-@

Dosfish said:

very awesome, also is there a way to stop the lensflare showing through the terrain?


that is a included feature actually. it is done automatically for u. i guess u want them to disappear earlier than they do right now.

simply change the time value in the if blocks for the update lensflare methods. and this should be fairly easy since i use earth 24 hr time system. i think right now they r 6am and 6pm, u can make them somethieng like 8am and 8pm~ just try it out. :D

good to know u guys think it is good. i still have some other utility classes that might be useful for the engine. ill post them all together when the project is done.
neakor said:

alright, i just modified the source code so it only uses the texture manager class to load the textures.

btw, how do i post this on the wiki?


Get an account, then just go to the URL where you want your page to be. It'll tell you it can't an article there and ask if you want to create one.

Well, typically anyway :)

what is the "plane"? the clouds?

HamsterofDeath said:

what is the "plane"? the clouds?


well the plane is like the bottom quad of the sky box. it is use for if ur scene is above the clouds. and yes u can use it as a cloud layer.

I'm trying to implement shadows using this skydome and while it displays shadows they don't move with the changing light position, soes anyone have any clues?

did you lock shadows by any chance? 

renanse said:

did you lock shadows by any chance?