packages feed

HGamer3D-Graphics3D 0.3.0 → 0.3.1

raw patch · 3 files changed

+19/−12 lines, 3 files

Files

HGamer3D-Graphics3D.cabal view
@@ -1,5 +1,5 @@ Name:                HGamer3D-Graphics3D
-Version:             0.3.0
+Version:             0.3.1
 Synopsis:            3D Graphics Functionality for HGamer3D
 Description:         
 	HGamer3D is a game engine for developing 3D games in the programming 
HGamer3D/Graphics3D/Light.hs view
@@ -30,9 +30,9 @@         
     -- * create and modify light sources
 	HGamer3D.Graphics3D.Light.setAmbientLight,
-	pointlight,
-	spotlight,
-	setSpotlightAngle,
+	pointLight,
+	spotLight,
+	setSpotLightAngle,
 	directionalLight
 ) 
 
@@ -126,12 +126,12 @@ 	
 
 -- | creates a point light at a specific location
-pointlight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D
+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
+pointLight g3ds (Colour r g b al) (Vec3 x y z) = do
 	let (SceneManager scm) = (g3dsSceneManager g3ds)
 	lightName <- nextUniqueName (g3dsUniqueName g3ds)
 	
@@ -144,11 +144,11 @@ 	return eo
 
 -- | creates a spot light at a specific location
-spotlight :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D
+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
+spotLight g3ds (Colour r g b al) (Vec3 x y z) = do
 	let (SceneManager scm) = (g3dsSceneManager g3ds)
 	lightName <- nextUniqueName (g3dsUniqueName g3ds)
 	
@@ -161,10 +161,10 @@ 	return eo
 
 -- | set the angle of a spotlight
-setSpotlightAngle :: Light -- ^ spotlight
+setSpotLightAngle :: Light -- ^ spotlight
 					-> Angle -- ^ angle of the light cone, should be between 5 and 355 degree
 					-> IO ()
-setSpotlightAngle (Light light) a = do
+setSpotLightAngle (Light light) a = do
 	if (a >= (Deg 5)) && (a <= (Deg 355))
 		then do
 			let innerAngle = fromAngle $ a `subA` (Deg 4.5)
@@ -182,7 +182,7 @@                     -> Vec3 -- ^ Position, where light is created
                     -> IO (Light) -- ^ The light object
 		
-directionalLight g3ds (Colour t r g b) (Vec3 x y z) = do
+directionalLight g3ds (Colour r g b al) (Vec3 x y z) = do
 	let (SceneManager scm) = (g3dsSceneManager g3ds)
 	lightName <- nextUniqueName (g3dsUniqueName g3ds)
 	
HGamer3D/Graphics3D/Object3D.hs view
@@ -78,6 +78,7 @@ 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.ClassHG3DUtilities as HG3DUtils
 
 import HGamer3D.Bindings.Ogre.ClassManualObject as ManualObject
 import HGamer3D.Bindings.Ogre.EnumRenderOperationOperationType
@@ -127,8 +128,9 @@ object3DFromMesh :: Graphics3DSystem -- ^ the Graphics3D system object, returned by initGraphics3D
                           -> Mesh -- ^ mesh used for creation
                           -> Maybe Material -- ^ a material to be applied, if needed
+                          -> Bool -- ^ flag, build tangent vectors, if set
                           -> IO Object3D -- ^ created 3d object
-object3DFromMesh g3ds mesh mbMaterial = do
+object3DFromMesh g3ds mesh mbMaterial buildTV = do
 	let (SceneManager scm) = (g3dsSceneManager g3ds)
         -- create the entity from the mesh
         entity <- case mesh of
@@ -137,6 +139,11 @@           PlaneMesh -> SceneManager.createEntity6 scm PT_PLANE
           ResourceMesh resourceName -> SceneManager.createEntity3 scm resourceName
           ManualMesh meshName -> SceneManager.createEntity3 scm meshName
+        -- create tangent vectors
+        if buildTV then 
+          HG3DUtils.buildTangentVectors entity
+          else
+            return ()
         -- apply material, if needed, wanted
         case mbMaterial of
           Just material -> _setMaterial entity material