]> Dogcows Code - chaz/yoink/commitdiff
scene drawing correctly implemented; new classes
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 14 Aug 2009 16:37:40 +0000 (10:37 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 14 Aug 2009 16:37:40 +0000 (10:37 -0600)
27 files changed:
configure.ac
data/scenes/Test.xml [deleted file]
src/Character.cc
src/Character.hh
src/Makefile.am
src/Moof/Aabb.cc [new file with mode: 0644]
src/Moof/Aabb.hh
src/Moof/Camera.cc [new file with mode: 0644]
src/Moof/Camera.hh
src/Moof/Cullable.hh
src/Moof/Drawable.hh
src/Moof/Entity.hh [moved from src/Moof/Profiler.hh with 73% similarity]
src/Moof/Frustum.hh [new file with mode: 0644]
src/Moof/Interpolator.hh
src/Moof/Octree.hh [new file with mode: 0644]
src/Moof/OpenGL.cc
src/Moof/OpenGL.hh
src/Moof/Plane.hh [new file with mode: 0644]
src/Moof/Scene.cc
src/Moof/Scene.hh
src/Moof/Texture.cc
src/Moof/Texture.hh
src/Moof/Tilemap.cc
src/Moof/Tilemap.hh
src/Moof/Tree.hh [new file with mode: 0644]
src/YoinkApp.cc
src/YoinkApp.hh

index 4aafa8126d55e5676bdb01b23546faa69dc5efec..9267e807d9756934773b1a42cc19f172acc6505b 100644 (file)
@@ -73,10 +73,10 @@ AC_SUBST([DATADIR])
 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
                                   [Define to path of game asset directory.])
 
-CONFIGFILES="\$HOME/.yoinkrc:/etc/yoinkrc:$DATADIR/yoinkrc"
+CONFIGFILES="\$HOME/.yoinkrc:/etc/yoinkrc"
 
 AC_DEFINE_UNQUOTED([YOINK_CONFIGFILES], ["$CONFIGFILES"],
-                                  [Define to colon-delimited config file paths.])
+                                  [Define to colon-delimited configuration file paths.])
 
 
 #
diff --git a/data/scenes/Test.xml b/data/scenes/Test.xml
deleted file mode 100644 (file)
index fa92959..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-<?xml version="1.0" standalone="yes"?> 
-<scene name="Test" playfield_bounds="0 0 -100 1280 500 100"
-       maximum_bounds="-800 0 -300 2400 1000 600">
-
-<!-- Left end tower block -->
-
-       <!-- Front -->
-
-       <reset_transform/>
-       <translate>-5 0 5</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="5">
-               2       2       2       2       2
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               1       0       0       1       0
-               4       4       4       4       4
-       </tilemap>
-
-       <!-- Right side -->
-
-       <reset_transform/>
-       <rotate axis="y">90</rotate>
-       <translate>0 0 5</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="right" width="5">
-               2       2       2       2       2
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       6
-               4       5       5       5       4
-       </tilemap>
-
-       <!-- Top -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>-5 15 0</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="top" width="5">
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-       </tilemap>
-
-<!-- Leftmost background tower block -->
-
-       <!-- Front -->
-
-       <reset_transform/>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="7" detail_level="1">
-               2       2       2       2       2       2       2
-               0       1       0       0       0       1       0
-               0       1       0       0       0       1       0
-               0       1       0       0       6       1       0
-               0       1       0       0       0       1       0
-               0       1       0       0       0       1       0
-               0       1       0       0       0       1       0
-               4       4       5       5       5       4       4
-       </tilemap>
-
-       <!-- Right side -->
-
-       <reset_transform/>
-       <rotate axis="y">90</rotate>
-       <translate>7 0 0</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="6" detail_level="1">
-               2       2       2       2       2       2
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               4       4       4       4       4       4
-       </tilemap>
-
-       <!-- Top -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>-2 8 -6</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="9" detail_level="1">
-               3       3       3       3       3       3       3       3       3
-               3       3       3       3       3       3       3       3       3
-               3       3       3       3       3       3       3       3       3
-               3       3       3       3       3       3       3       3       3
-               3       3       3       3       3       3       3       3       3
-               3       3       3       3       3       3       3       3       3
-       </tilemap>
-
-<!-- Foreground building with pitched roof -->
-
-       <!-- Left wall -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>10 0 1</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap surface_type="left" width="4">
-               -1      9       11      -1
-               9       10      12      11
-               15      7       7       16
-               3       5       6       4
-               3       6       5       4
-       </tilemap>
-
-       <!-- Right wall -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>13 0 1</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap surface_type="right" width="4">
-               -1      9       11      -1
-               9       10      12      11
-               15      7       7       16
-               3       5       6       4
-               3       8       5       4
-       </tilemap>
-
-       <!-- Front wall -->
-
-       <reset_transform/>
-       <translate>10 0 5</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3">
-               15      7       16
-               3       5       4
-               3       6       4
-       </tilemap>
-
-       <!-- Pitched roof -->
-
-       <reset_transform/>
-       <rotate axis="x">135</rotate>
-       <scale>1 1.5 1.5</scale>
-       <translate>10 5 3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3">
-               13      13      13
-               13      13      13
-       </tilemap>
-
-       <!-- Finial -->
-
-       <reset_transform/>
-       <translate>10 5 3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3">
-               18      18      18
-       </tilemap>
-
-       <!-- Cheaty invisible platform -->
-
-       <reset_transform/>
-       <translate>10 4 3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap surface_type="top" width="3">
-               -1      -1      -1
-       </tilemap>
-
-<!-- The ground -->
-
-       <!-- Courtyard -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>-3 0 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="13">
-               1       1       1       1       1       1       1       1       1       1       1       1       1
-               1       1       1       1       1       1       1       1       1       1       1       1       1
-               -1      -1      -1      1       0       0       0       0       0       0       0       0       1
-               -1      -1      -1      1       0       0       0       0       0       0       0       0       1
-               -1      -1      -1      1       0       0       0       0       0       0       0       0       1
-               -1      -1      -1      1       0       0       0       0       0       0       0       0       1
-               -1      -1      -1      1       1       1       1       1       1       1       1       1       1
-       </tilemap>
-
-       <!-- Front grass -->
-
-       <reset_transform/>
-       <scale>8 1 1</scale>
-       <translate>1 -0.5 5</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="8" detail_level="2"/>
-
-       <!-- Back grass -->
-
-       <reset_transform/>
-       <scale>8 1 1</scale>
-       <translate>1 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="8" detail_level="2"/>
-
-       <!-- Left grass -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>1 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Right grass -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>9 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Fence behind house -->
-
-       <reset_transform/>
-       <scale>11 1 1</scale>
-       <translate>7 0 0</translate>
-       <scale>32</scale>
-
-       <texture>Scenery</texture>
-       <billboard tile="4" u_scale="11" detail_level="2"/>
-
-<!-- Background building with pitched roof -->
-
-       <!-- Front wall -->
-
-       <reset_transform/>
-       <translate>19 0 0</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="4" detail_level="1">
-               -1      9       11      -1
-               9       10      12      11
-               15      7       7       16
-               3       6       5       4
-               3       5       6       4
-               3       8       5       4
-       </tilemap>
-
-       <!-- Left wall -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>19 0 -3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap surface_type="left" width="3" detail_level="1">
-               15      1       16
-               3       7       4
-               3       5       4
-               3       0       4
-       </tilemap>
-
-       <!-- Right wall -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>23 0 -3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap surface_type="right" width="3" detail_level="1">
-               15      0       16
-               3       7       4
-               3       6       4
-               3       2       4
-       </tilemap>
-
-       <!-- Left pitched roof -->
-
-       <reset_transform/>
-       <rotate axis="x">135</rotate>
-       <scale>1 1.5 1.5</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>21 6 -3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3" detail_level="1">
-               13      13      13
-               13      13      13
-       </tilemap>
-
-       <!-- Right pitched roof -->
-
-       <reset_transform/>
-       <rotate axis="x">-135</rotate>
-       <scale>1 1.5 1.5</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>21 6 -3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3" detail_level="1">
-               13      13      13
-               13      13      13
-       </tilemap>
-
-       <!-- Finial -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>21 6 -3</translate>
-       <scale>32</scale>
-
-       <texture>Building</texture>
-       <tilemap width="3" detail_level="1">
-               18      18      18
-       </tilemap>
-
-<!-- More ground to the right -->
-
-       <!-- Ground under house -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>10 0 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="3">
-               1       1       1
-               1       1       1
-               -1      -1      -1
-               -1      -1      -1
-               -1      -1      -1
-               -1      -1      -1
-               1       1       1
-       </tilemap>
-
-       <!-- Left part of centre courtyard -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>13 0 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="8">
-               1       1       1       1       1       1       1       1
-               1       1       1       1       1       1       1       1
-               1       0       0       0       0       0       0       0
-               1       0       0       0       0       0       1       1
-               0       0       0       0       0       0       1       1
-               1       0       0       0       0       0       0       0
-               1       1       1       1       1       0       0       0
-       </tilemap>
-
-       <!-- Front grass -->
-
-       <reset_transform/>
-       <scale>12 1 1</scale>
-       <translate>14 -0.5 5</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="12" detail_level="2"/>
-
-       <!-- Back grass -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <translate>14 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Front grass next to door -->
-
-       <reset_transform/>
-       <scale>1 1 1</scale>
-       <translate>13 -0.5 3</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="1" detail_level="2"/>
-
-       <!-- Back grass next to door -->
-
-       <reset_transform/>
-       <scale>1 1 1</scale>
-       <translate>13 -0.5 2</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="1" detail_level="2"/>
-
-       <!-- Left grass -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <translate>14 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap width="4" detail_level="2">
-               2       -1      2       2
-       </tilemap>
-
-       <!-- Grass left of house -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <scale>1 1 1</scale>
-       <translate>18 -0.5 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="1" detail_level="2"/>
-
-       <!-- Grass right of house -->
-
-       <reset_transform/>
-       <rotate axis="y">-90</rotate>
-       <scale>1 1 1</scale>
-       <translate>24 -0.5 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="1" detail_level="2"/>
-
-       <!-- Front grass in centre -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <translate>19 -0.5 4</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Back grass in centre -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <translate>19 -0.5 2</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Left grass in centre -->
-
-       <reset_transform/>
-       <scale>2 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>19 -0.5 2</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="2" detail_level="2"/>
-
-       <!-- Right grass in centre -->
-
-       <reset_transform/>
-       <scale>2 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>23 -0.5 2</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="2" detail_level="2"/>
-
-<!-- Still more ground -->
-
-       <!-- Right part of centre courtyard -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>21 0 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="7">
-               1       1       1       1       1       0       0
-               1       1       1       1       1       0       0
-               0       0       0       0       0       0       0
-               1       1       0       0       0       0       0
-               1       1       0       0       0       0       0
-               0       0       0       0       0       0       0
-               0       0       0       1       1       1       1
-       </tilemap>
-
-       <!-- Fence to right of back house -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <translate>24 0 0</translate>
-       <scale>32</scale>
-
-       <texture>Scenery</texture>
-       <billboard tile="4" u_scale="4" detail_level="2"/>
-
-       <!-- Grass in front of fence -->
-
-       <reset_transform/>
-       <scale>4 1 1</scale>
-       <translate>24 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="4" detail_level="2"/>
-
-       <!-- Grass to left of tower block -->
-
-       <reset_transform/>
-       <scale>2 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>26 -0.5 5</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="2" detail_level="2"/>
-
-       <!-- Grass to right of tower block -->
-
-       <reset_transform/>
-       <scale>2 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>35 -0.5 5</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="2" detail_level="2"/>
-
-       <!-- Next bit of grass -->
-
-       <reset_transform/>
-       <scale>5 1 1</scale>
-       <translate>35 -0.5 5</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="5" detail_level="2"/>
-
-       <!-- Back grass -->
-
-       <reset_transform/>
-       <scale>6 1 1</scale>
-       <translate>34 -0.5 1</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="6" detail_level="2"/>
-
-       <!-- Extra bit of back grass -->
-
-       <reset_transform/>
-       <scale>1 1 1</scale>
-       <rotate axis="y">-90</rotate>
-       <translate>34 -0.5 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <billboard tile="2" u_scale="1" detail_level="2"/>
-
-       <!-- Ground around tower block -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>28 0 4</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="5">
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-       </tilemap>
-
-       <!-- Rightmost ground -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>33 0 0</translate>
-       <scale>32</scale>
-       <texture>Scenery</texture>
-       <tilemap surface_type="top" width="10">
-               0       0       1       1       1       1       1       1       1       1
-               0       0       1       1       1       1       1       1       1       1
-               0       0       0       0       0       0       0       -1      -1      -1
-               0       0       0       0       0       0       0       -1      -1      -1
-               0       0       0       0       0       0       0       -1      -1      -1
-               0       0       0       0       0       0       0       -1      -1      -1
-               0       1       1       1       1       1       1       -1      -1      -1
-       </tilemap>
-
-<!-- Right foreground tower block -->
-
-       <!-- Front -->
-
-       <reset_transform/>
-       <translate>28 0 4</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="5">
-               2       2       2       2       2
-               0       0       0       0       0
-               0       0       0       0       6
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       6       0
-               4       4       4       4       4
-       </tilemap>
-
-       <!-- Right side -->
-
-       <reset_transform/>
-       <rotate axis="y">90</rotate>
-       <translate>33 0 4</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="right" width="6">
-               2       2       2       2       2       2
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               5       4       5       5       4       5
-       </tilemap>
-
-       <!-- Left side -->
-
-       <reset_transform/>
-       <rotate axis="y">90</rotate>
-       <translate>28 0 4</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="left" width="6">
-               2       2       2       2       2       2
-               0       1       6       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               0       1       0       0       1       0
-               5       4       5       5       4       5
-       </tilemap>
-
-       <!-- Top -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>28 7 -2</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="top" width="5">
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-       </tilemap>
-
-<!-- Right end tower block -->
-
-       <!-- Front -->
-
-       <reset_transform/>
-       <translate>40 0 5</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap width="5">
-               2       2       2       2       2
-               0       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               6       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               6       1       0       0       1
-               0       1       0       0       1
-               0       1       0       0       1
-               4       4       4       4       4
-       </tilemap>
-
-       <!-- Left side -->
-
-       <reset_transform/>
-       <rotate axis="y">90</rotate>
-       <translate>40 0 5</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="left" width="5">
-               2       2       2       2       2
-               6       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       6       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       6       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               0       0       0       0       0
-               4       5       5       5       4
-       </tilemap>
-
-       <!-- Top -->
-
-       <reset_transform/>
-       <rotate axis="x">90</rotate>
-       <translate>40 15 0</translate>
-       <scale>32</scale>
-
-       <texture>TowerBlock1</texture>
-       <tilemap surface_type="top" width="5">
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-               3       3       3       3       3
-       </tilemap>
-
-<!-- Background -->
-
-       <reset_transform/>
-       <translate>-0.3 -0.17 -900</translate>
-       <scale>3200 1600 1</scale>
-       <texture>BackgroundFar</texture>
-       <billboard fog="false"/>
-
-       <translate>0 0 300</translate>
-       <texture>BackgroundNear</texture>
-       <billboard blend="true" fog="false"/>
-
-<!-- Trees -->
-
-       <texture>Trees</texture>
-
-       <!-- Left courtyard -->
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>250 -2.5 16</translate>
-
-       <billboard tile="1" detail_level="1"/>
-
-       <!-- Centre courtyard -->
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>610 -2.5 85</translate>
-
-       <billboard tile="0"/>
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>650 -2.5 115</translate>
-
-       <billboard tile="1"/>
-
-       <!-- Right courtyard -->
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>1080 -2.5 10</translate>
-
-       <billboard tile="1" detail_level="1"/>
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>1120 -2.5 -15</translate>
-
-       <billboard tile="0" detail_level="1"/>
-
-       <reset_transform/>
-       <scale>96</scale>
-       <translate>1220 -2.5 -30</translate>
-
-       <billboard tile="1" detail_level="1"/>
-</scene>
index 1797f008552c29c000d83754e37d6a7c7829d68f..f508682944d3a5db96ca210d9a710cd7ef2065d8 100644 (file)
@@ -40,7 +40,7 @@ Character::~Character()
 }
 
 
-void Character::draw(Mf::Scalar alpha) {}
+void Character::draw(Mf::Scalar alpha) const {}
 
 Mf::Tilemap& Character::getTilemap()
 {
index 2894c5ebcd35f0591840b9cf33a6514a915358f4..e39e7ff93bb9ad3de3e66ef6e1ed163e6a97df11 100644 (file)
@@ -45,7 +45,7 @@ public:
        Character(const std::string& name);
        ~Character();
 
-       void draw(Mf::Scalar alpha);
+       void draw(Mf::Scalar alpha) const;
 
        Mf::Tilemap& getTilemap();
        Mf::Animation& getAnimation();
index 0826767c3f359dc3102789f2ae163466d5212491..ea68cde7fef42b8edc6039787f56204e067e5c16 100644 (file)
@@ -2,9 +2,11 @@
 noinst_LTLIBRARIES = libmoof.la
 
 libmoof_la_SOURCES = \
+                                  Moof/Aabb.cc \
                                   Moof/Aabb.hh \
                                   Moof/Animation.cc \
                                   Moof/Animation.hh \
+                                  Moof/Camera.cc \
                                   Moof/Camera.hh \
                                   Moof/ConvertUTF.c \
                                   Moof/ConvertUTF.h \
@@ -16,12 +18,16 @@ libmoof_la_SOURCES = \
                                   Moof/Drawable.hh \
                                   Moof/Engine.cc \
                                   Moof/Engine.hh \
+                                  Moof/Entity.hh \
                                   Moof/Event.hh \
+                                  Moof/Frustum.hh \
                                   Moof/Interpolator.hh \
                                   Moof/Math.hh \
                                   Moof/Mippleton.hh \
+                                  Moof/Octree.hh \
                                   Moof/OpenGL.cc \
                                   Moof/OpenGL.hh \
+                                  Moof/Plane.hh \
                                   Moof/Profiler.hh \
                                   Moof/Random.cc \
                                   Moof/Random.hh \
@@ -45,6 +51,7 @@ libmoof_la_SOURCES = \
                                   Moof/Tilemap.hh \
                                   Moof/Timer.cc \
                                   Moof/Timer.hh \
+                                  Moof/Tree.hh \
                                   Moof/Video.cc \
                                   Moof/Video.hh \
                                   Moof/fastevents.c \
@@ -75,8 +82,7 @@ yoink_LDADD    = libmoof.la
 EXTRA_DIST = Moof/cml
 
 
-YOINK_ENVIRONMENT = YOINK_DATADIR="$(top_srcdir)/data" \
-                                       YOINKRC="$(top_srcdir)/data/yoinkrc"
+YOINK_ENVIRONMENT = YOINK_DATADIR="$(top_srcdir)/data"
 
 run: all
        $(YOINK_ENVIRONMENT) ./yoink
diff --git a/src/Moof/Aabb.cc b/src/Moof/Aabb.cc
new file mode 100644 (file)
index 0000000..7b2ada7
--- /dev/null
@@ -0,0 +1,63 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#include <Moof/Aabb.hh>
+
+
+namespace Mf {
+
+
+void Aabb::draw(Scalar alpha) const
+{
+       Scalar vertices[] = {min[0], min[1], min[2],
+                                                min[0], max[1], min[2],
+                                                max[0], max[1], min[2],
+                                                max[0], min[1], min[2],
+                                                min[0], max[1], max[2],
+                                                min[0], min[1], max[2],
+                                                max[0], min[1], max[2],
+                                                max[0], max[1], max[2]};
+
+       GLubyte indicis[] = {0, 1, 2, 3,
+                                                1, 2, 7, 4,
+                                                3, 0, 5, 6,
+                                                2, 3, 6, 7,
+                                                5, 0, 1, 4,
+                                                4, 5, 6, 7};
+
+       glEnableClientState(GL_VERTEX_ARRAY);
+       glVertexPointer(3, GL_SCALAR, 0, vertices);
+
+       glDrawElements(GL_QUADS, sizeof(indicis), GL_UNSIGNED_BYTE, indicis);
+}
+
+
+} // namespace Mf
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index f66fb24fe6595f60d76a25f9498d38596aabe6c4..b43e194784df06c96892f11d8b7129fe8fef4587 100644 (file)
@@ -1,5 +1,5 @@
 
-/******************************************************************************
+/*******************************************************************************
 
  Copyright (c) 2009, Charles McGarvey
  All rights reserved.
  OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-******************************************************************************/
+*******************************************************************************/
 
 #ifndef _MOOF_AABB_HH_
 #define _MOOF_AABB_HH_
 
+#include <Moof/Drawable.hh>
 #include <Moof/Math.hh>
 
 
@@ -39,21 +40,70 @@ namespace Mf {
  * Axis-aligned Bounding Box
  */
 
-struct Aabb
+struct Aabb : public Drawable
 {
-       Aabb() {}
+       Vector3 min;
+       Vector3 max;
 
-       Aabb(const Vector3& minPoint, const Vector3& maxPoint) :
-               min(minPoint),
-               max(maxPoint) {}
 
-       Aabb (Scalar minX, Scalar minY, Scalar minZ,
-                       Scalar maxX, Scalar maxY, Scalar maxZ) :
-               min(minX, minY, minZ),
-               max(maxX, maxY, maxZ) {}
+       Aabb() {}
 
-       Vector3 min;
-       Vector3 max;
+       Aabb(const Vector3& a, const Vector3& b)
+       {
+               init(a, b);
+       }
+
+       Aabb(Scalar ax, Scalar ay, Scalar az,
+                       Scalar bx, Scalar by, Scalar bz)
+       {
+               Vector3 a(ax, ay, az);
+               Vector3 b(bx, by, bz);
+
+               init(a, b);
+       }
+
+       inline void init(const Vector3& a, const Vector3& b)
+       {
+               if (a[0] < b[0])
+               {
+                       min[0] = a[0];
+                       max[0] = b[0];
+               }
+               else
+               {
+                       min[0] = b[0];
+                       max[0] = a[0];
+               }
+               if (a[1] < b[1])
+               {
+                       min[1] = a[1];
+                       max[1] = b[1];
+               }
+               else
+               {
+                       min[1] = b[1];
+                       max[1] = a[1];
+               }
+               if (a[2] < b[2])
+               {
+                       min[2] = a[2];
+                       max[2] = b[2];
+               }
+               else
+               {
+                       min[2] = b[2];
+                       max[2] = a[2];
+               }
+       }
+
+       inline Vector3 getCenter() const
+       {
+               return Vector3((min[0] + max[0]) / 2.0,
+                                          (min[1] + max[1]) / 2.0,
+                                          (min[2] + max[2]) / 2.0);
+       }
+
+       void draw(Scalar alpha) const;
 };
 
 
diff --git a/src/Moof/Camera.cc b/src/Moof/Camera.cc
new file mode 100644 (file)
index 0000000..26e24ba
--- /dev/null
@@ -0,0 +1,166 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#include <iostream>
+#include <Moof/Camera.hh>
+
+
+namespace Mf {
+
+
+void Camera::setPosition(const Vector3& point)
+{
+       //position_ = point;
+       Vector3 coeff[2] = {position_, point};
+       pInterp_.init(coeff, 0.1);
+}
+void Camera::setRotation(const Quaternion& rotation)
+{
+       rotation_ = rotation;
+       //srcRotation_ = rotation_;
+       //dstRotation_ = rotation;
+       //tInterp_ = 0.0;
+}
+
+void Camera::update(Scalar t, Scalar dt)
+{
+       pInterp_.update(dt);
+       position_ = pInterp_.getState(0.0);
+
+       //tInterp_ += dt * 10.0;
+       //rotation_ = cml::slerp(srcRotation_, dstRotation_, cml::clamp(tInterp_, 0.0, 1.0));
+       //rotation_.normalize();
+
+       calculateSecondary();
+}
+
+
+void Camera::lookAt(const Vector3& point)
+{
+       quaternion_rotation_aim_at(rotation_, position_, point);
+}
+
+void Camera::adjustFromInput(const Event& event)
+{
+       switch (event.type)
+       {
+               case SDL_KEYDOWN:
+                       if (event.key.keysym.sym == SDLK_RIGHT ||
+                                       event.key.keysym.sym == SDLK_d)
+                       {
+                               Vector3 vec = position_;
+                               vec[0] -= 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.key.keysym.sym == SDLK_LEFT ||
+                                       event.key.keysym.sym == SDLK_a)
+                       {
+                               Vector3 vec = position_;
+                               vec[0] += 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.key.keysym.sym == SDLK_UP ||
+                                       event.key.keysym.sym == SDLK_w)
+                       {
+                               Vector3 vec = position_;
+                               vec[1] -= 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.key.keysym.sym == SDLK_DOWN ||
+                                       event.key.keysym.sym == SDLK_s)
+                       {
+                               Vector3 vec = position_;
+                               vec[1] += 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.key.keysym.sym == SDLK_PAGEUP)
+                       {
+                               Vector3 vec = position_;
+                               vec[2] += 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.key.keysym.sym == SDLK_PAGEDOWN)
+                       {
+                               //position_[2] -= 50.0;
+                               Vector3 vec = position_;
+                               vec[2] -= 50.0;
+                               setPosition(vec);
+                       }
+                       break;
+
+               case SDL_MOUSEMOTION:
+                       {
+                       Scalar xrel = cml::rad(Scalar(event.motion.xrel) / 5.0);
+                       Scalar yrel = cml::rad(Scalar(event.motion.yrel) / 5.0);
+
+                       Quaternion rotation = rotation_;
+
+                       quaternion_rotate_about_world_x(rotation, yrel);
+                       //rotation_.normalize();
+                       quaternion_rotate_about_world_y(rotation, xrel);
+                       rotation.normalize();
+
+                       setRotation(rotation);
+                       break;
+                       }
+
+               case SDL_MOUSEBUTTONDOWN:
+                       if (event.button.button == SDL_BUTTON_WHEELUP)
+                       {
+                               Vector3 vec = position_;
+                               vec[2] += 50.0;
+                               setPosition(vec);
+                       }
+                       else if (event.button.button == SDL_BUTTON_WHEELDOWN)
+                       {
+                               Vector3 vec = position_;
+                               vec[2] -= 50.0;
+                               setPosition(vec);
+                       }
+                       break;
+       }
+
+       calculateSecondary();
+}
+
+void Camera::calculateSecondary()
+{
+       matrix_rotation_quaternion(transformation_, rotation_);
+
+       Matrix4 translate;
+       matrix_translation(translate, position_);
+
+       //transformation_ = translate * transformation_;
+       transformation_ *= translate;
+}
+
+
+} // namespace Mf
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index 8800e3baf1fbf0b9f925d893459805df547988e0..8b3b1dabe12e2760612b25554cf3c5007cb22dcf 100644 (file)
 #ifndef _MOOF_CAMERA_HH_
 #define _MOOF_CAMERA_HH_
 
+#include <Moof/Event.hh>
+#include <Moof/Interpolator.hh>
+#include <Moof/Math.hh>
+
 
 namespace Mf {
 
 
 class Camera
 {
+       void calculateSecondary();
+
 public:
+       Camera() :
+               position_(0.0, 0.0, 0.0)
+       {
+               quaternion_rotation_world_y(rotation_, 0.0);
+               srcRotation_ = rotation_;
+               dstRotation_ = rotation_;
+               calculateSecondary();
+       }
+
+       void setPosition(const Vector3& point);
+       void setRotation(const Quaternion& rotation);
+
+       void lookAt(const Vector3& point);
+
+       const Matrix4& getTransformation() const
+       {
+               return transformation_;
+       }
+
+       void adjustFromInput(const Event& event);
+
+       void update(Scalar t, Scalar dt);
+
 private:
+       Vector3         position_;
+       Quaternion      rotation_;
+
+       Matrix4         transformation_;
+
+       Lerpv3          pInterp_;
+
+       Quaternion      srcRotation_;
+       Quaternion      dstRotation_;
+       Scalar          tInterp_;
 };
 
 
index d543d0f07ecc040f6b744a00fcbb50ee5e16a024..34a09b6a7ec3889d329a8053e5cec12868146525 100644 (file)
@@ -36,14 +36,16 @@ namespace Mf {
 
 
 /**
- * Interface for anything that can be culled.  This can include more than just
- * frustrum culling.
+ * Interface for anything that can be culled.
  */
 
 class Cullable
 {
 public:
-       virtual bool isVisible(const Camera& cam) = 0;
+       virtual bool isVisible(const Camera& cam) const
+       {
+               return true;
+       }
 };
 
 
index 8d93f0543aa4382367e1ca07d6fd94c14a25e3ce..1554b11ffca84a52610136b21b7fefc993d2b313 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef _MOOF_DRAWABLE_HH_
 #define _MOOF_DRAWABLE_HH_
 
+#include <Moof/Camera.hh>
 #include <Moof/Math.hh>
 
 
@@ -42,7 +43,7 @@ namespace Mf {
 class Drawable
 {
 public:
-       virtual void draw(Scalar alpha) = 0;
+       virtual void draw(Scalar alpha) const = 0;
 };
 
 
similarity index 73%
rename from src/Moof/Profiler.hh
rename to src/Moof/Entity.hh
index 40199df3e27706404b9177bc31c122c5ed30d45c..738e13785b0f3d77bcb09580ce83288dc1d02ffe 100644 (file)
 
 *******************************************************************************/
 
-#ifndef _MOOF_PROFILER_HH_
-#define _MOOF_PROFILER_HH_
+#ifndef _MOOF_ENTITY_HH_
+#define _MOOF_ENTITY_HH_
 
-/**
- * @file Profiler.hh
- * Braindead-simple profiler.
- */
+#include <boost/shared_ptr.hpp>
 
-#include <ctime>
+#include <Moof/Aabb.hh>
+#include <Moof/Drawable.hh>
+#include <Moof/Cullable.hh>
 
 
 namespace Mf {
 
-class Profiler
-{      
+
+/**
+ * Interface for game objects that can be drawn to the screen and half a
+ * specified size.
+ */
+
+class Entity : public Drawable, public Cullable
+{
 public:
-       Profiler(const char* name = "")
-       {
-               start(name);
-       }
-       ~Profiler()
+       const Aabb& getAabb() const
        {
-               stop();
-       }
-       
-       void start(const char* name = "")
-       {
-               begin = std::clock();
-               std::cout << "Profiling " << name << "... ";
+               return aabb_;
        }
 
-       void stop()
-       {
-               if (begin == -1) return;
-               double elapsed = double(std::clock() - begin) / double(CLOCKS_PER_SEC);
-               std::cout << elapsed << " sec" << std::endl;
-               begin = -1;
-       }
+protected:
+       Aabb aabb_;
+};
 
-       void cancel()
-       {
-        begin = -1;
-    }
+typedef boost::shared_ptr<Entity> EntityPtr;
 
-private:
-       std::clock_t begin;
-};
 
 } // namespace Mf
 
-
-#endif // _MOOF_PROFILER_HH_
+#endif // _MOOF_ENTITY_HH_
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
diff --git a/src/Moof/Frustum.hh b/src/Moof/Frustum.hh
new file mode 100644 (file)
index 0000000..82eba17
--- /dev/null
@@ -0,0 +1,56 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _MOOF_FRUSTUM_HH_
+#define _MOOF_FRUSTUM_HH_
+       
+#include <Moof/Plane.hh>
+
+
+namespace Mf {
+
+
+class Frustum
+{
+       Matrix4 projection;
+       //Plane left, right, bottom, top, near, far;
+
+public:
+       Frustum(Scalar l, Scalar r, Scalar b, Scalar t, Scalar n, Scalar f);
+       Frustum(Scalar fovy, Scalar aspect, Scalar near, Scalar far);
+
+       const Matrix4& getMatrix() const;
+};
+
+
+} // namespace Mf
+
+#endif // _MOOF_FRUSTUM_HH_
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index 87e3acdbcf26a517fdaaa84cfbdac1c8de1c98d4..2c33844262db6835cc5eaf02258f09cf5d11d767 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _MOOF_INTERPOLATOR_HH_
 #define _MOOF_INTERPOLATOR_HH_
 
+#include <Moof/Math.hh>
+
 
 namespace Mf {
 
@@ -124,7 +126,7 @@ public:
                Interpolator::init(seconds, mode);
 
                calculate(0.0); // set value
-               calculate(0.0); // set previous
+               previous_ = value_;
        }
 
        void calculate(Scalar alpha)
diff --git a/src/Moof/Octree.hh b/src/Moof/Octree.hh
new file mode 100644 (file)
index 0000000..2ee617f
--- /dev/null
@@ -0,0 +1,87 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _MOOF_OCTREE_HH_
+#define _MOOF_OCTREE_HH_
+
+#include <list>
+
+#include <boost/shared_ptr.hpp>
+
+#include <Moof/Math.hh>
+#include <Moof/Tree.hh>
+       
+
+namespace Mf {
+
+
+class Entity;
+
+
+class Octree
+{
+public:
+
+       class Node
+       {
+               Aabb    aabb_;
+               Vector3 center_;
+
+               std::list<boost::shared_ptr<Entity> > objects_;
+
+       public:
+
+               Node() :
+                       aabb_(-1.0, -1.0, -1.0, 1.0, 1.0, 1.0),
+                       center_(0.0, 0.0, 0.0) {}
+
+               Node(const Aabb& aabb) :
+                       aabb_(aabb),
+                       center_(aabb.getCenter()) {}
+       };
+
+       Octree() :
+               root_(new Tree<Node>()) {}
+
+       Octree(const Aabb& aabb) :
+               root_(new Tree<Node>(Node(aabb))) {}
+
+
+       Tree<Node>::WeakPtr add(EntityPtr object);
+
+private:
+       Tree<Node>::Ptr root_;
+};
+
+
+} // namespace Mf
+
+#endif // _MOOF_OCTREE_HH_
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index 6f223d1675cd52857a325e3ff56fd24712397ebc..e3e742b97c515d2a8ab2d58d1a1f57e12e3bc6d3 100644 (file)
 
 #if USE_DOUBLE_PRECISION
 
+void (*glGetScalarv)(GLenum, GLscalar*)(glGetDoublev);
+
 void (*glLoadMatrix)(const GLscalar*)(glLoadMatrixd);
 void (*glMultMatrix)(const GLscalar*)(glMultMatrixd);
 
+void (*glScale)(GLscalar, GLscalar, GLscalar)(glScaled);
+void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar)(glRotated);
+void (*glTranslate)(GLscalar, GLscalar, GLscalar)(glTranslated);
+
 void (*glColor3)(GLscalar, GLscalar, GLscalar)(glColor3d);
 void (*glColor4)(GLscalar, GLscalar, GLscalar, GLscalar)(glColor4d);
 void (*glColor3v)(const GLscalar*)(glColor3dv);
@@ -48,9 +54,15 @@ void (*glVertex4v)(const GLscalar*)(glVertex4dv);
 
 #else
 
+void (*glGetScalarv(GLenum, GLscalar*)(glGetFloatv);
+
 void (*glLoadMatrix)(const GLscalar*)(glLoadMatrixf);
 void (*glMultMatrix)(const GLscalar*)(glMultMatrixf);
 
+void (*glScale)(GLscalar, GLscalar, GLscalar)(glScalef);
+void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar)(glRotatef);
+void (*glTranslate)(GLscalar, GLscalar, GLscalar)(glTranslatef);
+
 void (*glVertex2)(GLscalar, GLscalar)(glVertex2f);
 void (*glVertex3)(GLscalar, GLscalar, GLscalar)(glVertex3f);
 void (*glVertex4)(GLscalar, GLscalar, GLscalar, GLscalar)(glVertex4f);
index 6db55ce98f6314f89ece1a0fc5056a2772824dcd..657f05f68fb22eb53ab7992e619604b6d69f085e 100644 (file)
@@ -49,9 +49,15 @@ typedef GLfloat              GLscalar;
 #endif
 
 
+extern void (*glGetScalarv)(GLenum, GLscalar*);
+
 extern void (*glLoadMatrix)(const GLscalar*);
 extern void (*glMultMatrix)(const GLscalar*);
 
+extern void (*glScale)(GLscalar, GLscalar, GLscalar);
+extern void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar);
+extern void (*glTranslate)(GLscalar, GLscalar, GLscalar);
+
 extern void (*glColor3)(GLscalar, GLscalar, GLscalar);
 extern void (*glColor4)(GLscalar, GLscalar, GLscalar, GLscalar);
 extern void (*glColor3v)(const GLscalar*);
diff --git a/src/Moof/Plane.hh b/src/Moof/Plane.hh
new file mode 100644 (file)
index 0000000..797edc0
--- /dev/null
@@ -0,0 +1,51 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _MOOF_PLANE_HH_
+#define _MOOF_PLANE_HH_
+       
+#include <Moof/Math.hh>
+
+
+namespace Mf {
+
+
+class Plane
+{
+       Vector4 components;
+
+public:
+};
+
+
+} // namespace Mf
+
+#endif // _MOOF_PLANE_HH_
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index 5f4a440c4ce0d06655afe62ed06de1b9b1d456db..b8cb23388c24b3ea8c41665bda818566eb504ce6 100644 (file)
 
 #include "Aabb.hh"
 #include "Camera.hh"
-#include "Cullable.hh"
 #include "Deserializer.hh"
-#include "Drawable.hh"
+#include "Entity.hh"
 #include "Math.hh"
 #include "Mippleton.hh"
+#include "Octree.hh"
 #include "OpenGL.hh"
 #include "Scene.hh"
 #include "Serializable.hh"
@@ -48,7 +48,7 @@ namespace Mf {
 
 class Scene::SceneImpl : public Mippleton<SceneImpl>
 {
-       class Scenery : public Drawable, public Cullable
+       class Scenery : public Entity
        {
        public:
                Scenery(const Matrix4& transform, const std::string& textureName) :
@@ -118,7 +118,7 @@ class Scene::SceneImpl : public Mippleton<SceneImpl>
                        }
                }
 
-               void draw(Scalar alpha)
+               void draw(Scalar alpha) const
                {
                        glPushMatrix();
                        //std::cout << "transforming..." << std::endl;
@@ -195,16 +195,31 @@ class Scene::SceneImpl : public Mippleton<SceneImpl>
                                {
                                        (*it).second->get(uScale);
                                }
+                               if ((it = rootObj.find("fog")) != rootObj.end())
+                               {
+                                       (*it).second->get(fog);
+                               }
+                               if ((it = rootObj.find("blend")) != rootObj.end())
+                               {
+                                       (*it).second->get(blending);
+                               }
                        }
 
                        image.getTileCoords(index, texCoords);
                }
 
-               void draw(Scalar alpha)
+               void draw(Scalar alpha) const
                {
                        glPushMatrix();
                        glMultMatrix(transformation.data());
 
+                       if (blending)
+                       {
+                               glEnable(GL_BLEND);
+                               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                       }
+                       /*if (fog) glEnable(GL_FOG);*/
+
                        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                        image.bind();
 
@@ -226,6 +241,9 @@ class Scene::SceneImpl : public Mippleton<SceneImpl>
                        glEnd();
                        }
 
+                       glDisable(GL_BLEND);
+                       glDisable(GL_FOG);
+
                        glPopMatrix();
                }
 
@@ -253,7 +271,27 @@ class Scene::SceneImpl : public Mippleton<SceneImpl>
 
                                if (numbers[0]->getNumber(num))
                                {
-
+                                       theBox.min[0] = Scalar(num);
+                               }
+                               if (numbers[1]->getNumber(num))
+                               {
+                                       theBox.min[1] = Scalar(num);
+                               }
+                               if (numbers[2]->getNumber(num))
+                               {
+                                       theBox.min[2] = Scalar(num);
+                               }
+                               if (numbers[3]->getNumber(num))
+                               {
+                                       theBox.max[0] = Scalar(num);
+                               }
+                               if (numbers[4]->getNumber(num))
+                               {
+                                       theBox.max[1] = Scalar(num);
+                               }
+                               if (numbers[5]->getNumber(num))
+                               {
+                                       theBox.max[2] = Scalar(num);
                                }
                        }
                }
@@ -268,6 +306,10 @@ public:
                loadFromFile();
        }
 
+       ~SceneImpl()
+       {
+       }
+
 
        void loadInstructions(SerializablePtr root)
        {
@@ -289,7 +331,6 @@ public:
                                        if (instruction == "reset_transform")
                                        {
                                                transform.identity();
-                                               //std::cout << "===================RESET=====================" << std::endl;
                                        }
                                        else if (instruction == "translate")
                                        {
@@ -313,8 +354,6 @@ public:
                                                        Matrix4 translation;
                                                        cml::matrix_translation(translation, vec);
                                                        transform = translation * transform;
-                                                       //std::cout << "TRANSLATE\t" << vec << std::endl
-                                                               //<< transform << std::endl;
                                                }
                                        }
                                        else if (instruction == "scale")
@@ -333,8 +372,6 @@ public:
                                                                Matrix4 scaling;
                                                                cml::matrix_uniform_scale(scaling, Scalar(value));
                                                                transform = scaling * transform;
-                                                               //std::cout << "SCALE\t\t" << value << std::endl
-                                                                       //<< transform << std::endl;
                                                        }
                                                        else if (values.size() == 3)
                                                        {
@@ -353,8 +390,6 @@ public:
                                                                Matrix4 scaling;
                                                                cml::matrix_scale(scaling, vec);
                                                                transform = scaling * transform;
-                                                               //std::cout << "SCALE\t\t" << vec << std::endl
-                                                                       //<< transform << std::endl;
                                                        }
                                                }
                                        }
@@ -370,28 +405,30 @@ public:
                                                                std::string axis;
                                                                size_t axisIndex = 0;
                                                                double value = 0.0;
+                                                               Vector3 vec(0.0, 0.0, 0.0);
 
                                                                if (values[0]->get(axis))
                                                                {
                                                                        if (axis == "x")
                                                                        {
                                                                                axisIndex = 0;
+                                                                               vec[0] = 1.0;
                                                                        }
                                                                        else if (axis == "y")
                                                                        {
                                                                                axisIndex = 1;
+                                                                               vec[1] = 1.0;
                                                                        }
                                                                        else if (axis == "z")
                                                                        {
                                                                                axisIndex = 2;
+                                                                               vec[2] = 1.0;
                                                                        }
                                                                        values[1]->getNumber(value);
                                                                }
 
-                                                               cml::matrix_rotate_about_local_axis(transform,
+                                                               cml::matrix_rotate_about_world_axis(transform,
                                                                                axisIndex, Scalar(value * cml::constantsd::rad_per_deg()));
-                                                               //std::cout << "ROTATE\t" << axis << " " << value << std::endl
-                                                                       //<< transform << std::endl;
                                                        }
                                                }
                                        }
@@ -402,9 +439,6 @@ public:
                                        }
                                        else if (instruction == "tilemap")
                                        {
-                                               //std::cout << "TILEMAP\t" << texture<< std::endl;
-                                               //std::cout << transform << std::endl;
-
                                                it++;
                                                TilePanel* tilePanel = new TilePanel(transform, texture,
                                                                *it);
@@ -413,9 +447,6 @@ public:
                                        }
                                        else if (instruction == "billboard")
                                        {
-                                               //std::cout << "BILLBOARD\t" << texture << std::endl;
-                                               //std::cout << transform << std::endl;
-
                                                it++;
                                                Billboard* billboard = new Billboard(transform, texture,
                                                                *it);
@@ -458,6 +489,9 @@ public:
                                }
                        }
                }
+
+               std::cout << "playfield: " << playfieldBounds.min << " ... " <<
+                       playfieldBounds.max << std::endl;
        }
 
 
@@ -470,6 +504,14 @@ public:
                        //std::cout << "draw object";
                        (*it)->draw(alpha);
                }
+
+               glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+               glBindTexture(GL_TEXTURE_2D, 0);
+               glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
+               playfieldBounds.draw(0.0);
+
+               glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        }
 
 
@@ -486,12 +528,18 @@ Scene::Scene(const std::string& name) :
        impl_(Scene::SceneImpl::retain(name), &Scene::SceneImpl::release) {}
 
 
-void Scene::draw(Scalar alpha)
+void Scene::draw(Scalar alpha) const
 {
        // pass through
        impl_->draw(alpha);
 }
 
+void Scene::refresh()
+{
+       impl_->objects.clear();
+       impl_->loadFromFile();
+}
+
 
 /**
  * Specialized search location for scene files.  They can be found in the
index 66a54a97936c22c543203780b9a110cb076c9261..db25db7a42ea096c0e017e6b008ba5695fc039b0 100644 (file)
@@ -45,7 +45,8 @@ class Scene : public Resource, public Drawable
 public:
        Scene(const std::string& name);
 
-       void draw(Scalar alpha);
+       void draw(Scalar alpha) const;
+       void refresh();
 
        static std::string getPathToResource(const std::string& name);
 
index 8bd3c4a3ae00a16657d670fe55620f48b0c99af0..128d54f3d7c8750b2087859a22b81aa6c5f18dc6 100644 (file)
@@ -396,7 +396,7 @@ Texture::Texture(const std::string& name) :
  * Bind the GL texture for mapping, etc.
  */
 
-void Texture::bind()
+void Texture::bind() const
 {
        // pass through
        impl_->bind();
@@ -407,20 +407,20 @@ void Texture::bind()
  * Get the texture object, for the curious.
  */
 
-GLuint Texture::getObject()
+GLuint Texture::getObject() const
 {
        // pass through
        return impl_->object_;
 }
 
 
-unsigned Texture::getWidth()
+unsigned Texture::getWidth() const
 {
        // pass through
        return impl_->width_;
 }
 
-unsigned Texture::getHeight()
+unsigned Texture::getHeight() const
 {
        // pass through
        return impl_->height_;
index 2ab4710cf55202dfd986808b820812be5b5fe5cf..d2b2359f0eb4e28d09194cac40816e66dd0536a0 100644 (file)
@@ -50,11 +50,11 @@ class Texture : public Resource
 public:
        Texture(const std::string& name);
 
-       void bind();
-       GLuint getObject();
+       void bind() const;
+       GLuint getObject() const;
 
-       unsigned getWidth();
-       unsigned getHeight();
+       unsigned getWidth() const;
+       unsigned getHeight() const;
 
        void setMinFilter(GLuint filter);
        void setMagFilter(GLuint filter);
index 1bfbfbcb9796e9b257970070b6243f2299a3b5eb..9f24b1bce91547a200bf7de7090f9ce6a8110ca8 100644 (file)
@@ -175,7 +175,7 @@ Tilemap::Tilemap(const std::string& name) :
 }
 
 
-bool Tilemap::getTileCoords(unsigned index, Scalar coords[8])
+bool Tilemap::getTileCoords(unsigned index, Scalar coords[8]) const
 {
        // make sure the index represents a real tile
        if (index >= impl_->nTilesS_ * impl_->nTilesT_) return false;
@@ -197,7 +197,7 @@ bool Tilemap::getTileCoords(unsigned index, Scalar coords[8])
 }
 
 bool Tilemap::getTileCoords(unsigned index, Scalar coords[8],
-               Orientation orientation)
+               Orientation orientation) const
 {
        if (getTileCoords(index, coords))
        {
index d8708f1f15f20acf9ff2caa382de4b06403134b1..f05688658cb659763d78d830f04bf9497b19f43a 100644 (file)
@@ -82,7 +82,7 @@ public:
         * @return True if index is valid, false otherwise.
         */
 
-       bool getTileCoords(Index index, Scalar coords[8]);
+       bool getTileCoords(Index index, Scalar coords[8]) const;
 
 
        /**
@@ -93,7 +93,7 @@ public:
         * @return True if index is valid, false otherwise.
         */
 
-       bool getTileCoords(Index index, Scalar coords[8], Orientation what);
+       bool getTileCoords(Index index, Scalar coords[8], Orientation what) const;
 
 
        static std::string getPathToResource(const std::string& name);
diff --git a/src/Moof/Tree.hh b/src/Moof/Tree.hh
new file mode 100644 (file)
index 0000000..2b5fdb8
--- /dev/null
@@ -0,0 +1,156 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _MOOF_TREE_HH_
+#define _MOOF_TREE_HH_
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+       
+
+namespace Mf {
+
+
+template <typename T>
+class Tree
+{
+public:
+       typedef boost::shared_ptr<Tree> Ptr;
+       typedef boost::weak_ptr<Tree> WeakPtr;
+
+private:
+       WeakPtr parent_;
+       WeakPtr prevSibling_;
+       Ptr             next_;
+       WeakPtr lastDescendant_;
+
+public:
+
+       T               data;
+
+       Tree() {}
+       Tree(const T& item) :
+               data(item) {}
+
+       inline Ptr next() const
+       {
+               return next_;
+       }
+
+       inline Ptr prev() const
+       {
+               Ptr parent = parent_.lock();
+
+               if (parent)
+               {
+                       if (parent->next_.get() == this)
+                       {
+                               return parent;
+                       }
+                       else
+                       {
+                               return prevSibling_.lock()->lastDescendant_.lock();
+                       }
+               }
+
+               return Ptr();
+       }
+
+       inline Ptr firstChild() const
+       {
+               if (next_ && next_->parent_.lock().get() == this)
+               {
+                       return next_;
+               }
+               
+               return Ptr();
+       }
+
+       inline Ptr lastChild() const
+       {
+               Ptr child = firstChild();
+
+               if (child)
+               {
+                       child = child->prevSibling_.lock();
+               }
+
+               return child;
+       }
+
+       inline Ptr nextSibling() const
+       {
+               Ptr sibling = lastDescendant_.lock()->next_;
+
+               if (sibling && sibling->parent_.lock() != parent_.lock())
+               {
+                       return Ptr();
+               }
+
+               return sibling;
+       }
+
+       inline Ptr prevSibling() const
+       {
+               Ptr parent = parent_.lock();
+
+               if (parent && parent->next_.get() != this)
+               {
+                       return prevSibling_.lock();
+               }
+
+               return Ptr();
+       }
+
+
+       class Iterator
+       {
+               Ptr current;
+
+       public:
+
+       };
+
+
+       void insert()
+       {
+       }
+
+       void remove()
+       {
+       }
+
+};
+
+
+} // namespace Mf
+
+#endif // _MOOF_TREE_HH_
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
index 232c097425b4f3a70803951644e3bdf634d1e203..023b3a30ce51837365e60d22136cc8a2e04cdce3 100644 (file)
@@ -50,6 +50,7 @@ static std::string configFiles()
        std::string files;
 
        char* configFile = getenv("YOINKRC");
+       char* dataDir = getenv("YOINK_DATADIR");
 
        if (configFile)
        {
@@ -59,8 +60,23 @@ static std::string configFiles()
                files += ":";
        }
 
+       // add the colon-delimited paths from configure
        files += YOINK_CONFIGFILES;
 
+       if (dataDir)
+       {
+               // if another data directory is set in the environment, look for a
+               // config file there
+               files += ":";
+               files += dataDir;
+               files += "/yoinkrc";
+       }
+
+       // look in the configured data directory last of all
+       files += ":";
+       files += (dataDir ? dataDir : YOINK_DATADIR);
+       files += "/yoinkrc";
+
        return files;
 }
 
@@ -71,8 +87,11 @@ static std::string iconFile()
        // first set up the search paths so we can find the icon and other resources
        if (dataDir)
        {
+               // look first in the data directory specified by the environment
                Mf::Resource::addSearchPath(dataDir);
        }
+
+       // then look in the configured data directory
        Mf::Resource::addSearchPath(YOINK_DATADIR);
 
        return Mf::Resource::getPathToResource("yoink.png");
@@ -125,7 +144,7 @@ void YoinkApp::setupGL()
        glEnable(GL_DEPTH_TEST);
 
        glShadeModel(GL_SMOOTH);
-       glEnable(GL_POLYGON_SMOOTH);
+       //glEnable(GL_POLYGON_SMOOTH);
 
        //int texSize;
        //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
@@ -138,6 +157,10 @@ void YoinkApp::setupGL()
 
        glClearColor(1.0, 0.0, 0.0, 1.0);
 
+       glMatrixMode(GL_PROJECTION);
+       glLoadIdentity();
+       gluPerspective(60.0, 1.33333, 1.0, 2500.0);
+       
        //glLineWidth(10.0f);
 }
 
@@ -155,6 +178,8 @@ void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
        
        fadeIn.update(dt);
 
+       camera.update(t, dt);
+
        someChar->getAnimation().update(t, dt);
        interp.update(dt);
 
@@ -177,16 +202,13 @@ void YoinkApp::draw(Mf::Scalar alpha)
        
 
 
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity();
-       gluPerspective(60.0, 1.33333, 1.0, 2000.0);
-       
        glMatrixMode(GL_MODELVIEW);
-       glLoadIdentity();
+       //glLoadIdentity();
 
        glBindTexture(GL_TEXTURE_2D, 0);
        //glRotatef(drawstate*15.0f, 0.0, 1.0, 0.0);
-       glTranslatef(x, y, z);
+       //glTranslatef(x, y, z);
+       glLoadMatrix(camera.getTransformation().data());
 
        // DRAW THE SCENE
        testScene->draw(alpha);
@@ -327,30 +349,43 @@ void YoinkApp::handleEvent(const Mf::Event& event)
                        {
                                someChar->getAnimation().startSequence("Punch");
                        }
-                       else if (event.key.keysym.sym == SDLK_RIGHT)
-                       {
-                               x -= 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_LEFT)
-                       {
-                               x += 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_UP)
-                       {
-                               y -= 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_DOWN)
+                       else if (event.key.keysym.sym == SDLK_r)
                        {
-                               y += 50.0;
+                               testScene->refresh();
                        }
-                       else if (event.key.keysym.sym == SDLK_PAGEUP)
+                       else if (event.key.keysym.sym == SDLK_l)
                        {
-                               z += 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEDOWN)
-                       {
-                               z -= 50.0;
+                               getVideo().toggleCursorGrab();
+                               getVideo().toggleCursorVisible();
                        }
+                       //else if (event.key.keysym.sym == SDLK_RIGHT)
+                       //{
+                               //x -= 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_LEFT)
+                       //{
+                               //x += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_UP)
+                       //{
+                               //y -= 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_DOWN)
+                       //{
+                               //y += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_PAGEUP)
+                       //{
+                               //z += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_PAGEDOWN)
+                       //{
+                               //z -= 50.0;
+                       //}
+
+               case SDL_MOUSEMOTION:
+               case SDL_MOUSEBUTTONDOWN:
+                       camera.adjustFromInput(event);
                        break;
 
                case SDL_QUIT:
@@ -359,11 +394,20 @@ void YoinkApp::handleEvent(const Mf::Event& event)
 
                case SDL_VIDEORESIZE:
                        glViewport(0, 0, event.resize.w, event.resize.h);
+
+                       glMatrixMode(GL_PROJECTION);
+                       glLoadIdentity();
+
+
+                       gluPerspective(60.0, double(event.resize.w / event.resize.h), 1.0, 2500.0);
+
+                       glMatrixMode(GL_MODELVIEW);
                        break;
        }
 }
 
 
+#include <Moof/Tree.hh>
 
 int main(int argc, char* argv[])
 {
@@ -374,6 +418,10 @@ int main(int argc, char* argv[])
 
        int status = 0;
 
+       //Mf::Tree<Mf::Drawable> myTree;
+       //Mf::Tree<Mf::Drawable>::Ptr prev = myTree.previousSibling();
+       //myTree = *prev;
+
        try
        {
                YoinkApp app(argc, argv);
index 19564b5d903e559849bb1bb2865986a48c08eee1..66406d2d4447c0979ddb0ef94f1bced85da45569 100644 (file)
@@ -37,6 +37,7 @@
 #include <iostream>
 #include <string>
 
+#include <Moof/Camera.hh>
 #include <Moof/Dispatcher.hh>
 #include <Moof/Engine.hh>
 #include <Moof/Interpolator.hh>
@@ -70,6 +71,7 @@ private:
        Mf::Cerpv2 interp;
        Mf::Lerps fadeIn;
 
+       Mf::Camera camera;
        Mf::Scene* testScene;
 
        Mf::Scalar x, y, z;
This page took 0.089666 seconds and 4 git commands to generate.