Outils pour utilisateurs

Outils du site


playground:tube

01-Tube.sb

01-Tube.sb
;Babylon.sbi - Tube
 
EnableExplicit
 
IncludeFile "babylon/babylon.sbi"
UseModule BJS
 
Enumeration
  #mf
  #mfRender
EndEnumeration
 
Global Scene, Camera, Tube, TubeMat, Light, 
 
;A tube consists of an array of 3D vectors. Example with 5 vectors
Dim TubeVectors.NewVector(4)
 
Declare LoadGame()
Declare RenderGame()
 
 
;Window & Render
OpenWindow(#mf, 0, 0, 900, 600, "CreateTube()", #PB_Window_ScreenCentered)
CanvasGadget(#mfRender, 0, 0, 900, 600, #PB_Canvas_Transparent)
 
;Init Babylon with a canvas and load game
InitEngine(@LoadGame(), #mfRender)
 
Procedure LoadGame()    
  Scene = CreateScene()
 
  If Scene
 
    ;Camera & Light
    Camera = CreateCamera("camera", 0, 10, 20, #BJS_ArcRotate)  
    Light = CreateLight("light", 0, 20, 0, 0.8)
 
    ;Create Tube
    TubeVectors(0)\x = 0    
    TubeVectors(0)\y = 0
    TubeVectors(0)\z = 0
 
    TubeVectors(1)\x = 0    
    TubeVectors(1)\y = 1
    TubeVectors(1)\z = 0
 
    TubeVectors(2)\x = 0    
    TubeVectors(2)\y = 2
    TubeVectors(2)\z = 0
 
    TubeVectors(3)\x = 0    
    TubeVectors(3)\y = 3
    TubeVectors(3)\z = 0
 
    TubeVectors(4)\x = 3    
    TubeVectors(4)\y = 4
    TubeVectors(4)\z = 0
 
    Tube = CreateTube("My tube", TubeVectors(), 2)
 
    ;Important : Assign a material 
    TubeMat = CreateMaterial("tube material", "data/textures/misc.jpg")
    SetMaterial(Tube, TubeMat)
 
    RenderLoop(@RenderGame())
  EndIf
EndProcedure
 
Procedure RenderGame()
  RotateMesh(Tube, 0, 0.01, 0, #PB_Relative)
  RenderWorld() 
EndProcedure
playground/tube.txt · Dernière modification: 2018/01/11 02:03 de falsam