Continue shape rendering improvements
This commit is contained in:
+3
-18
@@ -4,6 +4,7 @@ module Shape
|
||||
, translateSH
|
||||
, emptySH
|
||||
, upperPrismPoly
|
||||
, polyCirc
|
||||
, translateSHz
|
||||
, translateSHf
|
||||
, rotateSH
|
||||
@@ -24,8 +25,8 @@ emptySH :: Shape
|
||||
emptySH = mempty
|
||||
|
||||
polyCirc :: Int -> Float -> [Point2]
|
||||
{-# INLINE polycirc #-}
|
||||
polyCirc n r = map (\i -> rotateV ) [0..n]
|
||||
{-# INLINE polyCirc #-}
|
||||
polyCirc n x = map (\a -> rotateV a (V2 x 0)) $ take (n*2) [0,pi/(fromIntegral n)..]
|
||||
|
||||
upperPrismPoly
|
||||
:: Float -- ^ height, expected to be strictly positive
|
||||
@@ -53,22 +54,6 @@ upperPrismPoly h ps =
|
||||
sideEdges = shEfromList $ concat $ zipWith3 makeSideEdge ps (tail ps ++ [head ps]) (drop 2 ps ++ take 2 ps)
|
||||
makeSideEdge (V2 xl yl) (V2 x y) (V2 xr yr) = [V3 x y 0, V3 x y h, V3 xr yr 0, V3 xl yl h]
|
||||
|
||||
flatPoly :: [Point2] -> Shape
|
||||
flatPoly ps =
|
||||
( [ShapeObj ListV $ shVfromList $ polyToTris $ map f ps]
|
||||
, shEfromList $ concat $ zipWith g ps (tail ps ++ [head ps])
|
||||
)
|
||||
where
|
||||
f (V2 x y) = pairToSV ( V3 x y 0, black )
|
||||
g (V2 x y) (V2 a b) =
|
||||
[ V3 x y 0
|
||||
, V3 a b 0
|
||||
, V3 x y 0 -.-.- n
|
||||
, V3 a b 0 -.-.- n
|
||||
]
|
||||
where
|
||||
n = addZ 0 $ vNormal (V2 (a-x) (b-y))
|
||||
|
||||
colorSH :: Color -> Shape -> Shape
|
||||
{-# INLINE colorSH #-}
|
||||
colorSH col = overCol $ const col
|
||||
|
||||
Reference in New Issue
Block a user