IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

3D Java Discussion :

[Java 3D] rotation de text3D : bug !?


Sujet :

3D Java

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7
    Points : 3
    Points
    3
    Par défaut [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 : 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
    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

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7
    Points : 3
    Points
    3
    Par défaut
    Nan ben c'est bon en fait, on m'a filé un coup de main, j'ai un truc qui marche maintenant !

    la méthode creer_text doit ressembler a ca :

    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
    public void creer_texte()
    {
     
     
    		BranchGroup bg = new BranchGroup();
    		Transform3D recul = new Transform3D();
    		recul.set(new Vector3f(0f,0f,-3f));
    		TransformGroup tg = new TransformGroup(recul);
    		BranchGroup principal = new BranchGroup();
    		TransformGroup tourner = new TransformGroup();
    		tourner.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    		Font3D font = new Font3D(new Font("Helvetica",Font.PLAIN,1),new FontExtrusion());
    		Text3D texte = new Text3D(font , "Pouned",new Point3f(0f,0f,-1f));
    		texte.setAlignment(Text3D.ALIGN_CENTER);
    		Alpha transforme = new Alpha(-1,4000);
    		RotationInterpolator rotation = new RotationInterpolator(transforme,tourner);
    		rotation.setSchedulingBounds(new BoundingSphere());
    		tourner.addChild(new Shape3D(texte));
    		tourner.addChild(rotation);
    		principal.addChild(tourner);
    		tg.addChild(principal);
    		bg.addChild(tg);
     
    	//finalisation
    	bg.compile() ;
    	su.addBranchGraph (bg) ;
    }
    Enjoy

    The lsd

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [bug] java 1.6 JFrame
    Par soad dans le forum Agents de placement/Fenêtres
    Réponses: 3
    Dernier message: 19/04/2006, 00h05
  2. [java 3D] translations et rotations
    Par anotherboo dans le forum 3D
    Réponses: 2
    Dernier message: 29/01/2006, 16h23
  3. [JDialog] Icône d'une JDialog (bug Java or not ?)
    Par Oliveuh dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 22/07/2005, 13h03
  4. [PROPERTIES] Bug dans java.util.Properties ?
    Par mathieu dans le forum Collection et Stream
    Réponses: 6
    Dernier message: 28/04/2004, 16h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo