-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path08-SkyBox.sb
More file actions
84 lines (64 loc) · 2.13 KB
/
08-SkyBox.sb
File metadata and controls
84 lines (64 loc) · 2.13 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
;Babylon.sbi - Skybox
EnableExplicit
IncludeFile "babylon/babylon.sbi"
Enumeration
#mf
#mfRender
EndEnumeration
Global Camera, Light0, Light1, Sky, Ground, TexGround, MatGround, Torus0, Torus1, ShadowGenerator
Declare LoadGame()
Declare RenderGame()
UseModule BJS
OpenWindow(#mf, 0, 0, 0, 0 ,"", #PB_Window_Background)
CanvasGadget(#mfRender, 0, 0, WindowWidth(#mf), WindowHeight(#mf), #PB_Canvas_Transparent)
InitEngine(@LoadGame(), #mfRender)
Procedure LoadGame()
Protected n
If CreateScene()
Camera = CreateCamera("camera", 0, 20, -80, #BJS_ArcRotate)
Light0 = CreateLight("light0", 0, 30, 0, 0.6, #BJS_Point)
Light1 = CreateLight("light1", 0, 30, 0, 0.2, #BJS_Hemispheric)
;SkyBox
Sky = SkyBox("Night", "data/textures/sky/night", 1000)
;Ground
Ground = CreateGround("Ground", 1000, 1000)
TexGround = LoadTexture("Data/textures/grass1.jpg")
MatGround = CreateMaterial("Grass")
SetMaterialTexture(MatGround, #BJS_Diffuse, TexGround)
ScaleMaterial(MatGround, 40, 40)
SetMeshMaterial(Ground, MatGround)
;Torus
Torus0 = CreateTorus("torus0", 8, 2, 32)
MoveMesh(Torus0, 0, 8, 0)
Torus1 = CreateTorus("torus1", 4, 1, 32)
MoveMesh(Torus1, 0, 8, 0)
;Shadow
ShadowGenerator = InitShadow(Light0)
ShadowEmitter(ShadowGenerator, Torus0)
ShadowEmitter(ShadowGenerator, Torus1)
RenderShadows(Ground, #True)
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure RenderGame()
RotateMesh(Torus0, 0.5, 0.00, 0.5, #PB_Relative)
RotateMesh(Torus1, 1, 1, 0.00, #PB_Relative)
If GetCameraBeta(Camera) > 1.50
SetCameraBeta(Camera, 1.50)
EndIf
If GetCameraRadius(Camera) < 30
SetCameraRadius(Camera, 30)
EndIf
RenderWorld()
EndProcedure
; IDE Options = SpiderBasic 2.20 (Windows - x86)
; CursorPosition = 51
; Folding = -
; WebAppName = Skybox
; HtmlFilename = skybox.html
; JavaScriptFilename = skybox.js
; JavaScriptPath = sb
; iOSAppOrientation = 0
; AndroidAppOrientation = 0
; EnableXP
; CompileSourceDirectory