;Babylon.sbi - Create Terrain EnableExplicit IncludeFile "babylon/babylon.sbi" Global Camera, Light, Sky, Ground, GroundTex, GroundMat, Water, Box, Mesh, Texture, Material Global Box0, Box1, Box2 Declare LoadGame() Declare RenderGame() UseModule BJS InitEngine(@LoadGame()) Procedure LoadGame() If CreateScene() InitKey() ;Camera & Light Camera = CreateCamera("camera", 0, 65, 100, #BJS_Universal) CameraBodySize(Camera, 1, 15, 1) CameraLookAt(Camera, 0, 30, 0) ;Redefine the camera keys CameraMapKey(Camera, #PB_Key_Left, #PB_Key_A) CameraMapKey(Camera, #PB_Key_Right, #PB_Key_Z) Light = CreateLight("Light", 0, 200, -100, 0.8, #BJS_Point) ;SkyBox Sky = SkyBox("Clouds", "data/textures/sky/cloud", 2000) ;Terrain Ground = CreateTerrain("island", "data/textures/heightMap.png", 1000, 1000, 210, 0, 70) GroundTex = LoadTexture("sand", "data/textures/Ground.jpg") GroundMat = CreateMaterial("sand") SetMaterialTexture(GroundMat, #BJS_Diffuse, GroundTex) ScaleMaterial(GroundMat, 16, 16) SetMeshMaterial(Ground, GroundMat) SetMaterialColor(GroundMat, #BJS_Specular, RGB(80, 80, 80)) MoveMesh(Ground, 0, -12, 0) ;Box Box0 = CreateBox("box", 10, 10, 10) Texture = LoadTexture("box", "data/textures/crate.png") Material = CreateMaterial("box") SetMaterialTexture(Material, #BJS_Diffuse, Texture) SetMaterialColor(Material, #BJS_Emissive, RGB(80, 80, 80)) SetMeshMaterial(Box0, Material) MoveMesh(Box0, -4, 22, -70) Box1 = CloneMesh(Box0) MoveMesh(Box1, 7, 22, -70) Box2 = CloneMesh(Box0) MoveMesh(Box2, 0, 32, -70) RotateMesh(Box2, 0, 45, 0) ;Water Water = CreateWater("water", "data/textures/waterbump.png", 2000, 2000, 128) WaterRenderList(Water, Ground) WaterRenderList(Water, Sky) ;Shadow InitShadow(Light) ShadowEmitter(Box0) ShadowEmitter(Box1) ShadowEmitter(Box2) RenderShadows(Ground) RenderLoop(@RenderGame()) EndIf EndProcedure Procedure RenderGame() If KeyPushed(#PB_Key_Left) RotateCamera(Camera, 0, -0.05, 0, #PB_Relative) EndIf If KeyPushed(#PB_Key_Right) RotateCamera(Camera, 0, 0.05, 0, #PB_Relative) EndIf RenderWorld() EndProcedure