Outils pour utilisateurs

Outils du site


playground:shadow

03-Shadow.sb

Voir

03-Shadow.sb
;Babylon.sbi - Shadows
 
EnableExplicit
 
IncludeFile "babylon/babylon.sbi"
 
Global Camera, Light0, Light1, Plane, Sphere, MatPlane, MatSphere, 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, 10, 0, 0.5, #BJS_Hemispheric)
 
    ;Object
    Plane   = CreateGround("plane", 10, 10)
 
    Sphere  = CreateSphere("sphere", 2)
    MoveMesh(Sphere, 0, 2, 0)  
 
    ;Material
    MatPlane = CreateMaterial("MatPlane", "data/textures/grass.jpg")
    ScaleMaterial(MatPlane, 5, 5)
 
    MatSphere = CreateMaterial("MatPlane", "data/textures/tree.png")
 
    ;Apply material
    SetMaterial(Plane, MatPlane)
    SetMaterial(Sphere, MatSphere)
 
    ;Shadows (Create Shadow Generator)
    InitShadow(Light0)
    ShadowEmitter(Sphere)
    RenderShadows(Plane)
 
    RenderLoop(@RenderGame())
  EndIf
EndProcedure
 
Procedure RenderGame()
  RotateMesh(Sphere, 0, 0.01, 0, #PB_Relative)
  RenderWorld() 
EndProcedure
playground/shadow.txt · Dernière modification: 2018/01/11 01:53 de falsam