- changed status to resolved
Change the perspective on key press like blender.
Issue #4
resolved
Hi, I just used this cool stuff. can you give me idea on how to change the camera perspective just like blender. e.g if we press '1' show front view, on press '2' show right view etc..
see the code block I tried in AbstractEditorState. Some how the EditorCamera class is not letting change translation and rotation of camera. can you give me idea how can I make it working.
Class:- EditorCamera
<code>
public static enum Perspective {
FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM, USER
}
private Perspective perspective = Perspective.USER;
</code>
Class:- AbstractEditorState Register keys <code>
...
if (!inputManager.hasMapping(KEY_1)) {
inputManager.addMapping(KEY_1, new KeyTrigger(KeyInput.KEY_1));
}
if (!inputManager.hasMapping(KEY_2)) {
inputManager.addMapping(KEY_2, new KeyTrigger(KeyInput.KEY_2));
}
if (!inputManager.hasMapping(KEY_3)) {
inputManager.addMapping(KEY_3, new KeyTrigger(KeyInput.KEY_3));
}
if (!inputManager.hasMapping(KEY_4)) {
inputManager.addMapping(KEY_4, new KeyTrigger(KeyInput.KEY_4));
}
if (!inputManager.hasMapping(KEY_5)) {
inputManager.addMapping(KEY_5, new KeyTrigger(KeyInput.KEY_5));
}
if (!inputManager.hasMapping(KEY_6)) {
inputManager.addMapping(KEY_6, new KeyTrigger(KeyInput.KEY_6));
}
...
inputManager.addListener(actionListener, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6);
</code>
onActionImpl <code>
...
if (KEY_1.equals(name) && !getEditorCamera().isFrontPerspective()) {
cam.setLocation(new Vector3f(0, 0, 100));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
getEditorCamera().setPerspective(Perspective.FRONT);
cam.update();
} else if (KEY_2.equals(name) && !getEditorCamera().isBackPerspective()) {
cam.setLocation(new Vector3f(0, 0, -100));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
getEditorCamera().setPerspective(Perspective.BACK);
cam.update();
} else if (KEY_3.equals(name) && !getEditorCamera().isTopPerspective()) {
cam.setLocation(new Vector3f(0, 100, 0));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Z.negate());
getEditorCamera().setPerspective(Perspective.TOP);
cam.update();
} else if (KEY_4.equals(name) && !getEditorCamera().isBottomPerspective()) {
cam.setLocation(new Vector3f(0, -100, 0));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
getEditorCamera().setPerspective(Perspective.BOTTOM);
cam.update();
} else if (KEY_5.equals(name) && !getEditorCamera().isLeftPerspective()) {
cam.setLocation(new Vector3f(-100, 0, 0));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
getEditorCamera().setPerspective(Perspective.LEFT);
cam.update();
} else if (KEY_6.equals(name) && !getEditorCamera().isRightPerspective()) {
cam.setLocation(new Vector3f(100, 0, 0));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
getEditorCamera().setPerspective(Perspective.RIGHT);
cam.update();
}
</code>
Comments (1)
-
repo owner - Log in to comment
implemented for 0.7.3