Outils pour utilisateurs

Outils du site


playground:light

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
playground:light [2017/05/09 00:49] falsamplayground:light [2018/01/08 20:58] falsam
Ligne 1: Ligne 1:
 +**04-Light.sb**
  
 +[[http://falsam.com/sbbjs/light.html|Voir]]
 +
 +<file purebasic 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, 2, 10)
 +    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, 2, 5)
 +    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, 2, 6)
 +    SetLightColor(Light2, #BJS_Diffuse, RGB(0, 0, 255))
 +    SetLightColor(Light2, #BJS_Specular, RGB(0, 255, 0))
 +        
 +    ;Ground & Box
 +    Texture = LoadTexture("ground", "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("Box", "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()
 +  Static z.f
 +   
 +  RenderWorld() 
 +EndProcedure
 +</file>
playground/light.txt · Dernière modification : 2023/03/15 15:49 de 127.0.0.1