I'm about to go crazy with this code. I load the mesh/model from a 3ds file with a proper loader and I put it to render but nothing appears. Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| package teste; import com.sun.j3d.loaders.*; import com.sun.j3d.loaders.objectfile.ObjectFile; import com.sun.j3d.utils.geometry.Text2D; import javax.swing.*; import javax.media.j3d.*; import com.sun.j3d.utils.universe.*; import java.awt.*; import java.io.*; import javax.vecmath.*; import ncsa.j3d.*; import ncsa.j3d.loaders.*;
public class Main {
public static void main(String[] args) throws Exception{ JFrame frame = new JFrame("Teste Java3D"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(640, 480); frame.setResizable(false); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas = new Canvas3D(config); SimpleUniverse universe = new SimpleUniverse(canvas); BranchGroup group = new BranchGroup(); final int BOUNDSIZE = 100; BoundingSphere bounds = new BoundingSphere(new Point3d(0,0,0), BOUNDSIZE); Scene s = null; ModelLoader map = new ModelLoader(); try { s = map.load("/home/ramon/data/models/Coolrobo.3ds"); } catch(Exception e) { e.printStackTrace(); } BranchGroup gr = s.getSceneGroup(); gr.setBounds(bounds); TransformGroup tg = new TransformGroup(); tg.addChild(gr); Switch sw = new Switch(); sw.addChild(tg); sw.setCapability(Switch.ALLOW_SWITCH_WRITE); sw.setWhichChild( Switch.CHILD_ALL ); group.addChild(sw); group.compile(); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(group); frame.add(canvas); frame.setVisible(true); }
} |
Text3D works finely, Text2D also, the primitives as well, my only problem is with the mesh/model.
Please someone give me some help!!
P.S.: My problem is that I can't see the mesh rendered! It's not the API, other program(not written by me) works finely with the very same mesh. It's not the lib. I don't know what is!