package a3test.controller;

import jp.sourceforge.acerola3d.a3.*;
import javax.vecmath.*;
import java.awt.event.*;

public class NaviParamTest extends KeyAdapter {
    static Action3D avatar;
    public static void main(String args[]) throws Exception {
        A3Window w = new A3Window(300,300);
        Vector3d lookAt = new Vector3d(0.0,0.0,0.0);
        Vector3d camera = new Vector3d(0.0,3.0,-5.0);
        Vector3d up = new Vector3d(0.0,1.0,0.0);
        w.setNavigationMode(A3CanvasInterface.NaviMode.CHASE,lookAt,camera,up,1.0);
        Action3D a3 = new Action3D("x-res:///axis.a3");
        w.add(a3);
        avatar = new Action3D("x-res:///vesma9.a3");
        avatar.setEnableBehavior(true);
        avatar.setAutoActionControl(true);
        w.add(avatar);
        w.setAvatar(avatar);
        w.addKeyListener(new NaviParamTest());
    }
    public void keyPressed(KeyEvent e) {
        Vector3d front = avatar.getUnitVecZ();
        front.scale(0.1);
        switch(e.getKeyCode()) {
        case KeyEvent.VK_RIGHT: avatar.mulRot(0.0,-0.1,0.0);break;
        case KeyEvent.VK_LEFT: avatar.mulRot(0.0,0.1,0.0);break;
        case KeyEvent.VK_UP: avatar.addLoc(front); break;
        case KeyEvent.VK_DOWN: front.scale(-1.0);avatar.addLoc(front);break;
        }
    }
}
