Sky Issues

Blitz3D Forums/Blitz3D Programming/Sky Issues

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Firstly, i wouldn't use a blitz cube as a skybox. Mainly because your going to have problems texturing it.

Try this function. I can't remember where it came from, but i used it one of my projects. You call the function and it will create a skybox, based on the textures you pass.

Function create_skybox(f$,r$, b$,l$, t$, bt$, sx, sy, sz);front right back left top bottom scalex,y,z
    mesh = CreateMesh()

    ;front face
    brush = LoadBrush(f$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,-1,0,0
    AddVertex surface,+1,+1,-1,1,0
    AddVertex surface,+1,-1,-1,1,1
    AddVertex surface,-1,-1,-1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;right face
    brush = LoadBrush(r$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,+1,+1,-1,0,0
    AddVertex surface,+1,+1,+1,1,0
    AddVertex surface,+1,-1,+1,1,1
    AddVertex surface,+1,-1,-1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;back face
    brush = LoadBrush(b$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,+1,+1,+1,0,0
    AddVertex surface,-1,+1,+1,1,0
    AddVertex surface,-1,-1,+1,1,1
    AddVertex surface,+1,-1,+1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
 
    ;left face
    brush = LoadBrush(l$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,+1,0,0
    AddVertex surface,-1,+1,-1,1,0
    AddVertex surface,-1,-1,-1,1,1
    AddVertex surface,-1,-1,+1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;top face
    brush = LoadBrush(t$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,+1,0,1
    AddVertex surface,+1,+1,+1,0,0
    AddVertex surface,+1,+1,-1,1,0
    AddVertex surface,-1,+1,-1,1,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
   
    ;bottom face 
    brush = LoadBrush(bt$,49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,-1,-1,1,0
    AddVertex surface,+1,-1,-1,1,1
    AddVertex surface,+1,-1,+1,0,1
    AddVertex surface,-1,-1,+1,0,0
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
    
    ScaleMesh mesh,sx,sy,sz
    FlipMesh mesh
    EntityFX mesh,1+4+8; make fullbright
    Return mesh
End Function


You would do this to use this function. Just as you would to load a texture, include the file name of the texture for the TOP, BOTTOM, LEFT, RIGHT, FRONT and BACK sides, followed by an X Y and Z scale. The function does the rest. In the below example, the skybox would now by assigned the the variable "skybox"

Global skybox = create_skyBox("level1\sky_front.png","level1\sky_right.png","level1\sky_back.png","level1\sky_left.png", "level1\sky_top.png", "level1\sky_bottom.png",350,150,350)