Add various helpers for creating polyhedra

This commit is contained in:
jgk
2021-06-27 18:53:06 +02:00
parent 06f22a3ea5
commit 089dcc3f5d
14 changed files with 155 additions and 65 deletions
+4 -11
View File
@@ -59,14 +59,14 @@ createLightMap
-> (Float,Float) -- View from position
-> Picture -- foreground pictures
-> IO ()
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) _ = do
-- get viewport size so we can reset it later
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) fpics = do
-- get viewport size so we can reset it later
(vppos,vpsize) <- get viewport
-- set the viewport size to that of the render buffer
-- set the viewport size to that of the render buffer
viewport $= (vppos, divideSize resDiv vpsize)
bindFramebuffer Framebuffer $= _spareFBO pdata
-- store wall and light positions into buffer
-- store wall and light positions into buffer
nWallLights <- F.foldM (pokeShader $ _lightingWallShader pdata) (map Render22 wallPoints)
bindShaderBuffers [_lightingWallShader pdata] [nWallLights]
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
@@ -98,12 +98,6 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) _ = do
blendFunc $= (Zero, OneMinusSrcAlpha)
stencilTest $= Enabled
forM_ lightPoints $ \((x,y,z),r,lum) -> do
-- bind buffer for floor light circle
let lightPtr = _vboPointer $ _vaoVBO $ _shaderVAO $ _lightingFloorShader pdata
pokeFourOff lightPtr 0 (x,y,r,lum)
bindShaderBuffers [_lightingFloorShader pdata] [1]
-- stencil out walls
colorMask $= Color4 Disabled Disabled Disabled Disabled
clear [StencilBuffer]
@@ -121,7 +115,6 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) _ = do
cullFace $= Nothing
colorMask $= Color4 Disabled Disabled Disabled Enabled
stencilFunc $= (Equal, 0, 255)
-- drawShader (_lightingFloorShader pdata) 1
-- draw floor surface
currentProgram $= Just (_shaderProgram $ _lightingSurfaceShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingSurfaceShader pdata)
+11
View File
@@ -0,0 +1,11 @@
module Picture.ToPolyhedra
where
import Picture.Data
import Geometry.Data
toPolyhedra :: Picture -> [[Point3]]
toPolyhedra (OnLayer _ pic) = toPolyhedra pic
toPolyhedra (Pictures pics) = concatMap toPolyhedra pics
toPolyhedra (OverPic f _ pic) = map (map f) $ toPolyhedra pic
toPolyhedra (Poly3D _ vs) = [fst $ unzip vs]
toPolyhedra _ = []