hello,
so, i wanted to modify the loading procedure for the advanced car example, i got this function from the hello obj tutorial, slightly modified:
public static Node loadModelObj( String path ) {
try {
URL model = new URL( resourceSearchPath, path );
System.out.println(model.getPath());
// Create something to convert .obj format to .jme
FormatConverter converter = new ObjToJme();
// Point the converter to where it will find the .mtl file from
converter.setProperty("mtllib", model);
// This byte array will hold my .jme file
ByteArrayOutputStream BO = new ByteArrayOutputStream();
// Use the format converter to convert .obj to .jme
converter.convert(model.openStream(), BO);
Node maggie = (Node) BinaryImporter.getInstance().load( new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
maggie.setLocalScale(.1f);
maggie.setModelBound(new BoundingSphere());
maggie.updateModelBound();
// Put her on the scene graph
return maggie;
} catch (IOException e) { // Just in case anything happens
e.printStackTrace();
return null;
}
and it generates this error:
21.04.2010 19:26:29 class com.jmetest.physics.vehicle.TestAdvancedVehicle start()
SCHWERWIEGEND: Exception in game loop
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.jmex.model.converters.ObjToJme.buildStructure(ObjToJme.java:257)
at com.jmex.model.converters.ObjToJme.convert(ObjToJme.java:160)
at com.jmetest.physics.vehicle.Util.loadModelObj(Util.java:109)
at com.jmetest.physics.vehicle.Car.createChassi(Car.java:101)
at com.jmetest.physics.vehicle.Car.<init>(Car.java:60)
at com.jmetest.physics.vehicle.TestAdvancedVehicle.createCar(TestAdvancedVehicle.java:95)
at com.jmetest.physics.vehicle.TestAdvancedVehicle.simpleInitGame(TestAdvancedVehicle.java:77)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
at com.jme.app.BaseGame.start(BaseGame.java:74)
at com.jmetest.physics.vehicle.TestAdvancedVehicle.main(TestAdvancedVehicle.java:166)
i put the .obj file into the
com/jmetest/physics/vehicle/data/
path
so, how do i check if the bytestream was read correctly ?!
or what is the failure here ?!
i cretead a .obj file without materials
thanks in advance