Bonjour à tous,

J'ai un petit soucis, je cherche pour l'instant à afficher un fichier .obj (OBJECT FILE) dans un Applet Java en utilisant la librairie java3d.

Voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
package com.viewer3d;
 
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Frame;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URL;
 
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
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;
import com.mnstarfire.loaders3d.*;
 
public class Viewer3d extends Applet{
 
	String fileName = "C:\\Users\\Djinner\\Desktop\\Modele 3D\\frame090.obj";
	//String fileName = "Crane_turquoise.obj";
	URL url = null; 
 
	public Viewer3d() throws MalformedURLException {
 
		this.setLayout(new BorderLayout());
 
		Canvas3D canvas3d = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
		this.add(canvas3d, BorderLayout.CENTER);
		Button button = new Button("Bouton");
 
 
		this.add(button, BorderLayout.WEST);
		SimpleUniverse simpleU = new SimpleUniverse(canvas3d);
 
		simpleU.getViewingPlatform().setNominalViewingTransform();
 
	 	TransformGroup vpTrans = simpleU.getViewingPlatform().getViewPlatformTransform();
	 	Vector3f translate = new Vector3f();
	 	translate.set(0,0,25); // move the view to wherever you want it.
	 	Transform3D T3D = new Transform3D();
	 	T3D.setTranslation(translate);
	 	vpTrans.setTransform(T3D);
 
		BranchGroup scene = createSceneGraph();
 
 
	    simpleU.addBranchGraph(scene);
 
	}
 
	private BranchGroup createSceneGraph() throws MalformedURLException {
		BranchGroup parent = new BranchGroup();
		ObjectFile f = new ObjectFile();
		Inspector3DS loader = new Inspector3DS(fileName);
		Scene s = null;
 
 
		try {
			System.out.println("Pré chargement");
			s = f.load(fileName);
			System.out.println("Chargement fini");
		} catch (IncorrectFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParsingErrorException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("Chargement vraiment fini");
		parent.addChild(s.getSceneGroup());
		System.out.println("Chargement vraiment vraiment fini");
		return parent;
	}
 
	private static void main (String[] args) {
		try {
			Frame frame = new MainFrame(new Viewer3d(), 512, 512);
 
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
Cela affiche bien le bouton sur la gauche mais pour ce qui est du Canvas3D au centre, rien ne s'affiche (juste un fond noir).

Seriez vous d'où cela peut venir ?

Merci d'avance

Djinner