FlagRush help

hey ive got a small problem. I am kinda new to JME (obvious by my newbie status) and am having a hard time get FlagRush started. When i import and convert a .3ds model to a .jme, everything works fine. but when i try to get the model to stay on top of the terrain i get a NullPointerException. Any help plz?



heres the code that gets the error (agl is a float class variable.):



agl = ((BoundingBox)player.getWorldBound()).yExtent;

The only cause of a NPE in that code would be player is missing a bounding box/sphere?

thats wat i thought too. However, when i import my model, i create a Bounding Box. or at least i think i do. heres the code for that.



Spatial model = null;

try {

URL maxFile  = FlagRush.class.getClassLoader().

getResource("resources/Lamborghini Murcielago.3DS");

BinaryImporter importer = new BinaryImporter();

model = (Spatial)importer.load(maxFile.openStream());

model.setModelBound(new BoundingBox());

model.updateModelBound();

} catch(IOException e) {

e.printStackTrace();

}

I'd add a simple if (player == null) System.err.println("player was null") etc. to see what's null

i tried that. the player didnt return as null. however, i found another error that was displayed higher up so i didnt see it the first time. This one says:



java.io.IOException: Not in GZIP format

looking at this further, im  pretty sure this is the line my comp doesnt like:



model = (Spatial)importer.load(maxFile.openStream());



not too sure wat it doesnt like about it tho

Oh it's because its a .3ds file not .jme

well ya. the point is to convert it to .jme. but im getting this wierd error instead of my lamborghini :slight_smile:

damn actually u may b rite. i had the converter code a bit earlier, but i accidently deleted it, i think. :roll:



hehe. wow. i feel smart. let me try that.

ok. now i converted it. but im back to my first problem. here look at the code now and tell me if im missing something.

thanx for all the help, by the way. its awesome.



Spatial model = null;

try {

URL maxFile  = FlagRush.class.getClassLoader().

getResource("resources/Lamborghini Murcielago.3DS");

MaxToJme C1 = new MaxToJme();

ByteArrayOutputStream BO = new ByteArrayOutputStream();

C1.convert(new BufferedInputStream(maxFile.openStream()),BO);

BinaryImporter importer = new BinaryImporter();

model = (Spatial)importer.load(maxFile.openStream());

model.setModelBound(new BoundingBox());

model.updateModelBound();

} catch(IOException e) {

e.printStackTrace();

}



and the line that gives me the error:

agl = ((BoundingBox)player.getWorldBound()).yExtent;

Does the model display correctly?



EDIT:

This way works for me



model = (Spatial) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

this should work


Spatial model = null;
      try {
         URL maxFile  = FlagRush.class.getClassLoader().
         getResource("resources/Lamborghini Murcielago.3DS");
         MaxToJme C1 = new MaxToJme();
         ByteArrayOutputStream BO = new ByteArrayOutputStream();
         C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
         BinaryImporter importer = new BinaryImporter();
         model = (Spatial)importer.load(BO.toByteArray());
         model.setModelBound(new BoundingBox());
         model.updateModelBound();
      } catch(IOException e) {
         e.printStackTrace();
      }



with

        C1.convert(new BufferedInputStream(maxFile.openStream()),BO);

you convert it in jme and place the ByteArrayOutputStream in BO
and then you need to import the jme file in your scene with the importer

model = (Spatial)importer.load(BO.toByteArray());

ya it did work. thanks. i guess it makes sense. id want to import the converted one, not the .3ds. thanks guys. u guys r awesome.