From 33ac9c597f708c0f0d2232c25e1fbbf7840b9610 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 11 Jun 2019 02:58:54 -0400 Subject: Sundqvist parser: support vp token. --- src/Graphics/WaveFront/Parse/OBJ.hs | 6 +++++- src/Graphics/WaveFront/Types.hs | 1 + test/TestSundqvist.hs | 4 +--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Graphics/WaveFront/Parse/OBJ.hs b/src/Graphics/WaveFront/Parse/OBJ.hs index 2c3919e..df4b52e 100644 --- a/src/Graphics/WaveFront/Parse/OBJ.hs +++ b/src/Graphics/WaveFront/Parse/OBJ.hs @@ -83,6 +83,7 @@ token = (Atto.string "f" *> face) <|> -- TODO: How to deal with common prefix (v, vn, vt) (backtrack?) (doesn't seem to be a problem) (Atto.string "vn" *> normal) <|> (Atto.string "vt" *> texcoord) <|> + (Atto.string "vp" *> paramcoord) <|> (Atto.string "v" *> vertex) <|> (Atto.string "o" *> object) <|> (Atto.string "g" *> group) <|> @@ -137,10 +138,13 @@ normal :: (Fractional f) => Atto.Parser (OBJToken f Text i m) normal = OBJNormal <$> point3D --- | Two coordinates, separated by whitespace +-- | One to three coordinates, separated by whitespace texcoord :: (Fractional f) => Atto.Parser (OBJToken f Text i m) texcoord = OBJTexCoord <$> pointTo3 1 0.0 +-- | One to three coordinates, separated by whitespace +paramcoord :: (Fractional f) => Atto.Parser (OBJToken f Text i m) +paramcoord = OBJParamCoord <$> pointTo3 1 0.0 -- | Three coordinates, separated by whitespace vertex :: (Fractional f) => Atto.Parser (OBJToken f s i m) diff --git a/src/Graphics/WaveFront/Types.hs b/src/Graphics/WaveFront/Types.hs index 5b093de..f8cd6fe 100644 --- a/src/Graphics/WaveFront/Types.hs +++ b/src/Graphics/WaveFront/Types.hs @@ -68,6 +68,7 @@ import Linear (V2(..), V3(..), V4(..)) data OBJToken f s i m = OBJVertex (V4 f) | OBJNormal (V3 f) | OBJTexCoord (V3 f) | + OBJParamCoord (V3 f) | OBJFace (m (VertexIndices i)) | -- TODO: Associate material with each face, handle absent indices Line i i | -- Line (I'm assuming the arguments are indices to the endpoint vertices) diff --git a/test/TestSundqvist.hs b/test/TestSundqvist.hs index 935368a..25d3f8f 100644 --- a/test/TestSundqvist.hs +++ b/test/TestSundqvist.hs @@ -16,6 +16,4 @@ getDataDir = do main = do ddir <- getDataDir r1 <- Load.obj (ddir ++ "/01.obj") - print r1 - -- Failed: endOfInput - -- Reason: vp token,and blank lines + either print (mapM_ print) r1 -- cgit v1.2.3