-
Notifications
You must be signed in to change notification settings - Fork 9
/
hello_asset.clj
54 lines (46 loc) · 2.1 KB
/
hello_asset.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
48
49
50
51
52
53
54
;; Please start your REPL with `+test` profile
(ns examples.beginner-tutorials.hello-asset
"Clojure version of https://wiki.jmonkeyengine.org/docs/3.3/tutorials/beginner/hello_asset.html"
(:require [jme-clj.core :refer :all]))
(defn init []
(let [root-node (root-node)
mat-default (material "Common/MatDefs/Misc/ShowNormals.j3md")
teapot (load-model "Models/Teapot/Teapot.obj")
teapot (set* teapot :material mat-default)
root-node (attach-child root-node teapot)
;; Create a wall with a simple texture from test_data
box (box 2.5 2.5 1.0)
mat-brick (material "Common/MatDefs/Misc/Unshaded.j3md")
texture (load-texture "Textures/Terrain/BrickWall/BrickWall.jpg")
mat-brick (set* mat-brick :texture "ColorMap" texture)
wall (geo "Box" box)
wall (-> wall (set* :material mat-brick) (set* :local-translation 2.0 -2.5 0.0))
root-node (attach-child root-node wall)
;; Display a line of text with a default font
gui-node (detach-all-child (gui-node))
gui-font (load-font "Interface/Fonts/Default.fnt")
size (-> gui-font (get* :char-set) (get* :rendered-size))
hello-text (bitmap-text gui-font false)
hello-text (-> hello-text
(set* :size size)
(set* :text "Hello World")
(set* :local-translation 300 (get* hello-text :line-height) 0))]
(attach-child gui-node hello-text)
; Load a model from test_data (OgreXML + material + texture)
(-> (load-model "Models/Ninja/Ninja.mesh.xml")
(scale 0.05 0.05 0.05)
(rotate 0.0 -3.0 0.0)
(set* :local-translation 0.0 -5.0 -2.0)
(add-to-root))
;; You must add a light to make the model visible
(-> (light :directional)
(set* :direction (vec3 -0.1 -0.7 -1.0))
(add-light-to-root))))
(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))
)