lambdacube-engine-0.2.1: 3D rendering engine written entirely in Haskell

Graphics.LambdaCube

Contents

Description

This is the public interface of LambdaCube. All the other modules are exposed for the benefit of library writers, but if you feel the need to use any of them as a simple user, that should be considered a defect and reported in the issue tracker.

Synopsis

Documentation

Entry point

data RenderSystem r vb ib q t p lp => World r vb ib q t p lp Source

data LCM w e a Source

Instances

Monad (LCM w e) 
Functor (LCM w e) 
Applicative (LCM w e) 
MonadIO (LCM w e) 

runLCM :: RenderSystem r vb ib q t1 p lp => r -> [ImageLoader] -> LCM (World r vb ib q t1 p lp) e a -> IO ()Source

Embed a LambdaCube program in IO. The embedding manages a world, therefore it requires all the information to create one: the render system and a list of image loaders.

Resource management

data PathType Source

The type of path leading to a resource.

Constructors

PathDir

An ordinary directory.

PathZip

A zip compressed directory.

addResourceLibrary :: RenderSystem r vb ib q t p lp => [ResourceGroup] -> LCM (World r vb ib q t p lp) e ()Source

Add a resource library (essentially a collection of paths) to the current set of search paths stored in the world.

readFile :: RenderSystem r vb ib q t p lp => FilePath -> LCM (World r vb ib q t p lp) e ByteStringSource

Get the raw data for a resource in a lazy bytestring given its path. The data is cached, so this does not necessarily require disk I/O.

readFile' :: RenderSystem r vb ib q t p lp => FilePath -> LCM (World r vb ib q t p lp) e ByteStringSource

Get the raw data for a resource in a strict bytestring given its path. The data is cached, so this does not necessarily require disk I/O.

Scene graph management

addScene :: RenderSystem r vb ib q t p lp => [MkNodeAction r vb ib q t p lp e] -> LCM (World r vb ib q t p lp) e ()Source

Add a list of new nodes to the global scene.

updateTransforms :: RenderSystem r vb ib q t p lp => [(String, Proj4)] -> LCM (World r vb ib q t p lp) e ()Source

Update the transformation matrices of the given nodes.

updateObjects :: RenderSystem rs vb ib q t p lp => [(String, [MkSceneObjectAction rs vb ib q t p lp e])] -> LCM (World rs vb ib q t p lp) e ()Source

Update the objects associated with the given nodes.

Scene node definitions

data LightTypes Source

Possible types of light sources.

Constructors

LT_POINT

Point light sources give off light equally in all directions, so they require only position but no direction.

LT_DIRECTIONAL

Directional lights simulate parallel light beams from a distant source, hence have direction but no position.

LT_SPOTLIGHT

Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff.

data Camera Source

Camera description.

Constructors

Camera 

Fields

cmName :: String

The name of the camera.

cmFov :: FloatType

Field of view in radians.

cmNear :: FloatType

Near plane clipping distance.

cmFar :: FloatType

Far plane clipping distance.

cmAspectRatio :: Maybe FloatType

Camera aspect ratio (width/height).

cmPolygonMode :: PolygonMode

Rendering type.

data RenderQueuePriority Source

Standard render queue priorities. Note that any enumeration type can be used to specify render priorities (i.e. top-level drawing order), this is just a simple convenience type.

defaultRQP :: Maybe RenderQueuePrioritySource

The default render queue priority.

nodeSource

Arguments

:: RenderSystem r vb ib q t p lp 
=> String

The name of the parent node.

-> String

The name of the node.

-> Proj4

The transformation to apply the subtree with the node in its root.

-> [MkSceneObjectAction r vb ib q t p lp e]

The scene objects that make up the node.

-> MkNodeAction r vb ib q t p lp e 

Construct a scene graph node description.

camera :: RenderSystem r vb ib q t p lp => Camera -> MkSceneObjectAction r vb ib q t p lp eSource

Construct a scene object representing a camera with the given specification.

simpleCamera :: RenderSystem r vb ib q t p lp => String -> MkSceneObjectAction r vb ib q t p lp eSource

Construct a scene object representing a basic camera with the given name.

wireCamera :: RenderSystem r vb ib q t p lp => String -> MkSceneObjectAction r vb ib q t p lp eSource

Construct a scene object representing a wireframe-mode camera with the given name.

light :: RenderSystem r vb ib q t p lp => Light -> MkSceneObjectAction r vb ib q t p lp eSource

Construct a scene object representing a light source with the given specification.

defaultLight :: RenderSystem r vb ib q t p lp => MkSceneObjectAction r vb ib q t p lp eSource

Construct a scene object representing a basic light source.

meshSource

Arguments

:: (RenderSystem rs vb ib q t p lp, Enum rqp) 
=> Maybe rqp

Render queue priority (defaults to RQP_Main).

-> Maybe [String]

The list of materials to overried those supplied by the original mesh.

-> String

The name of the mesh to use as the source.

-> MkSceneObjectAction rs vb ib q t p lp e 

Construct a scene object representing a polygon mesh.

Rendering

addRenderTextureSource

Arguments

:: RenderSystem r vb ib q a p lp 
=> String

The name of the texture.

-> Int

Width in texels.

-> Int

Height in texels.

-> LCM (World r vb ib q a p lp) e () 

Create a new texture.

addRenderWindowSource

Arguments

:: RenderSystem r vb ib q t p lp 
=> String

The name of the window.

-> Int

The width of the window in pixels.

-> Int

The height of the window in pixels.

-> [LCM (World r vb ib q t p lp) e (Viewport t lp)]

The actions describing the viewports to use.

-> LCM (World r vb ib q t p lp) e () 

Specify the viewports to display in the window.

viewportSource

Arguments

:: RenderSystem r vb ib q t p lp 
=> FloatType

Viewport x position.

-> FloatType

Viewport y position.

-> FloatType

Viewport width.

-> FloatType

Viewport height.

-> String

The camera associated with the viewport.

-> [String]

The compositor chain to process the image with.

-> LCM (World r vb ib q t p lp) e (Viewport t lp) 

Create a viewport and attach given compositors.

renderWorldSource

Arguments

:: RenderSystem r vb ib q t p lp 
=> FloatType

The current time in seconds (needed for animation).

-> String

The target to render.

-> LCM (World r vb ib q t p lp) e () 

Render the given target.

updateTargetSizeSource

Arguments

:: RenderSystem rs vb ib q t p lp 
=> String

The target to adjust.

-> Int

The new width.

-> Int

The new height.

-> LCM (World rs vb ib q t p lp) e () 

Adjust the dimensions of a given render target.

Vector vertex buffers

data VMesh Source

Multimaterial geometry, including a default geometry for submeshes that don't provide their own.

Constructors

VMesh 

Fields

vmSubMeshList :: [VSubMesh]

The collection of single-material submeshes making up the mesh.

vmSharedVertexData :: Maybe VVB

Default geometry for submeshes.

data VSubMesh Source

Geometry with associated material.

Constructors

VSubMesh 

Fields

vsmMaterialName :: String

The material associated with the submesh.

vsmOperationType :: OperationType

The type of primitives making up the geometry.

vsmVertexData :: Maybe VVB

Optional vertex buffer (supplied by the containing mesh if absent).

vsmIndexData :: Maybe VIB

Optional index buffer.

data OperationType Source

The interpretation of a sequence of vertices.

Constructors

OT_POINT_LIST

A list of points, 1 vertex per point.

OT_LINE_LIST

A list of lines, 2 vertices per line.

OT_LINE_STRIP

A strip of connected lines, 1 vertex per line plus 1 start vertex.

OT_TRIANGLE_LIST

A list of triangles, 3 vertices per triangle.

OT_TRIANGLE_STRIP

A strip of triangles, 3 vertices for the first triangle, and 1 per triangle after that.

OT_TRIANGLE_FAN

A fan of triangles, 3 vertices for the first triangle, and 1 per triangle after that.

vectorVertexType :: VectorVertexData -> VectorVertexTypeSource

Extract the type of the vertex data.

addVMeshSource

Arguments

:: RenderSystem r vb ib q t p lp 
=> String

The name of the mesh in the world.

-> VMesh

The mesh to add.

-> LCM (World r vb ib q t p lp) e () 

Add a new vector mesh to the world.

getVMesh :: RenderSystem r vb ib q t p lp => String -> LCM (World r vb ib q t p lp) e VMeshSource

Retrieve a vector mesh from the world by name.