From 68d71025f47fd3d4d2c1e4d4dcda2180f2565ddd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 12 Apr 2010 02:17:42 +0200 Subject: Some minor changes --- src/Data/Obj3D/Parser.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Data/Obj3D/Parser.hs') diff --git a/src/Data/Obj3D/Parser.hs b/src/Data/Obj3D/Parser.hs index 2d3dbce..408eab5 100644 --- a/src/Data/Obj3D/Parser.hs +++ b/src/Data/Obj3D/Parser.hs @@ -1,6 +1,6 @@ module Data.Obj3D.Parser ( Vertex , VertexNormal - , TexCoords + , TexCoord , FaceVertex , Face , ObjLine(..) @@ -15,16 +15,16 @@ import Text.ParserCombinators.Parsec hiding (space, spaces, Parser) type Vertex = (Float, Float, Float) type VertexNormal = (Float, Float, Float) -type TexCoords = (Float, Float) +type TexCoord = (Float, Float) type FaceVertex = (Integer, Maybe Integer, Maybe Integer) type Face = (FaceVertex, FaceVertex, FaceVertex) -data ObjLine = VertexLine Vertex | TexCoordsLine TexCoords | VertexNormalLine VertexNormal | FaceLine Face | ObjectLine String | UnknownLine String | EmptyLine +data ObjLine = VertexLine Vertex | TexCoordLine TexCoord | VertexNormalLine VertexNormal | FaceLine Face | ObjectLine String | UnknownLine String | EmptyLine deriving Show data ParserState = ParserState { vertexCount :: Integer - , texCoordsCount :: Integer + , texCoordCount :: Integer , vertexNormalCount :: Integer } @@ -73,7 +73,7 @@ faceVertex = do v <- liftM (subtract 1) $ relativeInteger $ vertexCount state (t, n) <- option (Nothing, Nothing) $ do char '/' - t <- option Nothing $ liftM (Just . subtract 1) $ relativeInteger $ texCoordsCount state + t <- option Nothing $ liftM (Just . subtract 1) $ relativeInteger $ texCoordCount state n <- option Nothing $ do char '/' option Nothing $ liftM (Just . subtract 1) $ relativeInteger $ vertexNormalCount state @@ -101,8 +101,8 @@ vertexLine = do updateState $ \state -> state {vertexCount = 1 + vertexCount state} return $ VertexLine (x, y, z) -texCoordsLine :: Parser ObjLine -texCoordsLine = do +texCoordLine :: Parser ObjLine +texCoordLine = do try $ do string "vt" spaces @@ -112,8 +112,8 @@ texCoordsLine = do optional $ do spaces float - updateState $ \state -> state {texCoordsCount = 1 + texCoordsCount state} - return $ TexCoordsLine (u, v) + updateState $ \state -> state {texCoordCount = 1 + texCoordCount state} + return $ TexCoordLine (u, v) vertexNormalLine :: Parser ObjLine vertexNormalLine = do @@ -157,7 +157,7 @@ emptyLine = return EmptyLine line :: Parser ObjLine line = do optional spaces - l <- vertexLine <|> texCoordsLine <|> vertexNormalLine <|> faceLine <|> objectLine <|> anyLine <|> emptyLine + l <- vertexLine <|> texCoordLine <|> vertexNormalLine <|> faceLine <|> objectLine <|> anyLine <|> emptyLine optional spaces optional comment newline -- cgit v1.2.3