Your object is roughly 35 by 15 by 20 yet you only move your view
platform back the nominal and your object is off to the side, thus you
aren't looking at your object.

Bring the viewplatform back to about -50 or maybe -100 and adjust your
backclip value and you should be able to see it.

- John Wright
Starfire Research

Ghislain DZOU wrote:
I am trying to import 3ds image in Java3D
But everything seems ok but the frame loaded is emty with totally black
baground.
I ve made a 3D max robot and converted to 3Ds, I also tried some 3ds files
taken from the internet.

Can anyone tell me what's going wrong in my code?
I also join the 3dsfile
This mycode:

//--------------------------------------------------------------------------
-------------------------
package hellojava3d;

import java.io.FileNotFoundException;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.loaders.*;
import com.mnstarfire.loaders3d.Loader3DS;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;



//   Hello3D renders a single, static cube.
//   The cube is rotated, so it looks more like a 3D object.

public class mentor extends Applet {

public BranchGroup add3DObjects()
{
BranchGroup branchGroup = new BranchGroup();


TransformGroup transformGroup = loadAndScaleStarfire("mentor.3ds"); transformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_READ); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);


//Shape3D shape = (Shape3D) transformGroup.getChild(0); Transform3D transform3D = new Transform3D(); transform3D.rotX(Math.PI/2);//Depending of the cordinate system transform3D.setTranslation( new Vector3d( -1.0, 0.0, -8.0 ));

//transformGroup.setTransform(transform3D);
  branchGroup.addChild(transformGroup);

  BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),
1000.0);

 // Set up the ambient light
      Color3f ambientColor = new Color3f(1.0f, 1.0f, 1.0f);

      AmbientLight ambientLightNode = new AmbientLight(ambientColor);
      ambientLightNode.setInfluencingBounds(bounds);

branchGroup.addChild(ambientLightNode);

branchGroup.compile();
return branchGroup;
}

   public mentor() {
       setLayout(new BorderLayout());
       Canvas3D c = new Canvas3D(null);
       add("Center", c);

       BranchGroup scene = add3DObjects();
       // SimpleUniverse is a Convenience Utility class
       SimpleUniverse u = new SimpleUniverse(c);

// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.

       u.getViewingPlatform().setNominalViewingTransform();
       u.addBranchGraph(scene);

}

 public TransformGroup loadAndScaleStarfire(String filePath)
{
TransformGroup transformGroup = null;

try
{
Loader3DS loader = new Loader3DS();
Scene scene = loader.load(filePath);
if(scene != null)
{
BranchGroup model = scene.getSceneGroup();
transformGroup = new TransformGroup( );
transformGroup.addChild( model );
}
}
catch(FileNotFoundException e)
{
System.err.println("Could not find object file: " + e);
}
catch (ParsingErrorException e)
{
System.err.println(e);
System.exit(1);
}
catch (IncorrectFormatException e)
{
System.err.println(e);
System.exit(1);
}


return transformGroup; }


// The following allows this to be run as an application // as well as an applet

   public static void main(String[] args) {
       Frame frame = new MainFrame(new mentor(), 400, 400);
   }
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to