diff options
-rw-r--r-- | Spear.lkshs | 12 | ||||
-rw-r--r-- | Spear.lkshw | 2 | ||||
-rw-r--r-- | Spear/Assets/Model.hsc | 34 | ||||
-rw-r--r-- | Spear/Assets/Model/Model.c | 8 | ||||
-rw-r--r-- | Spear/Render/AnimatedModel.hs | 6 | ||||
-rw-r--r-- | Spear/Render/StaticModel.hs | 6 |
6 files changed, 36 insertions, 32 deletions
diff --git a/Spear.lkshs b/Spear.lkshs index 29bc011..41fc6c7 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 20:11:59 CEST 2012" | 4 | "Thu Aug 30 15:57:16 CEST 2012" |
5 | Layout: VerticalP (TerminalP {paneGroups = fromList [], paneTabs = Just TopP, currentPage = 4, 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}) 298) 192)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 678) 954 | 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}) 287) 184)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 654) 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 (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 3309)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject.hs" 831)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameState.hs" 0)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Math/MatrixUtils.hs" 1173)),[SplitP LeftP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Just (ModuleName ["Spear","Math","Matrix4"]),Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0,4],[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" 636)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/StaticGO.hs" 437)),[SplitP LeftP]),(Just (WorkspaceSt WorkspaceState),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP TopP])] | 6 | Population: [(Just (ErrorsSt ErrorsState),[SplitP RightP,SplitP TopP]),(Just (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 359)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Nothing,Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0,1],[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" 636)),[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" 5372)),[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 "MatrixUtils.hs" | 11 | Active pane: Just "Workspace" |
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 = "\170", entryHist = ["\170","\\","^","scale","Vector4.","asdad","translv","Vector3.","Vector.","copy_tr","asad","Octree"], 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/Spear/GLSL/Uniform.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/Matrix3.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/Matrix4.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/MatrixUtils.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/AnimatedModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Loader.hs","/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"] | 16 | ["/home/jeanne/programming/haskell/Spear/Spear/Assets/Model/OBJ/OBJ_load.c","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model/MD2/MD2_load.c","/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/Spear/App/Application.hs","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model.hsc","/home/jeanne/programming/haskell/Spear/Spear/Assets/Model/Model.c","/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameState.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/StaticModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/Camera.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/AnimatedGO.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 24a6e94..3021a3b 100644 --- a/Spear.lkshw +++ b/Spear.lkshw | |||
@@ -1,7 +1,7 @@ | |||
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 | "Thu Aug 30 12:51:30 CEST 2012" | 4 | "Thu Aug 30 15:57:13 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: |
diff --git a/Spear/Assets/Model.hsc b/Spear/Assets/Model.hsc index 525d377..f1adfd7 100644 --- a/Spear/Assets/Model.hsc +++ b/Spear/Assets/Model.hsc | |||
@@ -157,26 +157,30 @@ instance Storable CTriangle where | |||
157 | #{poke triangle, textureIndices[2]} ptr t2 | 157 | #{poke triangle, textureIndices[2]} ptr t2 |
158 | 158 | ||
159 | 159 | ||
160 | -- | A 2D axis-aligned bounding box. | 160 | -- | A 3D axis-aligned bounding box. |
161 | data Box = Box {-# UNPACK #-} !Vec2 {-# UNPACK #-} !Vec2 | 161 | data Box = Box {-# UNPACK #-} !Vec3 {-# UNPACK #-} !Vec3 |
162 | 162 | ||
163 | 163 | ||
164 | instance Storable Box where | 164 | instance Storable Box where |
165 | sizeOf _ = 4 * sizeFloat | 165 | sizeOf _ = 6 * sizeFloat |
166 | alignment _ = alignment (undefined :: CFloat) | 166 | alignment _ = alignment (undefined :: CFloat) |
167 | 167 | ||
168 | peek ptr = do | 168 | peek ptr = do |
169 | f0 <- peekByteOff ptr 0 | 169 | xmin <- peekByteOff ptr 0 |
170 | f1 <- peekByteOff ptr sizeFloat | 170 | ymin <- peekByteOff ptr sizeFloat |
171 | f2 <- peekByteOff ptr $ 2*sizeFloat | 171 | zmin <- peekByteOff ptr $ 2*sizeFloat |
172 | f3 <- peekByteOff ptr $ 3*sizeFloat | 172 | xmax <- peekByteOff ptr $ 3*sizeFloat |
173 | return $ Box (Vec2 f0 f1) (Vec2 f2 f3) | 173 | ymax <- peekByteOff ptr $ 4*sizeFloat |
174 | zmax <- peekByteOff ptr $ 5*sizeFloat | ||
175 | return $ Box (Vec3 xmin ymin zmin) (Vec3 xmax ymax zmax) | ||
174 | 176 | ||
175 | poke ptr (Box (Vec2 f0 f1) (Vec2 f2 f3)) = do | 177 | poke ptr (Box (Vec3 xmin ymin zmin) (Vec3 xmax ymax zmax)) = do |
176 | pokeByteOff ptr 0 f0 | 178 | pokeByteOff ptr 0 xmin |
177 | pokeByteOff ptr sizeFloat f1 | 179 | pokeByteOff ptr sizeFloat ymin |
178 | pokeByteOff ptr (2*sizeFloat) f2 | 180 | pokeByteOff ptr (2*sizeFloat) zmin |
179 | pokeByteOff ptr (3*sizeFloat) f3 | 181 | pokeByteOff ptr (3*sizeFloat) xmax |
182 | pokeByteOff ptr (4*sizeFloat) ymax | ||
183 | pokeByteOff ptr (5*sizeFloat) zmax | ||
180 | 184 | ||
181 | 185 | ||
182 | -- | A model skin. | 186 | -- | A model skin. |
@@ -448,11 +452,11 @@ foreign import ccall "Model.h model_to_ground" | |||
448 | model_to_ground :: Ptr Model -> IO () | 452 | model_to_ground :: Ptr Model -> IO () |
449 | 453 | ||
450 | 454 | ||
451 | -- | Get the model's 2D bounding boxes. | 455 | -- | Get the model's 3D bounding boxes. |
452 | modelBoxes :: Model -> IO (V.Vector Box) | 456 | modelBoxes :: Model -> IO (V.Vector Box) |
453 | modelBoxes model = | 457 | modelBoxes model = |
454 | with model $ \modelPtr -> | 458 | with model $ \modelPtr -> |
455 | allocaArray (numVerts model * numFrames model * 4) $ \pointsPtr -> do | 459 | allocaArray (numVerts model * numFrames model * 6) $ \pointsPtr -> do |
456 | model_compute_boxes modelPtr pointsPtr | 460 | model_compute_boxes modelPtr pointsPtr |
457 | let n = numFrames model | 461 | let n = numFrames model |
458 | getBoxes = peekBoxes pointsPtr n 0 0 $ return [] | 462 | getBoxes = peekBoxes pointsPtr n 0 0 $ return [] |
diff --git a/Spear/Assets/Model/Model.c b/Spear/Assets/Model/Model.c index d315da1..ff5e758 100644 --- a/Spear/Assets/Model/Model.c +++ b/Spear/Assets/Model/Model.c | |||
@@ -92,17 +92,21 @@ void model_compute_boxes (Model* model, float* points) | |||
92 | float xmax = v->x; | 92 | float xmax = v->x; |
93 | float ymin = v->y; | 93 | float ymin = v->y; |
94 | float ymax = v->y; | 94 | float ymax = v->y; |
95 | float zmin = v->z; | ||
96 | float zmax = v->z; | ||
95 | 97 | ||
96 | unsigned i; | 98 | unsigned i; |
97 | for (i = 0; i < model->numVertices; ++i, ++v) | 99 | for (i = 0; i < model->numVertices; ++i, ++v) |
98 | { | 100 | { |
99 | xmin = fmin (xmin, v->x); | 101 | xmin = fmin (xmin, v->x); |
100 | ymin = fmin (ymin, v->y); | 102 | ymin = fmin (ymin, v->y); |
103 | zmin = fmin (zmin, v->z); | ||
101 | xmax = fmax (xmax, v->x); | 104 | xmax = fmax (xmax, v->x); |
102 | ymax = fmax (ymax, v->y); | 105 | ymax = fmax (ymax, v->y); |
106 | zmax = fmax (zmax, v->z); | ||
103 | } | 107 | } |
104 | 108 | ||
105 | *points++ = xmin; *points++ = ymin; | 109 | *points++ = xmin; *points++ = ymin; *points++ = zmin; |
106 | *points++ = xmax; *points++ = ymax; | 110 | *points++ = xmax; *points++ = ymax; *points++ = zmax; |
107 | } | 111 | } |
108 | } | 112 | } |
diff --git a/Spear/Render/AnimatedModel.hs b/Spear/Render/AnimatedModel.hs index 552fada..091f97d 100644 --- a/Spear/Render/AnimatedModel.hs +++ b/Spear/Render/AnimatedModel.hs | |||
@@ -204,7 +204,5 @@ render uniforms (AnimatedModelRenderer model _ _ _ curFrame fp _) = | |||
204 | 204 | ||
205 | 205 | ||
206 | -- | Get the model's ith bounding box. | 206 | -- | Get the model's ith bounding box. |
207 | box :: Int -> AnimatedModelResource -> AABB | 207 | box :: Int -> AnimatedModelResource -> Box |
208 | box i model = | 208 | box i model = boxes model V.! i |
209 | let (Box (Vec2 xmin ymin) (Vec2 xmax ymax)) = boxes model V.! i | ||
210 | in AABB (vec2 xmin ymin) (vec2 xmax ymax) | ||
diff --git a/Spear/Render/StaticModel.hs b/Spear/Render/StaticModel.hs index ddf574d..ea0606f 100644 --- a/Spear/Render/StaticModel.hs +++ b/Spear/Render/StaticModel.hs | |||
@@ -130,7 +130,5 @@ render uniforms (StaticModelRenderer model) = | |||
130 | 130 | ||
131 | 131 | ||
132 | -- | Get the model's ith bounding box. | 132 | -- | Get the model's ith bounding box. |
133 | box :: Int -> StaticModelResource -> AABB | 133 | box :: Int -> StaticModelResource -> Box |
134 | box i model = | 134 | box i model = boxes model V.! i |
135 | let (Box (Vec2 xmin ymin) (Vec2 xmax ymax)) = boxes model V.! i | ||
136 | in AABB (vec2 xmin ymin) (vec2 xmax ymax) | ||