Outils pour utilisateurs

Outils du site


playground:picking

12-picking.sb

Voir

12-picking.sb
;Babylon.sbi - Picking
 
EnableExplicit
 
IncludeFile "babylon/babylon.sbi"
 
Declare LoadGame()
Declare RenderGame()
 
UseModule BJS
 
InitEngine(@LoadGame())
 
Procedure LoadGame()
  Protected Mesh
 
  If CreateScene()
    CreateCamera("camera", 5, 5, 10, #BJS_ArcRotate)
 
    CreateLight("Light", 0, 10, 0, 0.8, #BJS_Hemispheric)
 
    CreateGround("Sweet Ground", 10, 10)
    Mesh = CreateBox("My Box", 1, 1, 1)
    MoveMesh(Mesh, 0, 1, 0)
 
    Mesh = CreateSphere("Sphere", 0.5)    
    MoveMesh(Mesh, -2, 1, 1)
 
    Mesh = CreateCylinder("My Cylinder", 2, 1, 2)  
    MoveMesh(Mesh, 2, 1, -1)
 
    ;Active le systeme de picking
    PickEnable()
 
    RenderLoop(@RenderGame())
  EndIf
EndProcedure
 
Procedure RenderGame()
  Protected Mesh = IsPick() 
 
  If Mesh
    Debug "Name " + GetMeshName(PickMesh())
    Debug "Distance from camera " + PickDistance()  
    Debug "x/y/z " + StrD(PickX(), 3) + " / " + StrD(PickY(), 3) + " / " + StrD(PickZ(), 3) + #CRLF$
 
  EndIf  
 
  RenderWorld() 
EndProcedure
playground/picking.txt · Dernière modification: 2018/01/11 01:59 de falsam