-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03-Shadows.sb
More file actions
69 lines (52 loc) · 1.77 KB
/
03-Shadows.sb
File metadata and controls
69 lines (52 loc) · 1.77 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
;Babylon.sbi - Shadows
EnableExplicit
IncludeFile "babylon/babylon.sbi"
Global Camera, Light0, Light1, Plane, Sphere, MatPlane, TexPlane, MatSphere, TexSphere, ShadowGenerator
Declare LoadGame()
Declare RenderGame()
UseModule BJS
InitEngine(@LoadGame())
Procedure LoadGame()
If CreateScene()
;Camera & Light
Camera = CreateCamera("camera", 0, 5, 7, #BJS_ArcRotate)
Light0 = CreateLight("light", 5, 10, 0, 1, #BJS_Point)
Light1 = CreateLight("light", 0, 200, 0, 0.5, #BJS_Hemispheric)
;Object
Plane = CreateGround("plane", 10, 10)
Sphere = CreateSphere("sphere", 2)
MoveMesh(Sphere, 0, 2, 0)
;Texture
TexPlane = LoadTexture("Data/textures/grass.jpg")
TexSphere = LoadTexture("Data/textures/tree.png")
;Material
MatPlane = CreateMaterial("MatPlane")
SetMaterialTexture(MatPlane, #BJS_Diffuse, TexPlane)
ScaleMaterial(MatPlane, 5, 5)
MatSphere = CreateMaterial("MatPlane")
SetMaterialTexture(MatSphere, #BJS_Diffuse, TexSphere, #True)
;Apply material
SetMeshMaterial(Plane, MatPlane)
SetMeshMaterial(Sphere, MatSphere)
;Shadows (Create Shadow Generator)
ShadowGenerator = InitShadow(Light0, 1024)
ShadowEmitter(ShadowGenerator, Sphere)
RenderShadows(Plane)
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure RenderGame()
RotateMesh(Sphere, 0, 1, 0, #PB_Relative)
RenderWorld()
EndProcedure
; IDE Options = SpiderBasic 2.20 (Windows - x86)
; CursorPosition = 44
; Folding = -
; WebAppName = Shadow
; HtmlFilename = shadow.html
; JavaScriptFilename = shadow.js
; JavaScriptPath = sb
; iOSAppOrientation = 0
; AndroidAppOrientation = 0
; EnableXP
; CompileSourceDirectory