nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
563519d
)
lib/gamnit: intro `EulerCamera::look_at`
author
Alexis Laferrière
<alexis.laf@xymus.net>
Mon, 11 Jan 2016 14:11:18 +0000
(09:11 -0500)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Sun, 17 Jan 2016 22:50:28 +0000
(17:50 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/gamnit/cameras.nit
patch
|
blob
|
history
diff --git
a/lib/gamnit/cameras.nit
b/lib/gamnit/cameras.nit
index
2dfc706
..
df29341
100644
(file)
--- a/
lib/gamnit/cameras.nit
+++ b/
lib/gamnit/cameras.nit
@@
-98,6
+98,17
@@
class EulerCamera
position.y += dy
end
position.y += dy
end
+ # Aim the camera at `x, y, z`
+ fun look_at(x, y, z: Float)
+ do
+ var dx = position.x
+ var dy = position.y
+ var dz = position.z
+
+ yaw = atan2(dx, dz)
+ pitch = atan2(-dy, dz)
+ end
+
# Rotation matrix produced by the current rotation of the camera
protected fun rotation_matrix: Matrix
do
# Rotation matrix produced by the current rotation of the camera
protected fun rotation_matrix: Matrix
do