WaveFront-0.5.0.0: Parsers and utilities for the OBJ WaveFront 3D model format

LicenseMIT
MaintainerJonatan H Sundqvist
Stabilityexperimental|stable
PortabilityPOSIX (not sure)
Safe HaskellNone
LanguageHaskell2010

Graphics.WaveFront.Types

Description

 

Synopsis

Documentation

data OBJToken f s i m Source #

Represents a single (valid) OBJ token

TODO | - Polymorphic numerical types (?) - Add context, metadata (eg. line numbers, filename) (?) - Naming scheme (added OBJ prefix to prevent name clashes; cf. Face type) - Comment token (preserve comments in parser output or remove them) (?)

  • Cover the entire spec (http:/www.martinreddy.netgfx3dOBJ.spec) (and handle unimplemented attributes gracefully)

Constructors

OBJVertex (V3 f) 
OBJNormal (V3 f) 
OBJTexCoord (V2 f) 
OBJFace (m (VertexIndices i)) 
Line i i 
UseMTL s 
LibMTL s 
SmoothShading Bool 
Group (Set s) 
Object (Set s) 

Instances

(Show1 m, Show (m f), Show (m (VertexIndices i)), Show (m (V3 f)), Show (m s), Show f, Show s, Show i) => Show (OBJToken f s i m) Source # 

Methods

showsPrec :: Int -> OBJToken f s i m -> ShowS #

show :: OBJToken f s i m -> String #

showList :: [OBJToken f s i m] -> ShowS #

data VertexIndices i Source #

TODO: Rename (?) TODO: Use union instead of Maybe (?)

Constructors

VertexIndices 

Fields

type OBJ f s i m = m (OBJToken f s i m) Source #

Output type of the OBJ parser.

TODO | - Rename (?) - Use Integral for line number (?)

data MTLToken f s Source #

Represents a single (valid) MTL token

TODO | - Is the alpha channel optional, ignored, disallowed? - Include support for (Ns, Ni, d, Tr, illum) - Assume no colours have an alpha channel, since transparency is handled by the d attribute (?)

Instances

(Eq f, Eq s) => Eq (MTLToken f s) Source # 

Methods

(==) :: MTLToken f s -> MTLToken f s -> Bool #

(/=) :: MTLToken f s -> MTLToken f s -> Bool #

(Show f, Show s) => Show (MTLToken f s) Source # 

Methods

showsPrec :: Int -> MTLToken f s -> ShowS #

show :: MTLToken f s -> String #

showList :: [MTLToken f s] -> ShowS #

type Illumination = Int Source #

  1. Color on and Ambient off
  2. Color on and Ambient on
  3. Highlight on
  4. Reflection on and Ray trace on
  5. Transparency: Glass on, Reflection: Ray trace on
  6. Reflection: Fresnel on and Ray trace on
  7. Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
  8. Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
  9. Reflection on and Ray trace off
  10. Transparency: Glass on, Reflection: Ray trace off
  11. Casts shadows onto invisible surfaces

type MTL f s m = m (MTLToken f s) Source #

Output type of the MTL parser. Currently a list of line number and token (or error string) pairs TODO | - Add type for processed MTL (eg. a map between names and materials)

type MTLTable f s = Map s (Map s (Material f s)) Source #

type Vertices f m = m (V3 f) Source #

type TexCoords f m = m (Maybe (V2 f)) Source #

type Normals f m = m (Maybe (V3 f)) Source #

type Materials f s m = m (Material f s) Source #

data Face f s i m Source #

TODO | - Validation (eg. length ivertices == length == ivertices == length itextures if length isn't 0) - Pack indices in a tuple (eg. indices :: [(Int, Int, Int)]) (?) - Use (String, String) for the names of the mtl file and material instead of Material (?) - Use types so as not to confuse the indices (eg. newtype INormal, newtype ITexcoord)

Constructors

Face 

Fields

Instances

(Show1 m, Show (m f), Show (m (VertexIndices i)), Show (m (V3 f)), Show (m s), Show f, Show s, Show i) => Show (Face f s i m) Source # 

Methods

showsPrec :: Int -> Face f s i m -> ShowS #

show :: Face f s i m -> String #

showList :: [Face f s i m] -> ShowS #

HasIndices (Face f0 s0 i0 m0) (m0 (VertexIndices i0)) Source # 

Methods

indices :: Lens' (Face f0 s0 i0 m0) (m0 (VertexIndices i0)) Source #

HasFaces (Model f0 s0 i0 m0) (m0 (Face f0 s0 i0 m0)) Source # 

Methods

faces :: Lens' (Model f0 s0 i0 m0) (m0 (Face f0 s0 i0 m0)) Source #

HasMaterial (Face f0 s0 i0 m0) (Material f0 s0) Source # 

Methods

material :: Lens' (Face f0 s0 i0 m0) (Material f0 s0) Source #

data Colour f Source #

TODO | - Use a type from the colour package instead (?)

Constructors

Colour 

Fields

Instances

Functor Colour Source # 

Methods

fmap :: (a -> b) -> Colour a -> Colour b #

(<$) :: a -> Colour b -> Colour a #

Foldable Colour Source # 

Methods

fold :: Monoid m => Colour m -> m #

foldMap :: Monoid m => (a -> m) -> Colour a -> m #

foldr :: (a -> b -> b) -> b -> Colour a -> b #

foldr' :: (a -> b -> b) -> b -> Colour a -> b #

foldl :: (b -> a -> b) -> b -> Colour a -> b #

foldl' :: (b -> a -> b) -> b -> Colour a -> b #

foldr1 :: (a -> a -> a) -> Colour a -> a #

foldl1 :: (a -> a -> a) -> Colour a -> a #

toList :: Colour a -> [a] #

null :: Colour a -> Bool #

length :: Colour a -> Int #

elem :: Eq a => a -> Colour a -> Bool #

maximum :: Ord a => Colour a -> a #

minimum :: Ord a => Colour a -> a #

sum :: Num a => Colour a -> a #

product :: Num a => Colour a -> a #

Eq f => Eq (Colour f) Source # 

Methods

(==) :: Colour f -> Colour f -> Bool #

(/=) :: Colour f -> Colour f -> Bool #

Show f => Show (Colour f) Source # 

Methods

showsPrec :: Int -> Colour f -> ShowS #

show :: Colour f -> String #

showList :: [Colour f] -> ShowS #

HasRed (Colour f0) f0 Source # 

Methods

red :: Lens' (Colour f0) f0 Source #

HasGreen (Colour f0) f0 Source # 

Methods

green :: Lens' (Colour f0) f0 Source #

HasBlue (Colour f0) f0 Source # 

Methods

blue :: Lens' (Colour f0) f0 Source #

HasAlpha (Colour f0) f0 Source # 

Methods

alpha :: Lens' (Colour f0) f0 Source #

HasSpecular (Material f0 s0) (Colour f0) Source # 

Methods

specular :: Lens' (Material f0 s0) (Colour f0) Source #

HasDiffuse (Material f0 s0) (Colour f0) Source # 

Methods

diffuse :: Lens' (Material f0 s0) (Colour f0) Source #

HasAmbient (Material f0 s0) (Colour f0) Source # 

Methods

ambient :: Lens' (Material f0 s0) (Colour f0) Source #

data Material f s Source #

TODO | - Do all materials have an ambient, a diffuse and a specular colour (?) - Support more attributes (entire spec) (?) - Lenses (?)

Constructors

Material 

Fields

Instances

(Eq f, Eq s) => Eq (Material f s) Source # 

Methods

(==) :: Material f s -> Material f s -> Bool #

(/=) :: Material f s -> Material f s -> Bool #

(Show f, Show s) => Show (Material f s) Source # 

Methods

showsPrec :: Int -> Material f s -> ShowS #

show :: Material f s -> String #

showList :: [Material f s] -> ShowS #

HasTexture (Material f0 s0) (Maybe s0) Source # 

Methods

texture :: Lens' (Material f0 s0) (Maybe s0) Source #

HasSpecular (Material f0 s0) (Colour f0) Source # 

Methods

specular :: Lens' (Material f0 s0) (Colour f0) Source #

HasDiffuse (Material f0 s0) (Colour f0) Source # 

Methods

diffuse :: Lens' (Material f0 s0) (Colour f0) Source #

HasAmbient (Material f0 s0) (Colour f0) Source # 

Methods

ambient :: Lens' (Material f0 s0) (Colour f0) Source #

HasMaterial (Face f0 s0 i0 m0) (Material f0 s0) Source # 

Methods

material :: Lens' (Face f0 s0 i0 m0) (Material f0 s0) Source #

HasMaterials (Model f0 s0 i0 m0) (MTLTable f0 s0) Source # 

Methods

materials :: Lens' (Model f0 s0 i0 m0) (MTLTable f0 s0) Source #

data Model f s i m Source #

Abstract representation of an OBJ model with associated MTL definitions.

TODO | - Rename (?) - Include metadata, comments, rejected data (?) - Separate type for processed OBJTokens (ie. token + context) - Perform index lookups (?) - Reconsider the types (especially of the materials) - Rename accessor functions (eg. texcoords instead of textures) (?)

fTextures :: Set s, data Model f s i m = Model {

Constructors

Model 

Fields

Instances

(Show1 m, Show (m f), Show (m (V2 f)), Show (m (V3 f)), Show (m (Face f s i m)), Show (m s), Show f, Show s, Show i) => Show (Model f s i m) Source # 

Methods

showsPrec :: Int -> Model f s i m -> ShowS #

show :: Model f s i m -> String #

showList :: [Model f s i m] -> ShowS #

HasVertices (Model f0 s0 i0 m0) (m0 (V3 f0)) Source # 

Methods

vertices :: Lens' (Model f0 s0 i0 m0) (m0 (V3 f0)) Source #

HasTexcoords (Model f0 s0 i0 m0) (m0 (V2 f0)) Source # 

Methods

texcoords :: Lens' (Model f0 s0 i0 m0) (m0 (V2 f0)) Source #

HasRoot (Model f0 s0 i0 m0) (Maybe FilePath) Source # 

Methods

root :: Lens' (Model f0 s0 i0 m0) (Maybe FilePath) Source #

HasNormals (Model f0 s0 i0 m0) (m0 (V3 f0)) Source # 

Methods

normals :: Lens' (Model f0 s0 i0 m0) (m0 (V3 f0)) Source #

HasFaces (Model f0 s0 i0 m0) (m0 (Face f0 s0 i0 m0)) Source # 

Methods

faces :: Lens' (Model f0 s0 i0 m0) (m0 (Face f0 s0 i0 m0)) Source #

HasObjects (Model f0 s0 i0 m0) (Map (Set s0) (i0, i0)) Source # 

Methods

objects :: Lens' (Model f0 s0 i0 m0) (Map (Set s0) (i0, i0)) Source #

HasMaterials (Model f0 s0 i0 m0) (MTLTable f0 s0) Source # 

Methods

materials :: Lens' (Model f0 s0 i0 m0) (MTLTable f0 s0) Source #

HasGroups (Model f0 s0 i0 m0) (Map (Set s0) (i0, i0)) Source # 

Methods

groups :: Lens' (Model f0 s0 i0 m0) (Map (Set s0) (i0, i0)) Source #