-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Load GPipe meshes from Collada files -- -- This package provides data types for a Collada scene graph including -- geometries, cameras and lights that may be loaded from Collada (dae) -- files. Geometries are represented by GPipe PrimitiveStreams. A utility -- module is included that include traverse helpers and render functions. @package GPipe-Collada @version 0.1.4 -- | This module provides an axis aligned bounding box based on -- Vecs. module Data.Vec.AABB -- | An axis aligned bounding box. data AABB AABB :: Vec3 Float -> Vec3 Float -> AABB aabbMin :: AABB -> Vec3 Float aabbMax :: AABB -> Vec3 Float -- | Transforms an 'AABB* using a 4x4 matrix. Note that this may grow the -- AABB and is not associative with matrix multiplication, i.e. -- --
-- (m2 `multmm` m1) `aabbTransform` aabb ---- -- is usually not the same as -- --
-- m2 `aabbTransform` (m1 `aabbTransform` aabb) ---- -- (The former is preferred as it minimizes the growing of the AABB). aabbTransform :: Mat44 Float -> AABB -> AABB -- | Try if an AABB is inside a projection frustum. The AABB must be -- defined in the same vector space as the matrix, e.g. use the -- model-view-projection matrix for model-local aabb's. testAABBprojection :: Mat44 Float -> AABB -> Intersection data Intersection Inside :: Intersection Intersecting :: Intersection Outside :: Intersection instance Show AABB instance Eq AABB instance Eq Intersection instance Show Intersection instance Ord Intersection instance Enum Intersection instance Bounded Intersection instance Monoid AABB -- | This module contains the data types of the Collada scene graph. -- -- Orphan TypeableX instances are also provided for Vertex and -- Data.Vec vectors (:.) . module Graphics.GPipe.Collada type Scene = Tree (SID, Node) data Node Node :: Maybe ID -> [String] -> [(SID, Transform)] -> [(SID, Camera)] -> [(SID, Light)] -> [(SID, Geometry)] -> Node nodeId :: Node -> Maybe ID nodeLayers :: Node -> [String] nodeTransformations :: Node -> [(SID, Transform)] nodeCameras :: Node -> [(SID, Camera)] nodeLights :: Node -> [(SID, Light)] nodeGeometries :: Node -> [(SID, Geometry)] -- | The complete transform matrix of all Transform elements in a -- node. nodeMat :: Node -> Mat44 Float -- | The smallest AABB that contains all Geometry elements in -- a node. Note: This is not transformed using the nodes Transform -- elements. nodeAABB :: Node -> AABB data Transform LookAt :: Vec3 Float -> Vec3 Float -> Vec3 Float -> Transform lookAtEye :: Transform -> Vec3 Float lookAtInterest :: Transform -> Vec3 Float lookAtUp :: Transform -> Vec3 Float Matrix :: (Mat44 Float) -> Transform Rotate :: (Vec3 Float) -> Float -> Transform Scale :: (Vec3 Float) -> Transform Skew :: Float -> Vec3 Float -> Vec3 Float -> Transform skewAngle :: Transform -> Float skewRotation :: Transform -> Vec3 Float skewTranslation :: Transform -> Vec3 Float Translate :: (Vec3 Float) -> Transform -- | Gets the transformation matrix of a Transform element. transformMat :: Transform -> Mat44 Float -- | Gets the total transformation matrix of a list of Transform -- element. transformsMat :: [Transform] -> Mat44 Float data Camera Perspective :: ID -> ViewSize -> Z -> Camera perspectiveID :: Camera -> ID perspectiveFov :: Camera -> ViewSize perspectiveZ :: Camera -> Z Orthographic :: ID -> ViewSize -> Z -> Camera orthographicID :: Camera -> ID orthographicViewSize :: Camera -> ViewSize orthographicZ :: Camera -> Z -- | Gets the projection matrix of a Camera element. cameraMat :: Float -> Camera -> Mat44 Float data ViewSize ViewSizeX :: Float -> ViewSize ViewSizeY :: Float -> ViewSize ViewSizeXY :: (Vec2 Float) -> ViewSize data Z Z :: Float -> Float -> Z zNear :: Z -> Float zFar :: Z -> Float data Light Ambient :: ID -> Color RGBFormat Float -> Light ambientID :: Light -> ID ambientColor :: Light -> Color RGBFormat Float Directional :: ID -> Color RGBFormat Float -> Light directionalID :: Light -> ID directionalColor :: Light -> Color RGBFormat Float Point :: ID -> Color RGBFormat Float -> Attenuation -> Light pointID :: Light -> ID pointColor :: Light -> Color RGBFormat Float pointAttenuation :: Light -> Attenuation Spot :: ID -> Color RGBFormat Float -> Attenuation -> Float -> Float -> Light spotID :: Light -> ID spotColor :: Light -> Color RGBFormat Float spotAttenuation :: Light -> Attenuation spotFallOffAngle :: Light -> Float spotFallOffExponent :: Light -> Float data Attenuation Attenuation :: Float -> Float -> Float -> Attenuation attenuationConstant :: Attenuation -> Float attenuationLinear :: Attenuation -> Float attenuationQuadratic :: Attenuation -> Float data Geometry Mesh :: ID -> [Mesh] -> Geometry meshID :: Geometry -> ID meshPrimitives :: Geometry -> [Mesh] data Mesh TriangleMesh :: String -> Map Semantic TypeRep -> PrimitiveStream Triangle (Map Semantic Dynamic) -> AABB -> Mesh meshMaterial :: Mesh -> String meshDescription :: Mesh -> Map Semantic TypeRep meshPrimitiveStream :: Mesh -> PrimitiveStream Triangle (Map Semantic Dynamic) meshAABB :: Mesh -> AABB type ID = String type SID = Maybe String type Semantic = String -- | An axis aligned bounding box. data AABB AABB :: Vec3 Float -> Vec3 Float -> AABB aabbMin :: AABB -> Vec3 Float aabbMax :: AABB -> Vec3 Float instance Typeable2 :. instance Typeable V instance Typeable2 Shader instance Show Transform instance Eq Transform instance Show ViewSize instance Eq ViewSize instance Show Z instance Eq Z instance Show Attenuation instance Eq Attenuation instance Show Light instance Eq Light instance Show Camera instance Eq Camera instance Show Geometry instance Show Node instance Show Mesh -- | This module provides the means to load Collada scene graphs from -- Collada (dae) files. -- -- The parser supports Collada 1.5 core elements, including cameras -- lights and triangle meshes. Other elements such as animations, -- controllers or materials are ignored. Other meshes than triangles, -- trifans and tristrips are ignored. Only float_arrays are supported and -- others will be ignored. The parser only support local links and will -- ignore external ones. The parser supports parsing infinitely recursive -- structures into constant memory. module Graphics.GPipe.Collada.Parse -- | Parse a string containing a collada document and return Either -- an error message or the parsed Collada Scene. readCollada :: String -> Either String Scene -- | Open a Collada file and parse its contents and return a Collada -- Scene. Errors are thrown as userErrors. readColladaFile :: FilePath -> IO Scene -- | This module contains the data types of the Collada scene graph. module Graphics.GPipe.Collada.Utils -- | Traverse a Tree top down, much like mapAccumL. The function -- recieves an accumulator from its parent and generates one that is -- passed down to its children. Useful for accumulating transformations, -- etc. topDown :: (acc -> x -> (acc, y)) -> acc -> Tree x -> Tree y -- | Traverse a Tree bottom up, much like mapAccumR. The function -- recieves the accumulators of all its children and generates one that -- is passed up to its parent. Useful for accumulating AABBs, etc. bottomUp :: ([acc] -> x -> (acc, y)) -> Tree x -> (acc, Tree y) -- | Remove branches of a tree where the function evaluates to True. -- Useful for selecting LODs, etc. prune :: (a -> Bool) -> Tree a -> Maybe (Tree a) -- | A path where the first string in the list is the closest ID and the -- rest is all SIDs found in order. type SIDPath = [String] -- | Traverse a tree top down accumulating the SIDPath for each -- node. The projection function enables this to be used on trees that -- are not Scenes. The accumulated SIDPath for a node will -- include the node's SID at the end, but not its ID. The -- ID will however be the first String in the -- SIDPaths of the children, and the nodes SID won't be -- included in this case. topDownSIDPath :: (x -> (SID, Maybe ID)) -> Tree x -> Tree (SIDPath, x) -- | Traverse a tree top down accumulating the absolute transform for each -- node. The projection function enables this to be used on trees that -- are not Scenes. Use nodeMat to get the Mat44 -- Float from a node. The accumulated matrix for each node will -- contain the node's own transforms. topDownTransform :: (x -> Mat44 Float) -> Tree x -> Tree (Mat44 Float, x) -- | For each SID-attributed element in a list, apply the provided -- function. The elements where the function evaluates to Nothing -- are removed. alterSID :: (String -> a -> Maybe a) -> [(SID, a)] -> [(SID, a)] -- | Find the first element in the list that is attributed with the -- provided SID. lookupSID :: String -> [(SID, a)] -> Maybe a -- | Evaluates to True where the Map contains the semantic -- with the same type as the last argument (which is not evaluated and -- prefferably is a monotyped undefined). hasDynVertex :: Typeable a => Map Semantic TypeRep -> Semantic -> a -> Bool -- | Extract the value of a specific semantic from the Map. If the -- semantic is not found or the type is wrong, it evaluates to -- Nothing. dynVertex :: Typeable a => Map Semantic Dynamic -> Semantic -> Maybe a -- | Render the scene using a simple shading technique through the first -- camera found, or through a defult camera if the scene doesn't contain -- any cameras. The scene's lights aren't used in the rendering. The -- source of this function can also serve as an example of how a Collada -- Scene can be processed. viewScene :: Scene -> Vec2 Int -> FrameBuffer RGBFormat DepthFormat ()