diff options
author | Joe Crayne <joe@jerkface.net> | 2019-07-23 20:01:32 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-07-23 20:01:32 -0400 |
commit | d8dbabde5b6438a0298ed11275b2951f4ae6d7bf (patch) | |
tree | e6073b5188d9e5c00176a698fd0d06fca48d07ba | |
parent | 3a9d1a324b8728c5dfd12bb3c41dcf1170ae0596 (diff) |
Added missing source for objcat tool.
-rw-r--r-- | tools/objcat.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/objcat.hs b/tools/objcat.hs new file mode 100644 index 0000000..66ab9a9 --- /dev/null +++ b/tools/objcat.hs | |||
@@ -0,0 +1,37 @@ | |||
1 | import Data.Bool | ||
2 | import qualified Data.ByteString.Lazy as L | ||
3 | import qualified Data.DList as DList | ||
4 | import qualified Data.IntMap as IntMap | ||
5 | import Data.Char | ||
6 | import Data.Maybe | ||
7 | import System.Environment | ||
8 | import Control.Monad.Writer.Lazy | ||
9 | import Control.Monad.State.Strict | ||
10 | |||
11 | import Wavefront.Lex | ||
12 | import Wavefront | ||
13 | |||
14 | zflip b = b | ||
15 | { vertex = \xs -> case xs of | ||
16 | x:y:z:ws -> vertex b (x:y:(-z):ws) | ||
17 | _ -> vertex b xs | ||
18 | , vertexN = \xs -> case xs of | ||
19 | x:y:z:ws -> vertexN b (x:y:(-z):ws) | ||
20 | _ -> vertexN b xs | ||
21 | , face = \ts -> face b $ reverse ts | ||
22 | } | ||
23 | |||
24 | objcat b fs = (`evalStateT` renumFrom1) $ do | ||
25 | forM_ fs $ \f -> do | ||
26 | bs <- liftIO $ L.readFile f | ||
27 | parseCustom (applyRenumbering b) (modify' . addCounts) bs | ||
28 | return () | ||
29 | |||
30 | main = do | ||
31 | (b,fs) <- do | ||
32 | fs0 <- getArgs | ||
33 | case fs0 of | ||
34 | "--zflip":fs -> return (zflip echoBuilder, fs) | ||
35 | fs -> return (echoBuilder,fs) | ||
36 | out <- DList.toList <$> execWriterT (objcat b fs) | ||
37 | putStrLn $ unlines out | ||