I’ve tried starfire loader for .3ds files, and I cannot see anything. Yes, it loads OK (no errors) but no image is seen.
here is my code
[quote]import java.awt.;
import com.sun.j3d.utils.geometry.;
import javax.media.j3d.;
import javax.vecmath.;
import java.applet.Applet;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.loaders.Scene;
import java.net.URL;
import java.net.MalformedURLException;
import com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import java.io.FileNotFoundException;
import com.mnstarfire.loaders3d.Loader3DS;
//import com.microcrowd.loader.java3d.max3ds.Loader3DS;
//import com.mnstarfire.loaders3d.Inspector3DS;
public class load3d extends Applet
{
private Canvas3D c;
public load3d()
{
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
c = new Canvas3D(config);
add("Center",c);
SimpleUniverse u = new SimpleUniverse();
BranchGroup scene = createSceneBranchGroup();
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(scene);
}
protected BranchGroup createSceneBranchGroup()
{
BranchGroup objRoot = new BranchGroup();
TransformGroup objTrans1 = new TransformGroup();
Transform3D tr = new Transform3D();
objTrans1.getTransform( tr );
// tr.rotX(90.0 * Math.PI / 180.0);
tr.setScale( 0.7 );
objTrans1.setTransform( tr );
TransformGroup objTrans2 = new TransformGroup();
objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
BoundingSphere bounds = new BoundingSphere(
new Point3d(0.0,0.0,0.0), 100.0);
//Set up the global lights
Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
Vector3f lDir1 = new Vector3f(1.0f, 1.0f, 1.0f);
Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
lgt1.setInfluencingBounds(bounds);
objRoot.addChild(aLgt);
objRoot.addChild(lgt1);
//load the object file
Loader3DS loader = new Loader3DS();
loader.setFlags(Loader3DS.LOAD_ALL);
Scene scene = null;
try{
scene = loader.load("3Dimka_Pink_Panther_ready.3DS");
}
catch (Exception e)
{
scene = null;
System.err.println(e);
}
if( scene == null )
System.exit(1);
//connect the scenegraph
objTrans2.addChild( scene.getSceneGroup() );
objTrans1.addChild( objTrans2 );
objRoot.addChild( objTrans1 );
// Set up the background
Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
Background bgNode = new Background(bgColor);
bgNode.setApplicationBounds(bounds);
objRoot.addChild(bgNode);
return objRoot;
}
public static void main(String[] args)
{
load3d t = new load3d();
}
}
[/quote]
I tried to use obj loader and it work but without the color
what should I do to get the model on screen, is it something wrong with the model if so please show me where I can get a model that works(just for the test).
Does anyone have an example that uses any of the free .3ds loaders that actually WORKS?
THANKS!