But I finally got the terrain to load up with the Material. But the sky no matter what I do, does not show up.
Even when I try to load the sky as a separate scene, like in the code bellow, it still does not work.
package mygame.MyScenes;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.scene.Spatial;
public class MyTerrainScene extends SimpleApplication {
public static void main(String[] args){
MyTerrainScene app = new MyTerrainScene();
app.start();
}
RtsCam myCam;
@Override
public void simpleInitApp() {
flyCam.setEnabled(false);
Spatial mySky = assetManager.loadModel("Scenes/mySky.j3o");
Material mySkyMats = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
mySky.setMaterial(mySkyMats);
Spatial myTerrain = assetManager.loadModel("Scenes/myTerrainScene.j3o");
Material myTerrainMats = new Material(assetManager, "Common/MatDefs/Misc/ColoredTextured.j3md");
myTerrainMats.setTexture("ColorMap", assetManager.loadTexture("Textures/dirt.jpg"));
myTerrain.setMaterial(myTerrainMats);
myCam = new RtsCam(RtsCam.UpVector.Y_UP);
//myCam.setDistance();
stateManager.attach(myCam);
rootNode.attachChild(mySky);
rootNode.attachChild(myTerrain);
}
@Override
public void simpleUpdate(float tpf){
myCam.update(tpf);
}
}
Strangely, if I leave out the lines of creating the material and loading the texture for the myTerrain scene, the sky shows up. But when I add those two lines the sky does not…so whats up with this?
I did exactly as you said, and as the above tutorial you provide said, and still I got an Exception.
Jan 29, 2015 6:20:25 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Textures/Sky/Bright/BrightSky.dds (Flipped) (Cube) (Mipmapped)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:346)
at com.jme3.util.SkyFactory.createSky(SkyFactory.java:295)
at mygame.MyScenes.MyTerrainScene.simpleInitApp(MyTerrainScene.java:31)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
I don’t know what you make of this, but it didn’t work.
Let me ask you, where you fill in your asset library with the files that it needs…for instance the Exception I just pasted states, AssetNotFoundException…that’s because I might not have the required file.
Where do I get it, and how do I place it where it needs to be?
The easiest way to add a sky to a scene is by making a new j3o in the SDK, right-clicking the root node and selection Add Spatial->Sky. Then when you load that j3o the sky is loaded with it.
I did that, but when I add the texture to the main scene, the sky does not show either…that’s why it occurred to me to add the sky as a separate scene, but that does not work too.