not-gloss 0.5.0.5 → 0.6.0.0
raw patch · 4 files changed
+48/−39 lines, 4 filesdep ~spatial-math
Dependency ranges changed: spatial-math
Files
- Vis/Camera.hs +7/−7
- Vis/VisObject.hs +29/−29
- changelog.txt +5/−0
- not-gloss.cabal +7/−3
Vis/Camera.hs view
@@ -8,8 +8,8 @@ , cameraKeyboardMouse ) where -import Xyz import Graphics.UI.GLUT+import SpatialMath ( V3(..) ) data Camera0 = Camera0 { phi0 :: GLdouble , theta0 :: GLdouble@@ -19,7 +19,7 @@ data Camera = Camera { phi :: GLdouble , theta :: GLdouble , rho :: GLdouble- , pos :: Xyz GLdouble+ , pos :: V3 GLdouble , ballX :: GLint , ballY :: GLint , leftButton :: GLint@@ -30,7 +30,7 @@ makeCamera camera0 = Camera { phi = phi0 camera0 , theta = theta0 camera0 , rho = rho0 camera0- , pos = Xyz 0 0 0+ , pos = V3 0 0 0 , ballX = (-1) , ballY = (-1) , leftButton = 0@@ -40,7 +40,7 @@ setCamera :: Camera -> IO () setCamera camera = lookAt (Vertex3 xc yc zc) (Vertex3 x0 y0 z0) (Vector3 0 0 (-1)) where- Xyz x0 y0 z0 = pos camera+ V3 x0 y0 z0 = pos camera phi' = phi camera theta' = theta camera rho' = rho camera@@ -50,7 +50,7 @@ zc = z0 - rho'*sin(theta'*pi/180) cameraMotion :: Camera -> Position -> Camera-cameraMotion (Camera phi0' theta0' rho0' (Xyz x0 y0 z0) bx by lb rb) (Position x y) =+cameraMotion (Camera phi0' theta0' rho0' (V3 x0 y0 z0) bx by lb rb) (Position x y) = Camera nextPhi nextTheta rho0' nextPos nextBallX nextBallY lb rb where deltaX@@ -71,8 +71,8 @@ else (phi0', theta0') nextPos = if rb == 1- then Xyz nextX nextY z0- else Xyz x0 y0 z0+ then V3 nextX nextY z0+ else V3 x0 y0 z0 nextBallX = x nextBallY = y
Vis/VisObject.hs view
@@ -27,8 +27,8 @@ setMaterialDiffuse col = materialDiffuse Front $= (glColorOfColor col) data VisObject a = VisObjects [VisObject a]- | Trans (Xyz a) (VisObject a)- | RotQuat (Quat a) (VisObject a)+ | Trans (V3 a) (VisObject a)+ | RotQuat (Quaternion a) (VisObject a) | RotEulerRad (Euler a) (VisObject a) | RotEulerDeg (Euler a) (VisObject a) -- degrees more efficient | Scale (a,a,a) (VisObject a)@@ -37,16 +37,16 @@ | Cube a Flavour GlossColor.Color | Sphere a Flavour GlossColor.Color | Ellipsoid (a,a,a) Flavour GlossColor.Color- | Line [Xyz a] GlossColor.Color- | Line' [(Xyz a,GlossColor.Color)]- | Arrow (a,a) (Xyz a) GlossColor.Color+ | Line [V3 a] GlossColor.Color+ | Line' [(V3 a,GlossColor.Color)]+ | Arrow (a,a) (V3 a) GlossColor.Color | Axes (a,a)- | Plane (Xyz a) GlossColor.Color GlossColor.Color- | Triangle (Xyz a) (Xyz a) (Xyz a) GlossColor.Color- | Quad (Xyz a) (Xyz a) (Xyz a) (Xyz a) GlossColor.Color- | Text3d String (Xyz a) BitmapFont GlossColor.Color+ | Plane (V3 a) GlossColor.Color GlossColor.Color+ | Triangle (V3 a) (V3 a) (V3 a) GlossColor.Color+ | Quad (V3 a) (V3 a) (V3 a) (V3 a) GlossColor.Color+ | Text3d String (V3 a) BitmapFont GlossColor.Color | Text2d String (a,a) BitmapFont GlossColor.Color- | Points [Xyz a] (Maybe GLfloat) GlossColor.Color+ | Points [V3 a] (Maybe GLfloat) GlossColor.Color | Custom (IO ()) deriving instance Functor VisObject@@ -69,12 +69,12 @@ drawObject (VisObjects xs) = mapM_ drawObject xs -- list of objects-drawObject (Trans (Xyz x y z) visobj) =+drawObject (Trans (V3 x y z) visobj) = preservingMatrix $ do translate (Vector3 x y z :: Vector3 GLdouble) drawObject visobj -drawObject (RotQuat (Quat q0 q1 q2 q3) visobj) =+drawObject (RotQuat (Quaternion q0 (V3 q1 q2 q3)) visobj) = preservingMatrix $ do rotate (2 * acos q0 *180/pi :: GLdouble) (Vector3 q1 q2 q3) drawObject visobj@@ -97,7 +97,7 @@ normalize $= Disabled -- triangle-drawObject (Triangle (Xyz x0 y0 z0) (Xyz x1 y1 z1) (Xyz x2 y2 z2) col) =+drawObject (Triangle (V3 x0 y0 z0) (V3 x1 y1 z1) (V3 x2 y2 z2) col) = preservingMatrix $ do setMaterialDiffuse col setColor col@@ -108,7 +108,7 @@ glEnd -- quad-drawObject (Quad (Xyz x0 y0 z0) (Xyz x1 y1 z1) (Xyz x2 y2 z2) (Xyz x3 y3 z3) col) =+drawObject (Quad (V3 x0 y0 z0) (V3 x1 y1 z1) (V3 x2 y2 z2) (V3 x3 y3 z3) col) = preservingMatrix $ do lighting $= Disabled setColor col@@ -189,7 +189,7 @@ preservingMatrix $ do lighting $= Disabled setColor col- renderPrimitive LineStrip $ mapM_ (\(Xyz x' y' z') -> vertex $ Vertex3 x' y' z') path+ renderPrimitive LineStrip $ mapM_ (\(V3 x' y' z') -> vertex $ Vertex3 x' y' z') path lighting $= Enabled -- line where you set the color at each vertex@@ -199,7 +199,7 @@ glBegin gl_LINE_STRIP let f (xyz, col) = do- let Xyz x y z = fmap realToFrac xyz+ let V3 x y z = fmap realToFrac xyz setMaterialDiffuse col setColor col glVertex3f x y z@@ -208,7 +208,7 @@ lighting $= Enabled -- plane-drawObject (Plane (Xyz x y z) col1 col2) =+drawObject (Plane (V3 x y z) col1 col2) = preservingMatrix $ do let normInv = 1/(sqrt $ x*x + y*y + z*z) x' = x*normInv@@ -231,12 +231,12 @@ glDisable gl_BLEND let drawWithEps eps' = do- mapM_ drawObject $ concat [[ Line [ Xyz (-r) y0 eps'- , Xyz r y0 eps'- ] col1- , Line [ Xyz x0 (-r) eps',- Xyz x0 r eps'- ] col1+ mapM_ drawObject $ concat [[ Line [ V3 (-r) y0 eps'+ , V3 r y0 eps'+ ] col1+ , Line [ V3 x0 (-r) eps',+ V3 x0 r eps'+ ] col1 ] | x0 <- [-r,-r+r/n..r], y0 <- [-r,-r+r/n..r]] drawWithEps eps drawWithEps (-eps)@@ -245,7 +245,7 @@ -- arrow-drawObject (Arrow (size, aspectRatio) (Xyz x y z) col) =+drawObject (Arrow (size, aspectRatio) (V3 x y z) col) = preservingMatrix $ do let numSlices = 8 numStacks = 15@@ -268,14 +268,14 @@ renderObject Solid (GLUT.Cone coneRadius coneHeight numSlices numStacks) drawObject (Axes (size, aspectRatio)) = preservingMatrix $ do- let xAxis = Arrow (size, aspectRatio) (Xyz 1 0 0) (GlossColor.makeColor 1 0 0 1)- yAxis = Arrow (size, aspectRatio) (Xyz 0 1 0) (GlossColor.makeColor 0 1 0 1)- zAxis = Arrow (size, aspectRatio) (Xyz 0 0 1) (GlossColor.makeColor 0 0 1 1)+ let xAxis = Arrow (size, aspectRatio) (V3 1 0 0) (GlossColor.makeColor 1 0 0 1)+ yAxis = Arrow (size, aspectRatio) (V3 0 1 0) (GlossColor.makeColor 0 1 0 1)+ zAxis = Arrow (size, aspectRatio) (V3 0 0 1) (GlossColor.makeColor 0 0 1 1) drawObject $ VisObjects [xAxis, yAxis, zAxis] drawObject (Custom f) = preservingMatrix f -drawObject (Text3d string (Xyz x y z) font col) = preservingMatrix $ do+drawObject (Text3d string (V3 x y z) font col) = preservingMatrix $ do lighting $= Disabled setColor col glRasterPos3d x y z@@ -306,7 +306,7 @@ setColor col s' <- get pointSize when (isJust ps) $ pointSize $= (fromJust ps)- renderPrimitive GLUT.Points $ mapM_ (\(Xyz x' y' z') -> vertex $ Vertex3 x' y' z') xyzs+ renderPrimitive GLUT.Points $ mapM_ (\(V3 x' y' z') -> vertex $ Vertex3 x' y' z') xyzs pointSize $= s' lighting $= Enabled
+ changelog.txt view
@@ -0,0 +1,5 @@+0.6.0.0:+- use spatial-math 0.2, which uses types from `linear` package++0.5.0.5:+- GLUT/OpenGLRaw version bumps
not-gloss.cabal view
@@ -1,17 +1,21 @@ name: not-gloss-version: 0.5.0.5+version: 0.6.0.0 stability: Experimental synopsis: Painless 3D graphics, no affiliation with gloss description:{ This package intends to make it relatively easy to do simple 3d graphics using high-level primitives. It is inspired by gloss and attempts to emulate it. This is an early release and the api will certainly change.+ Note that transparency can be controlled by the alpha value: "makeColor r g b alpha" but that you must draw objects from back to front for transparency to properly work (just put clear things last). Also, transparent ellipsoids and cylinders have ugly artifacts, sorry.+ Look at the complimentary package not-gloss-examples to get started. -0.5.0.5 - GLUT/OpenGLRaw version bumps }++extra-source-files: changelog.txt+ license: BSD3 license-file: LICENSE author: Greg Horn@@ -35,7 +39,7 @@ GLUT >= 2.3.0.0 && < 2.6, time == 1.4.*, OpenGLRaw >= 1.2.0.0 && < 1.5,- spatial-math >= 0.1.7 && < 0.2+ spatial-math >= 0.2.0 && < 0.3 ghc-options: -O2