playground:terrain
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| playground:terrain [2017/05/11 17:58] – falsam | playground:terrain [2023/03/15 15:49] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | **10-Terrain.sb** | ||
| + | |||
| + | La représentation du relief d'un terrain passe par une carte des altitudes, plus communément appelée par son terme anglo-saxon, | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Exemple : heightMap.png | ||
| + | |||
| + | |||
| + | [[http:// | ||
| + | |||
| + | <file purebasic | ||
| + | ; | ||
| + | |||
| + | EnableExplicit | ||
| + | |||
| + | IncludeFile " | ||
| + | |||
| + | 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(" | ||
| + | CameraBodySize(Camera, | ||
| + | CameraLookAt(Camera, | ||
| + | | ||
| + | ;Redefine the camera keys | ||
| + | CameraMapKey(Camera, | ||
| + | CameraMapKey(Camera, | ||
| + | | ||
| + | Light = CreateLight(" | ||
| + | | ||
| + | ;SkyBox | ||
| + | Sky = SkyBox(" | ||
| + | | ||
| + | ;Terrain | ||
| + | Ground = CreateTerrain(" | ||
| + | GroundTex = LoadTexture(" | ||
| + | GroundMat = CreateMaterial(" | ||
| + | SetMaterialTexture(GroundMat, | ||
| + | ScaleMaterial(GroundMat, | ||
| + | SetMeshMaterial(Ground, | ||
| + | SetMaterialColor(GroundMat, | ||
| + | MoveMesh(Ground, | ||
| + | | ||
| + | ;Box | ||
| + | Box0 = CreateBox(" | ||
| + | Texture = LoadTexture(" | ||
| + | Material = CreateMaterial(" | ||
| + | SetMaterialTexture(Material, | ||
| + | SetMaterialColor(Material, | ||
| + | SetMeshMaterial(Box0, | ||
| + | MoveMesh(Box0, | ||
| + | Box1 = CloneMesh(Box0) | ||
| + | MoveMesh(Box1, | ||
| + | Box2 = CloneMesh(Box0) | ||
| + | MoveMesh(Box2, | ||
| + | RotateMesh(Box2, | ||
| + | | ||
| + | ;Water | ||
| + | Water = CreateWater(" | ||
| + | WaterRenderList(Water, | ||
| + | WaterRenderList(Water, | ||
| + | | ||
| + | ;Shadow | ||
| + | InitShadow(Light) | ||
| + | ShadowEmitter(Box0) | ||
| + | ShadowEmitter(Box1) | ||
| + | ShadowEmitter(Box2) | ||
| + | RenderShadows(Ground) | ||
| + | | ||
| + | RenderLoop(@RenderGame()) | ||
| + | EndIf | ||
| + | EndProcedure | ||
| + | |||
| + | Procedure RenderGame() | ||
| + | If KeyPushed(# | ||
| + | RotateCamera(Camera, | ||
| + | EndIf | ||
| + | | ||
| + | If KeyPushed(# | ||
| + | RotateCamera(Camera, | ||
| + | EndIf | ||
| + | | ||
| + | RenderWorld() | ||
| + | EndProcedure | ||
| + | </ | ||
| + | |||
