0 Replies Latest reply: Apr 5, 2010 3:42 AM by 843799 RSS

    how can i load (.3DS or .obj) models with its textures in java

      hi can someone plzzz tell me how i can load a 3ds or .obj model along with its texture

      plzzzz here is code in which i load the model but how can i load its texture plzzz some one help mee or if some one hav his code relating to 3ds or .obj loader then help in creating my game

      here is code ...

      import com.mnstarfire.loaders3d.Inspector3DS;
      import com.mnstarfire.loaders3d.Loader3DS;
      import java.applet.Applet;
      import java.awt.BorderLayout;
      import java.awt.Frame;
      import java.awt.GraphicsConfiguration;
      import java.io.FileNotFoundException;
      import java.net.MalformedURLException;
      import java.net.URL;

      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.media.j3d.BoundingSphere;
      import javax.media.j3d.BranchGroup;
      import javax.media.j3d.Canvas3D;
      import javax.media.j3d.DirectionalLight;
      import javax.media.j3d.Transform3D;
      import javax.media.j3d.TransformGroup;
      import javax.vecmath.Color3f;
      import javax.vecmath.Point3d;
      import javax.vecmath.Vector3f;

      import com.sun.j3d.loaders.IncorrectFormatException;
      import com.sun.j3d.loaders.ParsingErrorException;
      import com.sun.j3d.loaders.Scene;
      import com.sun.j3d.loaders.objectfile.ObjectFile;
      import com.sun.j3d.utils.applet.MainFrame;
      import com.sun.j3d.utils.universe.SimpleUniverse;

      public class ObjectLoader extends Applet {

      * init Methoden fur die Darstellung als Applet
      public void init() {
      setLayout(new BorderLayout());
      GraphicsConfiguration config = SimpleUniverse
      canvas3D = new Canvas3D(config);
      add("Center", canvas3D);
      BranchGroup szene = macheSzene();
      universe = new SimpleUniverse(canvas3D);

      public BranchGroup macheSzene() {
      BranchGroup objWurzel = new BranchGroup();
      // Transformation, 2 Rotationen:
      Transform3D drehung = new Transform3D();
      Transform3D drehung2 = new Transform3D();
      TransformGroup objDreh = new TransformGroup(drehung);
      ObjectFile file = new ObjectFile(ObjectFile.RESIZE);

      Scene scene = null;

      try {
      scene = file.load(ClassLoader.getSystemResource("aaa.obj"));
      } catch (FileNotFoundException ex) {
      Logger.getLogger(ObjectLoader.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IncorrectFormatException ex) {
      Logger.getLogger(ObjectLoader.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ParsingErrorException ex) {
      Logger.getLogger(ObjectLoader.class.getName()).log(Level.SEVERE, null, ex);


      DirectionalLight d_Licht = new DirectionalLight(new Color3f(1.0f, 0.5f,
      0.3f), new Vector3f(-1.0f, -1.0f, -1.0f));
      d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d,
      0.0d), 100.0d));
      d_Licht.setColor(new Color3f(1.0f,0.5f,0.3f));

      return objWurzel;

      public void destroy() {

      public static void main(String[] args) {
      frame = new MainFrame(new ObjectLoader(), 500, 500);

      //---- Attribute -----------------------
      private SimpleUniverse universe;

      private Canvas3D canvas3D;

      private static Frame frame;