Outils pour utilisateurs

Outils du site


playground:light

04-Light.sb

Voir

04-light.sb
;Babylon.sbi - Light
 
EnableExplicit
 
IncludeFile "babylon/babylon.sbi"
UseModule BJS
 
Global Scene, Camera, Light0, Light1, Light2, Ligh3, Mesh, Texture, Material
 
Declare LoadGame()
Declare RenderGame()
 
InitEngine(@LoadGame())
 
Procedure LoadGame()    
  Scene = CreateScene()
  If Scene
    Camera = CreateCamera("camera", 0, 10, 20, #BJS_ArcRotate)
 
    ;Lights
    CreateLight("General", 0, 20, 0, 0.2, #BJS_Hemispheric)
 
    Light0 = CreateLight("Red Light", -1, 10, -1, 1, #BJS_Spot)
    SpotLightRange(Light0, 120, 40)
    SetLightColor(Light0, #BJS_Diffuse, RGB(255, 0, 0))
    SetLightColor(Light0, #BJS_Specular, RGB(0, 255, 0))
 
    Light1 = CreateLight("Green Light", 5, 10, 1, 0.8, #BJS_Spot)
    SpotLightRange(Light1, 130, 40)
    SetLightColor(Light1, #BJS_Diffuse, RGB(0, 255, 0))
    SetLightColor(Light1, #BJS_Specular, RGB(0, 255, 0))
 
    Light2 = CreateLight("Blue Light", -9, 10, -9, 1, #BJS_Spot)
    SpotLightRange(Light2, 140, 40)
    SetLightColor(Light2, #BJS_Diffuse, RGB(0, 0, 255))
    SetLightColor(Light2, #BJS_Specular, RGB(0, 255, 0))
 
    ;Ground & Box
    Texture = LoadTexture("Data/textures/floor.png")
    Material = CreateMaterial("ground")
    SetMaterialTexture(Material, #BJS_Diffuse, Texture)
    Mesh = CreateGround("ground", 30, 30)
    SetMeshMaterial(Mesh, Material)
    ScaleMaterial(Material, 5, 5)
 
    Texture = LoadTexture("Data/textures/crate.png")
    Material = CreateMaterial("Box")
    SetMaterialTexture(Material, #BJS_Diffuse, Texture)
    SetMaterialColor(Material, #BJS_Emissive, RGB(80, 80, 80))
    Mesh = CreateBox("Box", 5, 5, 5)
    SetMeshMaterial(Mesh, Material)
    MoveMesh(Mesh, 0, 2.5, 0)
 
    RenderLoop(@RenderGame())
  EndIf
EndProcedure
 
Procedure RenderGame()
  RenderWorld() 
EndProcedure
playground/light.txt · Dernière modification: 2018/01/23 17:40 par falsam