View Single Post
Old 18-01-2010, 16:37   #13
franksisca
Senior Member
 
L'Avatar di franksisca
 
Iscritto dal: May 2005
Cittā: Roma
Messaggi: 7938
behaviior2
Codice:
package gestioneCollisioniAvanzata;

import java.awt.event.KeyEvent;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3d;

import dunJeonPac.Posizione;

public class EsecutoreEventi {

	private static final int forwardKey = KeyEvent.VK_W;
	private static final int backKey = KeyEvent.VK_S;
	private static final int leftKey = KeyEvent.VK_A;
	private static final int rightKey = KeyEvent.VK_D;
	private Vector3d spostamento;
	private Vector3d rotazione;
	private Transform3D nominal = new Transform3D();
	private TransformGroup targetTG;

	public EsecutoreEventi(TransformGroup targetTG) {

		this.targetTG = targetTG;
		this.targetTG.getTransform(nominal);
		this.spostamento = new Vector3d(0.0, 0.0, 0.0);
		this.rotazione = new Vector3d(0.0, 0.0, 0.0);

	}

	public void processKeyEvent(KeyEvent eventKey, int azione) {
		if (azione == 0)
			return;
		else {

			int evento = eventKey.getKeyCode();

			if (evento == forwardKey) {
				this.spostamento = new Vector3d(0.0, 0.0, -0.24);
			}
			if (evento == forwardKey && evento == rightKey) {
				this.spostamento = new Vector3d(0.240, 0.0, -0.24);
			}
			if (evento == backKey) {
				this.spostamento = new Vector3d(0.0, 0.0, 0.24);
			}
			if (evento == leftKey) {
				this.spostamento = new Vector3d(-0.240, 0.0, 0.0);
			}
			if (evento == rightKey) {
				this.spostamento = new Vector3d(0.24, 0.0, 0.0);
			}
			this.targetTG.getTransform(this.nominal);
			Transform3D toMove = new Transform3D();
			toMove.setTranslation(this.spostamento);
			this.nominal.mul(toMove);
			this.targetTG.setTransform(this.nominal);

			int keyCode = eventKey.getKeyCode();
			char keyChar = eventKey.getKeyChar();

			System.err.println("keyCode " + keyCode + "  keyChar " + keyChar);
		}
	}
}
altra cosa....volevo usare il mouse per spostare il punto di rotazione, ma se uso il mouse translate č un caso, che faccio...estendo e reipllmnenteo da 0?
__________________
My gaming placement
franksisca č offline   Rispondi citando il messaggio o parte di esso