Commit before attempting to change cloud shading
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
module Shader.Poke.Cloud (
|
||||
pokeCloud,
|
||||
) where
|
||||
|
||||
import qualified Data.Vector.Unboxed as UV
|
||||
import Dodge.Data.Cloud
|
||||
import Foreign
|
||||
import Geometry
|
||||
import Graphics.GL.Core45
|
||||
|
||||
pokeCloud :: Ptr Float -> Ptr GLushort -> (Int, Int) -> Cloud -> IO (Int, Int)
|
||||
pokeCloud vptr iptr (nv,ni) cl = do
|
||||
UV.imapM_ (pokeCloudVerx vptr cl nv) $ UV.fromList [(1, 1), (1, -1), (-1, -1), (-1, 1)]
|
||||
UV.imapM_ (pokeCloudIndex iptr nv ni) $ UV.fromList [0, 1, 2, 2, 1, 3]
|
||||
return (nv + 4, ni + 6)
|
||||
|
||||
pokeCloudVerx :: Ptr Float -> Cloud -> Int -> Int -> (Float, Float) -> IO ()
|
||||
pokeCloudVerx ptr cl nv i (dx, dy) =
|
||||
UV.imapM_ (pokeCloudFloat ptr (nv + i)) $ UV.fromList
|
||||
[x, y, cz, 1, r, g, b, a, cx, cy, cz, rad, dx, dy, 0, 0]
|
||||
where
|
||||
V3 cx cy cz = _clPos cl
|
||||
V2 x y = V2 cx cy - rad *.* V2 dx dy
|
||||
rad = _clRad cl
|
||||
V4 r g b a = case _clPict cl of
|
||||
CloudColor _ _ col -> col
|
||||
DrawGasCloud col -> col
|
||||
|
||||
pokeCloudFloat :: Ptr Float -> Int -> Int -> Float -> IO ()
|
||||
pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 16 + i)
|
||||
|
||||
pokeCloudIndex :: Ptr GLushort -> Int -> Int -> Int -> Int -> IO ()
|
||||
pokeCloudIndex ptr nv ni ioff voff = pokeElemOff ptr (ni + ioff) (fromIntegral $ nv + voff)
|
||||
Reference in New Issue
Block a user