Updated the resolution!
This commit is contained in:
parent
291d2c3936
commit
4fc6041cbf
2 changed files with 25 additions and 12 deletions
|
@ -51,7 +51,9 @@ The mapping between user input and actions.
|
||||||
> ,(Press 'e' , translate ydir 0.1)
|
> ,(Press 'e' , translate ydir 0.1)
|
||||||
> ,(Press 'd' , translate ydir (-0.1))
|
> ,(Press 'd' , translate ydir (-0.1))
|
||||||
> ,(Press '+' , zoom 1.1)
|
> ,(Press '+' , zoom 1.1)
|
||||||
> ,(Press '-' , zoom 0.9)
|
> ,(Press '-' , zoom (1/1.1))
|
||||||
|
> ,(Press 'r' , resize 1.2)
|
||||||
|
> ,(Press 'z' , resize (1/1.2))
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
The type of each couple should be of the form
|
The type of each couple should be of the form
|
||||||
|
@ -65,7 +67,8 @@ And of course a type design the World State:
|
||||||
> angle :: Point3D
|
> angle :: Point3D
|
||||||
> , scale :: Scalar
|
> , scale :: Scalar
|
||||||
> , position :: Point3D
|
> , position :: Point3D
|
||||||
> , shape :: YObject
|
> , shape :: Function3D
|
||||||
|
> , box :: Box3D
|
||||||
> }
|
> }
|
||||||
|
|
||||||
> instance DisplayableWorld World where
|
> instance DisplayableWorld World where
|
||||||
|
@ -73,7 +76,7 @@ And of course a type design the World State:
|
||||||
> camPos = position w,
|
> camPos = position w,
|
||||||
> camDir = angle w,
|
> camDir = angle w,
|
||||||
> camZoom = scale w }
|
> camZoom = scale w }
|
||||||
> objects w = [shape w]
|
> objects w = [XYFunc (shape w) (box w)]
|
||||||
|
|
||||||
With all associated functions:
|
With all associated functions:
|
||||||
|
|
||||||
|
@ -97,6 +100,11 @@ With all associated functions:
|
||||||
> zoom :: Scalar -> World -> World
|
> zoom :: Scalar -> World -> World
|
||||||
> zoom z world = world {
|
> zoom z world = world {
|
||||||
> scale = z * scale world }
|
> scale = z * scale world }
|
||||||
|
>
|
||||||
|
> resize :: Scalar -> World -> World
|
||||||
|
> resize r world = world {
|
||||||
|
> box = (box world) {
|
||||||
|
> resolution = (resolution (box world)) * r }}
|
||||||
|
|
||||||
- [`YBoiler.hs`](code/04_Mandelbulb/YBoiler.hs), the 3D rendering
|
- [`YBoiler.hs`](code/04_Mandelbulb/YBoiler.hs), the 3D rendering
|
||||||
- [`Mandel`](code/04_Mandelbulb/Mandel.hs), the mandel function
|
- [`Mandel`](code/04_Mandelbulb/Mandel.hs), the mandel function
|
||||||
|
@ -117,7 +125,10 @@ With all associated functions:
|
||||||
> angle = makePoint3D (0,1,0)
|
> angle = makePoint3D (0,1,0)
|
||||||
> , position = makePoint3D (0,0,0)
|
> , position = makePoint3D (0,0,0)
|
||||||
> , scale = 0.2
|
> , scale = 0.2
|
||||||
> , shape = XYSymFunc shapeFunc
|
> , shape = shapeFunc
|
||||||
|
> , box = Box3D { minPoint = makePoint3D (-2,-2,-2)
|
||||||
|
> , maxPoint = makePoint3D (2,2,2)
|
||||||
|
> , resolution = 0.2 }
|
||||||
> }
|
> }
|
||||||
>
|
>
|
||||||
> shapeFunc :: Function3D
|
> shapeFunc :: Function3D
|
||||||
|
|
|
@ -24,6 +24,7 @@ module YGL (
|
||||||
-- Datas related to DisplayableWorld
|
-- Datas related to DisplayableWorld
|
||||||
, Camera (Camera,camPos,camDir,camZoom)
|
, Camera (Camera,camPos,camDir,camZoom)
|
||||||
, YObject (XYFunc, XYSymFunc, Tri)
|
, YObject (XYFunc, XYSymFunc, Tri)
|
||||||
|
, Box3D (Box3D, minPoint, maxPoint, resolution)
|
||||||
-- Datas related to user Input
|
-- Datas related to user Input
|
||||||
, InputMap
|
, InputMap
|
||||||
, UserInput (Press,Ctrl,Alt,CtrlAlt)
|
, UserInput (Press,Ctrl,Alt,CtrlAlt)
|
||||||
|
@ -101,15 +102,16 @@ makeBox mini maxi res = Box3D {
|
||||||
, resolution = res }
|
, resolution = res }
|
||||||
|
|
||||||
type Function3D = Point -> Point -> Maybe Point
|
type Function3D = Point -> Point -> Maybe Point
|
||||||
data YObject = XYFunc Function3D
|
data YObject = XYFunc Function3D Box3D
|
||||||
| XYSymFunc Function3D
|
| XYSymFunc Function3D Box3D
|
||||||
| Tri [Point3D]
|
| Tri [Point3D]
|
||||||
|
|
||||||
triangles :: YObject -> Box3D -> [Point3D]
|
triangles :: YObject -> [Point3D]
|
||||||
triangles (XYFunc f) b = getObject3DFromShapeFunction f b
|
triangles (XYFunc f b) = getObject3DFromShapeFunction f b
|
||||||
triangles (XYSymFunc f) b = tris ++ ( reverse $ map (\(P(x,y,z)) -> P (x,y,-z)) tris )
|
triangles (XYSymFunc f b) = tris ++
|
||||||
|
( reverse $ map (\(P(x,y,z)) -> P (x,y,-z)) tris )
|
||||||
where tris = getObject3DFromShapeFunction f b
|
where tris = getObject3DFromShapeFunction f b
|
||||||
triangles (Tri tri) _ = tri
|
triangles (Tri tri) = tri
|
||||||
|
|
||||||
-- | We decalre the input map type we need here
|
-- | We decalre the input map type we need here
|
||||||
-- | It is our API
|
-- | It is our API
|
||||||
|
@ -297,7 +299,7 @@ drawObject shape = do
|
||||||
-- solarized base3 color
|
-- solarized base3 color
|
||||||
-- color $ Color3 (0.988::Point) (0.96::Point) (0.886::Point)
|
-- color $ Color3 (0.988::Point) (0.96::Point) (0.886::Point)
|
||||||
color $ hexColor "#fdf6e3"
|
color $ hexColor "#fdf6e3"
|
||||||
drawTriangles (triangles shape unityBox)
|
drawTriangles (triangles shape)
|
||||||
where
|
where
|
||||||
drawTriangles tri@(p0:p1:p2:points) = do
|
drawTriangles tri@(p0:p1:p2:points) = do
|
||||||
normal $ toGLNormal3 trinorm
|
normal $ toGLNormal3 trinorm
|
||||||
|
|
Loading…
Reference in a new issue