packages feed

HGamer3D-API 0.1.3 → 0.1.4

raw patch · 2 files changed

+51/−34 lines, 2 filesdep ~HGamer3D-Datadep ~HGamer3D-OIS-Bindingdep ~HGamer3D-Ogre-Binding

Dependency ranges changed: HGamer3D-Data, HGamer3D-OIS-Binding, HGamer3D-Ogre-Binding

Files

HGamer3D-API.cabal view
@@ -1,5 +1,5 @@ Name:                HGamer3D-API
-Version:             0.1.3
+Version:             0.1.4
 Synopsis:            Library to enable 3D game development for Haskell - API
 Description:         
 	Library, to enable 3D game development for Haskell,
@@ -24,7 +24,7 @@ Extra-source-files:  Setup.hs 
 
 Library
-  Build-Depends:     base >= 3 && < 5, HGamer3D-Data == 0.1.3, HGamer3D-Ogre-Binding == 0.1.3, HGamer3D-OIS-Binding == 0.1.3
+  Build-Depends:     base >= 3 && < 5, HGamer3D-Data == 0.1.4, HGamer3D-Ogre-Binding == 0.1.4, HGamer3D-OIS-Binding == 0.1.4
 
   Exposed-modules:   HGamer3D.APIs.One
   Other-modules:     
HGamer3D/APIs/One.hs view
@@ -34,11 +34,13 @@ 	-- Data types
 	-------------
 	
-	ColourValue (ColourValue),
-	Quaternion (Quaternion),
-	Vector3 (Vector3),
-	Radian (Radian),
-	Degree (Degree),
+	module HGamer3D.Data.Colour,
+	module HGamer3D.Data.Quaternion,
+	module HGamer3D.Data.Vector2,
+	module HGamer3D.Data.Vector3,
+	module HGamer3D.Data.Vector4,
+	module HGamer3D.Data.Matrix4,
+	module HGamer3D.Data.Angle,
 
 
 	-- Data types - basic systems
@@ -72,6 +74,7 @@ 	initializeHG3D,	
 	
 	-- Camera
+	getCameraPos,
 	setCameraPos,
 	setCameraLookAt,
 	
@@ -87,7 +90,7 @@ 
 
 	-- Graphics Object Functions
-	scale,
+	HGamer3D.APIs.One.scale,
 	translate,
 	roll,
 	pitch,
@@ -145,13 +148,15 @@ 
 import HGamer3D.Bindings.Ogre.Utils
 
-import HGamer3D.Data.ColourValue
+import HGamer3D.Data.Colour
 import HGamer3D.Data.Quaternion
+import HGamer3D.Data.Vector2
 import HGamer3D.Data.Vector3
-import HGamer3D.Data.Radian
-import HGamer3D.Data.Degree
+import HGamer3D.Data.Vector4
+import HGamer3D.Data.Matrix4
+import HGamer3D.Data.Angle
 
-import HGamer3D.Bindings.Ogre.TypeColourValue
+import HGamer3D.Bindings.Ogre.TypeColour
 import HGamer3D.Bindings.Ogre.TypeQuaternion
 import HGamer3D.Bindings.Ogre.TypeVector3
 import HGamer3D.Bindings.Ogre.TypeSharedPtr
@@ -192,8 +197,6 @@ 
 import HGamer3D.Bindings.OIS.TypeHG3DClass
 
-import HGamer3D.Data.Vector3
-import HGamer3D.Data.Quaternion
 import HGamer3D.Data.HG3DClass
 
 
@@ -254,8 +257,8 @@ getNewNode :: EngineSystem -> IO (Node)
 getNewNode es = do
 	rootNode <- cSmGetRootSceneNode (esSceneManager es)
-	let vzero = Vector3 0.0 0.0 0.0
-	let qident = Quaternion 1.0 0.0 0.0 0.0
+	let vzero = vector3 0.0 0.0 0.0
+	let qident = Quaternion 1.0 (vector3 0.0 0.0 0.0)
 	node <- cSnCreateChildSceneNode rootNode vzero qident
 	return (Node node)
 
@@ -337,7 +340,7 @@ 		
 	
 		viewport <- cRtAddViewport renderWindow camera 0 0.0 0.0 1.0 1.0
-		let bgColor = ColourValue 0.0 0.0 0.0 1.0
+		let bgColor = Colour 0.0 0.0 0.0 1.0
 		cVpSetBackgroundColour viewport bgColor
 		
 		height <- cVpGetActualHeight viewport
@@ -362,7 +365,13 @@ 
 -- camera functions
 
--- |Postions the camera
+-- |Get Postion of the camera
+getCameraPos :: ViewSystem -> IO (Vector3)
+getCameraPos vs = do
+	pos <- cCGetPosition (vsCamera vs)
+	return (pos)
+
+-- |Set Postion of the camera
 setCameraPos :: ViewSystem -> Vector3 -> IO ()
 setCameraPos vs pos = do
 	cCSetPosition2 (vsCamera vs)  pos
@@ -376,20 +385,20 @@ -- light functions
 
 -- | creates a light, which fills all the room with similar strength
-createAmbientLight :: EngineSystem -> ColourValue -> IO () 
+createAmbientLight :: EngineSystem -> Colour -> IO () 
 createAmbientLight es colour = do
 	cSmSetAmbientLight (esSceneManager es) colour
 	return ()
 	
 -- | creates a point light at a specific location
 createLight :: EngineSystem -> String -- ^Name of the light
-		-> ColourValue -- ^Color of the light
+		-> Colour -- ^Color of the light
 		-> Vector3 -- ^Position, where light is created
 		-> IO (GraphicsObject) -- ^Return value is a graphics object
-createLight es lightName colour (Vector3 x y z) = do
+createLight es lightName colour v = do
 	cSmSetAmbientLight (esSceneManager es) colour
 	light <- cSmCreateLight (esSceneManager es) lightName
-	cLSetPosition light x y z
+	cLSetPosition light (v3X v) (v3Y v) (v3Z v)
 	return (LightObject (Light lightName light))
 	
 
@@ -400,7 +409,7 @@ createLine :: EngineSystem -- ^The engine system
 		-> String -- ^The name of the line object
 		-> String -- ^The material used for the line
-		-> ColourValue -- ^The color of the line
+		-> Colour -- ^The color of the line
 		-> Vector3 -- ^The start point of the line
 		-> Vector3 -- ^The end point of the line
 		-> IO (MeshTemplate) -- ^Return value is a graphics object
@@ -420,7 +429,7 @@ createCube :: EngineSystem -- ^The engine system 
 		-> String -- ^The name of the cube object 
 		-> String -- ^The material used for the cube 
-		-> ColourValue -- ^The color of the line 
+		-> Colour -- ^The color of the line 
 		-> IO (MeshTemplate) -- ^Return value is a graphics object
 createCube es cubeName materialName colour = do
 	mo <- cSmCreateManualObject (esSceneManager es) cubeName
@@ -515,25 +524,25 @@ 	return () 
 
 --	roll
-roll :: GraphicsObject -> Radian -> EnumTransformSpace -> IO ()
+roll :: GraphicsObject -> Radians -> EnumTransformSpace -> IO ()
 roll go r ets = do
 	cNRoll (getNodeFromGo go) r ets
 	return () 
 
 --	pitch
-pitch :: GraphicsObject -> Radian -> EnumTransformSpace -> IO ()
+pitch :: GraphicsObject -> Radians -> EnumTransformSpace -> IO ()
 pitch go r ets = do
 	cNPitch (getNodeFromGo go) r ets
 	return () 
 
 --	yaw
-yaw :: GraphicsObject -> Radian -> EnumTransformSpace -> IO ()
+yaw :: GraphicsObject -> Radians -> EnumTransformSpace -> IO ()
 yaw go r ets = do
 	cNYaw (getNodeFromGo go) r ets
 	return () 
 
 --	rotate
-rotate :: GraphicsObject -> Vector3 -> Radian -> EnumTransformSpace -> IO ()
+rotate :: GraphicsObject -> Vector3 -> Radians -> EnumTransformSpace -> IO ()
 rotate go v r ets = do
 	cNRotate (getNodeFromGo go) v r ets
 	return () 
@@ -709,19 +718,27 @@ 	val <- cAaaGetRelativeValue action
 	return (val)
 	
--- renderLoop function
+-- renderStep a :: EngineSystem -> ViewSystem -> InputSystem -> Time -> a -> IO (Bool, a)
 
-renderLoop :: EngineSystem -> ViewSystem -> InputSystem -> Time -> (EngineSystem -> ViewSystem -> InputSystem -> IO ()) -> IO ()
-renderLoop es vs is (Time lastTime) stepFunc = do
+renderInternalStep :: EngineSystem -> ViewSystem -> InputSystem -> Time -> IO (Bool, Time)
+renderInternalStep es vs is (Time lastTime) = do
 	(Time time) <- getTime es
 	let delta = time - lastTime
 	runIsFrame is delta
 	fUMessagePump
 	closed <- cRwIsClosed (vsRenderWindow vs)
 	if (closed) then
-		return ()
+		return (False, (Time time))
 		else do
 			cRRenderOneFrame (esRoot es)
-			stepFunc es vs is
-			renderLoop es vs is (Time time) stepFunc
+			return (True, (Time time))
+
+renderLoop :: EngineSystem -> ViewSystem -> InputSystem -> Time -> a -> (EngineSystem -> ViewSystem -> InputSystem -> Time -> a -> IO (Bool, a)) -> IO ()
+renderLoop es vs is t a renderStep = do
+	(flagStep, time) <- renderInternalStep es vs is t
+	(flagLoop, a) <- renderStep es vs is time a
+	if (flagStep && flagLoop) then do
+		renderLoop es vs is time a renderStep
+		else return ()
+