Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blender] make camera move with constant speed #401

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified data/props/basics.blend
Binary file not shown.
28 changes: 14 additions & 14 deletions src/morse/blender/view_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,41 @@ def move(contr):
if not obj['move_cameraFP']:
return

# set the movement speed
speed = camera['Speed']
# set camera position increment from the movement speed
pos_inc = camera['Speed'] / blenderapi.getfrequency()

# Get Blender keyboard sensor
keyboard = contr.sensors['All_Keys']

# Default movement speed
move_speed = [0.0, 0.0, 0.0]
# Default movement
move_translation = [0.0, 0.0, 0.0]

keylist = keyboard.events
for key in keylist:
if key[1] == blenderapi.input_active():
# Also add the corresponding key for an AZERTY keyboard
if key[0] == blenderapi.WKEY or key[0] == blenderapi.ZKEY:
move_speed[2] = -speed
move_translation[2] = -pos_inc
elif key[0] == blenderapi.SKEY:
move_speed[2] = speed
move_translation[2] = pos_inc
# Also add the corresponding key for an AZERTY keyboard
elif key[0] == blenderapi.AKEY or key[0] == blenderapi.QKEY:
move_speed[0] = -speed
move_translation[0] = -pos_inc
elif key[0] == blenderapi.DKEY:
move_speed[0] = speed
move_translation[0] = pos_inc
elif key[0] == blenderapi.RKEY:
move_speed[1] = speed
move_translation[1] = pos_inc
elif key[0] == blenderapi.FKEY:
move_speed[1] = -speed
move_translation[1] = -pos_inc
else:
move_speed[0] = 0
move_speed[1] = 0
move_speed[2] = 0
move_translation[0] = 0
move_translation[1] = 0
move_translation[2] = 0

# The second parameter of 'applyMovement' determines
# a movement with respect to the object's local
# coordinate system
camera.applyMovement( move_speed, True )
camera.applyMovement( move_translation, True )

elif key[1] == blenderapi.input_just_activated():
# Other actions activated with the keyboard
Expand Down