GPipe-Collada-0.1.4: Load GPipe meshes from Collada files

Safe HaskellSafe-Infered




This module contains the data types of the Collada scene graph.


General Tree utilities

topDown :: (acc -> x -> (acc, y)) -> acc -> Tree x -> Tree ySource

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.

bottomUp :: ([acc] -> x -> (acc, y)) -> Tree x -> (acc, Tree y)Source

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.

prune :: (a -> Bool) -> Tree a -> Maybe (Tree a)Source

Remove branches of a tree where the function evaluates to True. Useful for selecting LODs, etc.

Scene utilities

type SIDPath = [String]Source

A path where the first string in the list is the closest ID and the rest is all SIDs found in order.

topDownSIDPath :: (x -> (SID, Maybe ID)) -> Tree x -> Tree (SIDPath, x)Source

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.

topDownTransform :: (x -> Mat44 Float) -> Tree x -> Tree (Mat44 Float, x)Source

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.

SID utilities

alterSID :: (String -> a -> Maybe a) -> [(SID, a)] -> [(SID, a)]Source

For each SID-attributed element in a list, apply the provided function. The elements where the function evaluates to Nothing are removed.

lookupSID :: String -> [(SID, a)] -> Maybe aSource

Find the first element in the list that is attributed with the provided SID.

Geometry utilities

hasDynVertex :: Typeable a => Map Semantic TypeRep -> Semantic -> a -> BoolSource

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).

dynVertex :: Typeable a => Map Semantic Dynamic -> Semantic -> Maybe aSource

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.

Debug utilities

viewScene :: Scene -> Vec2 Int -> FrameBuffer RGBFormat DepthFormat ()Source

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.