Allow tweaking z buffer when rendering polygon, improve explosion render

This commit is contained in:
jgk
2021-07-03 23:56:01 +02:00
parent 532f491327
commit 9df19a9e85
33 changed files with 339 additions and 82 deletions
+32
View File
@@ -4,6 +4,8 @@ module Geometry.Vector3D
import Geometry.Vector
import Geometry.Data
import Data.List
infixl 6 +.+.+, -.-.-
infixl 7 *.*.*
@@ -56,3 +58,33 @@ magV3 (x,y,z) = sqrt $ x^i + y^i + z^i
normalizeV3 :: Point3 -> Point3
normalizeV3 (0,0,0) = (0,0,0)
normalizeV3 p = (1 / magV3 p) *.*.* p
addZ :: Float -> Point2 -> Point3
addZ z (x,y) = (x,y,z)
orderAround3
:: Point3 -- ^ Vector to order around
-> [Point3]
-> [Point3]
orderAround3 v ps = sortOn (argV . prj) ps
where
xdir = crossProd v (head ps)
ydir = crossProd v xdir
prj p = (dotV3 xdir p, dotV3 ydir p)
vCen3 :: [Point3] -> Point3
vCen3 ps = (1 / fromIntegral (length ps)) *.*.* foldr (+.+.+) (0,0,0) ps
dotV3
:: Point3
-> Point3
-> Float
dotV3 (x,y,z) (a,b,c) = x*a + y*b + z*c
projV3
:: Point3
-> Point3
-> Point3
projV3 = undefined