3DS max and Jmonkey

Hey everyone,



What is the easiest way to get a model made in 3Ds max 2008 into Jmonkey? I've been trying to use Max's built in OBJ exporter which is working horribly. The model is of a small building with bitmap textures. Basically what happens is, I export it to OBJ format and the other M file (sorry im exhausted, cant remember). I modified the HelloModel tutorial with Maggie from the simpsons and when i run the application there is nothing there, no triangles or anything…



I then opened the exported OBJ in blender and noticed the life size building has shunk VERY small… I scaled it up and saved it, then the model appeared in Jmonkey but the materials were gone and it looks like the Max OBJ messed up the model a bit…



Any idea of what I'm doing wrong or is there a better way to get a model into Jme with 3Ds max… When I find a solution I definitely will repost!



EDIT:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=5828.0

I think this link might help me out, but if anyone else has any input let me know… Well ive got to get some rest, ill mess with this tomorrow at work… thanks for reading…

if it's a static model then export as 3ds…

that always worked for me…

the most important is that BEFORE exporting anything from 3DSMAX you have to make a "Reset XForm". just select everything and under the utility tab you will find the reset xform button.



the only format i had success with is OBJ.



i load my obj files like that:



URL model = getClass().getClassLoader().getResource("themes/rometheme/garden/terrain.obj");
 URL texture = getClass().getClassLoader().getResource("themes/rometheme/garden/terrain.mtl");
String jmeGardenString = getClass().getClassLoader().getResource("themes/rometheme/garden").getPath() + "/garden.jme";
ObjToJme converter = new ObjToJme();
converter.setProperty("mtllib", texture);
converter.setProperty("texurl", getClass().getClassLoader().getResource("themes/rometheme/garden/"));
converter.setProperty("texdir", getClass().getClassLoader().getResource("themes/rometheme/garden/"));

// save as jme file
File jmeGardenFile = new File(jmeGardenString);
if (!jmeGardenFile.exists()) {
  logger.debug("Creating file: " + jmeGardenString);
  converter.setProperty("mtllib", texture);
  FileOutputStream gardenOutStream = new FileOutputStream(jmeGardenFile);
  converter.convert(model.openStream(), gardenOutStream);
} // if

Spatial gardenSpatial =
          (Spatial)BinaryImporter.getInstance().load(
              getClass().getClassLoader().getResource("themes/rometheme/garden/garden.jme"));
      gardenSpatial.setLocalScale(10000f);



like that i load the obj file, optionally set a few things like mip mapping quality and so on.

then i export the model as .jme file so it will load a lot faster the next time. you have to play around with the scale factor

hope i could help,
so long,
Andy

Thanks guys, I think i found the weird scaling problem… Its definitely max's deal. However Loading the exported file in max or blender and then scaling up it works. In the export diag box on max, there is a vertex scale option that seems to control this stuff. Problem is when i set the scale to like 20 or higher, the model looks stretched out.



But that is something the modelers here can help me with. It looks like Jmonkey is the winner out of the following engines:

The nebula Device 2

Torque Advanced

Unreal engine

GameStudio

DX studio

Panda3D



Jmonkey won by a land slide, mainly because it actually compiled without me having to hold my left hand in the air while simultaneously tapping my stomach with my right hand haha! OH and the fact that it actually works. Great job guys



Maybe later ill upload some awesome screen shots of these models.

andy… How to reset Xform like what u said?? because i dont see any button to reset Xform…im using 3DS Max 2009…thanx…:wink:

Hi there !



The resetXform option in 3DSMax is on the “utlity” panel. here is a screen :slight_smile:







And for information i use this exporter : http://www.ogremax.com/ (offline for the moment) to get my model into jme via ogre xml files.



Regards,

thanx glorrr…(^_^)v



i’ve try using andy code above…but got an error…i don’t understand where the File and Spatial class comes from…it is a library??? below is my full code… i really need a help…thanx…(T_T)



/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.

    */



    package LoadModel.test;



    import java.io.ByteArrayInputStream;

    import java.io.ByteArrayOutputStream;

    import java.io.IOException;

    import java.net.URL;

    import java.util.logging.Level;

    import java.util.logging.Logger;



    import com.jme.app.SimpleGame;

    import com.jme.bounding.BoundingSphere;

    import com.jme.scene.Node;

    import com.jme.util.export.binary.BinaryImporter;

    import com.jmex.model.converters.FormatConverter;

    import com.jmex.model.converters.ObjToJme;





    public class HelloModelLoading extends SimpleGame {

    private static final Logger logger = Logger

    .getLogger(HelloModelLoading.class.getName());



    public static void main(String[] args) {

    HelloModelLoading app = new HelloModelLoading();

    app.setConfigShowMode(ConfigShowMode.AlwaysShow);

    // Turn the logger off so we can see the XML later on

    app.start();

    }



    protected void simpleInitGame() {



    URL model = getClass().getClassLoader().getResource(“LoadModel/data/model/telur2.obj”);

    URL texture = getClass().getClassLoader().getResource(“LoadModel/data/model/telur2.mtl”);

    String jmeGardenString = getClass().getClassLoader().getResource(“LoadModel/data/model”).getPath() + “/garden.jme”;

    ObjToJme converter = new ObjToJme();

    converter.setProperty(“mtllib”, texture);

    converter.setProperty(“texurl”, getClass().getClassLoader().getResource(“LoadModel/data/model/”));

    converter.setProperty(“texdir”, getClass().getClassLoader().getResource(“LoadModel/data/model/”));



    // save as jme file

    File jmeGardenFile = new File(jmeGardenString);

    if (!jmeGardenFile.exists()) {

    logger.debug("Creating file: " + jmeGardenString);

    converter.setProperty(“mtllib”, texture);

    FileOutputStream gardenOutStream = new FileOutputStream(jmeGardenFile);

    converter.convert(model.openStream(), gardenOutStream);

    } // if



    Spatial gardenSpatial =

    (Spatial)BinaryImporter.getInstance().load(

    getClass().getClassLoader().getResource(“themes/rometheme/garden/garden.jme”));

    gardenSpatial.setLocalScale(10000f);



    // // Point to a URL of my model

    // URL model=HelloModelLoading.class.getClassLoader().getResource(“LoadModel/data/model/telur2.obj”);

    //

    // // 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();

    try {

    // Use the format converter to convert .obj to .jme

    converter.convert(model.openStream(), BO);

    Node telur=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

    // shrink this baby down some

    telur.setLocalScale(.1f);

    telur.setModelBound(new BoundingSphere());

    telur.updateModelBound();

    // Put her on the scene graph

    rootNode.attachChild(telur);

    } catch (IOException e) { // Just in case anything happens

    logger.logp(Level.SEVERE, this.getClass().toString(),

    “simpleInitGame()”, “Exception”, e);

    System.exit(0);

    }

    }

    }