Bonjour tout le monde,

j'aurais tout simplement besoin d'avoir une vue 3D dans un JPanel qui est dans une JFrame comme dit le titre en faite...
J'ai commenté ma classe qui affiche normalement ma vue 3D dans mon JPanel:

J'espère que quelqu'un me viendra en aide,
Merci d'avance.

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
 
public class Fenetre{
 
    JLabel labelSelec = new JLabel();// pas important concernant mon problème
    BranchGroup[] groupe;
    BranchGroup objRoot=new BranchGroup();
    Canvas3D canvas3D;
    TransformGroup tg = new TransformGroup();
    SimpleUniverse simpleU;
    public void openFile(String nameFile, int j,int nbreFile){
        if(nameFile.endsWith(".stl")){
            labelSelec.setText("Selection : ");// pas important concernant mon problème
            try{
                File file = new File(nameFile);
                final STLFileReader reader = new STLFileReader(file);
                STLLoader loader = new STLLoader();
                Scene scene = loader.createScene(reader);
                groupe = new BranchGroup[200];
                groupe[j] = scene.getSceneGroup();
            }catch (IOException ex){
                System.out.println(ex);
            }
            simpleU = new SimpleUniverse(canvas3D);
            simpleU.getViewingPlatform().setNominalViewingTransform();
            tg.addChild(groupe[j]);
            objRoot.addChild(tg);        
            tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); 
            tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); 
 
            canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());     
            canvas3D.setPreferredSize(vue.getSize());
            fonctionMouse();// pas important concernant mon problème
 
            simpleU.addBranchGraph(objRoot);
            View view = simpleU.getViewer().getView();
            view.setBackClipDistance(10000);//permet d'agrandir la profondeur du milieu3D de 10000 unités
            canvas3D.repaint();
            vue.setLayout(layout);
            vue.add(canvas3D);
            vue.repaint();
            vue.validate();
            vue.setBackground(Color.green);//test pour savoir si mon panel réagit bien (la couleur change bien lorsque la fonction openFile() est appelée)
            framePrincipale.add(vue, BorderLayout.CENTER); // framePrincipale est ma JFrame et mon panel vue s'étends bien au centre
        }
    }
    public void fonctionMouse(){ // pas important concernant mon problème
        //******fonction zoom******//
        MouseZoom myMouseZoom = new MouseZoom();
        myMouseZoom.setTransformGroup(tg);
        myMouseZoom.setSchedulingBounds(new BoundingSphere());
        //******fonction rotation******//
        MouseRotate rotate = new MouseRotate(tg);
        rotate.setSchedulingBounds(new BoundingSphere());
        //******fonction déplacement******//
        MouseTranslate translate = new MouseTranslate(tg);
        translate.setSchedulingBounds(new BoundingSphere());
 
        objRoot.addChild(myMouseZoom);
        objRoot.addChild(rotate);
        objRoot.addChild(translate);
    }
}