From 4806f6d6c4ecad725301b0dcea1e14fa9fd16bb6 Mon Sep 17 00:00:00 2001 From: Kamn Date: Mon, 16 Feb 2015 18:05:38 -0700 Subject: [PATCH 1/2] Added the ability to get the up vector of a camera. I didn't add the set ability yet. --- src/play_clj/core_cameras.clj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/play_clj/core_cameras.clj b/src/play_clj/core_cameras.clj index 060e5ca..9267b77 100644 --- a/src/play_clj/core_cameras.clj +++ b/src/play_clj/core_cameras.clj @@ -186,6 +186,11 @@ camera will be set." (.lookAt camera x y z) (.update camera))) +(defn up [screen] + "Returns the up vector of the camera in `screen`." + (let [^Camera camera (u/get-obj screen :camera)] + (. camera up))) + (defn near "Returns the near clipping plane distance of the camera in `screen`." [screen] From 99402624a1725d422fe0fd4befb0da619c028dd6 Mon Sep 17 00:00:00 2001 From: oakes Date: Wed, 18 Feb 2015 19:34:42 -0500 Subject: [PATCH 2/2] Add up! and make a few aesthetic changes --- src/play_clj/core_cameras.clj | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/play_clj/core_cameras.clj b/src/play_clj/core_cameras.clj index 9267b77..389a389 100644 --- a/src/play_clj/core_cameras.clj +++ b/src/play_clj/core_cameras.clj @@ -169,9 +169,9 @@ camera will be set." ([object x-val y-val] (position! object x-val y-val nil)) ([object x-val y-val z-val] - (when x-val (x! object x-val)) - (when y-val (y! object y-val)) - (when z-val (z! object z-val)))) + (some->> x-val (x! object)) + (some->> y-val (y! object)) + (some->> z-val (z! object)))) (defn direction "Returns the direction of the camera in `screen`." @@ -181,9 +181,9 @@ camera will be set." (defn direction! "Sets the direction of the camera in `screen`." - [screen x y z] + [screen x-val y-val z-val] (let [^Camera camera (u/get-obj screen :camera)] - (.lookAt camera x y z) + (.lookAt camera x-val y-val z-val) (.update camera))) (defn up [screen] @@ -191,6 +191,16 @@ camera will be set." (let [^Camera camera (u/get-obj screen :camera)] (. camera up))) +(defn up! + "Sets the up vector of the camera in `screen`." + [screen x-val y-val z-val] + (let [^Camera camera (u/get-obj screen :camera) + ^Vector3 up-vec (up screen)] + (some->> x-val (x! up-vec)) + (some->> y-val (y! up-vec)) + (some->> z-val (z! up-vec)) + (.update camera))) + (defn near "Returns the near clipping plane distance of the camera in `screen`." [screen]