Allow tweaking z buffer when rendering polygon, improve explosion render
This commit is contained in:
@@ -3,6 +3,7 @@ Helpers for random generation.
|
||||
-}
|
||||
module Dodge.RandomHelp where
|
||||
import Geometry
|
||||
import Geometry.Vector3D
|
||||
import Geometry.Data
|
||||
|
||||
import System.Random
|
||||
@@ -68,6 +69,26 @@ randInCirc maxRad = do rad <- state $ randomR (0,maxRad)
|
||||
ang <- state $ randomR (0,2*pi)
|
||||
return $ rad *.* unitVectorAtAngle ang
|
||||
|
||||
randOnUnitSphere :: RandomGen g => State g Point3
|
||||
randOnUnitSphere = do
|
||||
z <- state $ randomR (negate 1,1)
|
||||
longitude <- state $ randomR (0, 2*pi)
|
||||
let (x,y) = sqrt (1 - z^(2::Int)) *.* unitVectorAtAngle longitude
|
||||
return (x,y,z)
|
||||
|
||||
randOnHemisphere :: RandomGen g => State g Point3
|
||||
randOnHemisphere = do
|
||||
z <- state $ randomR (0,1)
|
||||
longitude <- state $ randomR (0, 2*pi)
|
||||
let (x,y) = sqrt (1 - z^(2::Int)) *.* unitVectorAtAngle longitude
|
||||
return (x,y,z)
|
||||
|
||||
randInHemisphere :: RandomGen g => State g Point3
|
||||
randInHemisphere = do
|
||||
p <- randOnHemisphere
|
||||
r <- state $ randomR (0,1)
|
||||
return $ r *.*.* p
|
||||
|
||||
randInRect :: RandomGen g => Float -> Float -> State g Point2
|
||||
randInRect w h = do x <- state $ randomR (0,w)
|
||||
y <- state $ randomR (0,h)
|
||||
|
||||
Reference in New Issue
Block a user