We are going to rename Entity to Transform. See #71.
Instances
Instances are used to associate an object to a Transform as in:
data Instance a = Instance a Transform deriving (Eq,Read,Show)
Hierarchy
A Hierarchy is used to perform a hierarchical computation. We can create a hierarchy perform computations in there. From a given hierarchy, we can go down one level by introducing another hierarchy. Each hierarchy is just a computation that has access to a Transform. When introducing a new hierarchy, we have to provide the Transform to use in the hierarchy. Transforms get
combined as we traverse down the whole hierarchy.
newtype Hierarchy a = Hierarchy { unHierarchy :: Reader Transform a } deriving (Applicative,Functor,Monad)
We can add a new level of hierarchy with the function hierarchy, which takes a Transform and the Hierarchy, and outputs the resulting Hierarchy.
We can access the outer hierarchy’s transform with parent.
We can instantiate any value in a Hierarchy with the instantiate function. For instance, we can
instantiate a Light at the origin with the following code:
Then, we can run a hierarchy to get the resulting object with:
runHierarchy :: Hierarchy a -> Transform -> a
The Transform needed is the master transform. It’s used to affect the whole hierarchy tree. If the root of the hierarchy represents the total scene space, it’s often set to origin then.
Transforms
We are going to rename
Entity
toTransform
. See #71.Instances
Instances are used to associate an object to a
Transform
as in:Hierarchy
A
Hierarchy
is used to perform a hierarchical computation. We can create a hierarchy perform computations in there. From a given hierarchy, we can go down one level by introducing another hierarchy. Each hierarchy is just a computation that has access to aTransform
. When introducing a new hierarchy, we have to provide theTransform
to use in the hierarchy.Transform
s get combined as we traverse down the whole hierarchy.We can add a new level of hierarchy with the function
hierarchy
, which takes aTransform
and theHierarchy
, and outputs the resultingHierarchy
.We can access the outer hierarchy’s transform with
parent
.We can instantiate any value in a
Hierarchy
with theinstantiate
function. For instance, we can instantiate aLight
at the origin with the following code:Then, we can run a hierarchy to get the resulting object with:
The
Transform
needed is the master transform. It’s used to affect the whole hierarchy tree. If the root of the hierarchy represents the total scene space, it’s often set toorigin
then.