Can't apply a material or texture to a 3ds model

Hi all,



I’ve created a simple 8x5x3 tile with bevelled edges in Blender, and exported to 3ds format. I load the model into my test app, and create a sphere as a test object as well. I set both objects to have a green emissive material, and put a red light in the scene. The sphere then looks correct – green, with red on top – but the tile is gray with white on top. What am I doing wrong? Is there something wrong with the Blender file? The code?



Here is the original Blender file, and here is the exported 3ds file. I’ve placed the 3ds file in the test directory where the below class file lives. And finally, here’s the complete source code for my test app:



(P.S. I am a N00B, so please be gentle. My application is trying to be a Japanese language learning game!)



package test;

import com.jme.app.*;
import com.jme.util.*;
import com.jme.util.export.binary.*;
import com.jme.scene.shape.*;
import com.jme.scene.state.*;
import com.jme.scene.*;
import com.jme.math.*;
import com.jme.bounding.*;
import com.jme.renderer.*;
import com.jme.light.*;
import com.jme.image.*;
import com.jme.util.geom.*;
import com.jme.input.*;
import java.nio.*;
import java.net.*;
import java.io.*;
import com.jmex.model.XMLparser.Converters.*;
import com.jmex.model.XMLparser.*;

public class Test1 extends SimpleGame
{
   protected void simpleInitGame()
   {
      Node modelNode = null;

      try
      {
         MaxToJme converter = new MaxToJme();
         ByteArrayOutputStream BO = new ByteArrayOutputStream();

         URL file = Test1.class.getClassLoader()
               .getResource("test/tile.3ds");

         System.out.println("Starting to convert .3ds to .jme at " + file);

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

         // load as a TriMesh if single object, Node if multiple objects

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

         // modelNode.setLocalScale(0.5f);
         modelNode.setModelBound(new BoundingBox());
         modelNode.updateModelBound();

      }
      catch (IOException e)
      {
         e.printStackTrace();
      }

      Node n = new Node("My root node");

      // this is just a test object

      Sphere s = new Sphere("My sphere", 15, 15, 1);
      s.setLocalTranslation(-5, -5, 0);
      s.setModelBound(new BoundingSphere());
      s.updateModelBound();

      // Add green emission to sphere and tile
      
      MaterialState ms = display.getRenderer().createMaterialState();
      ms.setEmissive(new ColorRGBA(0, 0.2f, 0, 1));
      s.setRenderState(ms);
      modelNode.setRenderState(ms);

      // Add a red light
      
      PointLight pl = new PointLight();
      pl.setDiffuse(ColorRGBA.red);
      pl.setLocation(new Vector3f(0, 10, 5));
      pl.setEnabled(true);

      LightState ls = display.getRenderer().createLightState();
      ls.attach(pl);

      lightState.detachAll();
      n.setRenderState(ls);

      n.attachChild(s);
      n.attachChild(modelNode);
      rootNode.attachChild(n);

   }

   public static void main(String[] args)
   {
      Test1 app = new Test1();

      app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }
}

I've placed the 3ds file in the test directory where the below class file lives.


.getResource("test/tile.3ds")


I don't know if i understand this right but Your class file should be one above the test directory in this case
(which maybe has to be in the classpath too)

If this isn't Your problem then search the output of the app for warnings like file not found or null pointer ...
and report back

hth

The class is in the test package, so it is in the test directory. There are no errors in the output.



–Rob

so try to change

.getResource("test/tile.3ds")





to .getResource("tile.3ds")



or add the directory above test to the classpath