diff --git a/src/morse/blender/view_camera.py b/src/morse/blender/view_camera.py index 636855100..8e5abf465 100644 --- a/src/morse/blender/view_camera.py +++ b/src/morse/blender/view_camera.py @@ -39,12 +39,20 @@ def store_default(contr): if 'move_cameraFP' in obj.getPropertyNames(): keyboard_ctrl_objects.append(obj) -def reset_position(contr): +def reset_position(camera): """ Put the camera in the initial position and orientation """ - camera = contr.owner camera.worldPosition = start_position camera.worldOrientation = start_orientation +def look_robot(camera): + """ Put the camera above a robot """ + robots = [r for r in blenderapi.persistantstorage().robotDict] + robot = robots[0] # TODO + loc = robot.worldPosition + rot = robot.worldOrientation.to_euler() + camera.worldPosition = [ loc.x - 2, loc.y, loc.z + 2 ] + camera.worldOrientation = [ rot.x + 1.1, rot.y, rot.z - 1.5 ] + def move(contr): """ Read the keys for specific combinations @@ -106,7 +114,9 @@ def move(contr): # Other actions activated with the keyboard # Reset camera to center if key[0] == blenderapi.F8KEY and keyboard.positive: - reset_position(contr) + reset_position(camera) + if key[0] == blenderapi.F7KEY and keyboard.positive: + look_robot(camera) def rotate(contr): diff --git a/src/morse/core/blenderapi.py b/src/morse/core/blenderapi.py index 2fb645850..4bf1d2725 100644 --- a/src/morse/core/blenderapi.py +++ b/src/morse/core/blenderapi.py @@ -53,6 +53,7 @@ RIGHTMOUSE = None F5KEY = None +F7KEY = None F8KEY = None @@ -87,6 +88,7 @@ RIGHTMOUSE = bge.events.RIGHTMOUSE F8KEY = bge.events.F8KEY + F7KEY = bge.events.F7KEY F5KEY = bge.events.F5KEY def input_active():