Bonjour à tous,
je voudrais afficher au bout de mes axes 3D (eux mêmes affichés dans un BrachGroup) les lettres correspondantes (x, y et z). Dans le code source suivant, tout marche sauf l'ajout du texte.
Code source :
En effet, lors de la compilation, j'ai une erreur :
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 import java.awt.Font; import javax.media.j3d.Shape3D; import javax.media.j3d.*; import javax.vecmath.*; public class Axes extends Shape3D { public Axes() { LineArray la = new LineArray(6,LineArray.COORDINATES|LineArray.COLOR_3); Point3f origin = new Point3f(0.0f,0.0f,0.0f); Point3f x = new Point3f(1.0f,0.0f,0.0f); Point3f y = new Point3f(0.0f,1.0f,0.0f); Point3f z = new Point3f(0.0f,0.0f,1.0f); Point3f coords[] = {origin, x, origin, y, origin, z}; la.setCoordinates(0,coords); Color3f red = new Color3f(1.0f, 0.0f, 0.0f); Color3f green = new Color3f(0.0f, 1.0f, 0.0f); Color3f blue = new Color3f(0.0f, 0.0f, 1.0f); Color3f [] colors = {red,red, green,green,blue,blue}; la.setColors(0,colors); addGeometry(la); //BUG A PARTIR D'ICI - tout le reste au dessus fonctionne //affichage de la lettre "X" au bout de l'axe X Font3D font3D = new Font3D(new Font("Dialog", Font.BOLD, 10), new FontExtrusion()); Text3D text3D = new Text3D(font3D, "X", new Point3f(1.0f, 0.0f, 0.0f)); addGeometry(text3D); //fin bug :) } }
java.lang.IllegalArgumentException: Shape3D: the new geometry component is not of the same equivalence class as the existing geometry components.
at javax.media.j3d.Shape3DRetained.checkEquivalenceClass(Shape3DRetained.java:2649)
at javax.media.j3d.Shape3DRetained.addGeometry(Shape3DRetained.java:266)
at javax.media.j3d.Shape3D.addGeometry(Shape3D.java:396)
at Axes.<init>(Axes.java:34)
at RubikCube.createSceneGraph(RubikCube.java:184)
at RubikCube.<init>(RubikCube.java:137)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
J'ai beau lire la doc mais cela ne m'explique pas en quoi mon code ne marche pas :/
Si quelqu'un pouvait m'indiquer une piste... Cela serait sympa
Merci à tous et bonne journée !
Tamiii
Partager