Fredrik,

Your code seems to go through a lot of work (which of course makes it
error prone) in loading and returning the loaded model.

Have you considered using our Starfire 3DS loader (and using the
directions / sample code from our website documentation)?

- John Wright
Starfire Research

Fredrik Andersson wrote:
>
> Hello!
>
> I try to load a 3DS-object but the object will not be visible at all. I have
> also add some light but I still can't see the object.
>
> On each side where the 3DS-object should appaer I have added a Cone, just
> for reference and se if the light works.
>
> I'm not so good at 3D-studio so I downloaded a object from the Internet so I
> have something to test with.
>
> That object can be found at:
> http://medlem.spray.se/fredand44/questions/girl.3DS
> I also have an other one that I have developed my self at:
> http://medlem.spray.se/fredand44/questions/test.3DS
> But my own object doesn't seems to have any Shape3Ds? Perhaps any one could
> give a hint about that as well.
>
> I use the Import3DS from:
> http://www.j3d.org/utilities/loaders/3ds/mulder.html
> to load my objects. So if you would like to test this I think you have to
> download it.
>
> So if any one could give me a hint I would be most thankfull!
>
> Best regards
> Fredrik Andersson
>
> My code to test this is:
>
> import java.applet.*;
> import java.awt.*;
> import java.awt.Frame;
> import java.awt.event.*;
> import com.sun.j3d.utils.applet.MainFrame;
> import com.sun.j3d.utils.universe.*;
> import com.sun.j3d.utils.geometry.*;
> import com.sun.j3d.utils.behaviors.keyboard.*;
> import javax.media.j3d.*;
> import javax.vecmath.*;
> import javax.swing.*;
> import com.sun.j3d.loaders.*;
>
> import java.util.*;
>
> import java3d.loaders.*;
>
> public class TestLoad extends Applet
> {
>         BranchGroup branchGroup;
>
>         public void init()
>         {
>                 setLayout(new BorderLayout());
>                 GraphicsConfiguration config = 
> SimpleUniverse.getPreferredConfiguration();
>                 Canvas3D canvas3D = new Canvas3D(config);
>                 add("Center", canvas3D);
>                 SimpleUniverse simpleUniverse = new SimpleUniverse(canvas3D);
>                 branchGroup = new BranchGroup();
>
>                 TransformGroup transformGroup1 = new TransformGroup();
>                 Transform3D transform3D1 = new Transform3D();
>                 transform3D1.set(new Vector3f(-2.0f, 0.0f, -20.0f));
>                 transformGroup1.setTransform(transform3D1);
>                 Appearance appearance1 = new Appearance();
>                 Color3f objColor1 = new Color3f(0.7f, 0.7f, 0.7f);
>                 Color3f black1 = new Color3f(0.0f, 0.0f, 0.0f);
>                 appearance1.setMaterial(new Material(objColor1, black1, objColor1, 
> black1,
> 80.0f));
>                 Cone cone1 = new Cone(0.4f, 0.4f);
>                 cone1.setAppearance(appearance1);
>                 transformGroup1.addChild(cone1);
>                 branchGroup.addChild(transformGroup1);
>
>                 TransformGroup transformGroup2 = loadTransformGroup();
>                 Transform3D transform3D2 = new Transform3D();
>                 transform3D2.set(new Vector3f(0.0f, 0.0f, -20.0f));
>                 transformGroup2.setTransform(transform3D2);
>                 branchGroup.addChild(transformGroup2);
>
>                 TransformGroup transformGroup3 = new TransformGroup();
>                 Transform3D transform3D3 = new Transform3D();
>                 transform3D3.set(new Vector3f(2.0f, 0.0f, -20.0f));
>                 transformGroup3.setTransform(transform3D3);
>                 Appearance appearance2 = new Appearance();
>                 Color3f objColor2 = new Color3f(0.7f, 0.7f, 0.7f);
>                 Color3f black2 = new Color3f(0.0f, 0.0f, 0.0f);
>                 appearance2.setMaterial(new Material(objColor2, black2, objColor2, 
> black2,
> 80.0f));
>                 Cone cone2 = new Cone(0.4f, 0.4f);
>                 cone2.setAppearance(appearance2);
>                 transformGroup3.addChild(cone2);
>                 branchGroup.addChild(transformGroup3);
>
>                 addDirectionalLight(new Vector3f(0.0f, 0.0f, -20.0f), new 
> Color3f(0.9f,
> 0.9f, 0.9f));
>                 addDirectionalLight(new Vector3f(0.0f, 0.0f, -20.0f), new 
> Color3f(0.9f,
> 0.9f, 0.9f));
>
>                 branchGroup.compile();
>                 simpleUniverse.addBranchGraph(branchGroup);
>         }
>
>         public TransformGroup loadTransformGroup()
>         {
>                 TransformGroup transformGroup = null;
>                 try
>                 {
>                         Loader loader = new ThreeDSLoader();
>                         Scene scene = loader.load("girl.3ds");
>                         BranchGroup branchGroup = scene.getSceneGroup();
>                         transformGroup = new TransformGroup();
>
>                         System.out.println();
>
>                         Enumeration enumeration = branchGroup.getAllChildren();
>                         int i =0;
>                         while(enumeration.hasMoreElements())
>                         {
>                                 i++;
>                                 Object obj = enumeration.nextElement();
>                                 Class cl = obj.getClass();
>                                 System.out.println(cl.getName());
>
>                         }
>                         System.out.println(i);
>                         System.out.println();
>
>                         transformGroup = (TransformGroup) branchGroup.getChild(1);
>                         branchGroup.removeChild(1);
>
>                         enumeration = transformGroup.getAllChildren();
>                         i =0;
>                         Appearance appearance = new Appearance();
>                         Color3f objColor = new Color3f(0.9f, 0.9f, 0.9f);
>                         Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
>                         appearance.setMaterial(new Material(objColor, black, 
> objColor, black,
> 80.0f));
>
>                         while(enumeration.hasMoreElements())
>                         {
>                                 i++;
>                                 Shape3D obj = (Shape3D)enumeration.nextElement();
>                                 Class cl = obj.getClass();
>                                 System.out.println(cl.getName());
>                                 obj.setAppearance(appearance);
>                         }
>                         System.out.println(i);
>                 }
>                 catch(Exception e)
>                 {
>                         e.printStackTrace();
>                 }
>
>                 return transformGroup;
>         }
>
>         public void addDirectionalLight(Vector3f direction, Color3f color)
>         {
>                 BoundingSphere bounds = new BoundingSphere();
>                 bounds.setRadius(1000d);
>
>                 DirectionalLight lightD = new DirectionalLight(color, direction);
>                 lightD.setInfluencingBounds(bounds);
>
>                 branchGroup.addChild(lightD);
>         }
>
>         public static void main(String[] args)
>         {
>                 Frame frame = new MainFrame(new TestLoad(), 600, 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