| Copyright | (c) Alexis Williams 2016 |
|---|---|
| License | BSD3 |
| Maintainer | sasinestro@gmail.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.WavefrontObj
Description
A (very) minimal microlibrary to load 3D geometry from Wavefront .obj files.
- data WavefrontVertex = WavefrontVertex {
- _vertexPoint :: !(Point V3 Double)
- _textureCoordinate :: !(Maybe (Point V2 Double))
- _vertexNormal :: !(Maybe (V3 Double))
- newtype WavefrontFace' a = WavefrontFace [a]
- type WavefrontFace = WavefrontFace' WavefrontVertex
- newtype WavefrontModel' a = WavefrontModel [a]
- type WavefrontModel = WavefrontModel' WavefrontFace
- parseWavefrontObj :: Text -> Either String WavefrontModel
- loadWavefrontObj :: FilePath -> IO (Either String WavefrontModel)
Types
data WavefrontVertex Source #
Contains the data for an individual vertex, with the world-space coordinate, (optional) texture-space coordinate, and the (optional) precalculated normal vector.
TODO: Add an option to add normals for models without them(?).
Constructors
| WavefrontVertex | |
Fields
| |
Instances
newtype WavefrontFace' a Source #
The underlying datatype to store the vertices for a face.
Constructors
| WavefrontFace [a] |
Instances
| Functor WavefrontFace' Source # | |
| Foldable WavefrontFace' Source # | |
| Eq a => Eq (WavefrontFace' a) Source # | |
| Show a => Show (WavefrontFace' a) Source # | |
type WavefrontFace = WavefrontFace' WavefrontVertex Source #
An alias to make the the type signatures look nicer while still allowing the instances that you would want (without pulling in mono-traversable).
newtype WavefrontModel' a Source #
Models are not exactly complicated in this system, just a list of faces.
Constructors
| WavefrontModel [a] |
Instances
| Functor WavefrontModel' Source # | |
| Foldable WavefrontModel' Source # | |
| Eq a => Eq (WavefrontModel' a) Source # | |
| Show a => Show (WavefrontModel' a) Source # | |
type WavefrontModel = WavefrontModel' WavefrontFace Source #
Another alias to beautify type signatures.
Interface
parseWavefrontObj :: Text -> Either String WavefrontModel Source #
Takes a Text and gives you either an error message or a WavefrontModel containing the geometry data from the input.
loadWavefrontObj :: FilePath -> IO (Either String WavefrontModel) Source #
A convienence function for the common case of loading a model from a text file on disk.