import Data.PMD
import Data.Serialize
import qualified Data.ByteString as BS (readFile)
import qualified Data.Vector as V

main = do
  x <- decode `fmap` BS.readFile "test.pmd" :: IO (Either String PMD)
  case x of
    (Left e) -> error e
    (Right (PMD FileHeaderV1
            (ModelHeader name comment)
            (VertexVec vs)
            (IndexInfo is)
            (Materials ms))) -> do
      let v = findv 0 is vs
      print v
      print name
      print comment

findv i is vs = (p, q, r)
  where
    p = vs V.! (fromIntegral (is V.! (i*3    )))
    q = vs V.! (fromIntegral (is V.! (i*3 + 1)))
    r = vs V.! (fromIntegral (is V.! (i*3 + 2)))
