LoadBSP ( file$[,gamma_adj#][,parent] )
Parameters
|
file$ - filename of the BSP level gamma_adj# (optional) - brightens the level's lightmaps at load time; 0 leaves them unchanged (default), values towards 1 brighten parent (optional) - parent entity of the level |
Description
|
Loads a Quake 3 BSP level and returns its entity handle. BSP levels are complete game environments - geometry plus baked "lightmap" lighting - built with Quake 3 level editors. LoadBSP gives you an instant, professionally-lit arena to run around in: load it, set up Collisions against its entity type, and the level is solid for collisions and picking like any mesh. The loader reads the Quake 3 format (IBSP version 46) and returns 0 if the file is missing or not that format - always check the result. The level's textures are loaded from the BSP's own folder, so keep them next to the file. No .bsp ships with Blitz3D+, which is why the example falls back to a primitive arena until you drop a level of your own into media/level.bsp. gamma_adj is applied to the lightmaps once, at load time: 0 leaves them as baked, and pushing it towards 1 brightens a level that was compiled too dark. You cannot change it later without reloading. A BSP lights itself: lightmaps are on by default (toggle with BSPLighting), and the level ignores the scene's AmbientLight - it has its own ambient colour, black until you set it with BSPAmbientLight. Surfaces without lightmaps draw fullbright. See also: BSPAmbientLight, BSPLighting, LoadMesh, Collisions, AmbientLight. |
Example
; LoadBSP Example ; --------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-10 light=CreateLight() RotateEntity light,45,45,0 ; Try to load a Quake 3 level. No .bsp file ships with Blitz3D+, ; so LoadBSP returns 0 unless you supply your own level file. bsp=LoadBSP("media/level.bsp",0) If bsp=0 ; Honest fallback: a placeholder arena built from primitives arena=CreatePlane() EntityColor arena,60,70,90 For i=0 To 7 pillar=CreateCylinder() ScaleEntity pillar,0.6,3,0.6 PositionEntity pillar,Cos(i*45)*6,3,Sin(i*45)*6 EntityColor pillar,120,130,160 Next EndIf ; A spinning marker so something always moves marker=CreateSphere() ScaleEntity marker,0.5,0.5,0.5 PositionEntity marker,0,1,0 EntityColor marker,255,200,0 While Not KeyDown(1) TurnEntity marker,0,3,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld If bsp=0 Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"LoadBSP('media/level.bsp',0) returned 0 - no file found." Text 0,40,"Copy any Quake 3 .bsp to media/level.bsp and run again" Text 0,60,"to fly around the real thing here." Else Text 0,0,"Arrow keys: fly through the level Esc: exit" Text 0,20,"LoadBSP loaded the level with its lightmaps on." EndIf Flip Wend End
Index