diff options
-rw-r--r-- | Spear.lkshs | 10 | ||||
-rw-r--r-- | Spear.lkshw | 4 | ||||
-rw-r--r-- | Spear/Render/AnimatedModel.hs | 35 | ||||
-rw-r--r-- | Spear/Scene/GameObject.hs | 2 |
4 files changed, 32 insertions, 19 deletions
diff --git a/Spear.lkshs b/Spear.lkshs index 946985e..f2dd70a 100644 --- a/Spear.lkshs +++ b/Spear.lkshs | |||
@@ -1,18 +1,18 @@ | |||
1 | Version of session file format: | 1 | Version of session file format: |
2 | 1 | 2 | 1 |
3 | Time of storage: | 3 | Time of storage: |
4 | "Wed Aug 29 15:21:06 CEST 2012" | 4 | "Wed Aug 29 17:33:27 CEST 2012" |
5 | Layout: VerticalP (TerminalP {paneGroups = fromList [], paneTabs = Just TopP, currentPage = 1, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [("Browser",HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 312) 201)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 704) 954 | 5 | Layout: VerticalP (TerminalP {paneGroups = fromList [], paneTabs = Just TopP, currentPage = 2, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [("Browser",HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 286) 184)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 653) 954 |
6 | Population: [(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/AnimatedGO.hs" 605)),[SplitP LeftP]),(Just (ErrorsSt ErrorsState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Factory.hs" 1165)),[SplitP LeftP]),(Just (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 86)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject.hs" 61)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/App/Input.hs" 5198)),[SplitP LeftP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Just (ModuleName ["Spear","App","Input"]),Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0,0],[0]],[]), packageDExp = ([],[]), packageDExpNoBlack = ([],[]), workspaceExp = ([],[]), workspaceExpNoBlack = ([],[]), workspaceDExp = ([],[]), workspaceDExpNoBlack = ([],[]), systemExp = ([],[]), systemExpNoBlack = ([],[])}))),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Player.hs" 210)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/StaticGO.hs" 496)),[SplitP LeftP]),(Just (WorkspaceSt WorkspaceState),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP TopP])] | 6 | Population: [(Just (ErrorsSt ErrorsState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Factory.hs" 359)),[SplitP LeftP]),(Just (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 3133)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject.hs" 846)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/Loader.hs" 11796)),[SplitP LeftP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Just (ModuleName ["Game","GameObject","Player"]),Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0,1],[0,0],[0]],[]), packageDExp = ([],[]), packageDExpNoBlack = ([],[]), workspaceExp = ([],[]), workspaceExpNoBlack = ([],[]), workspaceDExp = ([],[]), workspaceDExpNoBlack = ([],[]), systemExp = ([],[]), systemExpNoBlack = ([],[])}))),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Player.hs" 0)),[SplitP LeftP]),(Just (WorkspaceSt WorkspaceState),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/main.hs" 886)),[SplitP LeftP])] |
7 | Window size: (1820,939) | 7 | Window size: (1820,939) |
8 | Completion size: | 8 | Completion size: |
9 | (750,399) | 9 | (750,399) |
10 | Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw" | 10 | Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw" |
11 | Active pane: Just "Factory.hs" | 11 | Active pane: Just "GameObject.hs(1)" |
12 | Toolbar visible: | 12 | Toolbar visible: |
13 | True | 13 | True |
14 | FindbarState: (False,FindState {entryStr = "asdad", entryHist = ["asdad","translv","Vector3.","Vector.","copy_tr","asad","Octree","idxs","elemIndexa","elemtIn","splitAt","allocaBytes"], replaceStr = "V3.", replaceHist = [], caseSensitive = True, entireWord = False, wrapAround = False, regex = False, lineNr = 1}) | 14 | FindbarState: (False,FindState {entryStr = "asdad", entryHist = ["asdad","translv","Vector3.","Vector.","copy_tr","asad","Octree","idxs","elemIndexa","elemtIn","splitAt","allocaBytes"], replaceStr = "V3.", replaceHist = [], caseSensitive = True, entireWord = False, wrapAround = False, regex = False, lineNr = 1}) |
15 | Recently opened files: | 15 | Recently opened files: |
16 | ["/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Player.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Scene.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/AnimatedModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/StaticModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Collisioner.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/Circle.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameState.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Render.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/main.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/MatrixUtils.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Loader.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/Matrix3.hs"] | 16 | ["/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Factory.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameState.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/main.hs","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model/Model.c","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model/Model.h","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model.hsc","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/AnimatedGO.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/StaticGO.hs","/home/jeanne/programming/haskell/Spear/Spear/App/Input.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Player.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Scene.hs"] |
17 | Recently opened workspaces: | 17 | Recently opened workspaces: |
18 | ["/home/jeanne/programming/haskell/hagen/hagen.lkshw","/home/jeanne/programming/haskell/foo/foo.lkshw","/home/jeanne/programming/haskell/Spear/Spear.lkshw","/home/jeanne/programming/haskell/nexus/nexus.lkshw","/home/jeanne/leksah.lkshw"] \ No newline at end of file | 18 | ["/home/jeanne/programming/haskell/hagen/hagen.lkshw","/home/jeanne/programming/haskell/foo/foo.lkshw","/home/jeanne/programming/haskell/Spear/Spear.lkshw","/home/jeanne/programming/haskell/nexus/nexus.lkshw","/home/jeanne/leksah.lkshw"] \ No newline at end of file |
diff --git a/Spear.lkshw b/Spear.lkshw index 128fcfd..b7737af 100644 --- a/Spear.lkshw +++ b/Spear.lkshw | |||
@@ -1,10 +1,10 @@ | |||
1 | Version of workspace file format: | 1 | Version of workspace file format: |
2 | 1 | 2 | 1 |
3 | Time of storage: | 3 | Time of storage: |
4 | "Wed Aug 29 17:13:01 CEST 2012" | 4 | "Wed Aug 29 17:58:31 CEST 2012" |
5 | Name of the workspace: | 5 | Name of the workspace: |
6 | "Spear" | 6 | "Spear" |
7 | File paths of contained packages: | 7 | File paths of contained packages: |
8 | ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] | 8 | ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] |
9 | Maybe file path of an active package: | 9 | Maybe file path of an active package: |
10 | Just "demos/simple-scene/simple-scene.cabal" \ No newline at end of file | 10 | Just "Spear.cabal" \ No newline at end of file |
diff --git a/Spear/Render/AnimatedModel.hs b/Spear/Render/AnimatedModel.hs index bdeb916..6e3c535 100644 --- a/Spear/Render/AnimatedModel.hs +++ b/Spear/Render/AnimatedModel.hs | |||
@@ -2,11 +2,14 @@ module Spear.Render.AnimatedModel | |||
2 | ( | 2 | ( |
3 | AnimatedModelResource | 3 | AnimatedModelResource |
4 | , AnimatedModelRenderer | 4 | , AnimatedModelRenderer |
5 | , AnimationSpeed | ||
5 | , animatedModelResource | 6 | , animatedModelResource |
6 | , animatedModelRenderer | 7 | , animatedModelRenderer |
7 | , Spear.Render.AnimatedModel.release | 8 | , Spear.Render.AnimatedModel.release |
8 | , setAnimation | 9 | , setAnimation |
9 | , currentAnimation | 10 | , currentAnimation |
11 | , animationSpeed | ||
12 | , setAnimationSpeed | ||
10 | , bind | 13 | , bind |
11 | , render | 14 | , render |
12 | , update | 15 | , update |
@@ -30,6 +33,9 @@ import Graphics.Rendering.OpenGL.Raw.Core31 | |||
30 | import Unsafe.Coerce (unsafeCoerce) | 33 | import Unsafe.Coerce (unsafeCoerce) |
31 | 34 | ||
32 | 35 | ||
36 | type AnimationSpeed = Float | ||
37 | |||
38 | |||
33 | -- | An animated model resource. | 39 | -- | An animated model resource. |
34 | -- | 40 | -- |
35 | -- Contains model data necessary to render an animated model. | 41 | -- Contains model data necessary to render an animated model. |
@@ -64,12 +70,13 @@ instance Ord AnimatedModelResource where | |||
64 | -- state changes by sorting 'AnimatedModelRenderer's by their underlying | 70 | -- state changes by sorting 'AnimatedModelRenderer's by their underlying |
65 | -- 'AnimatedModelResource' when rendering the scene. | 71 | -- 'AnimatedModelResource' when rendering the scene. |
66 | data AnimatedModelRenderer = AnimatedModelRenderer | 72 | data AnimatedModelRenderer = AnimatedModelRenderer |
67 | { modelResource :: AnimatedModelResource | 73 | { modelResource :: AnimatedModelResource |
68 | , currentAnim :: Int | 74 | , currentAnim :: Int |
69 | , frameStart :: Int | 75 | , frameStart :: Int |
70 | , frameEnd :: Int | 76 | , frameEnd :: Int |
71 | , currentFrame :: Int | 77 | , currentFrame :: Int |
72 | , frameProgress :: Float | 78 | , frameProgress :: Float |
79 | , animationSpeed :: Float | ||
73 | } | 80 | } |
74 | 81 | ||
75 | 82 | ||
@@ -135,13 +142,14 @@ release = Setup.release . rkey | |||
135 | 142 | ||
136 | 143 | ||
137 | -- | Create an 'AnimatedModelRenderer' from the given 'AnimatedModelResource'. | 144 | -- | Create an 'AnimatedModelRenderer' from the given 'AnimatedModelResource'. |
138 | animatedModelRenderer :: AnimatedModelResource -> AnimatedModelRenderer | 145 | animatedModelRenderer :: AnimationSpeed -> AnimatedModelResource -> AnimatedModelRenderer |
139 | animatedModelRenderer modelResource = AnimatedModelRenderer modelResource 0 0 0 0 0 | 146 | animatedModelRenderer animSpeed modelResource = |
147 | AnimatedModelRenderer modelResource 0 0 0 0 0 animSpeed | ||
140 | 148 | ||
141 | 149 | ||
142 | -- | Update the 'AnimatedModelRenderer'. | 150 | -- | Update the 'AnimatedModelRenderer'. |
143 | update dt (AnimatedModelRenderer model curAnim startFrame endFrame curFrame fp) = | 151 | update dt (AnimatedModelRenderer model curAnim startFrame endFrame curFrame fp s) = |
144 | AnimatedModelRenderer model curAnim startFrame endFrame curFrame' fp' | 152 | AnimatedModelRenderer model curAnim startFrame endFrame curFrame' fp' s |
145 | where f = fp + dt | 153 | where f = fp + dt |
146 | nextFrame = f >= 1.0 | 154 | nextFrame = f >= 1.0 |
147 | fp' = if nextFrame then f - 1.0 else f | 155 | fp' = if nextFrame then f - 1.0 else f |
@@ -166,6 +174,11 @@ currentAnimation :: Enum a => AnimatedModelRenderer -> a | |||
166 | currentAnimation = toEnum . currentAnim | 174 | currentAnimation = toEnum . currentAnim |
167 | 175 | ||
168 | 176 | ||
177 | -- | Set the renderer's animation speed. | ||
178 | setAnimationSpeed :: AnimationSpeed -> AnimatedModelRenderer -> AnimatedModelRenderer | ||
179 | setAnimationSpeed s r = r { animationSpeed = s } | ||
180 | |||
181 | |||
169 | -- | Bind the given 'AnimatedModelRenderer' to prepare it for rendering. | 182 | -- | Bind the given 'AnimatedModelRenderer' to prepare it for rendering. |
170 | bind :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO () | 183 | bind :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO () |
171 | bind (AnimatedProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _ _) modelRend = | 184 | bind (AnimatedProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _ _) modelRend = |
@@ -179,7 +192,7 @@ bind (AnimatedProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _ _) modelRend | |||
179 | 192 | ||
180 | -- | Render the model described by the given 'AnimatedModelRenderer'. | 193 | -- | Render the model described by the given 'AnimatedModelRenderer'. |
181 | render :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO () | 194 | render :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO () |
182 | render uniforms (AnimatedModelRenderer model _ _ _ curFrame fp) = | 195 | render uniforms (AnimatedModelRenderer model _ _ _ curFrame fp _) = |
183 | let n = nVertices model | 196 | let n = nVertices model |
184 | (Material _ ka kd ks shi) = material model | 197 | (Material _ ka kd ks shi) = material model |
185 | in do | 198 | in do |
diff --git a/Spear/Scene/GameObject.hs b/Spear/Scene/GameObject.hs index 9f4d950..2efadf0 100644 --- a/Spear/Scene/GameObject.hs +++ b/Spear/Scene/GameObject.hs | |||
@@ -119,7 +119,7 @@ goNew style (Left smr) col transf = | |||
119 | goUpdate' style (Left $ SM.staticModelRenderer smr) col transf 0 | 119 | goUpdate' style (Left $ SM.staticModelRenderer smr) col transf 0 |
120 | 120 | ||
121 | goNew style (Right amr) col transf = | 121 | goNew style (Right amr) col transf = |
122 | goUpdate' style (Right $ AM.animatedModelRenderer amr) col transf 0 | 122 | goUpdate' style (Right $ AM.animatedModelRenderer 1 amr) col transf 0 |
123 | 123 | ||
124 | 124 | ||
125 | goUpdate' :: GameStyle | 125 | goUpdate' :: GameStyle |