HGamer3D-Graphics3D (empty) → 0.3.0
raw patch · 10 files changed
+1334/−0 lines, 10 filesdep +HGamer3D-Datadep +HGamer3D-Ogre-Bindingdep +basesetup-changed
Dependencies added: HGamer3D-Data, HGamer3D-Ogre-Binding, base, directory, filepath, mtl, transformers
Files
- HGamer3D-Graphics3D.cabal +34/−0
- HGamer3D/Graphics3D.hs +58/−0
- HGamer3D/Graphics3D/Basic3D.hs +129/−0
- HGamer3D/Graphics3D/Engine.hs +201/−0
- HGamer3D/Graphics3D/Light.hs +196/−0
- HGamer3D/Graphics3D/Object3D.hs +335/−0
- HGamer3D/Graphics3D/PlatonObjects.hs +233/−0
- HGamer3D/Graphics3D/Types.hs +84/−0
- LICENSE +42/−0
- Setup.hs +22/−0
+ HGamer3D-Graphics3D.cabal view
@@ -0,0 +1,34 @@+Name: HGamer3D-Graphics3D +Version: 0.3.0 +Synopsis: 3D Graphics Functionality for HGamer3D +Description: + HGamer3D is a game engine for developing 3D games in the programming + language Haskell. This package provides the 3D Graphics functionality + based on the package HGamer3D-Ogre-Binding. HGamer3D-Graphics3D is + available on Windows and Linux. + +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, mtl, transformers, filepath, directory, HGamer3D-Data >= 0.3.0 && < 0.4.0, HGamer3D-Ogre-Binding >= 0.3.0 && < 0.4.0 + + + Exposed-modules: HGamer3D.Graphics3D.Types, HGamer3D.Graphics3D.Basic3D, HGamer3D.Graphics3D.Object3D, HGamer3D.Graphics3D.Light, HGamer3D.Graphics3D.PlatonObjects, HGamer3D.Graphics3D.Engine, HGamer3D.Graphics3D + Other-modules: + + c-sources: + + ghc-options: + cc-options: -Wno-attributes + hs-source-dirs: . + Include-dirs: . + build-depends: + extra-libraries:
+ HGamer3D/Graphics3D.hs view
@@ -0,0 +1,58 @@+-- 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.++-- Graphics.hs++-- | 3D Graphics for HGamer3D+module HGamer3D.Graphics3D++(+ module HGamer3D.Data,+ module HGamer3D.Util,+ module HGamer3D.Graphics3D.Types,+ module HGamer3D.Graphics3D.Basic3D,+ module HGamer3D.Graphics3D.Object3D,+ module HGamer3D.Graphics3D.Light,+ module HGamer3D.Graphics3D.PlatonObjects,+ module HGamer3D.Graphics3D.Engine,+ initHGamer3D,+ exitHGamer3D,+ loopHGamer3D+)++where++ import HGamer3D.Data+ import HGamer3D.Util+ import HGamer3D.Graphics3D.Types+ import HGamer3D.Graphics3D.Basic3D+ import HGamer3D.Graphics3D.Object3D+ import HGamer3D.Graphics3D.Light+ import HGamer3D.Graphics3D.PlatonObjects+ import HGamer3D.Graphics3D.Engine++ initHGamer3D windowName sceneManagerType fConfig fLog = do+ (g3ds, camera, viewport, window) <- initGraphics3D windowName sceneManagerType fConfig fLog+ return (g3ds, camera, viewport)+ + exitHGamer3D = exitGraphics3D+ + loopHGamer3D = loopGraphics3D+++
+ HGamer3D/Graphics3D/Basic3D.hs view
@@ -0,0 +1,129 @@+{-# LANGUAGE FlexibleContexts #-}++-- 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.++-- Basic3D.hs++-- | Basic functions for the Graphics3D module+module HGamer3D.Graphics3D.Basic3D (+++ cameraLookAt,+ + -- * Background Colour+ HGamer3D.Graphics3D.Basic3D.setBackgroundColour,+ + -- * Resource locations+ -- $audioresource+ + addResourceLocationMedia,+ addResourceZipfileMedia,+ addResourceLocationGUI+)++where ++import HGamer3D.Data++import HGamer3D.Bindings.Ogre.ClassCamera as Camera+import HGamer3D.Bindings.Ogre.ClassViewport as Viewport+import HGamer3D.Bindings.Ogre.ClassResourceGroupManager as ResourceGroupManager++import HGamer3D.Graphics3D.Types++-- Camera functions+--+++instance Position3D Camera where++ position3D (Camera c) = do+ pos <- Camera.getPosition c+ return (pos)+ + positionTo3D (Camera c) pos = do+ Camera.setPosition2 c pos+ return ()+ +instance Direction3D Camera where++ direction3D (Camera c) = do+ d <- Camera.getDirection c+ return d+ + directionTo3D (Camera c) v = do+ Camera.setDirection2 c v+ +instance Orientation3D Camera where++ orientation3D (Camera c) = do+ q <- Camera.getOrientation c+ let uq = mkNormal q+ return uq+ + orientationTo3D (Camera c) uq = do+ Camera.setOrientation c (fromNormal uq)+ return ()++-- | set the direction in a way, that the camera looks toward a specified point+cameraLookAt :: Camera -> Vec3 -> IO ()+cameraLookAt (Camera c) v = do+ Camera.lookAt c v+ return ()+++-- specific single function+--++-- | sets the background colour of the 3d drawing window+setBackgroundColour :: Viewport -> Colour -> IO ()+setBackgroundColour (Viewport viewport) bgColour = do+ Viewport.setBackgroundColour viewport bgColour++-- locations of media in same folder as program resides+-- ++-- | adds a resource location for 3D media (Ogre)+addResourceLocationMedia :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D+ -> String -- ^ path to new resource location, the path should identify a directory+ -> IO ()+addResourceLocationMedia g3ds path = do+ let (ResourceGroupManager rgm) = (g3dsResourceGroupManager g3ds)+ ResourceGroupManager.addResourceLocation rgm path "FileSystem" "General" False+ ResourceGroupManager.initialiseResourceGroup rgm "General"++-- | adds a resource location for 3D media (Ogre) which is a zip file+addResourceZipfileMedia :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> String -- ^ path to new resource location, the path should identify a zip file+ -> IO ()+addResourceZipfileMedia g3ds path = do+ let (ResourceGroupManager rgm) = (g3dsResourceGroupManager g3ds)+ ResourceGroupManager.addResourceLocation rgm path "Zip" "General" False+ ResourceGroupManager.initialiseResourceGroup rgm "General"++-- | adds a resource location for GUI media (CEGUI) which is a directory+addResourceLocationGUI :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D+ -> String -- ^ path to the directory with the GUI media in it+ -> String -- ^ category of GUI media, for example: Layout, Images, ...+ -> IO ()+addResourceLocationGUI g3ds path category = do+ let (ResourceGroupManager rgm) = (g3dsResourceGroupManager g3ds)+ ResourceGroupManager.addResourceLocation rgm path "FileSystem" category False+ ResourceGroupManager.initialiseResourceGroup rgm category+
+ HGamer3D/Graphics3D/Engine.hs view
@@ -0,0 +1,201 @@+{-# LANGUAGE FlexibleContexts #-}++-- 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.++-- EngineHelper.hs++-- | Initialization functions for the Graphics3D module+module HGamer3D.Graphics3D.Engine (++ initGraphics3D,+ graphics3DPumpWindowMessages,+ exitGraphics3D,+ loopGraphics3D,+ renderOneFrame,+ checkQuitReceived+) ++where++import HGamer3D.Data+import HGamer3D.Util++import qualified HGamer3D.Bindings.Ogre.ClassRoot as Root+import HGamer3D.Bindings.Ogre.ClassSceneManager as SceneManager+import HGamer3D.Bindings.Ogre.ClassResourceGroupManager as ResourceGroupManager+import HGamer3D.Bindings.Ogre.ClassTextureManager as TextureManager+import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager+import HGamer3D.Bindings.Ogre.ClassViewport as Viewport+import HGamer3D.Bindings.Ogre.ClassFrustum as Frustum+import HGamer3D.Bindings.Ogre.ClassAnimationState as AnimationState+import HGamer3D.Bindings.Ogre.ClassEntity as Entity+import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager+import HGamer3D.Bindings.Ogre.ClassLogManager as LogManager+import HGamer3D.Bindings.Ogre.ClassLog as Log+import HGamer3D.Bindings.Ogre.ClassHG3DUtilities as Util+import HGamer3D.Bindings.Ogre.ClassRenderTarget as RenderTarget+import HGamer3D.Bindings.Ogre.ClassManualObject as ManualObject+import HGamer3D.Bindings.Ogre.EnumRenderOperationOperationType+import HGamer3D.Bindings.Ogre.StructHG3DClass+import HGamer3D.Bindings.Ogre.EnumSceneManagerPrefabType+import HGamer3D.Bindings.Ogre.ClassWindowEventUtilities as WindowEventUtilities++import HGamer3D.Graphics3D.Types+import HGamer3D.Graphics3D.Basic3D++import Control.Monad+import Control.Monad.Trans+import Control.Monad.IO.Class+import Control.Monad.State.Class++import Control.Concurrent+import Data.Maybe++-- | pump window messages for graphics+-- Not to be used, if WinEvent pollWinEvent or pumpWinEvents is used!+graphics3DPumpWindowMessages :: IO ()+graphics3DPumpWindowMessages = do+ WindowEventUtilities.messagePump+ return ()++-- | renders one frame on the screen+renderOneFrame :: Graphics3DSystem -> IO ()+renderOneFrame g3ds = do + let (RootObject root) = g3dsRoot g3ds+ Root.renderOneFrame root+ return ()+++loopGraphics3D :: Graphics3DSystem -> IO Bool+loopGraphics3D g3ds = do+ renderOneFrame g3ds+ graphics3DPumpWindowMessages+ i <- checkQuitReceived+ return (i == 1)+ +exitGraphics3D :: Graphics3DSystem -> IO ()+exitGraphics3D g3ds = do+ let (RootObject root) = g3dsRoot g3ds+ let (RenderTarget rt) = g3dsRenderTarget g3ds+ Root.destroyRenderTarget root rt+ Root.delete root+ return ()++-- | initializes the 3d graphics module+initGraphics3D :: String -- ^ Name of the window, displayed+ -> String -- ^ SceneManager type used+ -> Bool -- ^ flag, show configuration dialogue+ -> Bool -- ^ flag, is logging enabled+ -> IO (Graphics3DSystem, Camera, Viewport, Window)+ +initGraphics3D windowName sceneManagerType fConfig fLog = do++ -- configuration path can be app user dir or local dir+ localDir <- getAppConfigDirectory+ appDir <- getExeConfigDirectory+ configFile <- findFileInDirs "engine.cfg" [localDir, appDir]+ pluginsFile <- findFileInDirs "plugins.cfg" [localDir, appDir]+ + -- check both files exists+ let config = case configFile of+ Just cf -> cf+ Nothing -> error $ "HGamer3D - Graphics3D: could not find engine configuration file engine.cfg"+ + let plugins = case pluginsFile of+ Just pf -> pf+ Nothing -> error $ "HGamer3D - Graphics3D: could not find plugins configuration file plugins.cfg"+ + root <- Root.new plugins config ""+ lmgr <- LogManager.getSingletonPtr+ if not fLog then do+ newlog <- LogManager.createLog lmgr "SilentLog" True False True+ return ()+ else do+ newlog <- LogManager.createLog lmgr "hgamer3d-engine.log" True False False+ return ()+ + fOk <- if fConfig then+ Root.showConfigDialog root+ else do+ fLoaded <- Root.restoreConfig root+ if not fLoaded then+ Root.showConfigDialog root+ else+ return True+ + +-- fUAddResourceLocations "resources.cfg"+ renderWindow <-Root.initialise root True windowName ""+ setupCloseEventHandler renderWindow+ windowHandle <- Util.getWindowHandle renderWindow+ + -- Suppress logging unless, fLog+ + sceneManager <- Root.createSceneManager root sceneManagerType "SceneManager"+ + camera <- SceneManager.createCamera sceneManager "SimpleCamera"+ Frustum.setNearClipDistance camera 5.0+ Frustum.setFarClipDistance camera 5000.0+ ++ viewport <- RenderTarget.addViewport renderWindow camera 0 0.0 0.0 1.0 1.0+ let bgColor = Colour 0.0 0.0 0.0 1.0+ Viewport.setBackgroundColour viewport bgColor+ + height <- Viewport.getActualHeight viewport+ width <- Viewport.getActualWidth viewport+ + Frustum.setAspectRatio camera ((fromIntegral width) / (fromIntegral height))+ + tm <- TextureManager.getSingletonPtr+ TextureManager.setDefaultNumMipmaps tm 20+ + -- resource locations, if path given, use this as base, if not use standard locations+ + rgm <- ResourceGroupManager.getSingletonPtr+ + ResourceGroupManager.createResourceGroup rgm "Schemes" False+ ResourceGroupManager.createResourceGroup rgm "Imagesets" False+ ResourceGroupManager.createResourceGroup rgm "Fonts" False+ ResourceGroupManager.createResourceGroup rgm "Layouts" False+ ResourceGroupManager.createResourceGroup rgm "LookNFeel" False+ ResourceGroupManager.createResourceGroup rgm "LuaScripts" False+ ResourceGroupManager.createResourceGroup rgm "XMLSchemas" False+ + mediapath1 <- getAppMediaDirectory+ mediapath2 <- getExeMediaDirectory+ + mapM (\mediapath -> do+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "materials") "FileSystem" "General" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "schemes") "FileSystem" "Schemes" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "imagesets") "FileSystem" "Imagesets" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "fonts") "FileSystem" "Fonts" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "layouts") "FileSystem" "Layouts" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "looknfeel") "FileSystem" "LookNFeel" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "lua_scripts") "FileSystem" "LuaScripts" False+ ResourceGroupManager.addResourceLocation rgm (mediapath ++ osSep ++ "xml_schemas") "FileSystem" "XMLSchemas" False+ return ()) [mediapath1, mediapath2]+ ++ ResourceGroupManager.initialiseAllResourceGroups rgm+ uniqueName <- createUniqueName "HG3DObj"+ + return $ (Graphics3DSystem (RootObject root) (SceneManager sceneManager) (ResourceGroupManager rgm) (LogManager lmgr) (TextureManager tm) (RenderTarget renderWindow) uniqueName, (Camera camera), (Viewport viewport), (Window windowHandle)) ++
+ HGamer3D/Graphics3D/Light.hs view
@@ -0,0 +1,196 @@+{-# LANGUAGE FlexibleContexts #-} + +-- 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. + +-- Light.hs + +-- | Creating and managing Light in Base API. + + +module HGamer3D.Graphics3D.Light ( + + -- * Types + Light (..), + + -- * create and modify light sources + HGamer3D.Graphics3D.Light.setAmbientLight, + pointlight, + spotlight, + setSpotlightAngle, + directionalLight +) + +where + + +import HGamer3D.Data +import HGamer3D.Util + +import GHC.Ptr + +import HGamer3D.Bindings.Ogre.ClassPtr +import HGamer3D.Bindings.Ogre.Utils + +import HGamer3D.Bindings.Ogre.StructColour +import HGamer3D.Bindings.Ogre.StructSharedPtr + +import HGamer3D.Bindings.Ogre.EnumSceneType +import HGamer3D.Bindings.Ogre.EnumNodeTransformSpace +import HGamer3D.Bindings.Ogre.EnumLightType + +--import HGamer3D.Bindings.Ogre.ClassCamera as Camera +--import HGamer3D.Bindings.Ogre.ClassRoot as Root +import HGamer3D.Bindings.Ogre.ClassLight as Light +import HGamer3D.Bindings.Ogre.ClassNode as Node +import HGamer3D.Bindings.Ogre.ClassSceneManager as SceneManager +import HGamer3D.Bindings.Ogre.ClassSceneNode as SceneNode +import HGamer3D.Bindings.Ogre.ClassRenderTarget as RenderTarget +import HGamer3D.Bindings.Ogre.ClassRenderWindow as RenderWindow +import HGamer3D.Bindings.Ogre.ClassResourceGroupManager as ResourceGroupManager +import HGamer3D.Bindings.Ogre.ClassTextureManager as TextureManager +import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager +import HGamer3D.Bindings.Ogre.ClassViewport as Viewport +import HGamer3D.Bindings.Ogre.ClassFrustum as Frustum +import HGamer3D.Bindings.Ogre.ClassAnimationState as AnimationState +import HGamer3D.Bindings.Ogre.ClassEntity as Entity +import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager +import HGamer3D.Bindings.Ogre.ClassWindowEventUtilities as WindowEventUtilities + +import HGamer3D.Bindings.Ogre.ClassManualObject as ManualObject +import HGamer3D.Bindings.Ogre.EnumRenderOperationOperationType +import HGamer3D.Bindings.Ogre.StructHG3DClass +import HGamer3D.Bindings.Ogre.EnumSceneManagerPrefabType + +import HGamer3D.Data.HG3DClass +import HGamer3D.Data.Operation3D +import HGamer3D.Graphics3D.Types +import HGamer3D.Graphics3D.Engine + +import Control.Monad +import Control.Monad.Trans +import Control.Monad.IO.Class +import Control.Monad.State.Class + + + +-- | The light. +data Light = Light HG3DClass deriving (Show) + +instance Position3D Light where + + position3D (Light l) = do + pos <- Light.getPosition l + return (pos) + + positionTo3D (Light l) pos = do + let (Vec3 x y z) = pos + Light.setPosition l x y z + return () + +instance Direction3D Light where + + direction3D (Light l) = do + d <- Light.getDirection l + return d + + directionTo3D (Light l) v = do + Light.setDirection2 l v + return () + + +-- | Ambient light is present everywhere, this function creates it and sets the colour of it. +-- There is no light object, since movement, rotation, scaling would make no sense anyhow. + +setAmbientLight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Colour -> IO () +setAmbientLight g3ds colour = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + SceneManager.setAmbientLight scm colour + return () + + +-- | creates a point light at a specific location +pointlight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Colour -- ^ Color of the light + -> Vec3 -- ^ Position, where light is created + -> IO (Light) -- ^ The light object + +pointlight g3ds (Colour t r g b) (Vec3 x y z) = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + lightName <- nextUniqueName (g3dsUniqueName g3ds) + + light <- SceneManager.createLight scm lightName + Light.setType light LT_POINT + Light.setPosition light x y z + Light.setDiffuseColour light r g b + Light.setSpecularColour light r g b + let eo = Light light + return eo + +-- | creates a spot light at a specific location +spotlight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Colour -- ^ Color of the light + -> Vec3 -- ^ Position, where light is created + -> IO Light -- ^ The light object +spotlight g3ds (Colour t r g b) (Vec3 x y z) = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + lightName <- nextUniqueName (g3dsUniqueName g3ds) + + light <- SceneManager.createLight scm lightName + Light.setType light LT_SPOTLIGHT + Light.setPosition light x y z + Light.setDiffuseColour light r g b + Light.setSpecularColour light r g b + let eo = Light light + return eo + +-- | set the angle of a spotlight +setSpotlightAngle :: Light -- ^ spotlight + -> Angle -- ^ angle of the light cone, should be between 5 and 355 degree + -> IO () +setSpotlightAngle (Light light) a = do + if (a >= (Deg 5)) && (a <= (Deg 355)) + then do + let innerAngle = fromAngle $ a `subA` (Deg 4.5) + let outerAngle = fromAngle $ a `addA` (Deg 4.5) + Light.setSpotlightInnerAngle light innerAngle + Light.setSpotlightOuterAngle light outerAngle + return () + else do + return () + + +-- | creates a directional light at a specific location +directionalLight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Colour -- ^ Color of the light + -> Vec3 -- ^ Position, where light is created + -> IO (Light) -- ^ The light object + +directionalLight g3ds (Colour t r g b) (Vec3 x y z) = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + lightName <- nextUniqueName (g3dsUniqueName g3ds) + + light <- SceneManager.createLight scm lightName + Light.setType light LT_DIRECTIONAL + Light.setPosition light x y z + Light.setDiffuseColour light r g b + Light.setSpecularColour light r g b + let eo = Light light + return eo +
+ HGamer3D/Graphics3D/Object3D.hs view
@@ -0,0 +1,335 @@+{-# LANGUAGE FlexibleContexts #-} + +-- 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. + +-- Object3D.hs + +-- | Creating and managing 3D objects functionality for Graphics3D module +module HGamer3D.Graphics3D.Object3D ( + + -- * Mesh creation functions, standard meshes + sphereMesh, + cubeMesh, + planeMesh, + resourceMesh, + + -- * Mesh creation functions, special meshes + colouredCubeMesh, + colouredLineMesh, + rainbowCubeMesh, + + -- * clone objects from meshes + object3DFromMesh, + object3DFromObjects, + + -- * Special movements + yaw3D, + roll3D, + pitch3D +) + +where + +import HGamer3D.Data +import HGamer3D.Util + +import GHC.Ptr + +import HGamer3D.Bindings.Ogre.ClassPtr +import HGamer3D.Bindings.Ogre.Utils + +import HGamer3D.Bindings.Ogre.StructColour +import HGamer3D.Bindings.Ogre.StructSharedPtr + +import HGamer3D.Bindings.Ogre.EnumSceneType +import HGamer3D.Bindings.Ogre.EnumNodeTransformSpace +import HGamer3D.Bindings.Ogre.EnumLightType + +--import HGamer3D.Bindings.Ogre.ClassCamera as Camera +--import HGamer3D.Bindings.Ogre.ClassRoot as Root +import HGamer3D.Bindings.Ogre.ClassLight as Light +import HGamer3D.Bindings.Ogre.ClassNode as Node +import HGamer3D.Bindings.Ogre.ClassSceneManager as SceneManager +import HGamer3D.Bindings.Ogre.ClassSceneNode as SceneNode +import HGamer3D.Bindings.Ogre.ClassRenderTarget as RenderTarget +import HGamer3D.Bindings.Ogre.ClassRenderWindow as RenderWindow +import HGamer3D.Bindings.Ogre.ClassResourceGroupManager as ResourceGroupManager +import HGamer3D.Bindings.Ogre.ClassTextureManager as TextureManager +import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager +import HGamer3D.Bindings.Ogre.ClassViewport as Viewport +import HGamer3D.Bindings.Ogre.ClassFrustum as Frustum +import HGamer3D.Bindings.Ogre.ClassAnimationState as AnimationState +import HGamer3D.Bindings.Ogre.ClassEntity as Entity +import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager +import HGamer3D.Bindings.Ogre.ClassWindowEventUtilities as WindowEventUtilities + +import HGamer3D.Bindings.Ogre.ClassManualObject as ManualObject +import HGamer3D.Bindings.Ogre.EnumRenderOperationOperationType +import HGamer3D.Bindings.Ogre.StructHG3DClass +import HGamer3D.Bindings.Ogre.EnumSceneManagerPrefabType + +import HGamer3D.Data.HG3DClass +import HGamer3D.Data.Operation3D +import HGamer3D.Graphics3D.Types +import HGamer3D.Graphics3D.Engine + +import Control.Monad +import Control.Monad.Trans +import Control.Monad.IO.Class +import Control.Monad.State.Class + + +-- set the material of an Ogre entity, used during mesh creation +_setMaterial :: HG3DClass -- ^ 3d object + -> Material -- ^ material + -> IO () +_setMaterial entity material = do + case material of + (ResourceMaterial name) -> do + Entity.setMaterialName entity name "General" + return () + + +-- | creates a Sphere Mesh, from which Spheres can be cloned +sphereMesh :: Mesh -- ^ the mesh created +sphereMesh = SphereMesh + +-- | creates a Cube Mesh, from which Cubes can be cloned +cubeMesh :: Mesh -- ^ the mesh created +cubeMesh = CubeMesh + +-- | creates a Plane Mesh, from which Planes can be cloned +planeMesh :: Mesh -- ^ the mesh created +planeMesh = PlaneMesh + +-- | creates a Plane Mesh, from which Planes can be cloned +resourceMesh :: String -- ^ the name of the resource + -> Mesh -- ^ the mesh created +resourceMesh resourceName = ResourceMesh resourceName + +-- | clones a 3D object from a mesh +object3DFromMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Mesh -- ^ mesh used for creation + -> Maybe Material -- ^ a material to be applied, if needed + -> IO Object3D -- ^ created 3d object +object3DFromMesh g3ds mesh mbMaterial = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + -- create the entity from the mesh + entity <- case mesh of + CubeMesh -> SceneManager.createEntity6 scm PT_CUBE + SphereMesh -> SceneManager.createEntity6 scm PT_SPHERE + PlaneMesh -> SceneManager.createEntity6 scm PT_PLANE + ResourceMesh resourceName -> SceneManager.createEntity3 scm resourceName + ManualMesh meshName -> SceneManager.createEntity3 scm meshName + -- apply material, if needed, wanted + case mbMaterial of + Just material -> _setMaterial entity material + Nothing -> return () + -- now create node and attach entity to it + rootNode <- SceneManager.getRootSceneNode scm + let vzero = Vec3 0.0 0.0 0.0 + let qident = Q (Vec4 1.0 0.0 0.0 0.0) + node <- SceneNode.createChildSceneNode rootNode vzero qident + SceneNode.attachObject node entity + -- return object + return (SingleObject3D mesh node) + +_getNode :: Object3D -> HG3DClass +_getNode (SingleObject3D entity node) = node +_getNode (CombinedObject3D objects node) = node + +-- | combine 3D objects to a new object +object3DFromObjects :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + ->[Object3D] -- ^ A list of objects, to be grouped + -> IO Object3D -- ^ The return value is a new 3d object. +object3DFromObjects g3ds listObjects = do + let (SceneManager scm) = (g3dsSceneManager g3ds) + rootNode <- SceneManager.getRootSceneNode scm + let vzero = Vec3 0.0 0.0 0.0 + let qident = Q (Vec4 1.0 0.0 0.0 0.0) + node <- SceneNode.createChildSceneNode rootNode vzero qident + sequence_ (map ( \object -> do + let objectnode = _getNode object + parent <- Node.getParent objectnode + Node.removeChild2 parent objectnode + Node.addChild node objectnode + return () ) listObjects) + return ( CombinedObject3D listObjects node) + +-- | Creates a line with a colour from start and end point (mesh as object template) +colouredLineMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Vec3 -- ^ start point + -> Vec3 -- ^ end point + -> Colour -- ^ colour + -> IO Mesh -- ^ line mesh +colouredLineMesh g3ds vStart vEnd colour = do + uid <- nextUniqueName (g3dsUniqueName g3ds) + let (SceneManager scm) = (g3dsSceneManager g3ds) + let lineName = "L" ++ uid + let meshName = "M" ++ uid + + mo <- SceneManager.createManualObject scm lineName + ManualObject.begin mo "BaseWhiteNoLighting" OT_LINE_LIST "General" + ManualObject.position mo vStart + ManualObject.colour mo colour + ManualObject.position mo vEnd + ManualObject.colour mo colour + ManualObject.end mo + ManualObject.convertToMesh mo meshName "General" + return $ ManualMesh meshName + +-- |Creates a coloured cube mesh +colouredCubeMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> Colour -- ^ colour + -> IO Mesh -- ^ cube mesh +colouredCubeMesh g3ds colour = do + uid <- nextUniqueName (g3dsUniqueName g3ds) + let (SceneManager scm) = (g3dsSceneManager g3ds) + let cubeName = "C" ++ uid + let meshName = "M" ++ uid + + mo <- SceneManager.createManualObject scm cubeName + + -- basic parameters + let lsize = 1.0 + let cp = 1.0 * lsize + let cm = -1.0 * lsize + + ManualObject.begin mo "BaseWhiteNoLighting" OT_TRIANGLE_LIST "General" + + ManualObject.position2 mo cm cp cm -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cp cp cm -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cp cm cm -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cm cm cm -- a vertex + ManualObject.colour mo colour + + ManualObject.position2 mo cm cp cp -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cp cp cp -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cp cm cp -- a vertex + ManualObject.colour mo colour + ManualObject.position2 mo cm cm cp -- a vertex + ManualObject.colour mo colour + + ManualObject.triangle mo 0 1 2 + ManualObject.triangle mo 2 3 0 + ManualObject.triangle mo 4 6 5 + ManualObject.triangle mo 6 4 7 + + ManualObject.triangle mo 0 4 5 + ManualObject.triangle mo 5 1 0 + ManualObject.triangle mo 2 6 7 + ManualObject.triangle mo 7 3 2 + + ManualObject.triangle mo 0 7 4 + ManualObject.triangle mo 7 0 3 + ManualObject.triangle mo 1 5 6 + ManualObject.triangle mo 6 2 1 + + ManualObject.end mo + + ManualObject.convertToMesh mo meshName "General" + return $ ManualMesh meshName + + +-- | Creates a rainbow coloured cube mesh +rainbowCubeMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D + -> IO Mesh +rainbowCubeMesh g3ds = do + uid <- nextUniqueName (g3dsUniqueName g3ds) + let (SceneManager scm) = (g3dsSceneManager g3ds) + let cubeName = "C" ++ uid + let meshName = "M" ++ uid + let materialName = "BaseWhiteNoLighting" + + mo <- SceneManager.createManualObject scm cubeName + + -- basic parameters + let lsize = 1.0 + let cp = 1.0 * lsize + let cm = -1.0 * lsize + + ManualObject.begin mo "BaseWhiteNoLighting" OT_TRIANGLE_LIST "General" + + sequence $ map (\(x, y, z, c) -> liftIO (ManualObject.position2 mo x y z) >> liftIO (ManualObject.colour mo c) ) [ + (cm, cp, cm, (Colour 0.0 1.0 0.0 1.0) ), + (cp, cp, cm, (Colour 1.0 1.0 0.0 1.0) ), + (cp, cm, cm, (Colour 1.0 0.0 0.0 1.0) ), + (cm, cm, cm, (Colour 0.0 0.0 0.0 1.0) ), + + (cm, cp, cp, (Colour 0.0 1.0 1.0 1.0) ), + (cp, cp, cp, (Colour 1.0 1.0 1.0 1.0) ), + (cp, cm, cp, (Colour 1.0 0.0 1.0 1.0) ), + (cm, cm, cp, (Colour 0.0 0.0 1.0 1.0) ) ] + + sequence $ map (\(x,y,z) -> ManualObject.triangle mo x y z) [ + (0, 1, 2), + (2, 3, 0), + (4, 6, 5), + (6, 4, 7), + + (0, 4, 5), + (5, 1, 0), + (2, 6, 7), + (7, 3, 2), + + (0, 7, 4), + (7, 0, 3), + (1, 5, 6), + (6, 2, 1) ] + + ManualObject.end mo + ManualObject.convertToMesh mo meshName "General" + return $ ManualMesh meshName + +instance Position3D Object3D where + + position3D obj = do + pos <- Node.getPosition (_getNode obj) + return (pos) + + positionTo3D obj pos = do + Node.setPosition (_getNode obj) pos + return () + +instance Scale3D Object3D where + + scale3D obj = do + pos <- Node.getScale (_getNode obj) + return (pos) + + scaleTo3D obj pos = do + Node.setScale (_getNode obj) pos + return () + +instance Orientation3D Object3D where + + orientation3D obj = do + q <- Node.getOrientation (_getNode obj) + let uq = mkNormal q + return uq + + orientationTo3D obj uq = do + Node.setOrientation (_getNode obj) (fromNormal uq) + return () +
+ HGamer3D/Graphics3D/PlatonObjects.hs view
@@ -0,0 +1,233 @@+{-# LANGUAGE FlexibleContexts #-}++-- 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.++-- PlatonObjects.hs++-- | Create platonic objects, ikosaeder and dodekaeder+module HGamer3D.Graphics3D.PlatonObjects (++ createIkosaederMesh,+ createDodekaederMesh+) ++where+++import GHC.Ptr++import HGamer3D.Data+import HGamer3D.Util++import HGamer3D.Bindings.Ogre.ClassPtr+import HGamer3D.Bindings.Ogre.Utils++import HGamer3D.Bindings.Ogre.StructColour+import HGamer3D.Bindings.Ogre.StructSharedPtr+import HGamer3D.Bindings.Ogre.StructHG3DClass++import HGamer3D.Bindings.Ogre.EnumSceneType+import HGamer3D.Bindings.Ogre.EnumNodeTransformSpace+import HGamer3D.Bindings.Ogre.EnumLightType+import HGamer3D.Bindings.Ogre.EnumRenderOperationOperationType+import HGamer3D.Bindings.Ogre.EnumSceneManagerPrefabType++--import HGamer3D.Bindings.Ogre.ClassCamera as Camera+--import HGamer3D.Bindings.Ogre.ClassRoot as Root+import HGamer3D.Bindings.Ogre.ClassLight as Light+import HGamer3D.Bindings.Ogre.ClassNode as Node+import HGamer3D.Bindings.Ogre.ClassSceneManager as SceneManager+import HGamer3D.Bindings.Ogre.ClassSceneNode as SceneNode+import HGamer3D.Bindings.Ogre.ClassRenderTarget as RenderTarget+import HGamer3D.Bindings.Ogre.ClassRenderWindow as RenderWindow+import HGamer3D.Bindings.Ogre.ClassResourceGroupManager as ResourceGroupManager+import HGamer3D.Bindings.Ogre.ClassTextureManager as TextureManager+import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager+import HGamer3D.Bindings.Ogre.ClassViewport as Viewport+import HGamer3D.Bindings.Ogre.ClassFrustum as Frustum+import HGamer3D.Bindings.Ogre.ClassAnimationState as AnimationState+import HGamer3D.Bindings.Ogre.ClassEntity as Entity+import HGamer3D.Bindings.Ogre.ClassControllerManager as ControllerManager+import HGamer3D.Bindings.Ogre.ClassWindowEventUtilities as WindowEventUtilities+import HGamer3D.Bindings.Ogre.ClassManualObject as ManualObject++import HGamer3D.Graphics3D.Types+import HGamer3D.Graphics3D.Object3D+import HGamer3D.Graphics3D.Engine++import Control.Monad+import Control.Monad.Trans+import Control.Monad.IO.Class+import Control.Monad.State.Class+++vminus = Vec3 (-1.0) (-1.0) (-1.0)++getNormOfFace vertices (a, b, c) = normalize cross+ where + v1 = vertices !! a+ v2 = vertices !! b+ v3 = vertices !! c + cross = (v2 &- v1) `crossprod` (v3 &- v1)+ ++isIn (a, b, c) n = if n == a then True else + if n == b then True else+ if n == c then True else+ False+++_createPlatonObject :: Graphics3DSystem -> Colour -> [Vec3] -> [(Int, Int, Int)] -> Int -> IO HG3DClass+_createPlatonObject g3ds colour vertices faces iColor = do++ let (SceneManager scm) = (g3dsSceneManager g3ds)+ uid <- nextUniqueName (g3dsUniqueName g3ds)++ mo <- SceneManager.createManualObject scm uid+ -- set Dynamic to false+ ManualObject.setDynamic mo False++ let normsOfFaces = map (getNormOfFace vertices) faces+ + let vzero = Vec3 0.0 0.0 0.0 + + let normsOfVertices = map vnorm allVerticesIndexes+ where + allVerticesIndexes = [ i | i <- [0..(length vertices)]] + vnorm = (\i -> normalize $ foldr (&+) vzero (map (\face -> if isIn face i then normsOfFaces !! i else vzero) faces))++ sequence $ map (\((x,y,z), norm) -> do+ ManualObject.begin mo "BaseWhiteNoLightning" OT_TRIANGLE_LIST "General"+ ManualObject.position mo (vertices !! x)+ ManualObject.normal mo norm+ ManualObject.position mo (vertices !! y)+ ManualObject.position mo (vertices !! z)+ ManualObject.triangle mo 0 1 2+ ManualObject.end mo) (zip faces normsOfFaces)++ return mo+ ++-- | create an ikoaeder mesh - from the mesh more objects can be created+createIkosaederMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D+ -> Colour -- ^ colour of the ikosaeder+ -> IO Mesh -- ^ created mesh object+createIkosaederMesh g3ds colour = do+ let (SceneManager scm) = (g3dsSceneManager g3ds)+ uid <- nextUniqueName (g3dsUniqueName g3ds)++ let bodyName = "B" ++ uid+ let meshName = "M" ++ uid+ + let x = 0.525731112119133606+ let z = 0.850650808352039932+ + let vertices = [+ ( Vec3 (-x) 0.0 z),+ ( Vec3 x 0.0 z),+ ( Vec3 (-x) 0.0 (-z)),+ ( Vec3 x 0.0 (-z)),+ ( Vec3 0.0 z x), + ( Vec3 0.0 z (-x)), + ( Vec3 0.0 (-z) x), + ( Vec3 0.0 (-z) (-x)),+ ( Vec3 z x 0.0),+ ( Vec3 (-z) x 0.0), + ( Vec3 z (-x) 0.0),+ ( Vec3 (-z) (-x) 0.0)+ ]+ + let faces = [++ (0,4,1), (0,9,4), (9,5,4), (4,5,8), (4,8,1), + (8,10,1), (8,3,10), (5,3,8), (5,2,3), (2,7,3),+ (7,10,3), (7,6,10), (7,11,6), (11,0,6), (0,1,6),+ (6,1,10), (9,0,11), (9,11,2), (9,2,5), (7,2,11)+ + ]+ + mo <- _createPlatonObject g3ds colour vertices faces 0+ ManualObject.convertToMesh mo meshName "General"+ return $ ManualMesh meshName+ ++-- | create a dodekaeder mesh+createDodekaederMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D+ -> Colour -- ^ colour of the dodekaeder+ -> IO Mesh -- ^ created dodekaeder mesh+createDodekaederMesh g3ds colour = do+ let (SceneManager scm) = (g3dsSceneManager g3ds)+ uid <- nextUniqueName (g3dsUniqueName g3ds)++ let bodyName = "B" ++ uid+ let meshName = "M" ++ uid+ + let s = 0.618034+ let t = 1.618034++ + let vertices = [+ + (Vec3 1.0 1.0 1.0), + (Vec3 1.0 1.0 (-1.0)), + (Vec3 1.0 (-1.0) 1.0), + (Vec3 1.0 (-1.0) (-1.0)), + (Vec3 (-1.0) 1.0 1.0), + (Vec3 (-1.0) 1.0 (-1.0)), + (Vec3 (-1.0) (-1.0) 1.0), + (Vec3 (-1.0) (-1.0) (-1.0)), + (Vec3 s t 0.0),+ (Vec3 (-s) t 0.0), + (Vec3 s (-t) 0.0),+ (Vec3 (-s) (-t) 0.0), + (Vec3 t 0.0 s), + (Vec3 t 0.0 (-s)),+ (Vec3 (-t) 0.0 s), + (Vec3 (-t) 0.0 (-s)), + (Vec3 0.0 s t),+ (Vec3 0.0 (-s) t), + (Vec3 0.0 s (-t)), + (Vec3 0.0 (-s) (-t))++ ]+ + let faces = [+ +-- (1,8,0,12,13), (4, 9, 5, 15, 14), +-- (2, 10, 3, 13, 12), (7, 11, 6, 14, 15), +-- (2, 12, 0, 16, 17), (1, 13, 3, 19, 18),+-- (4, 14, 6, 17, 16), (7, 15, 5, 18, 19),+-- (4, 16, 0, 8, 9), (2, 17, 6, 11, 10),+-- (1, 18, 5, 9, 8), (7, 19, 3, 10, 11)+ + (1,8,0,12,13), (4, 9, 5, 15, 14), + (2, 10, 3, 13, 12), (7, 11, 6, 14, 15), + (2, 12, 0, 16, 17), (1, 13, 3, 19, 18),+ (4, 14, 6, 17, 16), (7, 15, 5, 18, 19),+ (4, 16, 0, 8, 9), (2, 17, 6, 11, 10),+ (1, 18, 5, 9, 8), (7, 19, 3, 10, 11)+ + ]+ + let faces2 = foldl (++) [] $ map ( \(a, b, c, d, e) -> [ (a, b, e), (b, d, e), (c, d, b) ] ) faces++ mo <- _createPlatonObject g3ds colour vertices faces2 0+ ManualObject.convertToMesh mo meshName "General"+ mesh <- SceneManager.createEntity3 scm meshName+ return $ ManualMesh meshName
+ HGamer3D/Graphics3D/Types.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE FlexibleContexts #-} + +-- 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. + +-- Types.hs + +-- | Basic types for the Graphics3D module +module HGamer3D.Graphics3D.Types ( + + -- * Basic Engine Entities + SceneManager (..), + ResourceGroupManager (..), + RootObject (..), + Viewport (..), + LogManager (..), + TextureManager (..), + Camera (..), + RenderTarget (..), + + Graphics3DSystem (..), + + -- * Type Definitions + Object3D (..), + Material (..), + Mesh (..), + +) + +where + +import HGamer3D.Data +import HGamer3D.Util + +-- | The material. Define how an object is looking. Currently we have materials from resources +data Material = ResourceMaterial String -- ^ a named material, already installed as a resource + +-- | The mesh. A mesh in HGamer3D is just that, a mesh loaded from a template, a manual mesh, or loaded from file. It comes with default +-- material, but 3D objects based on this can get other materials individually. +data Mesh = CubeMesh | -- ^ Cube Mesh-Type + PlaneMesh | -- ^ Plane Mesh-Type + SphereMesh | -- ^ Sphere Mesh-Type + ResourceMesh String | -- ^ Mesh resource loaded from file + ManualMesh String -- ^ Manual Mesh-Type, identified by name + +-- | The basic 3D object. Each object is a single instance, which can be displayed, moved, scaled, rotated, ... +-- Objects are created cloned from meshes (templates for ojbects) or manually, by manual object creation methods. +data Object3D = SingleObject3D Mesh HG3DClass | -- ^ a single object, consisting of a Mesh and a Node (Ogre) + CombinedObject3D [Object3D] HG3DClass -- ^ a combined object,consisting of many objects and a node for the combined one + +data SceneManager = SceneManager HG3DClass +data ResourceGroupManager = ResourceGroupManager HG3DClass +data RootObject = RootObject HG3DClass +data Viewport = Viewport HG3DClass +data TextureManager = TextureManager HG3DClass +data LogManager = LogManager HG3DClass +data Camera = Camera HG3DClass +data RenderTarget = RenderTarget HG3DClass + +data Graphics3DSystem = Graphics3DSystem { + g3dsRoot :: RootObject, + g3dsSceneManager :: SceneManager, + g3dsResourceGroupManager :: ResourceGroupManager, + g3dsLogManager :: LogManager, + g3dsTextureManager :: TextureManager, + g3dsRenderTarget :: RenderTarget, + g3dsUniqueName :: UniqueName +} +
+ LICENSE view
@@ -0,0 +1,42 @@+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 +------------------------------------------- + +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 module uses the following Haskell libraries from Hackage: + +base, license: BSD3 +containers, license: BSD3 +text, license: BSD3 +directory, license: BSD3 +mtl, license: BSD3 +FindBin, license: BSD3 +monad-loops, license: PublicDomain, BSD3 similar +split, license: BSD3 +netwire, license: BSD3 +HGamer3D-Data, license: Apache 2.0 +HGamer3D-Ogre-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-SFML-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-CEGUI-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-Enet-Binding, license: Apache 2.0 and dependencies see in that module
+ 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.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