HGamer3D-Data (empty) → 0.1.0
raw patch · 12 files changed
+480/−0 lines, 12 filesdep +basedep +haskell98setup-changed
Dependencies added: base, haskell98
Files
- HGamer3D-Data.cabal +38/−0
- HGamer3D/Data/Angle.hs +37/−0
- HGamer3D/Data/ColourValue.hs +38/−0
- HGamer3D/Data/Degree.hs +36/−0
- HGamer3D/Data/HG3DClass.hs +56/−0
- HGamer3D/Data/Quaternion.hs +89/−0
- HGamer3D/Data/Radian.hs +37/−0
- HGamer3D/Data/Vector2.hs +37/−0
- HGamer3D/Data/Vector3.hs +38/−0
- HGamer3D/Data/Vector4.hs +39/−0
- LICENSE +13/−0
- Setup.hs +22/−0
+ HGamer3D-Data.cabal view
@@ -0,0 +1,38 @@+Name: HGamer3D-Data +Version: 0.1.0 +Synopsis: Library to enable 3D game development for Haskell - API +Description: + Library, to enable 3D game development for Haskell, + based on bindings to 3D Graphics, pyhsics engine and additional libraries. + Current implementation contains the following features: + OGRE Binding, OIS Binding (limited functionality) + Platform: Windows only + Install following packages in sequence: HGamer3D-Data, HGamer3D-Ogre-Binding, HGamer3D-OIS-Binding, HGamer3D-API + License: Apache License, Version 2.0 + + This part contains different Data types of the HGamer3D API + +License: OtherLicense +License-file: LICENSE +Author: Dr. 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 + + Exposed-modules: HGamer3D.Data.Vector2,HGamer3D.Data.Vector3,HGamer3D.Data.Vector4,HGamer3D.Data.ColourValue,HGamer3D.Data.Quaternion,HGamer3D.Data.HG3DClass,HGamer3D.Data.Radian,HGamer3D.Data.Degree,HGamer3D.Data.Angle + Other-modules: + + c-sources: + + ghc-options: + cc-options: -Wno-attributes + hs-source-dirs: . + Include-dirs: . + build-depends: haskell98 + extra-libraries: stdc++.dll
+ HGamer3D/Data/Angle.hs view
@@ -0,0 +1,37 @@+-- 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 +-- +-- Copyright 2011 Dr. 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 + +module HGamer3D.Data.Angle + +( + -- export Angle Type again + Angle (Angle), + + -- export all functions + +) + +where + +data Angle = Angle { + aA :: Float + } deriving (Eq, Show) + +
+ HGamer3D/Data/ColourValue.hs view
@@ -0,0 +1,38 @@+-- 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 +-- +-- Copyright 2011 Dr. 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.ColourValue + +( + -- export ColourValue Type again + ColourValue (ColourValue), + + -- export all functions + +) + +where +data ColourValue = ColourValue { + cvR :: Float, + cvG :: Float, + cvB :: Float, + cvA :: Float + } deriving (Eq, Show) +
+ HGamer3D/Data/Degree.hs view
@@ -0,0 +1,36 @@+-- 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 +-- +-- Copyright 2011 Dr. 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. + +-- Degree.hs + +module HGamer3D.Data.Degree + +( + -- export Degree Type again + Degree (Degree), + + -- export all functions + +) + +where + + +data Degree = Degree { + dD :: Float + } deriving (Eq, Show)
+ HGamer3D/Data/HG3DClass.hs view
@@ -0,0 +1,56 @@+{-# 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 +-- +-- Copyright 2011 Dr. 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) + + +
+ HGamer3D/Data/Quaternion.hs view
@@ -0,0 +1,89 @@+-- 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 +-- +-- Copyright 2011 Dr. 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), + + -- export all functions + realQ, + imagQ, + fromScalarQ, + listFromQ, + fromListQ, + addQ, + subQ, + mulQ, + normQ, + conjQ, + negQ, + fromRotationQ, + +) + +where + +import HGamer3D.Data.Vector3 + +data Quaternion = Quaternion { + qFW :: Float, + qFX :: Float, + qFY :: Float, + qFZ :: Float + } deriving (Eq, Show) + +realQ :: Quaternion -> Float +realQ (Quaternion r _ _ _) = r + +imagQ :: Quaternion -> [Float] +imagQ (Quaternion _ i j k) = [i, j, k] + +fromScalarQ s = Quaternion s 0 0 0 + +listFromQ (Quaternion a b c d) = [a,b,c,d] +fromListQ [a, b, c, d] = Quaternion a b c d + +addQ, subQ, mulQ :: Quaternion -> Quaternion -> Quaternion + +addQ (Quaternion a b c d) (Quaternion p q r s) = Quaternion (a+p) (b+q) (c+r) (d+s) + +subQ (Quaternion a b c d) (Quaternion p q r s) = Quaternion (a-p) (b-q) (c-r) (d-s) + +mulQ (Quaternion a b c d) (Quaternion p q r s) = + Quaternion (a*p - b*q - c*r - d*s) + (a*q + b*p + c*s - d*r) + (a*r - b*s + c*p + d*q) + (a*s + b*r - c*q + d*p) + +normQ :: Quaternion -> Float +normQ q = sqrt $ sum $ zipWith (*) x x where x = listFromQ q + +conjQ, negQ :: Quaternion -> Quaternion + +conjQ (Quaternion a b c d) = Quaternion a (-b) (-c) (-d) + +negQ (Quaternion a b c d) = Quaternion (-a) (-b) (-c) (-d) + +fromRotationQ :: Float -> Vector3 -> Quaternion +fromRotationQ a (Vector3 x y z) = Quaternion (cos h) (s*x) (s*y) (s*z) where + h = a/2.0 + s = sin h
+ HGamer3D/Data/Radian.hs view
@@ -0,0 +1,37 @@+-- 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 +-- +-- Copyright 2011 Dr. 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. + +-- Radian.hs + +module HGamer3D.Data.Radian + +( + -- export Radian Type again + Radian (Radian), + + -- export all functions + +) + +where + +data Radian = Radian { + rR :: Float + } deriving (Eq, Show) + +
+ HGamer3D/Data/Vector2.hs view
@@ -0,0 +1,37 @@+-- 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 +-- +-- Copyright 2011 Dr. 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 again + Vector2 (Vector2), + + -- export all functions + +) + +where + +data Vector2 = Vector2 { + v2X :: Float, + v2Y :: Float + } deriving (Eq, Show) +
+ HGamer3D/Data/Vector3.hs view
@@ -0,0 +1,38 @@+-- 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 +-- +-- Copyright 2011 Dr. 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 again + Vector3 (Vector3), + + -- export all functions + +) + +where + +data Vector3 = Vector3 { + v3X :: Float, + v3Y :: Float, + v3Z :: Float + } deriving (Eq, Show) +
+ HGamer3D/Data/Vector4.hs view
@@ -0,0 +1,39 @@+-- 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 +-- +-- Copyright 2011 Dr. 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.Vector4 + +( + -- export Vector4 Type again + Vector4 (Vector4), + + -- export all functions + +) + +where + +data Vector4 = Vector4 { + v4X :: Float, + v4Y :: Float, + v4Z :: Float, + v4W :: Float + } deriving (Eq, Show) +
+ LICENSE view
@@ -0,0 +1,13 @@+Copyright 2012 Dr. 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 view
@@ -0,0 +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 +-- +-- Copyright 2011 Dr. 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