wavefront 0.3 → 0.4
raw patch · 10 files changed
+86/−30 lines, 10 files
Files
- CHANGELOG.md +6/−0
- src/Codec/Wavefront.hs +45/−2
- src/Codec/Wavefront/Face.hs +5/−2
- src/Codec/Wavefront/Line.hs +4/−1
- src/Codec/Wavefront/Location.hs +6/−6
- src/Codec/Wavefront/Normal.hs +5/−5
- src/Codec/Wavefront/Point.hs +3/−2
- src/Codec/Wavefront/TexCoord.hs +5/−5
- src/Codec/Wavefront/Token.hs +2/−2
- wavefront.cabal +5/−5
CHANGELOG.md view
@@ -1,3 +1,9 @@+# 0.4++- Removed most modules from the exposed interface. Everything can be found in Codec.Wavefront.+- Changed internal structures of a few types. The structure of those types shouldn’t be used in the+ interface, so a few functions to access them was provided.+ # 0.3 #### Breaking changes
src/Codec/Wavefront.hs view
@@ -12,9 +12,52 @@ ----------------------------------------------------------------------------- module Codec.Wavefront (- module Codec.Wavefront.Object+ -- * Vertex location+ Location+ , locX+ , locY+ , locZ+ , locW+ -- * Vertex texture coordinates+ , TexCoord+ , texcoordR+ , texcoordS+ , texcoordT+ -- * Vertex normals+ , Normal+ , norX+ , norY+ , norZ+ -- * Points+ , Point+ , pointLocIndex+ -- * Lines+ , Line+ , lineLocIndex+ , lineTexCoordIndex+ -- * Faces+ , Face+ , faceLocIndex+ , faceTexCoordIndex+ , faceNorIndex+ -- * Element+ , Element+ , elObject+ , elGroups+ , elMtl+ , elValue+ -- * Object+ , WavefrontOBJ(..)+ -- * Re-exports , module Codec.Wavefront.IO ) where -import Codec.Wavefront.Object+import Codec.Wavefront.Element+import Codec.Wavefront.Face import Codec.Wavefront.IO+import Codec.Wavefront.Line+import Codec.Wavefront.Location+import Codec.Wavefront.Normal+import Codec.Wavefront.Object+import Codec.Wavefront.Point+import Codec.Wavefront.TexCoord
src/Codec/Wavefront/Face.hs view
@@ -18,5 +18,8 @@ -- -- Keep in mind that 'Face' doesn’t represent a polygonal face directly. It represents a face index, -- which is a triplet. In theory, a polygonal face is 3 'Face's.-data Face = Face {-# UNPACK #-} !(Int,Maybe Int,Maybe Int) deriving (Eq,Show)-+data Face = Face {+ faceLocIndex :: {-# UNPACK #-} !Int+ , faceTexCoordIndex :: !(Maybe Int)+ , faceNorIndex :: !(Maybe Int)+ } deriving (Eq,Show)
src/Codec/Wavefront/Line.hs view
@@ -17,5 +17,8 @@ -- -- Keep in mind that 'Line' doesn’t represent a polygonal line directly. It represents a line index, -- which is a pair. In theory, a polygonal line is 2 'Line's.-data Line = Line {-# UNPACK #-} !(Int,Maybe Int) deriving (Eq,Show)+data Line = Line {+ lineLocIndex :: {-# UNPACK #-} !Int+ , lineTexCoordIndex :: !(Maybe Int)+ } deriving (Eq,Show)
src/Codec/Wavefront/Location.hs view
@@ -18,9 +18,9 @@ -- @ -- -- That type is strict and unboxed.-data Location = Location- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- deriving (Eq,Show)+data Location = Location {+ locX :: {-# UNPACK #-} !Float+ , locY :: {-# UNPACK #-} !Float+ , locZ :: {-# UNPACK #-} !Float+ , locW :: {-# UNPACK #-} !Float+ } deriving (Eq,Show)
src/Codec/Wavefront/Normal.hs view
@@ -18,8 +18,8 @@ -- @ -- -- That type is strict and unboxed.-data Normal = Normal- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- deriving (Eq,Show)+data Normal = Normal {+ norX :: {-# UNPACK #-} !Float+ , norY :: {-# UNPACK #-} !Float+ , norZ :: {-# UNPACK #-} !Float+ } deriving (Eq,Show)
src/Codec/Wavefront/Point.hs view
@@ -13,5 +13,6 @@ -- |A point is a single index that references the locations. It’s a canonical type that truly -- represents a polygonal point.-data Point = Point {-# UNPACK #-} !Int deriving (Eq,Show)-+data Point = Point {+ pointLocIndex :: {-# UNPACK #-} !Int+ } deriving (Eq,Show)
src/Codec/Wavefront/TexCoord.hs view
@@ -19,9 +19,9 @@ -- @ -- -- That type is strcit and unboxed.-data TexCoord = TexCoord- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- {-# UNPACK #-} !Float- deriving (Eq,Show)+data TexCoord = TexCoord {+ texcoordR :: {-# UNPACK #-} !Float+ , texcoordS :: {-# UNPACK #-} !Float+ , texcoordT :: {-# UNPACK #-} !Float+ } deriving (Eq,Show)
src/Codec/Wavefront/Token.hs view
@@ -120,7 +120,7 @@ -- TODO: ensure we have at least 2 pairs, otherwise it should fail lines :: Parser [Line]-lines = skipSpace *> string "l " *> skipHSpace *> fmap Line parseLinePair `sepBy1` skipHSpace <* eol+lines = skipSpace *> string "l " *> skipHSpace *> fmap (\(i,k) -> Line i k) parseLinePair `sepBy1` skipHSpace <* eol where parseLinePair = do v <- decimal@@ -131,7 +131,7 @@ -- TODO: ensure we have at least 3 triples, otherwise it should fail faces :: Parser [Face]-faces = skipSpace *> string "f " *> skipHSpace *> fmap Face parseFaceTriple `sepBy1` skipHSpace <* eol+faces = skipSpace *> string "f " *> skipHSpace *> fmap (\(i,k,j) -> Face i k j) parseFaceTriple `sepBy1` skipHSpace <* eol where parseFaceTriple = do v <- decimal
wavefront.cabal view
@@ -1,5 +1,5 @@ name: wavefront-version: 0.3+version: 0.4 synopsis: Wavefront OBJ loader description: A Wavefront OBJ loader. Currently supports polygonal information. More could be added if needed (like curves and surface) if people contribute. Feel free@@ -25,17 +25,17 @@ ghc-options: -W -Wall exposed-modules: Codec.Wavefront- , Codec.Wavefront.Element- , Codec.Wavefront.Face , Codec.Wavefront.IO++ other-modules: Codec.Wavefront.Element+ , Codec.Wavefront.Face , Codec.Wavefront.Line , Codec.Wavefront.Location , Codec.Wavefront.Normal , Codec.Wavefront.Object , Codec.Wavefront.Point , Codec.Wavefront.TexCoord-- other-modules: Codec.Wavefront.Token+ , Codec.Wavefront.Token , Codec.Wavefront.Lexer default-extensions: OverloadedStrings