Problem with my little converter

I was written a little converter which should convert .3ds format to .jme , and create external .jme file but something is wrong and it doesn't work… if somebody know what I should change or add please tell me about it.

Here is source:


import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import com.jme.app.SimpleGame;
import com.jmex.model.converters.MaxToJme;


public class Konwerter extends SimpleGame {


   /**
    * @param args
    */
   public static void main(String[] args) {
      Konwerter app = new Konwerter();
      app.start();
      
   }
   
   protected void simpleInitGame() {
      
      File plik = new File("bin/models/test2.jme");
      
      if (!plik.exists()){
         try {
         plik.createNewFile();
         } catch (IOException e) {
         e.printStackTrace();
         return;
         }
         }
      
      
        try {
              MaxToJme C1 = new MaxToJme();
           ByteArrayOutputStream BO = new ByteArrayOutputStream();
           URL sciezka = Konwerter.class.getClassLoader().getResource("models/bike.3ds");
            C1.convert(new BufferedInputStream(sciezka.openStream()),BO);
                           
               //model = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
                       
            ByteArrayInputStream dane= new ByteArrayInputStream(BO.toByteArray());
           
            byte[] b = new byte[dane.available()];
           
            int z=0;
            int x=dane.available();
           
            dane.read(b,z,x);
           
            for (int i=0;i<b.length;i++){
               System.out.println(b[i]);
            }
           
                      
            try {
               FileWriter wrt = new FileWriter(plik,false);
               for (int i=0;i<b.length;i++){
                  wrt.write(b[i]);
                  System.out.println(b[i]);
                }
               wrt.close();
               } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               }
                                
           
                 
        } catch (IOException e) {
           
        e.printStackTrace();
        }
       
       
      
                    
       
       

   }
   
}

Thanks a lot!  :smiley:

I don't know about that tool… that's why I started to writting my own.

you're welcome.

take a look onto the ModelLoader class.

It contains everything you need.

For loading check line 340-355, and for saving check line 173.

:slight_smile:



You can just use it for you purposes as well… it ask you which file you would like to open, and saves a .jme file in the same directory.

If you run it again, and a jme file exists, the Loader loads the .jme instead of the .3ds… so you might have to delete the .jme file to get a altered .3ds loaded.