Hi,
I have a problem with my application. At first I have to say, that I'm not an expert in Java, but I hope some of you can help me.
I've created a virtual lab in Blender and exported it as an xml-File and loaded it to jME. This works pretty good, but when I want to load a picture as a texture on an imported plane (this should be a window of the lab) I get an exception:
22-Mar-2007 11:33:00 com.jme.scene.state.lwjgl.LWJGLTextureState load
WARNING: Attempted to apply texture with size that is not power of 2: 800 x 600
22-Mar-2007 11:33:00 com.jme.scene.state.lwjgl.LWJGLTextureState load
WARNING: Rescaling image to 1024 x 512 !!!
22-Mar-2007 11:33:01 com.jme.scene.state.lwjgl.LWJGLTextureState load
WARNING: Attempted to apply texture with size that is not power of 2: 2048 x 1536
22-Mar-2007 11:33:01 com.jme.scene.state.lwjgl.LWJGLTextureState load
WARNING: Rescaling image to 2048 x 2048 !!!
java.lang.OutOfMemoryError: Java heap space
I don't know why this exception comes, because on a similar PC with the same hard- and software it works.
I'm using JSK 1.6 and Eclipse 3.2 as the compiler. I've already tried to increase the heap in Eclipse with "-vmargs -Xms1512m -Xmx1512m" but it doesn't change anything.
here is my code:
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import com.jme.app.SimpleGame;
import com.jme.scene.Node;
import com.jme.scene.state.TextureState;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.util.TextureManager;
import com.jmex.model.XMLparser.JmeBinaryReader;
import com.jmex.model.XMLparser.JmeBinaryWriter;
import com.jmex.model.XMLparser.XMLtoBinary;
import com.jmex.model.util.ModelLoader;
import com.jme.scene.state.LightState;
import com.jme.light.PointLight;
import com.jme.renderer.ColorRGBA;
import com.jme.bounding.BoundingBox;
//
public class LaborXML extends SimpleGame{
protected LightState lightState;
public static void main(String[] args) {
LaborXML app = new LaborXML();
app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
//
protected void simpleInitGame() {
//System.out.println("In the simple init game method");
//display.setTitle("Test");
//
//Lights
// Set up a basic, default light
PointLight light = new PointLight();
light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
light.setLocation( new Vector3f( 4, 4, 4 ) );
light.setEnabled( true );
//Attach the light to a lightState and the lightState to rootNode
lightState = display.getRenderer().createLightState();
lightState.setEnabled( true );
lightState.attach( light );
rootNode.setRenderState( lightState );
cam.setLocation(new Vector3f(4,2,6));
cam.update();
//
try {
//Initialise binary converter
XMLtoBinary converter = new XMLtoBinary();
//Initialise binary reader
JmeBinaryReader jbr = new JmeBinaryReader();
//Initialise binary writer
JmeBinaryWriter jbw = new JmeBinaryWriter();
//
// convert the input file to a jme-binary "LabNoExtra"
ByteArrayOutputStream LabNoExtra = new ByteArrayOutputStream();
URL LabModel = ModelLoader.class.getClassLoader().getResource("labnoextra2.xml");
converter.sendXMLtoBinary(new BufferedInputStream(LabModel.openStream()), LabNoExtra);
//get the "LabNoExtra"
Node lab = jbr.loadBinaryFormat(new ByteArrayInputStream(LabNoExtra.toByteArray()));
// write the "LabNoExtra"
ByteArrayOutputStream BO2 = new ByteArrayOutputStream();
jbw.writeScene(lab,BO2);
// Send the new jME binary to a jME SceneGraph and attach it.
lab = jbr.loadBinaryFormat(new ByteArrayInputStream(BO2.toByteArray()));
// attach our LabNoExtra to the scene grap
rootNode.attachChild(lab);
//
//convert the input file to a jme-binary "MediaPlayer"
ByteArrayOutputStream MediaPlayer = new ByteArrayOutputStream();
URL MediaPlayerModel = ModelLoader.class.getClassLoader().getResource("dvd.xml");
converter.sendXMLtoBinary(new BufferedInputStream(MediaPlayerModel.openStream()), MediaPlayer);
//get the "MediaPlayer"
Node media = jbr.loadBinaryFormat(new ByteArrayInputStream(MediaPlayer.toByteArray()));
//write the "MediaPlayer"
ByteArrayOutputStream BO3 = new ByteArrayOutputStream();
jbw.writeScene(media,BO3);
//Send the new jME binary to a jME SceneGraph and attach it.
media = jbr.loadBinaryFormat(new ByteArrayInputStream(BO3.toByteArray()));
// attach our MediaPlayer to the scene grap
rootNode.attachChild(media);
//
//convert the input file to a jme-binary "TV"
ByteArrayOutputStream TV = new ByteArrayOutputStream();
URL TVModel = ModelLoader.class.getClassLoader().getResource("tv.xml");
converter.sendXMLtoBinary(new BufferedInputStream(TVModel.openStream()), TV);
//get the "TV"
Node tvscreen = jbr.loadBinaryFormat(new ByteArrayInputStream(TV.toByteArray()));
//write the "TV"
ByteArrayOutputStream BO4 = new ByteArrayOutputStream();
jbw.writeScene(tvscreen,BO4);
//Send the new jME binary to a jME SceneGraph and attach it.
tvscreen = jbr.loadBinaryFormat(new ByteArrayInputStream(BO4.toByteArray()));
// attach our TV to the scene grap
rootNode.attachChild(tvscreen);
//
//convert the input file to a jme-binary "Window"
ByteArrayOutputStream Window = new ByteArrayOutputStream();
URL WindowModel = ModelLoader.class.getClassLoader().getResource("window2.xml");
converter.sendXMLtoBinary(new BufferedInputStream(WindowModel.openStream()), Window);
//get the "Window"
Node labwindow = jbr.loadBinaryFormat(new ByteArrayInputStream(Window.toByteArray()));
//write the "Window"
ByteArrayOutputStream BO5 = new ByteArrayOutputStream();
jbw.writeScene(labwindow,BO5);
//Send the new jME binary to a jME SceneGraph and attach it.
labwindow = jbr.loadBinaryFormat(new ByteArrayInputStream(BO5.toByteArray()));
// attach our Window to the scene grap
//rootNode.attachChild(labwindow);
labwindow.setModelBound(new BoundingBox());
labwindow.updateModelBound();
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
ts.setTexture(
TextureManager.loadTexture(
LaborXML.class.getClassLoader().getResource(
"landscape.jpg"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR));
// rootNode.setRenderState(ts);
rootNode.attachChild(labwindow);
//
}catch (IOException e){
System.out.println("Couldn't load the input file:" + e);
e.printStackTrace();}
catch (java.lang.NullPointerException npe ) {
npe.printStackTrace();
}
}
}
Thanks for every helpfull answers.