3ds to jme Convertion problem

Hi,



I have problem with 3ds to jme convertion. I used this example:



http://www.jmonkeyengine.com/wiki/doku.php?id=model_loading&s[]=3ds&s[]=model



And netbeans can't  find class JmeBinaryReader. I have jme 1.0 from cvs.

here is my code:



package testjme;

import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;
import com.jme.scene.Node;
import com.jmex.model.converters.MaxToJme;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.URL;


/**
 *
 * @author Michal
 */
public class Main extends SimpleGame{
 public static void main(String[] args) {
  Main app = new Main(); // Create Object
  // Signal to show properties dialog
  app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
  app.start(); // Start the program
 }
 protected void simpleInitGame() {

MaxToJme maxtojme = new MaxToJme();
Node node = null; //Where to dump mesh.
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); //For loading the raw file
URL url = Main.class.getClassLoader().getResource("Model.3ds"); // File Path for the model
maxtojme.convert(url.openStream(), bytearrayoutputstream); // Converts the file into a jme usable file
JmeBinaryReader jmebinaryreader = new JmeBinaryReader(); // Used to convert the jme usable file to a TriMesh
node = jmebinaryreader.loadBinaryFormat(new ByteArrayInputStream(bytearrayoutputstream.toByteArray()));
//converts file into a TriMesh
  rootNode.attachChild(node); // Put it in the scene graph
 }
}

JmeBinaryReader is replaced with com.jme.util.export.binary.BinaryImporter



Hellmaster

Thx, for help. I have anoter question is it posible to load 3ds object with textures automaticly?? an anoter one this time witch *.obj . When I try to convert I get exception java.lang.ClassCastException: com.jme.scene.TriMesh cannot be cast to com.jme.scene.Node in this try catch block:

try {
 
    // Converts the file into a jme usable file
    maxtojme.convert(is, bytearrayoutputstream);
 
    // Used to convert the jme usable file to a TriMesh
    BinaryImporter binaryImporter = new BinaryImporter();
    ByteArrayInputStream in=new ByteArrayInputStream(bytearrayoutputstream.toByteArray());
 
    //importer returns a Loadable, cast to Node
    node = (Node)binaryImporter.load(in);
 
} catch(Exception err)  {
    System.out.println("Error loading md3 model:"+err);
}


It depends on the loaded model if it will be a trimesh or a node so its best to cast to Spatial which is the superclass of both.



To load textures at the same time make use of the resourcelocaterTool, with this tool you simply specify the directory the loader should look in while loading the model.

ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(url to you texture directory));



Hellmaster.