Hello…
can any1 help me with this problem of White Background…
import com.jme.app.FixedFramerateGame;
import com.jme.input.FirstPersonHandler;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
public class Game extends FixedFramerateGame {
private Camera cam;
private Node rootNode;
private LightState lightstate;
private CameraNode cNode;
@Override
protected void cleanup() {
// TODO Auto-generated method stub
}
@Override
protected void initGame() {
// TODO Auto-generated method stub
rootNode = new Node("rootNode");
BackgroundCore back = new BackgroundCore("night",rootNode);
cNode = new CameraNode("Camera Node", cam);
CreateAmbientLight();
back.initBackground();
rootNode.attachChild(cNode);
FirstPersonHandler input = new FirstPersonHandler(cam,10f,1f);
/** Signal to all key inputs they should work 10x faster. */
input.setEnabled(true);
}
@Override
protected void initSystem() {
// TODO Auto-generated method stub
display = DisplaySystem.getDisplaySystem(properties.getRenderer());
display.createWindow(properties.getWidth(), properties.getHeight(), properties.getDepth(), properties.getFreq(), properties.getFullscreen());
cam = display.getRenderer().createCamera(properties.getWidth(), properties.getWidth());
display.getRenderer().setBackgroundColor(ColorRGBA.black);
/** Set up how our camera sees. */
cam.setFrustumPerspective(45.0f, (float) display.getWidth()
/ (float) display.getHeight(), 1, 1000);
Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
/** Move our camera to a correct place and orientation. */
cam.setFrame(loc, left, up, dir);
/** Signal that we've changed our camera's location/frustum. */
cam.update();
display.getRenderer().setCamera(cam);
}
@Override
protected void quit() {
// TODO Auto-generated method stub
}
@Override
protected void reinit() {
// TODO Auto-generated method stub
}
@Override
protected void render(float arg0) {
// TODO Auto-generated method stub
display.getRenderer().clearBuffers();
display.getRenderer().draw(rootNode);
}
@Override
protected void update(float arg0) {
// TODO Auto-generated method stub
}
private void CreateAmbientLight()
{
PointLight light = new PointLight();
light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
light.setLocation(new Vector3f(100, 100, 100));
light.setEnabled(true);
lightstate = display.getRenderer().createLightState();
lightstate.setEnabled(true);
lightstate.attach(light);
cNode.setRenderState(lightstate);
}
}
Skybox code
import java.io.File;
import java.net.MalformedURLException;
import com.jme.image.Texture;
import com.jme.scene.Node;
import com.jme.scene.Skybox;
import com.jme.util.TextureManager;
public class BackgroundCore {
private Skybox skybox;
private String dir;
private Node rootNode;
public BackgroundCore(String backgroundname,Node rootNode)
{
this.dir = backgroundname;
this.rootNode = rootNode;
skybox = new Skybox("Background",100,100,100);
}
public void initBackground()
{
try {
Texture north = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/north.jpg").toURI().toURL(), true);
Texture south = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/south.jpg").toURI().toURL(), true);
Texture east = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/east.jpg").toURI().toURL(), true);
Texture west = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/west.jpg").toURI().toURL(), true);
Texture up = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/up.jpg").toURI().toURL(), true);
Texture down = TextureManager.loadTexture(new File("Data/Textures/" + dir + "/down.jpg").toURI().toURL(), true);
skybox.setTexture(Skybox.NORTH, north);
skybox.setTexture(Skybox.SOUTH, south);
skybox.setTexture(Skybox.EAST, east);
skybox.setTexture(Skybox.WEST, west);
skybox.setTexture(Skybox.UP, up);
skybox.setTexture(Skybox.DOWN, down);
rootNode.attachChild(skybox);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
the Picutes r loaded and the Skycode Node is attatch to the rootNode..
but its only White Background.
Specs : 640x480 16bbp 60Mhz LWJGL
every1 is loaded according to the Tutorial here in Eclipse
thanx for ur help.. :D