# HG changeset patch # User Robert McIntyre # Date 1320997967 25200 # Node ID ee55966ce7f6191b4cccd5cd3f63a0e91e0ddc25 # Parent 286a00500ee51974913b2f9ba4d647550913ffe4 enhanced cortex.utils to do proper lighting when viewing objects diff -r 286a00500ee5 -r ee55966ce7f6 .hgignore --- a/.hgignore Thu Nov 10 23:24:02 2011 -0700 +++ b/.hgignore Fri Nov 11 00:52:47 2011 -0700 @@ -3,4 +3,8 @@ src* html* tmp* -capture-video.html \ No newline at end of file +capture-video.html + + +syntax: regexp +^.*blend\d$ \ No newline at end of file diff -r 286a00500ee5 -r ee55966ce7f6 assets/Models/uv/uv3.blend Binary file assets/Models/uv/uv3.blend has changed diff -r 286a00500ee5 -r ee55966ce7f6 assets/Models/uv/uv3.blend1 Binary file assets/Models/uv/uv3.blend1 has changed diff -r 286a00500ee5 -r ee55966ce7f6 assets/Models/uv/uv3.blend2 Binary file assets/Models/uv/uv3.blend2 has changed diff -r 286a00500ee5 -r ee55966ce7f6 org/body.org --- a/org/body.org Thu Nov 10 23:24:02 2011 -0700 +++ b/org/body.org Fri Nov 11 00:52:47 2011 -0700 @@ -27,7 +27,6 @@ (doto (asset-manager) (.registerLoader BlenderModelLoader (into-array String ["blend"]))) model))) - #+end_src diff -r 286a00500ee5 -r ee55966ce7f6 org/util.org --- a/org/util.org Thu Nov 10 23:24:02 2011 -0700 +++ b/org/util.org Fri Nov 11 00:52:47 2011 -0700 @@ -92,6 +92,7 @@ (:import com.jme3.scene.shape.Box) (:import com.jme3.scene.Node) (:import com.jme3.scene.shape.Sphere) + (:import com.jme3.light.AmbientLight) (:import com.jme3.light.DirectionalLight) (:import com.jme3.math.ColorRGBA) (:import com.jme3.bullet.BulletAppState) @@ -185,6 +186,9 @@ #+end_src +#+results: util +: #'cortex.util/apply-map + *** Creating Basic Shapes @@ -284,6 +288,37 @@ (view [geo] (view (doto (Node.)(.attachChild geo))))) +(defn basic-light-setup + "returns a sequence of lights appropiate for fully lighting a scene" + [] + (conj + (doall + (map + (fn [direction] + (doto (DirectionalLight.) + (.setDirection direction) + (.setColor ColorRGBA/White))) + [;; six faces of a cube + Vector3f/UNIT_X + Vector3f/UNIT_Y + Vector3f/UNIT_Z + (.mult Vector3f/UNIT_X (float -1)) + (.mult Vector3f/UNIT_Y (float -1)) + (.mult Vector3f/UNIT_Z (float -1))])) + (doto (AmbientLight.) + (.setColor ColorRGBA/White)))) + +(defn light-up-everything + "Add lights to a world appropiate for quickly seeing everything + in the scene. Adds six DirectionalLights facing in orthogonal + directions, and one AmbientLight to provide overall lighting + coverage." + [world] + (dorun + (map + #(.addLight (.getRootNode world) %) + (basic-light-setup)))) + (extend-type com.jme3.scene.Node Viewable (view @@ -295,13 +330,7 @@ (fn [world] (enable-debug world) (set-gravity world Vector3f/ZERO) - (let [sun - (doto (DirectionalLight.) - (.setDirection - (.normalizeLocal (Vector3f. 1 0 -2))) - (.setColor ColorRGBA/White))] - ;; lights are required to view some objects. - (.addLight (.getRootNode world) sun))) + (light-up-everything world)) no-op)))) #+end_src