| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.Math
Synopsis
- module Linear
- data Quat
- newtype GlobalTransform = GlobalTransform {}
- data Transform = Transform {}
- propTransform :: System ()
- data TransformPlugin
Dependencies
- [mischief-ecs])(Mischief.ECS)
How to Use
This library is mostly a wrapper around the Linear library, which it also re-exports types, functions and operators from.
The most notable addition is Transform. A component that encodes the translation (position), rotation and scale of entities.
Transform is usually constructed with its Default instance, optionally specifying some of its fields:
insert (def{translation=V35 1 0})
To manipulate Transforms, you can import the following module:
import Mischief.Math.Transform qualified as Transform
This module contains a few useful functions, such as move which is used to update the translation:
Transform.move(V35 0 0) transform
Other notable functions are Transform.. There is also rotateTransform. if you wish to rotate
a 2d object.rotateZ
Transform Propagation
You can add TransformPlugin to your app. This will propagate the transform of all entities through the ChildOf component.
Basically, each entity's Transform will become their position relative to their parent.
This plugin also inserts the GlobalTransform component to all relevant entities, which is a wrapper around a Transform that's global.
module Linear
newtype GlobalTransform Source #
Constructors
| GlobalTransform | |
Instances
Instances
| Default Transform Source # | |||||
Defined in Mischief.Math.Transform | |||||
| Generic Transform Source # | |||||
Defined in Mischief.Math.Transform Associated Types
| |||||
| Show Transform Source # | |||||
| Eq Transform Source # | |||||
| Component Transform Source # | |||||
Defined in Mischief.Math.Transform Associated Types
| |||||
| type Rep Transform Source # | |||||
Defined in Mischief.Math.Transform type Rep Transform = D1 ('MetaData "Transform" "Mischief.Math.Transform" "mischief-math-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Transform" 'PrefixI 'True) (S1 ('MetaSel ('Just "translation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float)) :*: (S1 ('MetaSel ('Just "rotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Quat) :*: S1 ('MetaSel ('Just "scale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float))))) | |||||
| type IsExclusiveRel Transform Source # | |||||
Defined in Mischief.Math.Transform | |||||
propTransform :: System () Source #
data TransformPlugin Source #
Instances
| Plugin TransformPlugin Source # | |
Defined in Mischief.Math.Transform.Plugin | |