-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path07-Parenting.sb
More file actions
56 lines (42 loc) · 1.57 KB
/
07-Parenting.sb
File metadata and controls
56 lines (42 loc) · 1.57 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
;;Babylon.js for SpiderBasic - Parenting.
;Another Babylon feature is attaching an object, relatively to another, by creating a parent-child link between two meshes.
;This link implies that all parent transformations (position/rotation/scaling) will also be applied To the child’s transformations.
EnableExplicit
IncludeFile "babylon/babylon.sbi"
Global Light, Ground, Torus1, Torus2, ShadowGenerator
Declare LoadGame()
Declare RenderGame()
UseModule BJS
InitEngine(@LoadGame())
Procedure LoadGame()
If CreateScene()
;Camera & Light
CreateCamera("camera", 0, 20, 30, #BJS_ArcRotate)
CreateLight("ambiance", 0, 40, 0, 0.5)
Light = CreateLight("Light", 10, 40, 20, 0.6, #BJS_Point)
Torus1 = CreateTorus("Torus1", 5, 1)
RotateMesh(Torus1, 45, 0, 0)
Torus2 = CreateTorus("Torus2", 5, 1)
RotateMesh(Torus2, -45, 0, 0)
Ground = CreateGround("Ground", 30, 30)
AttachMesh(Ground, Torus1, 0, 3, 0)
AttachMesh(Ground, Torus2, 0, 7, 0)
;Shadows (Create Shadow Generator)
ShadowGenerator = InitShadow(Light, 2048)
ShadowEmitter(ShadowGenerator, Torus1)
ShadowEmitter(ShadowGenerator, Torus2)
RenderShadows(Ground)
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure RenderGame()
RotateMesh(Ground, 0, 0.3, 0, #PB_Relative)
RenderWorld()
EndProcedure
; IDE Options = SpiderBasic 2.20 (Windows - x86)
; CursorPosition = 38
; Folding = -
; iOSAppOrientation = 0
; AndroidAppOrientation = 0
; EnableXP
; CompileSourceDirectory