-
Notifications
You must be signed in to change notification settings - Fork 9
/
hello_terrain.clj
47 lines (39 loc) · 1.72 KB
/
hello_terrain.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;; Please start your REPL with `+test` profile
(ns examples.beginner-tutorials.hello-terrain
"Clojure version of https://wiki.jmonkeyengine.org/docs/3.3/tutorials/beginner/hello_terrain.html"
(:require
[jme-clj.core :refer :all])
(:import
(com.jme3.texture Texture$WrapMode)))
(defn init []
(set* (fly-cam) :move-speed 50)
(let [grass (set* (load-texture "Textures/Terrain/splat/grass.jpg") :wrap Texture$WrapMode/Repeat)
dirt (set* (load-texture "Textures/Terrain/splat/dirt.jpg") :wrap Texture$WrapMode/Repeat)
rock (set* (load-texture "Textures/Terrain/splat/road.jpg") :wrap Texture$WrapMode/Repeat)
mat (material "Common/MatDefs/Terrain/Terrain.j3md")
height-map-tex (load-texture "Textures/Terrain/splat/mountains512.png")
height-map (->> height-map-tex image image-based-height-map load-height-map)
patch-size 65
terrain (terrain-quad "my terrain" patch-size 513 (get-height-map height-map))]
(-> mat
(set* :texture "Alpha" (load-texture "Textures/Terrain/splat/alphamap.png"))
(set* :texture "Tex1" grass)
(set* :float "Tex1Scale" (float 64))
(set* :texture "Tex2" dirt)
(set* :float "Tex2Scale" (float 32))
(set* :texture "Tex3" rock)
(set* :float "Tex3Scale" (float 128)))
(-> terrain
(set* :material mat)
(set* :local-translation 0 -100 0)
(set* :local-scale 2 1 2)
(add-to-root)
(add-control (terrain-lod-control terrain (cam))))))
(defsimpleapp app :init init)
(comment
(start app)
;;after calling unbind-app, we need to re-define the app with defsimpleapp
(unbind-app #'app)
(run app
(re-init init))
)