Skybox

Working with Steam Edition : (put after self.world=World:Create() in App.lua)

        camera = Camera:Create()
        camera:Move(0,4,-20)

        --Create skybox
        sky = Model:Create()
        --just render a plane and project cubemap onto it
        local surface = sky:AddSurface()
        surface:AddVertex(-0.5,-0.5,0, 0,0,-1)
        surface:AddVertex(0.5,-0.5,0, 0,0,-1)
        surface:AddVertex(0.5,0.5,0, 0,0,-1)
        surface:AddVertex(-0.5,0.5,0, 0,0,-1)
        surface:AddTriangle(2,1,0)
        surface:AddTriangle(0,3,2)

        --position in front of camera but far out to near camera clip plane
        sky:SetPosition(camera:GetPosition())
        sky:SetRotation(camera:GetRotation())
        sky:Move(0,0,camera:GetRange().y-50)
        sky:SetScale(camera:GetRange().y*10)
        sky:SetParent(camera)

        -- and paint it
        skymat=Material:Load("Materials/Sky/skybox_texture.mat")
        sky:SetMaterial(skymat)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License