[Java 3D] Problème avec Behavior
Bonjour!
Je travaille avec Java3D et j'aimerais ajouter un Behavior qui recupère la touche sur laquelle l'utilisateur appuie.
J'ai créé une classe ActionBehavior qui hérite de Behavior.
Je crée une instance comme ça:
Code:
1 2 3 4 5
|
TransformGroup objet = new TransformGroup();
ActionBehavior actionBehavior = new ActionBehavior(objet);
actionBehavior.setSchedulingBounds(new BoundingSphere(new Point3d(), 150d));
objet.addChild(actionBehavior); |
Et voici le code de ma classe ActionBehavior
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
|
private TransformGroup objet;
private WakeupOnAWTEvent keyPressed = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
public ActionBehavior(TransformGroup objet)
{
super();
this.objet = objet;
System.out.println("Constructed");
}
public void initialize()
{
// Ce Behavior reagit aux commandes du joueur
this.wakeupOn(keyPressed);
System.out.println("Initialize");
}
public void processStimulus(Enumeration arg)
{
System.out.println("Process");
// On reactive le behavior
this.wakeupOn(keyPressed);
} |
La console affiche que l'objet est construit et initialisé mais processStimulus ne se lance jamais!
Si vous savez pourquoi, merci de répondre:D