I'm a newb myself, but I might be able to help you a little since I struggled with this myself.
The 3ds model will need to have texture names assigned to its various parts. This has to be done inside a 3ds editing program. The easiest way to start is to find a 3ds model that already comes with textures.
Place all the textures in a directory and then point code to load the textures from that directory.
Here's a simple program I wrote (with much borrowed code from the wise folk of this forum) that loads a 3ds model and applies textures to it.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingSphere;
import com.jme.scene.Node;
import com.jme.util.LoggingSystem;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.XMLparser.Converters.FormatConverter;
import com.jmex.model.XMLparser.Converters.ObjToJme;
import com.jmex.model.XMLparser.Converters.MaxToJme;
import com.jme.image.Texture;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
import com.jme.util.TextureKey;
import com.jme.math.Vector3f;
import com.jme.input.NodeHandler;
import com.jme.light.PointLight;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.shape.Quad;
public class modeltex extends SimpleGame
{
public static void main(String[] args)
{
modeltex app = new modeltex();
app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
// Turn the logger off so we can see the XML later on
LoggingSystem.getLogger().setLevel(Level.OFF);
app.start();
}
protected void simpleInitGame() {
//camera
cam.setLocation( new Vector3f( 0, 0, 100 ) );
cam.update();
//Vector3f modelpos = new Vector3f(0,0,0);
//background
Quad background = new Quad( "Background" );
background.initialize( 150, 120 );
background.setLocalTranslation( new Vector3f( 0, 0, -30 ) );
Texture bg = TextureManager.loadTexture(
model.class.getClassLoader().getResource(
"skycloud.jpg" ),
Texture.MM_LINEAR,
Texture.FM_LINEAR );
TextureState bgts = display.getRenderer().createTextureState();
bgts.setTexture( bg );
bgts.setEnabled( true );
background.setRenderState( bgts );
//background.setDetailTexture(1, 64);
rootNode.attachChild( background );
//light
PointLight pl = new PointLight();
pl.setAmbient( new ColorRGBA( 0.75f, 0.75f, 0.75f, 1 ) );
pl.setDiffuse( new ColorRGBA( 1, 0, 0, 1 ) );
pl.setLocation( new Vector3f( 50, 0, 0 ) );
pl.setEnabled( true );
lightState.attach( pl );
// Point to a URL of my model
URL model=model.class.getClassLoader().getResource("3dm-v-38.3ds");
// Create something to convert .obj format to .jme
//FormatConverter converter=new ObjToJme();
// Create something to convert .3ds format to .jme
FormatConverter converter=new MaxToJme();
// Point the converter to where it will find the .mtl file from (for .obj)
// converter.setProperty("mtllib",model);
// This byte array will hold my .jme file
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
// Use the format converter to convert to .jme
//for textures
TextureKey.setOverridingLocation(new URL("file:modeltextex\"));
//do conversion
converter.convert(model.openStream(), BO);
Node starship=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
starship.setLocalScale(.1f);
starship.setModelBound(new BoundingSphere());
starship.updateModelBound();
// Put it on the scene graph
rootNode.attachChild(starship);
input = new NodeHandler( starship, 10, 2 );
}
catch (IOException e)
{ // Just in case anything happens
System.out.println("Damn exceptions!" + e);
//System.out.println("Texture URL was" + texuredir);
e.printStackTrace();
System.exit(0);
}
}
}