-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path25-SceneGui.sb
More file actions
108 lines (85 loc) · 2.79 KB
/
25-SceneGui.sb
File metadata and controls
108 lines (85 loc) · 2.79 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
;Babylon.sbi - GUI (Graphical User Interface)
EnableExplicit
IncludeFile "babylon/babylon.sbi"
;Scene
Global Scene, Camera, Light, Mesh, Texture, Material
;GUI
Global SceneGUI, Text, Slider, Button, PickerColor
Declare LoadGame()
Declare GUIEvent(Control, Name.s, Value)
Declare RenderGame()
UseModule BJS
InitEngine(@LoadGame())
Procedure LoadGame()
Scene = CreateScene()
If Scene
;Camera
Camera = CreateCamera("camera", 0, 10, -20, #BJS_ArcRotate)
CameraLookAt(Camera, 0, 0, 0)
;Light
ClearScene(RGB(63, 60, 60))
Light = CreateLight("light", 0, 200, 0)
;Material
Texture = LoadTexture("Data/textures/beton1.png")
Material = CreateMaterial("ground")
SetMaterialTexture(Material, #BJS_Diffuse, Texture)
SetMaterialColor(Material, #BJS_Specular, RGB(60, 60, 60))
ScaleMaterial(Material, 5, 5)
;Ground
Mesh = CreateBox("ground", 20, 0.5, 20)
SetMeshMaterial(Mesh, Material)
;Scene GUI
SceneGUI = CreateDynamicTexture()
Text = Text3D("text", 20, 20, 150, 24, "Light Intensity", #BJS_Left)
AddControl3D(SceneGUI, Text)
Slider = Slider3D("light intensity", 200, 22, 150, 20, 0, 1, @GUIEvent(), 9)
SetState3D(Slider, 1)
SetColor3D(Slider, #BJS_BackColor, RGB(220, 220, 220))
SetColor3D(Slider, #BJS_FrontColor, RGB(128, 128, 128))
AddControl3D(SceneGUI, Slider)
Button = Button3D("On Off", 360, 20, 60, 24, "Off", @GUIEvent())
AddControl3D(SceneGUI, Button)
Text = Text3D("text", 20, 60, 150, 24, "Scene Color", #BJS_Left)
AddControl3D(SceneGUI, Text)
PickerColor = PickerColor3D("SceneColor", 200, 60, 150, 150, @GUIEvent())
AddControl3D(SceneGUI, PickerColor)
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure GUIEvent(Control, Name.s, Value)
Select Control
Case Slider
If Value > 0
SetText3D(Button, "Off")
Else
SetText3D(Button, "On")
EndIf
SetLightIntensity(Light, Value)
Case Button
Debug GetText3D(Button)
If GetText3D(Button) = "Off"
SetState3D(Slider, 0)
SetLightIntensity(Light, 0)
SetText3D(Button, "On")
Else
SetState3D(Slider, 1)
SetLightIntensity(Light, 1)
SetText3D(Button, "Off")
EndIf
Case PickerColor
ClearScene(Value)
EndSelect
EndProcedure
Procedure RenderGame()
RenderWorld()
EndProcedure
; IDE Options = SpiderBasic 2.20 (Windows - x86)
; Folding = -
; WebAppName = GUI Demo
; HtmlFilename = gui.html
; JavaScriptFilename = gui.js
; JavaScriptPath = sb
; iOSAppOrientation = 0
; AndroidAppOrientation = 0
; EnableXP
; CompileSourceDirectory