HGamer3D-Data 0.1.5 → 0.5.0
raw patch · 18 files changed
Files
- HGamer3D-Data.cabal +33/−42
- HGamer3D/Data.hs +46/−0
- HGamer3D/Data/Angle.hs +100/−82
- HGamer3D/Data/Colour.hs +74/−38
- HGamer3D/Data/GameTime.hs +98/−0
- HGamer3D/Data/Geometry2D.hs +64/−0
- HGamer3D/Data/HG3DClass.hs +59/−56
- HGamer3D/Data/Matrix4.hs +0/−115
- HGamer3D/Data/Quaternion.hs +0/−87
- HGamer3D/Data/Transform3D.hs +96/−0
- HGamer3D/Data/TypeSynonyms.hs +33/−0
- HGamer3D/Data/Vector.hs +70/−0
- HGamer3D/Data/Vector2.hs +0/−118
- HGamer3D/Data/Vector3.hs +0/−125
- HGamer3D/Data/Vector4.hs +0/−125
- HGamer3D/Data/Window.hs +32/−0
- LICENSE +34/−13
- Setup.hs +22/−22
HGamer3D-Data.cabal view
@@ -1,42 +1,33 @@-Name: HGamer3D-Data -Version: 0.1.5 -Synopsis: Library to enable 3D game development for Haskell - Data -Description: - Library, to enable 3D game development for Haskell, - based on bindings to 3D Graphics, Audio and GUI libraries. - THIS MODULE: Basic Data Types - List of features and modules: - Data Module (Basic Data Types), - OGRE Binding (3D Graphics Engine), - OIS Binding (Input System), - cAudio Binding (Audio), - CEGUI Binding (GUI System), - APIs (Haskell style APIs, different ways, to approach API) - Platform: Windows only - License: Apache License, Version 2.0 - Install: see http://www.althainz.de/HGamer3D/Download-and-Installation.html - -License: OtherLicense -License-file: LICENSE -Author: Peter Althainz -Maintainer: althainz@googlemail.com -Build-Type: Simple -Cabal-Version: >=1.2 -Homepage: http://www.althainz.de/HGamer3D.html -Category: Game -Extra-source-files: Setup.hs - -Library - Build-Depends: base >= 3 && < 5, Vec == 0.9.7, Vec-Transform == 1.0.4 - - Exposed-modules: HGamer3D.Data.Vector2,HGamer3D.Data.Vector3,HGamer3D.Data.Vector4,HGamer3D.Data.Matrix4,HGamer3D.Data.Colour,HGamer3D.Data.Quaternion,HGamer3D.Data.HG3DClass,HGamer3D.Data.Angle - Other-modules: - - c-sources: - - ghc-options: - cc-options: -Wno-attributes - hs-source-dirs: . - Include-dirs: . - build-depends: haskell98 - extra-libraries: +Name: HGamer3D-Data+Version: 0.5.0+Synopsis: Toolset for the Haskell Game Programmer - Data Definitions+Description: + HGamer3D is a toolset for developing 3D games in the programming + language Haskell. HGamer3D is available on Windows and Linux. This + package provides common data definitions and utility functions for HGamer3D.+ Also in this package, the Entity Component System is placed.++License: OtherLicense+License-file: LICENSE+Author: Peter Althainz+Maintainer: althainz@gmail.com+Build-Type: Simple+Cabal-Version: >=1.4+Homepage: http://www.hgamer3d.org+Category: Game Engine+Extra-source-files: Setup.hs ++Library+ Build-Depends: base >= 3 && < 5, FindBin, directory, filepath, vect, clock, stm, containers++ Exposed-modules: HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector,HGamer3D.Data.Colour,HGamer3D.Data.HG3DClass,HGamer3D.Data.Angle,HGamer3D.Data.GameTime,HGamer3D.Data.Transform3D,HGamer3D.Data.Geometry2D,HGamer3D.Data.Window,HGamer3D.Data+ Other-modules: ++ c-sources: + + ghc-options: -O2+ cc-options: -Wno-attributes + hs-source-dirs: .+ Include-dirs: . + build-depends: + extra-libraries:
+ HGamer3D/Data.hs view
@@ -0,0 +1,46 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+-- +-- (c) 2011 - 2013 Peter Althainz+-- +-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+-- +-- http://www.apache.org/licenses/LICENSE-2.0+-- +-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.+-- +-- Data.hs+-- ++-- | Common data definitions for HGamer3D +module HGamer3D.Data ++(+ module HGamer3D.Data.Angle,+ module HGamer3D.Data.Colour,+ module HGamer3D.Data.Transform3D,+ module HGamer3D.Data.GameTime,+ module HGamer3D.Data.Vector,+ module HGamer3D.Data.Geometry2D,+ module HGamer3D.Data.TypeSynonyms,+ Window,+)++where++import HGamer3D.Data.Angle+import HGamer3D.Data.Colour+import HGamer3D.Data.Transform3D+import HGamer3D.Data.GameTime+import HGamer3D.Data.Vector+import HGamer3D.Data.Geometry2D+import HGamer3D.Data.Window+import HGamer3D.Data.TypeSynonyms+
HGamer3D/Data/Angle.hs view
@@ -1,82 +1,100 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Angle.hs - -{- | - Angles as Degrees or Radians, based on Float datatype - copied and changed to float from AC-Angle packet --} - -module HGamer3D.Data.Angle - -( - -- export Radians and Degrees - Radians (Radians), - Degrees (Degrees), - degrees, - radians - - -- instances are automatically exported - -- Angle, sine, cosine, tangent, arcsine, arccosine, arctangent - -) - -where - --- | An angle in radians. -data Radians = Radians Float deriving (Eq, Ord, Show) - --- | An angle in degrees. -data Degrees = Degrees Float deriving (Eq, Ord, Show) - --- | Convert from radians to degrees. -degrees :: Radians -> Degrees -degrees (Radians x) = Degrees (x/pi*180) - --- | Convert from degrees to radians. -radians :: Degrees -> Radians -radians (Degrees x) = Radians (x/180*pi) - --- | Type-class for angles. -class Angle a where - sine :: a -> Float - cosine :: a -> Float - tangent :: a -> Float - - arcsine :: Float -> a - arccosine :: Float -> a - arctangent :: Float -> a - -instance Angle Radians where - sine (Radians x) = sin x - cosine (Radians x) = cos x - tangent (Radians x) = tan x - - arcsine x = Radians (asin x) - arccosine x = Radians (acos x) - arctangent x = Radians (atan x) - -instance Angle Degrees where - sine = sine . radians - cosine = cosine . radians - tangent = tangent . radians - - arcsine = degrees . arcsine - arccosine = degrees . arccosine - arctangent = degrees . arctangent +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Angle.hs++-- | Angles as Degrees or Radians, based on Float datatype+module HGamer3D.Data.Angle ++(+ -- * Data definitions and conversions+ Angle (..),+ Radians (..),+ Degrees (..),+ fromAngle,+ + -- * Mathematical functions+ addA,+ subA,+ mulA,+ divA,+ sinA,+ cosA,+ tanA,+ asinA,+ acosA,+ atanA,+)++where+++data Angle = Rad Float | Deg Float deriving (Eq, Ord, Show)++sinA :: Angle -> Float+sinA = sin . fromAngle++cosA :: Angle -> Float+cosA = cos . fromAngle++tanA :: Angle -> Float+tanA = tan . fromAngle++asinA :: Float -> Angle+asinA = Rad . asin++acosA :: Float -> Angle+acosA = Rad . acos++atanA :: Float -> Angle+atanA = Rad . atan++addA :: Angle -> Angle -> Angle+addA a b = Rad $ (fromAngle a) + (fromAngle b)++subA :: Angle -> Angle -> Angle+subA a b = Rad $ (fromAngle a) - (fromAngle b)++mulA :: Angle -> Float -> Angle+mulA a b = Rad $ (fromAngle a) * b++divA :: Angle -> Float -> Angle+divA a b = Rad $ (fromAngle a) / b++data Radians = Radians Float deriving (Eq, Ord, Show)+data Degrees = Degrees Float deriving (Eq, Ord, Show)++class Angles a where+ toAngle :: a -> Angle+ fromAngle :: Angle -> a+ +instance Angles Float where+ toAngle r = Rad r+ fromAngle (Rad r) = r+ fromAngle (Deg d) = d/180*pi+ +instance Angles Radians where+ toAngle (Radians r) = Rad r+ fromAngle (Rad r) = (Radians r)+ fromAngle (Deg d) = (Radians (d/180*pi))+ +instance Angles Degrees where+ toAngle (Degrees d) = Deg d+ fromAngle (Deg d) = (Degrees d)+ fromAngle (Rad r) = (Degrees (r/pi*180))+
HGamer3D/Data/Colour.hs view
@@ -1,38 +1,74 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- ColourValue.hs - -module HGamer3D.Data.Colour - -( - -- export Colour Type again - Colour (Colour, cRed, cGreen, cBlue, cAlpha), - - -- export all functions - -) - -where -data Colour = Colour { - cRed :: Float, - cGreen :: Float, - cBlue :: Float, - cAlpha :: Float - } deriving (Eq, Show) - +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- ColourValue.hs++-- | Module providing the Colour type and some standard colours+module HGamer3D.Data.Colour ++(+ Colour (Colour, cRed, cGreen, cBlue, cAlpha),+ white,+ silver,+ grey,+ darkgrey,+ black,+ red,+ maroon,+ yellow,+ olive,+ lime,+ green,+ aqua,+ teal,+ blue,+ navy,+ fuchsia,+ purple+)++where++-- | HGamer3D colour type+data Colour = Colour {+ cRed :: Float, -- ^ red component ranging from 0.0 to 1.0+ cGreen :: Float, -- ^ green component ranging from 0.0 to 1.0+ cBlue :: Float, -- ^ blue component ranging from 0.0 to 1.0+ cAlpha :: Float -- ^ alpha component ranging from 0.0 to 1.0 with 1.0 being fully opaque+ } deriving (Eq, Show)++white = Colour 1.0 1.0 1.0 1.0 +silver = Colour 0.75 0.75 0.75 1.0+grey = Colour 0.5 0.5 0.5 1.0+darkgrey = Colour 0.25 0.25 0.25 1.0+black = Colour 0.0 0.0 0.0 1.0+red = Colour 1.0 0.0 0.0 1.0+maroon = Colour 0.5 0.0 0.0 1.0+yellow = Colour 1.0 1.0 0.0 1.0+olive = Colour 0.5 0.5 0.0 1.0+lime = Colour 0.0 1.0 0.0 1.0+green = Colour 0.0 0.5 0.0 1.0+aqua = Colour 0.0 1.0 1.0 1.0+teal = Colour 0.0 0.5 0.5 1.0+blue = Colour 0.0 0.0 1.0 1.0 +navy = Colour 0.0 0.0 0.5 1.0+fuchsia = Colour 1.0 0.0 1.0 1.0+purple = Colour 0.5 0.0 0.5 1.0+++
+ HGamer3D/Data/GameTime.hs view
@@ -0,0 +1,98 @@+{-# LANGUAGE TypeSynonymInstances #-}+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- TimeMS.hs++-- | Module providing the time type for HGamer3D+module HGamer3D.Data.GameTime++(+ GameTime,+ sec,+ msec,+ usec,+ + secT,+ msecT,+ usecT,+ + getTime,+ getThreadCPUTime,+ getProcessCPUTime,++ sleepFor+)++where++import Control.Concurrent+import qualified System.Clock as C++type GameTime = C.TimeSpec++_toInteger :: C.TimeSpec -> Integer+_toInteger ts = let+ s = (fromIntegral (C.sec ts)) :: Integer+ ns = (fromIntegral (C.nsec ts)) :: Integer+ in s * 1000000000 + ns++_fromInteger :: Integer -> C.TimeSpec+_fromInteger i = let+ s = fromIntegral (i `quot` 1000000000)+ ns = fromIntegral (i `rem` 1000000000)+ in C.TimeSpec s ns++instance Num GameTime where+ (+) a b = _fromInteger((_toInteger a) Prelude.+ (_toInteger b) )+ (-) a b = _fromInteger((_toInteger a) Prelude.- (_toInteger b) )+ (*) a b = _fromInteger((_toInteger a) Prelude.* (_toInteger b) )+ abs a = _fromInteger( Prelude.abs (_toInteger a))+ signum a = _fromInteger( Prelude.signum (_toInteger a))+ fromInteger i = _fromInteger i++sec :: C.TimeSpec -> Int+sec ts = fromIntegral ((_toInteger ts) `quot` 1000000000)++msec :: C.TimeSpec -> Int+msec ts = fromIntegral ((_toInteger ts) `quot` 1000000)++usec :: C.TimeSpec -> Int+usec ts = fromIntegral ((_toInteger ts) `quot` 1000)++secT :: Int -> C.TimeSpec+secT i = _fromInteger ((fromIntegral i) * 1000000000)++msecT :: Int -> C.TimeSpec+msecT i = _fromInteger ((fromIntegral i) * 1000000)++usecT :: Int -> C.TimeSpec+usecT i = _fromInteger ((fromIntegral i) * 1000)++getTime :: IO GameTime+getTime = C.getTime C.Realtime++getThreadCPUTime :: IO GameTime+getThreadCPUTime = C.getTime C.ThreadCPUTime++getProcessCPUTime :: IO GameTime+getProcessCPUTime = C.getTime C.ProcessCPUTime++sleepFor :: GameTime -> IO ()+sleepFor gt = threadDelay (usec gt)+
+ HGamer3D/Data/Geometry2D.hs view
@@ -0,0 +1,64 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Rectangle.hs++-- | Type definitions for 2D geometry +module HGamer3D.Data.Geometry2D+(+ -- * Geometry+ Point (..),+ Rectangle (..),+ rectFromPoints,+ pointsFromRect+ +) where+ +import HGamer3D.Data.Vector++-- | A point has two coordinates an x and y one+data Point a = Point {+ ptX :: a,+ ptY :: a+ }+ +-- | A rectangle has an a position as x and y and widht and height+data Num a => Rectangle a = Rectangle {+ rectX :: a,+ rectY :: a,+ rectWidth :: a,+ rectHeight :: a } deriving (Eq, Show)++-- | derive a rectangle from upper left and lower right points+rectFromPoints :: Num a => Point a -> Point a -> Rectangle a+rectFromPoints upperLeft lowerRight = Rectangle rx ry rw rh where+ rx = ptX upperLeft+ ry = ptY upperLeft+ rw = (ptY lowerRight) - rx+ rh = (ptY lowerRight) - ry+ +-- | get upper left and lower right point from a rect+pointsFromRect :: Num a => Rectangle a -> (Point a, Point a)+pointsFromRect rect = (ul, lr) where+ rx = rectX rect+ ry = rectY rect+ rx' = rx + (rectWidth rect)+ ry' = ry + (rectHeight rect)+ ul = Point rx ry+ lr = Point rx' ry'+
HGamer3D/Data/HG3DClass.hs view
@@ -1,56 +1,59 @@-{-# LANGUAGE ForeignFunctionInterface #-} -{-# LANGUAGE TypeSynonymInstances #-} - --- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- HG3DClass.hs --- - -module HGamer3D.Data.HG3DClass where - --- import C2HS -import Foreign -import Foreign.Ptr -import Foreign.C -import Monad (liftM, liftM2) - - -import Data.Bits - -data HG3DClass = HG3DClass { - ocPtr :: Ptr (), - ocFptr :: Ptr () - } deriving (Eq, Show) - -instance Storable HG3DClass where - alignment _ = alignment (undefined :: CDouble) - sizeOf _ = 8 - - peek p = do - ptr <- (\ptr -> do {peekByteOff ptr 0 ::IO (Ptr ())}) p - fptr <- (\ptr -> do {peekByteOff ptr 4 ::IO (Ptr ())}) p - let hc = HG3DClass (ptr) (fptr) - return hc - - poke p (HG3DClass ptr fptr) = do - (\ptr val -> do {pokeByteOff ptr 0 (val::(Ptr ()))}) p (ptr) - (\ptr val -> do {pokeByteOff ptr 4 (val::(Ptr ()))}) p (fptr) - - - +{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE TypeSynonymInstances #-}++-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+-- +-- (c) 2011-2013 Peter Althainz+-- +-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+-- +-- http://www.apache.org/licenses/LICENSE-2.0+-- +-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.+-- +-- HG3DClass.hs+-- ++-- | Utility class to encapsulate class pointers+module HGamer3D.Data.HG3DClass where++-- import C2HS+import Foreign+import Foreign.Ptr+import Foreign.C+import Foreign.Storable+++import Data.Bits++data HG3DClass = HG3DClass {+ ocPtr :: Ptr (),+ ocFptr :: Ptr ()+ } deriving (Eq, Show)++instance Storable HG3DClass where+ alignment _ = alignment (undefined :: CDouble)+ sizeOf _ = 2 * (sizeOf nullPtr)+ + peek p = do+ ptr <- (\ptr -> do {peekByteOff ptr 0 ::IO (Ptr ())}) p+ fptr <- (\ptr -> do {peekByteOff ptr (sizeOf nullPtr) ::IO (Ptr ())}) p+ let hc = HG3DClass (ptr) (fptr)+ return hc+ + poke p (HG3DClass ptr fptr) = do+ (\ptr val -> do {pokeByteOff ptr 0 (val::(Ptr ()))}) p (ptr)+ (\ptr val -> do {pokeByteOff ptr (sizeOf nullPtr) (val::(Ptr ()))}) p (fptr)+ ++++
− HGamer3D/Data/Matrix4.hs
@@ -1,115 +0,0 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Matrix4.hs, the 4x4 matrix type - -module HGamer3D.Data.Matrix4 - -( - Matrix4, - HGamer3D.Data.Matrix4.matToLists, - HGamer3D.Data.Matrix4.matFromLists, - extendV3, - oneV3, - zeroV3, - toV3, - HGamer3D.Data.Matrix4.multvm, - HGamer3D.Data.Matrix4.multmv, - HGamer3D.Data.Matrix4.multmm, - HGamer3D.Data.Matrix4.transpose, - - HGamer3D.Data.Matrix4.translation, - HGamer3D.Data.Matrix4.rotationX, - HGamer3D.Data.Matrix4.rotationY, - HGamer3D.Data.Matrix4.rotationZ, - HGamer3D.Data.Matrix4.rotationVec, - HGamer3D.Data.Matrix4.rotationEuler, - HGamer3D.Data.Matrix4.rotationQuat -) - -where - -import Data.Vec.Base -import Data.Vec.Nat -import Data.Vec.Packed -import Data.Vec.LinAlg -import Data.Vec.LinAlg.Transform3D -import HGamer3D.Data.Vector3 -import HGamer3D.Data.Vector4 -import HGamer3D.Data.Quaternion - -newtype Matrix4 = Matrix4 (Mat44 Float) - -matToLists :: Matrix4 -> [[Float]] -matToLists (Matrix4 mat) = Data.Vec.Base.matToLists mat - -matFromLists :: [[Float]] -> Matrix4 -matFromLists lists = Matrix4 $ Data.Vec.Base.matFromLists lists - -extendV3 :: Vector3 -> Float -> Vector4 -extendV3 v3 f = vector4 (v3X v3) (v3X v3) (v3Z v3) f - -oneV3 :: Vector3 -> Vector4 -oneV3 v3 = extendV3 v3 1.0 - -zeroV3 :: Vector3 -> Vector4 -zeroV3 v3 = extendV3 v3 0.0 - -toV3 :: Vector4 -> Vector3 -toV3 v4 = vector3 (v4X v4) (v4Y v4) (v4Z v4) - -multvm :: Vector4 -> Matrix4 -> Vector4 -multvm (Vector4 v) (Matrix4 m) = Vector4 $ pack (Data.Vec.LinAlg.multvm (unpack v) m) - -multmv :: Matrix4 -> Vector4 -> Vector4 -multmv (Matrix4 m) (Vector4 v) = Vector4 $ pack (Data.Vec.LinAlg.multmv m (unpack v)) - -multmm :: Matrix4 -> Matrix4 -> Matrix4 -multmm (Matrix4 m1) (Matrix4 m2) = Matrix4 (Data.Vec.LinAlg.multmm m1 m2) - -transpose :: Matrix4 -> Matrix4 -transpose (Matrix4 m) = Matrix4 (Data.Vec.LinAlg.transpose m) - -translation :: Vector3 -> Matrix4 -translation (Vector3 v) = Matrix4 (Data.Vec.LinAlg.Transform3D.translation (unpack v) ) - -rotationX :: Float -> Matrix4 -rotationX f = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationX f ) - -rotationY :: Float -> Matrix4 -rotationY f = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationY f ) - -rotationZ :: Float -> Matrix4 -rotationZ f = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationZ f ) - -rotationVec :: Vector3 -> Float -> Matrix4 -rotationVec (Vector3 v) f = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationVec (unpack v) f ) - -rotationEuler :: Vector3 -> Matrix4 -rotationEuler (Vector3 v) = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationEuler (unpack v) ) - -rotationQuat :: Quaternion -> Matrix4 -rotationQuat q = Matrix4 (Data.Vec.LinAlg.Transform3D.rotationQuat v4 ) where - w = qW q - v = qV q - x = v3X v - y = v3Y v - z = v3Z v - v4 = x :. y :. z :. w :. () - -
− HGamer3D/Data/Quaternion.hs
@@ -1,87 +0,0 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Quaternion.hs - -module HGamer3D.Data.Quaternion - -( - -- export Quaternion Type again - Quaternion (Quaternion, qW, qV), - quaternion, - mulQ, - conjQ, - normQ, - normalizeQ, - dotQ, - rotateVQ, - fromRotationQ - - -- export all functions -) - -where - -import HGamer3D.Data.Vector3 -import HGamer3D.Data.Vector4 (Vector4, vector4) - -data Quaternion = Quaternion { - qW :: Float, - qV :: Vector3 -} deriving (Eq, Show) - -quaternion w x y z = Quaternion w (vector3 x y z) - -mulQ :: Quaternion -> Quaternion -> Quaternion -mulQ q1 q2 = Quaternion ((w1 * w2) - (v1 `dotV3` v2)) ( (scaleV3 w1 v2) + (scaleV3 w2 v1) + (v1 `crossV3` v2) ) where - w1 = qW q1 - w2 = qW q2 - v1 = qV q1 - v2 = qV q2 - -conjQ :: Quaternion -> Quaternion -conjQ q = Quaternion (qW q) (scaleV3 (-1.0) (qV q)) - -normQ :: Quaternion -> Float -normQ q = sqrt $ dotQ q (conjQ q) - -normalizeQ :: Quaternion -> Quaternion -normalizeQ q = Quaternion ( (qW q) / n ) ( (scaleV3 (1/n)) (qV q) ) where - n = normQ q - -dotQ :: Quaternion -> Quaternion -> Float -dotQ q1 q2 = (w1 * w2) + (v1 `dotV3` v2) where - w1 = qW q1 - w2 = qW q2 - v1 = qV q1 - v2 = qV q2 - -fromRotationQ :: Float -> Vector3 -> Quaternion -fromRotationQ a v = Quaternion (cos h) (scaleV3 s v) where - h = a/2.0 - s = sin h - -rotateVQ :: Vector3 -> Quaternion -> Vector3 -rotateVQ v q = qV (mulQ q (mulQ v' q')) where - v' = Quaternion 0.0 v - q' = conjQ q - -toVector4 :: Quaternion -> Vector4 -toVector4 q = vector4 (v3X v) (v3Y v) (v3Z v) w where - v = qV q - w = qW q
+ HGamer3D/Data/Transform3D.hs view
@@ -0,0 +1,96 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Transform3D.hs++-- | Typeclasses for basic 3D transformations++module HGamer3D.Data.Transform3D+(+ -- * Types+ HasPosition (..),+ HasSize (..),+ HasOrientation (..),+ + -- * Functions+ translate,+ scale, + yaw,+ pitch,+ roll+)++where++import HGamer3D.Data.Vector+import HGamer3D.Data.Angle+import HGamer3D.Data.TypeSynonyms++-- | a type with a HasPosition instance has a Position+class HasPosition t where++ -- | get position function+ position :: t -> IO Position+ -- | set position function+ positionTo :: t -> Position -> IO ()++-- | a type with a HasSize instance has a Size+class HasSize t where + + -- | get scale function+ size :: t -> IO Size+ -- | set scale function+ sizeTo :: t -> Size -> IO ()++-- | a type with an HasOrientation instance has an oriented in space+class HasOrientation t where+ -- | get orientation function+ orientation :: t -> IO Orientation+ -- | set orientation function+ orientationTo :: t -> Orientation -> IO ()+++-- | move the position +translate :: Position -> Position -> Position+translate = (&+)++-- | scale the size+scale :: Size -> Vec3 -> Size+scale = (&!)++-- yaw, roll, pitch functions+-- functions, to rotate on axis, relative to object+rotRelativeToObjectAxis :: Orientation -> Vec3 -> Float -> Orientation+rotRelativeToObjectAxis ori axis val = let+ odir = actU ori axis+ qrot = rotU odir val+ nrot = qrot .*. ori+ in nrot+ +-- | rotate object on own axis (yaw) by angle+yaw :: Orientation -> Angle -> Orientation+yaw ori val = rotRelativeToObjectAxis ori vec3Y (fromAngle val)++-- | rotate object on own axis (roll) by angle+roll :: Orientation -> Angle -> Orientation+roll ori val = rotRelativeToObjectAxis ori vec3Z (fromAngle val)++-- | rotate object on own axis (pitch) by angle+pitch :: Orientation -> Angle -> Orientation+pitch ori val = rotRelativeToObjectAxis ori vec3X (fromAngle val)+
+ HGamer3D/Data/TypeSynonyms.hs view
@@ -0,0 +1,33 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- HGamer3D/Data/TypeSynonyms.hs++-- | Module providing better type names for standard types in HGamer3D+module HGamer3D.Data.TypeSynonyms++where++import HGamer3D.Data.Vector+ +-- | the Size, Position and Orientation types, implemented as a Vec3 and UnitQuaternion+type Size = Vec3+type Position = Vec3+type Orientation = UnitQuaternion++
+ HGamer3D/Data/Vector.hs view
@@ -0,0 +1,70 @@+{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving, DeriveDataTypeable #-}++-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- HGamer3D/Data/Vector.hs+++-- | Vector library for HGamer3D+module HGamer3D.Data.Vector+(+ + -- * the Vect libray of Balazs Komuves, see: <http://hackage.haskell.org/package/vect>+ + module Data.Vect.Float,+ module Data.Vect.Float.Util.Quaternion,++ -- * some constants++ zeroVec3,+ unitVec2,++ zeroVec3,+ unitVec3++)++where++import Data.Typeable+import Data.Vect.Float+import Data.Vect.Float.Util.Quaternion++deriving instance Eq UnitQuaternion+deriving instance Eq Vec2+deriving instance Eq Vec3+deriving instance Eq Vec4++deriving instance Typeable UnitQuaternion+deriving instance Typeable Vec2+deriving instance Typeable Vec3+deriving instance Typeable Vec4++-- | the 2d zero vector+zeroVec2 = Vec2 0.0 0.0++-- | the 2d unity vector+unitVec2 = Vec2 1.0 1.0++-- | the 3d Zero vector+zeroVec3 = Vec3 0.0 0.0 0.0++-- | the 3d Unity vector+unitVec3 = Vec3 1.0 1.0 1.0+
− HGamer3D/Data/Vector2.hs
@@ -1,118 +0,0 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Vector2.hs - -module HGamer3D.Data.Vector2 - -( - -- export Vector2 Type and its functions again - - Vector2 (Vector2), - vector2, - uniV2, - v2X,v2Y, - HGamer3D.Data.Vector2.dotV2, - HGamer3D.Data.Vector2.normSqV2, - HGamer3D.Data.Vector2.normV2, - HGamer3D.Data.Vector2.normalizeV2, - HGamer3D.Data.Vector2.scaleV2 - -) - -where - -import Data.Vec.Base -import Data.Vec.Nat -import Data.Vec.Packed -import Data.Vec.LinAlg - -newtype Vector2 = Vector2 Vec2F - -vector2 :: Float -> Float -> Vector2 -vector2 a b = Vector2 ( pack (a :. b :. ()) ) - -uniV2 :: Float -> Vector2 -uniV2 f = Vector2 (pack (vec f)) - -v2X :: Vector2 -> Float -v2X (Vector2 v2) = get n0 v2 - -v2Y :: Vector2 -> Float -v2Y (Vector2 v2) = get n1 v2 - - - -liftv :: (a -> Vec2F) -> (a -> Vector2) -liftv f = f1 where - f1 a1 = (Vector2 (f a1)) - - -lift1 :: (Vec2F -> a) -> (Vector2 -> a) -lift1 f = f1 where - f1 (Vector2 a1) = f a1 - -lift1v :: (Vec2F -> Vec2F) -> (Vector2 -> Vector2) -lift1v f = f2 where - f2 a = (Vector2 (f1 a)) - f1 (Vector2 a1) = f a1 - -lift2 :: (Vec2F -> Vec2F -> a) -> (Vector2 -> Vector2 -> a) -lift2 f = f1 where - f1 (Vector2 a1) (Vector2 b1) = f a1 b1 - -lift2v :: (Vec2F -> Vec2F -> Vec2F) -> (Vector2 -> Vector2 -> Vector2) -lift2v f = f2 where - f2 a b = (Vector2 (f1 a b)) - f1 (Vector2 a1) (Vector2 b1) = f a1 b1 - -lift2vp :: (Vec2 Float -> Vec2 Float -> Vec2 Float) -> (Vector2 -> Vector2 -> Vector2) -lift2vp f = f2 where - f2 a b = (Vector2 (pack (f1 a b))) - f1 (Vector2 (Vec2F a1 a2)) (Vector2 (Vec2F b1 b2)) = f (a1 :. a2 :. ()) (b1 :. b2 :. ()) - -instance Show Vector2 where - show = lift1 (Prelude.show) - -instance Eq Vector2 where - (==) = lift2 (Prelude.==) - -instance Num Vector2 where - abs = lift1v (Prelude.abs) - signum = lift1v (Prelude.signum) - fromInteger = liftv (Prelude.fromInteger) - - (+) = lift2v (Prelude.+) - (-) = lift2v (Prelude.-) - (*) = lift2v (Prelude.*) - -dotV2 :: Vector2 -> Vector2 -> Float -dotV2 = lift2 Data.Vec.LinAlg.dot - -normSqV2 :: Vector2 -> Float -normSqV2 = lift1 Data.Vec.LinAlg.normSq - -normV2 :: Vector2 -> Float -normV2 = lift1 Data.Vec.LinAlg.norm - -normalizeV2 :: Vector2 -> Vector2 -normalizeV2 = lift1v Data.Vec.LinAlg.normalize - -scaleV2 :: Float -> Vector2 -> Vector2 -scaleV2 f (Vector2 v) = Vector2 (Data.Vec.Base.map (*f) v) -
− HGamer3D/Data/Vector3.hs
@@ -1,125 +0,0 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Vector3.hs - -module HGamer3D.Data.Vector3 - -( - -- export Vector3 Type and its functions again - - Vector3 (Vector3), - vector3, - uniV3, - v3X,v3Y,v3Z, - HGamer3D.Data.Vector3.dotV3, - HGamer3D.Data.Vector3.normSqV3, - HGamer3D.Data.Vector3.normV3, - HGamer3D.Data.Vector3.normalizeV3, - HGamer3D.Data.Vector3.crossV3, - HGamer3D.Data.Vector3.scaleV3 - -) - -where - -import Data.Vec.Base -import Data.Vec.Nat -import Data.Vec.Packed -import Data.Vec.LinAlg - -newtype Vector3 = Vector3 Vec3F - -vector3 :: Float -> Float -> Float -> Vector3 -vector3 a b c = Vector3 ( pack (a :. b :. c :. ()) ) - -uniV3 :: Float -> Vector3 -uniV3 f = Vector3 (pack (vec f)) - -v3X :: Vector3 -> Float -v3X (Vector3 v3) = get n0 v3 - -v3Y :: Vector3 -> Float -v3Y (Vector3 v3) = get n1 v3 - -v3Z :: Vector3 -> Float -v3Z (Vector3 v3) = get n2 v3 - - - -liftv :: (a -> Vec3F) -> (a -> Vector3) -liftv f = f1 where - f1 a1 = (Vector3 (f a1)) - - -lift1 :: (Vec3F -> a) -> (Vector3 -> a) -lift1 f = f1 where - f1 (Vector3 a1) = f a1 - -lift1v :: (Vec3F -> Vec3F) -> (Vector3 -> Vector3) -lift1v f = f2 where - f2 a = (Vector3 (f1 a)) - f1 (Vector3 a1) = f a1 - -lift2 :: (Vec3F -> Vec3F -> a) -> (Vector3 -> Vector3 -> a) -lift2 f = f1 where - f1 (Vector3 a1) (Vector3 b1) = f a1 b1 - -lift2v :: (Vec3F -> Vec3F -> Vec3F) -> (Vector3 -> Vector3 -> Vector3) -lift2v f = f2 where - f2 a b = (Vector3 (f1 a b)) - f1 (Vector3 a1) (Vector3 b1) = f a1 b1 - -lift2vp :: (Vec3 Float -> Vec3 Float -> Vec3 Float) -> (Vector3 -> Vector3 -> Vector3) -lift2vp f = f2 where - f2 a b = (Vector3 (pack (f1 a b))) - f1 (Vector3 (Vec3F a1 a2 a3)) (Vector3 (Vec3F b1 b2 b3)) = f (a1 :. a2 :. a3 :. ()) (b1 :. b2 :. b3 :. ()) - -instance Show Vector3 where - show = lift1 (Prelude.show) - -instance Eq Vector3 where - (==) = lift2 (Prelude.==) - -instance Num Vector3 where - abs = lift1v (Prelude.abs) - signum = lift1v (Prelude.signum) - fromInteger = liftv (Prelude.fromInteger) - - (+) = lift2v (Prelude.+) - (-) = lift2v (Prelude.-) - (*) = lift2v (Prelude.*) - -dotV3 :: Vector3 -> Vector3 -> Float -dotV3 = lift2 Data.Vec.LinAlg.dot - -normSqV3 :: Vector3 -> Float -normSqV3 = lift1 Data.Vec.LinAlg.normSq - -normV3 :: Vector3 -> Float -normV3 = lift1 Data.Vec.LinAlg.norm - -normalizeV3 :: Vector3 -> Vector3 -normalizeV3 = lift1v Data.Vec.LinAlg.normalize - -crossV3 :: Vector3 -> Vector3 -> Vector3 -crossV3 = lift2vp Data.Vec.LinAlg.cross - -scaleV3 :: Float -> Vector3 -> Vector3 -scaleV3 f (Vector3 v) = Vector3 (Data.Vec.Base.map (*f) v) -
− HGamer3D/Data/Vector4.hs
@@ -1,125 +0,0 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Vector4.hs - -module HGamer3D.Data.Vector4 - -( - -- export Vector4 Type and its functions again - - Vector4 (Vector4), - vector4, - uniV4, - v4X,v4Y,v4Z,v4W, - HGamer3D.Data.Vector4.dotV4, - HGamer3D.Data.Vector4.normSqV4, - HGamer3D.Data.Vector4.normV4, - HGamer3D.Data.Vector4.normalizeV4, - HGamer3D.Data.Vector4.scaleV4 - -) - -where - -import Data.Vec.Base -import Data.Vec.Nat -import Data.Vec.Packed -import Data.Vec.LinAlg - - -newtype Vector4 = Vector4 Vec4F - -vector4 :: Float -> Float -> Float -> Float -> Vector4 -vector4 a b c d = Vector4 ( pack (a :. b :. c :. d :. ()) ) - -uniV4 :: Float -> Vector4 -uniV4 f = Vector4 (pack (vec f)) - -v4X :: Vector4 -> Float -v4X (Vector4 v4) = get n0 v4 - -v4Y :: Vector4 -> Float -v4Y (Vector4 v4) = get n1 v4 - -v4Z :: Vector4 -> Float -v4Z (Vector4 v4) = get n2 v4 - -v4W :: Vector4 -> Float -v4W (Vector4 v4) = get n3 v4 - - - -liftv :: (a -> Vec4F) -> (a -> Vector4) -liftv f = f1 where - f1 a1 = (Vector4 (f a1)) - - -lift1 :: (Vec4F -> a) -> (Vector4 -> a) -lift1 f = f1 where - f1 (Vector4 a1) = f a1 - -lift1v :: (Vec4F -> Vec4F) -> (Vector4 -> Vector4) -lift1v f = f2 where - f2 a = (Vector4 (f1 a)) - f1 (Vector4 a1) = f a1 - -lift2 :: (Vec4F -> Vec4F -> a) -> (Vector4 -> Vector4 -> a) -lift2 f = f1 where - f1 (Vector4 a1) (Vector4 b1) = f a1 b1 - -lift2v :: (Vec4F -> Vec4F -> Vec4F) -> (Vector4 -> Vector4 -> Vector4) -lift2v f = f2 where - f2 a b = (Vector4 (f1 a b)) - f1 (Vector4 a1) (Vector4 b1) = f a1 b1 - -lift2vp :: (Vec4 Float -> Vec4 Float -> Vec4 Float) -> (Vector4 -> Vector4 -> Vector4) -lift2vp f = f2 where - f2 a b = (Vector4 (pack (f1 a b))) - f1 (Vector4 (Vec4F a1 a2 a3 a4)) (Vector4 (Vec4F b1 b2 b3 b4)) = f (a1 :. a2 :. a3 :. a4 :. ()) (b1 :. b2 :. b3 :. b4 :. ()) - -instance Show Vector4 where - show = lift1 (Prelude.show) - -instance Eq Vector4 where - (==) = lift2 (Prelude.==) - -instance Num Vector4 where - abs = lift1v (Prelude.abs) - signum = lift1v (Prelude.signum) - fromInteger = liftv (Prelude.fromInteger) - - (+) = lift2v (Prelude.+) - (-) = lift2v (Prelude.-) - (*) = lift2v (Prelude.*) - -dotV4 :: Vector4 -> Vector4 -> Float -dotV4 = lift2 Data.Vec.LinAlg.dot - -normSqV4 :: Vector4 -> Float -normSqV4 = lift1 Data.Vec.LinAlg.normSq - -normV4 :: Vector4 -> Float -normV4 = lift1 Data.Vec.LinAlg.norm - -normalizeV4 :: Vector4 -> Vector4 -normalizeV4 = lift1v Data.Vec.LinAlg.normalize - -scaleV4 :: Float -> Vector4 -> Vector4 -scaleV4 f (Vector4 v) = Vector4 (Data.Vec.Base.map (*f) v) -
+ HGamer3D/Data/Window.hs view
@@ -0,0 +1,32 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Rectangle.hs++-- | Type definitions for 2D window+module HGamer3D.Data.Window+(+ -- * Windowing+ Window (..),+ + +) where++-- | A window is simply represented by it's window id, an unsigned C int+data Window = Window Int+
LICENSE view
@@ -1,13 +1,34 @@-(c) 2011-2012 Peter Althainz - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +LICENSE+-------++(c) 2011-2014 Peter Althainz+++HGamer3D (http://www.hgamer3d.org)+----------------------------------++HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0+ +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.+++Source Code+-----------+You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D+++Open Source Software Used - Module HGamer3D.Data+------------------------------------------------++HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. ++The HGamer3D.Data module uses the following Haskell libraries from Hackage:++base, license: BSD3+FindBin, license: BSD3+directory, license: BSD3+filepath, license: BSD3+vect, license: license: BSD3+
Setup.hs view
@@ -1,22 +1,22 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.althainz.de/HGamer3D.html --- --- (c) 2011 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Setup.hs - -import Distribution.Simple -main = defaultMain +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Setup.hs++import Distribution.Simple+main = defaultMain