[Java 3D] rotation de text3D : bug !?
Bonjour,
J'ai un souci avec Java 3d, et plus précisement la classe Text3D.
En fait, je cherche a faire tourner un texte en 3D. Le texte tourne bien, cependant, il y a un bug/probleme.
En fait, le texte clignote a chaque moitié de tour.Apres des heures intensives de bataille avec java j'ai compris qu'il clignotait uniquement si il etait trop court. Par exemple, le texte "essai" buggue, mais le texte "essai qui marche" ne buggue pas. Voici mon code
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 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
| import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.*;
import com.sun.j3d.utils.behaviors.mouse.* ;
import java.awt.* ;
import java.awt.event.* ;
import javax.media.j3d.* ;
import javax.swing.*;
import javax.vecmath.* ;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
public class troisd extends JPanel
{
//initialisation des objets
Canvas3D can ;
SimpleUniverse su ;
Text3D texte ;
public static troisd owi ;
public static final long serialVersionUID = 24362462L; //evite les warnings (option XLint)
public troisd ()
{
}
public void univers ()
{
//compile de l'univers
can = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
su = new SimpleUniverse(can) ;
su.getViewingPlatform().setNominalViewingTransform() ;
}
public void creer_texte(float nombre)
{
//initialisation
BranchGroup bg = new BranchGroup () ;
Font3D font3D = new Font3D(new Font("Arial", Font.PLAIN, 1), new FontExtrusion());
texte = new Text3D (font3D , "essai", new Point3f(1f, -0.5f, -6f), Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT) ;
Transform3D scale3D = new Transform3D() ;
TransformGroup scale = new TransformGroup(scale3D) ;
scale.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Shape3D text=new Shape3D();
text.setGeometry(texte);
scale.addChild(text);
Transform3D tr = new Transform3D () ;
tr.set ( new Vector3f(1f, -0.5f, -6f)) ;
Alpha alpha = new Alpha(-1,4000);
RotationInterpolator rotator=new RotationInterpolator(alpha,scale);
rotator.setTransformAxis(tr) ;
BoundingSphere bounds=new BoundingSphere();
rotator.setSchedulingBounds(bounds);
scale.addChild(rotator); //on rajoute l'objet3D a la scene
bg.addChild(scale);
//finalisation
bg.compile() ;
su.addBranchGraph (bg) ;
}
public void changer_texte (String texte_3d)
{
texte.setString(texte_3d) ;
}
public void fin ()
{
//options
this.setLayout (new BorderLayout()) ;
this.add("Center", can) ;
this.setVisible(true) ;
}
public static void main (String[]args)
{
owi = new troisd() ;
owi.univers() ;
owi.creer_texte(2f) ;
owi.fin() ;
}
} |
Merci de vos réponses
Enjoy
The lsd