Skip to content

Commit

Permalink
[camera] F7 moves CameraFP to robot
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickKoch committed Jan 9, 2014
1 parent 27095fc commit bc46e9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/morse/blender/view_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions src/morse/core/blenderapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
RIGHTMOUSE = None

F5KEY = None
F7KEY = None
F8KEY = None


Expand Down Expand Up @@ -87,6 +88,7 @@
RIGHTMOUSE = bge.events.RIGHTMOUSE

F8KEY = bge.events.F8KEY
F7KEY = bge.events.F7KEY
F5KEY = bge.events.F5KEY

def input_active():
Expand Down

0 comments on commit bc46e9b

Please sign in to comment.