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 :

[JAVA3D] Minuterie d'un WakeupOnElapsedTime dui déconne


Sujet :

3D Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3
    Par défaut [JAVA3D] Minuterie d'un WakeupOnElapsedTime dui déconne
    Bonjour, je suis en train de réaliser un manege en java3D pour mes études,

    J'ai réaliser les objets et je dois fair bouger une nacelle prédéfinie suivant la touche utilisé et suivant un temps voulu.

    Mon problème se base sur ma classe des touches utilisé, suivant cette classe quand j'appuie sur une touche un nacelle tourne durant un moment prédefini mais il faut que je reste appuyer sur cette touche pour la faire tourner.

    Voici le code de ma classe KeyBehavior :

    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
    97
    98
    99
    100
     
    import java.util.Enumeration;
    import java.awt.event.KeyEvent;
    import java.awt.AWTEvent;
    import javax.vecmath.Point3d;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.Behavior;
    import javax.media.j3d.WakeupCriterion;
    import javax.media.j3d.WakeupCondition;
    import javax.media.j3d.WakeupOr;
    import javax.media.j3d.WakeupOnElapsedTime;
    import javax.media.j3d.WakeupOnAWTEvent;
     
     
    public class KeyBehavior extends Behavior
    {
     
    	private WakeupCriterion[] wakeup;
    	private WakeupCondition wakeupCombi;
        private Controlable ctrl;
       private boolean fixed = true;
     
    	public KeyBehavior (Controlable ctrl)
    	{
    		wakeup = new WakeupCriterion[2];
    		wakeup[0] = new WakeupOnAWTEvent (KeyEvent.KEY_PRESSED );
    		wakeup[1] = new WakeupOnElapsedTime (50L); // minuterie
    		wakeupCombi = new WakeupOr (wakeup);
    	 this.ctrl = ctrl;
        setSchedulingBounds (new BoundingSphere (new Point3d (), 300.0));
     
    	}
     
    	public void initialize()
    	{
    		this.wakeupOn (wakeup[0]);
    	}
     
    	public void processStimulus(Enumeration Criteria)
    	{
     
    		AWTEvent[] tabEvent = ( (WakeupOnAWTEvent) wakeup[0]).getAWTEvent();
    		AWTEvent event;
    		for (int i = 0; i < tabEvent.length; i++) 
    		{
    			event  = tabEvent[i];
     
    			switch (((KeyEvent) event).getKeyCode()) 
    			{
    				case KeyEvent.VK_UP :
    					System.out.println("UP");
    					if (fixed = !fixed) this.wakeupOn (wakeup[0]);
                        else this.wakeupOn (wakeupCombi);
     
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    					 else
    					      {
    					        this.wakeupOn (wakeup[0]);
    					        fixed = true;
    					      }
     
    					break;
     
    				case KeyEvent.VK_DOWN :
    					System.out.println("DOWN");
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    				      else
    				      {
    				        this.wakeupOn (wakeup[0]);
    				        fixed = true;
    				      }
     
    					break;
     
    				case KeyEvent.VK_LEFT :
    					System.out.println("LEFT");
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    				      else
    				      {
    				        this.wakeupOn (wakeup[0]);
    				        fixed = true;
    				      }
     
    					break;
    				case KeyEvent.VK_RIGHT :
    					System.out.println("RIGHT");
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    				      else
    				      {
    				        this.wakeupOn (wakeup[0]);
    				        fixed = true;
    				      }
     
    					break;
    			}
     
                  // System.out.println(" fin switch");
    		}wakeupOn(wakeupCombi);
        }
    }
    Auriez vous une solution pour mon problème ? C'est à dire j'appuie sur une touche et une nacelle tourne durant un moment?

    Merci par avance.

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3
    Par défaut [JAVA3D] Minuterie d'un WakeupOnElapsedTime dui déconne
    voici mon nouveau algo :
    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
     
    import java.util.Enumeration;
    import java.awt.event.KeyEvent;
    import java.awt.AWTEvent;
    import javax.vecmath.Point3d;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.Behavior;
    import javax.media.j3d.WakeupCriterion;
    import javax.media.j3d.WakeupCondition;
    import javax.media.j3d.WakeupOr;
    import javax.media.j3d.WakeupOnElapsedTime;
    import javax.media.j3d.WakeupOnAWTEvent;
     
    /** Tache de fond applicable a un objet KeyPressedControlable. */
     
    public class KeyBehavior extends Behavior
    {
     
    	private WakeupCriterion[] wakeup;
    	private WakeupCondition wakeupCombi;
        private Controlable ctrl;
       private boolean fixed = true;
     
    	public KeyBehavior (Controlable ctrl)
    	{
    		wakeup = new WakeupCriterion[2];
    		wakeup[0] = new WakeupOnAWTEvent (KeyEvent.KEY_PRESSED );
    		wakeup[1] = new WakeupOnElapsedTime (50L); // minuterie
    		wakeupCombi = new WakeupOr (wakeup);
    	 this.ctrl = ctrl;
        setSchedulingBounds (new BoundingSphere (new Point3d (), 300.0));
     
    	}
     
    	public void initialize()
    	{
    		this.wakeupOn (wakeup[0]);
    	}
     
    	public void processStimulus(Enumeration Criteria)
    	{
     
    		AWTEvent[] tabEvent = ( (WakeupOnAWTEvent) wakeup[0]).getAWTEvent();
    		AWTEvent event;
    		for (int i = 0; i < tabEvent.length; i++) 
    		{
    			event  = tabEvent[i];
     
    			switch (((KeyEvent) event).getKeyCode()) 
    			{
    				case KeyEvent.VK_UP :
    					System.out.println("UP");
    					if (fixed = !fixed) this.wakeupOn (wakeup[0]);
                        else this.wakeupOn (wakeupCombi);
     
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    					 else
    					      {
    					        this.wakeupOn (wakeup[0]);
    					        fixed = true;
    					      }
     
    					break;
     
    				case KeyEvent.VK_DOWN :
    					System.out.println("DOWN");
    					if (fixed = !fixed) this.wakeupOn (wakeup[0]);
                        else this.wakeupOn (wakeupCombi);
     
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    					 else
    					      {
    					        this.wakeupOn (wakeup[0]);
    					        fixed = true;
    					      }
     
    					break;
     
    				case KeyEvent.VK_LEFT :
    					System.out.println("LEFT");
    					if (fixed = !fixed) this.wakeupOn (wakeup[0]);
                        else this.wakeupOn (wakeupCombi);
     
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    					 else
    					      {
    					        this.wakeupOn (wakeup[0]);
    					        fixed = true;
    					      }
     
    					break;
    				case KeyEvent.VK_RIGHT :
    					System.out.println("RIGHT");
    					if (fixed = !fixed) this.wakeupOn (wakeup[0]);
                        else this.wakeupOn (wakeupCombi);
     
    					if (ctrl.incrementer ()) this.wakeupOn (wakeupCombi);
    					 else
    					      {
    					        this.wakeupOn (wakeup[0]);
    					        fixed = true;
    					      }
     
    					break;
    			}
     
                  // System.out.println(" fin switch");
    		}wakeupOn(wakeupCombi);
        }
    }
    et il me marque parfois (durant l'utilisation d'une touche) :
    wglMakeCurrent Failed: L'operation de transfoemation demandée n'est pas prise en charge

    wglMakeCurrent Failed: Descripteur non valide

    Je connais pas du tout cette erreur et je ne vois pas ou elle se trouve.

    Si vous avez une iddée je suis tout ouie. Merci d'avance pour votre aide

Discussions similaires

  1. [java3D][collision]
    Par geofun dans le forum 3D
    Réponses: 7
    Dernier message: 12/02/2007, 14h49
  2. [java] java3d vs Jogl
    Par mandale dans le forum OpenGL
    Réponses: 3
    Dernier message: 03/01/2005, 15h44
  3. [java3d] superposition des éléments
    Par moutse dans le forum 3D
    Réponses: 3
    Dernier message: 19/10/2004, 12h59
  4. Réponses: 3
    Dernier message: 07/10/2004, 17h02
  5. [Java3D]Construction de terrain
    Par zoulou1212 dans le forum 3D
    Réponses: 6
    Dernier message: 17/09/2004, 11h06

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