diff options
author | Joe Crayne <joe@jerkface.net> | 2019-06-11 02:58:54 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-06-11 02:58:54 -0400 |
commit | 33ac9c597f708c0f0d2232c25e1fbbf7840b9610 (patch) | |
tree | f257f8d041818ccdfd54347964ffa5c3d9dfda60 | |
parent | 6fbc401f5cbb89e9c8b6be48f746e911848aed36 (diff) |
Sundqvist parser: support vp token.
-rw-r--r-- | src/Graphics/WaveFront/Parse/OBJ.hs | 6 | ||||
-rw-r--r-- | src/Graphics/WaveFront/Types.hs | 1 | ||||
-rw-r--r-- | 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) <|> | |||
83 | -- TODO: How to deal with common prefix (v, vn, vt) (backtrack?) (doesn't seem to be a problem) | 83 | -- TODO: How to deal with common prefix (v, vn, vt) (backtrack?) (doesn't seem to be a problem) |
84 | (Atto.string "vn" *> normal) <|> | 84 | (Atto.string "vn" *> normal) <|> |
85 | (Atto.string "vt" *> texcoord) <|> | 85 | (Atto.string "vt" *> texcoord) <|> |
86 | (Atto.string "vp" *> paramcoord) <|> | ||
86 | (Atto.string "v" *> vertex) <|> | 87 | (Atto.string "v" *> vertex) <|> |
87 | (Atto.string "o" *> object) <|> | 88 | (Atto.string "o" *> object) <|> |
88 | (Atto.string "g" *> group) <|> | 89 | (Atto.string "g" *> group) <|> |
@@ -137,10 +138,13 @@ normal :: (Fractional f) => Atto.Parser (OBJToken f Text i m) | |||
137 | normal = OBJNormal <$> point3D | 138 | normal = OBJNormal <$> point3D |
138 | 139 | ||
139 | 140 | ||
140 | -- | Two coordinates, separated by whitespace | 141 | -- | One to three coordinates, separated by whitespace |
141 | texcoord :: (Fractional f) => Atto.Parser (OBJToken f Text i m) | 142 | texcoord :: (Fractional f) => Atto.Parser (OBJToken f Text i m) |
142 | texcoord = OBJTexCoord <$> pointTo3 1 0.0 | 143 | texcoord = OBJTexCoord <$> pointTo3 1 0.0 |
143 | 144 | ||
145 | -- | One to three coordinates, separated by whitespace | ||
146 | paramcoord :: (Fractional f) => Atto.Parser (OBJToken f Text i m) | ||
147 | paramcoord = OBJParamCoord <$> pointTo3 1 0.0 | ||
144 | 148 | ||
145 | -- | Three coordinates, separated by whitespace | 149 | -- | Three coordinates, separated by whitespace |
146 | vertex :: (Fractional f) => Atto.Parser (OBJToken f s i m) | 150 | 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(..)) | |||
68 | data OBJToken f s i m = OBJVertex (V4 f) | | 68 | data OBJToken f s i m = OBJVertex (V4 f) | |
69 | OBJNormal (V3 f) | | 69 | OBJNormal (V3 f) | |
70 | OBJTexCoord (V3 f) | | 70 | OBJTexCoord (V3 f) | |
71 | OBJParamCoord (V3 f) | | ||
71 | OBJFace (m (VertexIndices i)) | -- TODO: Associate material with each face, handle absent indices | 72 | OBJFace (m (VertexIndices i)) | -- TODO: Associate material with each face, handle absent indices |
72 | 73 | ||
73 | Line i i | -- Line (I'm assuming the arguments are indices to the endpoint vertices) | 74 | 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 | |||
16 | main = do | 16 | main = do |
17 | ddir <- getDataDir | 17 | ddir <- getDataDir |
18 | r1 <- Load.obj (ddir ++ "/01.obj") | 18 | r1 <- Load.obj (ddir ++ "/01.obj") |
19 | print r1 | 19 | either print (mapM_ print) r1 |
20 | -- Failed: endOfInput | ||
21 | -- Reason: vp token,and blank lines | ||