Browse Source

Added Sprite,TileSet and Text class attachments for Node 2D support

seanpaultaylor 11 years ago
parent
commit
965d4bfcc9
73 changed files with 3103 additions and 1365 deletions
  1. 24 8
      gameplay/gameplay.xcodeproj/project.pbxproj
  2. 5 0
      gameplay/src/AIAgent.cpp
  3. 5 0
      gameplay/src/AIAgent.h
  4. 3 2
      gameplay/src/Animation.cpp
  5. 3 3
      gameplay/src/Animation.h
  6. 27 0
      gameplay/src/Curve.cpp
  7. 33 5
      gameplay/src/Curve.h
  8. 5 291
      gameplay/src/Font.cpp
  9. 12 81
      gameplay/src/Font.h
  10. 1 1
      gameplay/src/Label.cpp
  11. 10 10
      gameplay/src/Model.h
  12. 142 44
      gameplay/src/Node.cpp
  13. 141 63
      gameplay/src/Node.h
  14. 8 1
      gameplay/src/ParticleEmitter.cpp
  15. 3 0
      gameplay/src/PlatformMacOSX.mm
  16. 7 7
      gameplay/src/Quaternion.cpp
  17. 61 2
      gameplay/src/SceneLoader.cpp
  18. 4 1
      gameplay/src/SceneLoader.h
  19. 1 1
      gameplay/src/Slider.cpp
  20. 478 0
      gameplay/src/Sprite.cpp
  21. 404 0
      gameplay/src/Sprite.h
  22. 42 40
      gameplay/src/SpriteBatch.cpp
  23. 29 26
      gameplay/src/SpriteBatch.h
  24. 289 0
      gameplay/src/Text.cpp
  25. 274 0
      gameplay/src/Text.h
  26. 1 1
      gameplay/src/TextBox.cpp
  27. 241 0
      gameplay/src/TileSet.cpp
  28. 203 0
      gameplay/src/TileSet.h
  29. 4 2
      gameplay/src/gameplay.h
  30. 2 411
      gameplay/src/lua/lua_Font.cpp
  31. 0 1
      gameplay/src/lua/lua_Font.h
  32. 0 156
      gameplay/src/lua/lua_FontText.cpp
  33. 0 16
      gameplay/src/lua/lua_FontText.h
  34. 0 43
      gameplay/src/lua/lua_Form.cpp
  35. 0 1
      gameplay/src/lua/lua_Form.h
  36. 0 43
      gameplay/src/lua/lua_Model.cpp
  37. 0 1
      gameplay/src/lua/lua_Model.h
  38. 0 1
      gameplay/src/lua/lua_all_bindings.cpp
  39. 0 1
      gameplay/src/lua/lua_all_bindings.h
  40. BIN
      samples/browser/res/common/sprites/background.png
  41. BIN
      samples/browser/res/common/sprites/level.png
  42. 143 0
      samples/browser/res/common/sprites/level.txt
  43. BIN
      samples/browser/res/common/sprites/player1.png
  44. 16 0
      samples/browser/res/common/sprites/player1.txt
  45. BIN
      samples/browser/res/common/sprites/player2.png
  46. 16 0
      samples/browser/res/common/sprites/player2.txt
  47. BIN
      samples/browser/res/common/sprites/player3.png
  48. 16 0
      samples/browser/res/common/sprites/player3.txt
  49. BIN
      samples/browser/res/common/sprites/rocket.png
  50. BIN
      samples/browser/res/common/sprites/water2d-noise.png
  51. 31 0
      samples/browser/res/common/sprites/water2d.frag
  52. BIN
      samples/browser/res/common/sprites/water2d.png
  53. 32 24
      samples/browser/sample-browser.xcodeproj/project.pbxproj
  54. 1 1
      samples/browser/src/Audio3DSample.cpp
  55. 1 1
      samples/browser/src/BillboardSample.cpp
  56. 9 9
      samples/browser/src/FontSample.cpp
  57. 5 5
      samples/browser/src/FontSample.h
  58. 1 1
      samples/browser/src/FormsSample.cpp
  59. 1 1
      samples/browser/src/LightSample.cpp
  60. 0 5
      samples/browser/src/MeshPrimitiveSample.cpp
  61. 1 1
      samples/browser/src/MeshPrimitiveSample.h
  62. 1 1
      samples/browser/src/PhysicsCollisionObjectSample.cpp
  63. 1 1
      samples/browser/src/PostProcessSample.cpp
  64. 10 10
      samples/browser/src/SceneCreateSample.cpp
  65. 4 4
      samples/browser/src/SceneCreateSample.h
  66. 13 13
      samples/browser/src/SceneLoadSample.cpp
  67. 4 4
      samples/browser/src/SceneLoadSample.h
  68. 262 0
      samples/browser/src/SpriteSample.cpp
  69. 64 0
      samples/browser/src/SpriteSample.h
  70. 1 1
      samples/browser/src/TerrainSample.cpp
  71. 7 18
      samples/browser/src/TextureSample.cpp
  72. 0 1
      samples/browser/src/TextureSample.h
  73. 1 1
      samples/browser/src/WaterSample.cpp

+ 24 - 8
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -7,6 +7,10 @@
 	objects = {
 	objects = {
 
 
 /* Begin PBXBuildFile section */
 /* Begin PBXBuildFile section */
+		4204EC411A2EB8310074FCE9 /* TileSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4204EC3F1A2EB8310074FCE9 /* TileSet.cpp */; };
+		4204EC421A2EB8310074FCE9 /* TileSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4204EC3F1A2EB8310074FCE9 /* TileSet.cpp */; };
+		4204EC451A2F878C0074FCE9 /* Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4204EC441A2F878C0074FCE9 /* Sprite.cpp */; };
+		4204EC461A2F878C0074FCE9 /* Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4204EC441A2F878C0074FCE9 /* Sprite.cpp */; };
 		420BBC0E1817416F00C7B720 /* ControlFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA21817416D00C7B720 /* ControlFactory.cpp */; };
 		420BBC0E1817416F00C7B720 /* ControlFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA21817416D00C7B720 /* ControlFactory.cpp */; };
 		420BBC0F1817416F00C7B720 /* ControlFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA21817416D00C7B720 /* ControlFactory.cpp */; };
 		420BBC0F1817416F00C7B720 /* ControlFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA21817416D00C7B720 /* ControlFactory.cpp */; };
 		420BBC121817416F00C7B720 /* lua_AbsoluteLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA61817416D00C7B720 /* lua_AbsoluteLayout.cpp */; };
 		420BBC121817416F00C7B720 /* lua_AbsoluteLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBAA61817416D00C7B720 /* lua_AbsoluteLayout.cpp */; };
@@ -105,8 +109,6 @@
 		420BBCCB1817416F00C7B720 /* lua_FontJustify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB021817416E00C7B720 /* lua_FontJustify.cpp */; };
 		420BBCCB1817416F00C7B720 /* lua_FontJustify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB021817416E00C7B720 /* lua_FontJustify.cpp */; };
 		420BBCCE1817416F00C7B720 /* lua_FontStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB041817416E00C7B720 /* lua_FontStyle.cpp */; };
 		420BBCCE1817416F00C7B720 /* lua_FontStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB041817416E00C7B720 /* lua_FontStyle.cpp */; };
 		420BBCCF1817416F00C7B720 /* lua_FontStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB041817416E00C7B720 /* lua_FontStyle.cpp */; };
 		420BBCCF1817416F00C7B720 /* lua_FontStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB041817416E00C7B720 /* lua_FontStyle.cpp */; };
-		420BBCD21817416F00C7B720 /* lua_FontText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB061817416E00C7B720 /* lua_FontText.cpp */; };
-		420BBCD31817416F00C7B720 /* lua_FontText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB061817416E00C7B720 /* lua_FontText.cpp */; };
 		420BBCD61817416F00C7B720 /* lua_Form.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB081817416E00C7B720 /* lua_Form.cpp */; };
 		420BBCD61817416F00C7B720 /* lua_Form.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB081817416E00C7B720 /* lua_Form.cpp */; };
 		420BBCD71817416F00C7B720 /* lua_Form.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB081817416E00C7B720 /* lua_Form.cpp */; };
 		420BBCD71817416F00C7B720 /* lua_Form.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB081817416E00C7B720 /* lua_Form.cpp */; };
 		420BBCDA1817416F00C7B720 /* lua_FrameBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */; };
 		420BBCDA1817416F00C7B720 /* lua_FrameBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */; };
@@ -580,6 +582,8 @@
 		42CC5A1B1809A4EF00AAD8AD /* VertexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55651809A4EE00AAD8AD /* VertexFormat.cpp */; };
 		42CC5A1B1809A4EF00AAD8AD /* VertexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55651809A4EE00AAD8AD /* VertexFormat.cpp */; };
 		42CC5A1E1809A4EF00AAD8AD /* VerticalLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55671809A4EE00AAD8AD /* VerticalLayout.cpp */; };
 		42CC5A1E1809A4EF00AAD8AD /* VerticalLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55671809A4EE00AAD8AD /* VerticalLayout.cpp */; };
 		42CC5A1F1809A4EF00AAD8AD /* VerticalLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55671809A4EE00AAD8AD /* VerticalLayout.cpp */; };
 		42CC5A1F1809A4EF00AAD8AD /* VerticalLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CC55671809A4EE00AAD8AD /* VerticalLayout.cpp */; };
+		42ECC3FA1A4EF5A00036C839 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42ECC3F81A4EF5A00036C839 /* Text.cpp */; };
+		42ECC3FB1A4EF5A00036C839 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42ECC3F81A4EF5A00036C839 /* Text.cpp */; };
 		5B21E99616153890006EBEAC /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B21E99516153890006EBEAC /* IOKit.framework */; };
 		5B21E99616153890006EBEAC /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B21E99516153890006EBEAC /* IOKit.framework */; };
 		5B2BC75F1512514500D176CD /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC75D1512514500D176CD /* OpenAL.framework */; };
 		5B2BC75F1512514500D176CD /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC75D1512514500D176CD /* OpenAL.framework */; };
 		5B2BC7601512514500D176CD /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC75E1512514500D176CD /* OpenGL.framework */; };
 		5B2BC7601512514500D176CD /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC75E1512514500D176CD /* OpenGL.framework */; };
@@ -601,6 +605,10 @@
 /* End PBXBuildFile section */
 /* End PBXBuildFile section */
 
 
 /* Begin PBXFileReference section */
 /* Begin PBXFileReference section */
+		4204EC3F1A2EB8310074FCE9 /* TileSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileSet.cpp; path = src/TileSet.cpp; sourceTree = SOURCE_ROOT; };
+		4204EC401A2EB8310074FCE9 /* TileSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileSet.h; path = src/TileSet.h; sourceTree = SOURCE_ROOT; };
+		4204EC431A2F70BA0074FCE9 /* Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sprite.h; path = src/Sprite.h; sourceTree = SOURCE_ROOT; };
+		4204EC441A2F878C0074FCE9 /* Sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sprite.cpp; path = src/Sprite.cpp; sourceTree = SOURCE_ROOT; };
 		420BBAA21817416D00C7B720 /* ControlFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ControlFactory.cpp; path = src/ControlFactory.cpp; sourceTree = SOURCE_ROOT; };
 		420BBAA21817416D00C7B720 /* ControlFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ControlFactory.cpp; path = src/ControlFactory.cpp; sourceTree = SOURCE_ROOT; };
 		420BBAA31817416D00C7B720 /* ControlFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ControlFactory.h; path = src/ControlFactory.h; sourceTree = SOURCE_ROOT; };
 		420BBAA31817416D00C7B720 /* ControlFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ControlFactory.h; path = src/ControlFactory.h; sourceTree = SOURCE_ROOT; };
 		420BBAA61817416D00C7B720 /* lua_AbsoluteLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_AbsoluteLayout.cpp; sourceTree = "<group>"; };
 		420BBAA61817416D00C7B720 /* lua_AbsoluteLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_AbsoluteLayout.cpp; sourceTree = "<group>"; };
@@ -699,8 +707,6 @@
 		420BBB031817416E00C7B720 /* lua_FontJustify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_FontJustify.h; sourceTree = "<group>"; };
 		420BBB031817416E00C7B720 /* lua_FontJustify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_FontJustify.h; sourceTree = "<group>"; };
 		420BBB041817416E00C7B720 /* lua_FontStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_FontStyle.cpp; sourceTree = "<group>"; };
 		420BBB041817416E00C7B720 /* lua_FontStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_FontStyle.cpp; sourceTree = "<group>"; };
 		420BBB051817416E00C7B720 /* lua_FontStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_FontStyle.h; sourceTree = "<group>"; };
 		420BBB051817416E00C7B720 /* lua_FontStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_FontStyle.h; sourceTree = "<group>"; };
-		420BBB061817416E00C7B720 /* lua_FontText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_FontText.cpp; sourceTree = "<group>"; };
-		420BBB071817416E00C7B720 /* lua_FontText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_FontText.h; sourceTree = "<group>"; };
 		420BBB081817416E00C7B720 /* lua_Form.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_Form.cpp; sourceTree = "<group>"; };
 		420BBB081817416E00C7B720 /* lua_Form.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_Form.cpp; sourceTree = "<group>"; };
 		420BBB091817416E00C7B720 /* lua_Form.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_Form.h; sourceTree = "<group>"; };
 		420BBB091817416E00C7B720 /* lua_Form.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_Form.h; sourceTree = "<group>"; };
 		420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_FrameBuffer.cpp; sourceTree = "<group>"; };
 		420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_FrameBuffer.cpp; sourceTree = "<group>"; };
@@ -1206,6 +1212,8 @@
 		42CD0DA7147D8EA80000361E /* libogg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libogg.a; path = "../external-deps/ogg/lib/macosx/x64/libogg.a"; sourceTree = "<group>"; };
 		42CD0DA7147D8EA80000361E /* libogg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libogg.a; path = "../external-deps/ogg/lib/macosx/x64/libogg.a"; sourceTree = "<group>"; };
 		42CD0DA8147D8EA80000361E /* libvorbis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvorbis.a; path = "../external-deps/vorbis/lib/macosx/x64/libvorbis.a"; sourceTree = "<group>"; };
 		42CD0DA8147D8EA80000361E /* libvorbis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvorbis.a; path = "../external-deps/vorbis/lib/macosx/x64/libvorbis.a"; sourceTree = "<group>"; };
 		42DFAB4F16AD8ECD0000F342 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
 		42DFAB4F16AD8ECD0000F342 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
+		42ECC3F81A4EF5A00036C839 /* Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Text.cpp; path = src/Text.cpp; sourceTree = SOURCE_ROOT; };
+		42ECC3F91A4EF5A00036C839 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Text.h; path = src/Text.h; sourceTree = SOURCE_ROOT; };
 		42FA645D1953DDD600337ABC /* libBulletCollision.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletCollision.a; path = "../external-deps/bullet/lib/macosx/x64/libBulletCollision.a"; sourceTree = "<group>"; };
 		42FA645D1953DDD600337ABC /* libBulletCollision.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletCollision.a; path = "../external-deps/bullet/lib/macosx/x64/libBulletCollision.a"; sourceTree = "<group>"; };
 		42FA645E1953DDD600337ABC /* libBulletDynamics.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletDynamics.a; path = "../external-deps/bullet/lib/macosx/x64/libBulletDynamics.a"; sourceTree = "<group>"; };
 		42FA645E1953DDD600337ABC /* libBulletDynamics.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletDynamics.a; path = "../external-deps/bullet/lib/macosx/x64/libBulletDynamics.a"; sourceTree = "<group>"; };
 		42FA645F1953DDD600337ABC /* libLinearMath.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libLinearMath.a; path = "../external-deps/bullet/lib/macosx/x64/libLinearMath.a"; sourceTree = "<group>"; };
 		42FA645F1953DDD600337ABC /* libLinearMath.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libLinearMath.a; path = "../external-deps/bullet/lib/macosx/x64/libLinearMath.a"; sourceTree = "<group>"; };
@@ -1369,8 +1377,6 @@
 				420BBB031817416E00C7B720 /* lua_FontJustify.h */,
 				420BBB031817416E00C7B720 /* lua_FontJustify.h */,
 				420BBB041817416E00C7B720 /* lua_FontStyle.cpp */,
 				420BBB041817416E00C7B720 /* lua_FontStyle.cpp */,
 				420BBB051817416E00C7B720 /* lua_FontStyle.h */,
 				420BBB051817416E00C7B720 /* lua_FontStyle.h */,
-				420BBB061817416E00C7B720 /* lua_FontText.cpp */,
-				420BBB071817416E00C7B720 /* lua_FontText.h */,
 				420BBB081817416E00C7B720 /* lua_Form.cpp */,
 				420BBB081817416E00C7B720 /* lua_Form.cpp */,
 				420BBB091817416E00C7B720 /* lua_Form.h */,
 				420BBB091817416E00C7B720 /* lua_Form.h */,
 				420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */,
 				420BBB0A1817416E00C7B720 /* lua_FrameBuffer.cpp */,
@@ -1862,6 +1868,10 @@
 				42CC55301809A4EE00AAD8AD /* ScriptTarget.h */,
 				42CC55301809A4EE00AAD8AD /* ScriptTarget.h */,
 				42CC55311809A4EE00AAD8AD /* Slider.cpp */,
 				42CC55311809A4EE00AAD8AD /* Slider.cpp */,
 				42CC55321809A4EE00AAD8AD /* Slider.h */,
 				42CC55321809A4EE00AAD8AD /* Slider.h */,
+				4204EC441A2F878C0074FCE9 /* Sprite.cpp */,
+				4204EC431A2F70BA0074FCE9 /* Sprite.h */,
+				4204EC3F1A2EB8310074FCE9 /* TileSet.cpp */,
+				4204EC401A2EB8310074FCE9 /* TileSet.h */,
 				42CC55451809A4EE00AAD8AD /* SpriteBatch.cpp */,
 				42CC55451809A4EE00AAD8AD /* SpriteBatch.cpp */,
 				42CC55461809A4EE00AAD8AD /* SpriteBatch.h */,
 				42CC55461809A4EE00AAD8AD /* SpriteBatch.h */,
 				42CC55471809A4EE00AAD8AD /* Stream.h */,
 				42CC55471809A4EE00AAD8AD /* Stream.h */,
@@ -1871,6 +1881,8 @@
 				42CC554B1809A4EE00AAD8AD /* Terrain.h */,
 				42CC554B1809A4EE00AAD8AD /* Terrain.h */,
 				42CC554C1809A4EE00AAD8AD /* TerrainPatch.cpp */,
 				42CC554C1809A4EE00AAD8AD /* TerrainPatch.cpp */,
 				42CC554D1809A4EE00AAD8AD /* TerrainPatch.h */,
 				42CC554D1809A4EE00AAD8AD /* TerrainPatch.h */,
+				42ECC3F81A4EF5A00036C839 /* Text.cpp */,
+				42ECC3F91A4EF5A00036C839 /* Text.h */,
 				42CC554E1809A4EE00AAD8AD /* TextBox.cpp */,
 				42CC554E1809A4EE00AAD8AD /* TextBox.cpp */,
 				42CC554F1809A4EE00AAD8AD /* TextBox.h */,
 				42CC554F1809A4EE00AAD8AD /* TextBox.h */,
 				42CC55501809A4EE00AAD8AD /* Texture.cpp */,
 				42CC55501809A4EE00AAD8AD /* Texture.cpp */,
@@ -2071,6 +2083,7 @@
 				42CC55DE1809A4EF00AAD8AD /* FlowLayout.cpp in Sources */,
 				42CC55DE1809A4EF00AAD8AD /* FlowLayout.cpp in Sources */,
 				420BBE861817416F00C7B720 /* lua_TextureFormat.cpp in Sources */,
 				420BBE861817416F00C7B720 /* lua_TextureFormat.cpp in Sources */,
 				426F831B187F72DF00640CBA /* lua_JoystickControl.cpp in Sources */,
 				426F831B187F72DF00640CBA /* lua_JoystickControl.cpp in Sources */,
+				4204EC411A2EB8310074FCE9 /* TileSet.cpp in Sources */,
 				42CC59F61809A4EF00AAD8AD /* Texture.cpp in Sources */,
 				42CC59F61809A4EF00AAD8AD /* Texture.cpp in Sources */,
 				42CC55CA1809A4EF00AAD8AD /* Curve.cpp in Sources */,
 				42CC55CA1809A4EF00AAD8AD /* Curve.cpp in Sources */,
 				420BBDAE1817416F00C7B720 /* lua_PhysicsCollisionShapeDefinition.cpp in Sources */,
 				420BBDAE1817416F00C7B720 /* lua_PhysicsCollisionShapeDefinition.cpp in Sources */,
@@ -2204,6 +2217,7 @@
 				420BBCE61817416F00C7B720 /* lua_GameClearFlags.cpp in Sources */,
 				420BBCE61817416F00C7B720 /* lua_GameClearFlags.cpp in Sources */,
 				42CC59261809A4EF00AAD8AD /* Node.cpp in Sources */,
 				42CC59261809A4EF00AAD8AD /* Node.cpp in Sources */,
 				42CC597A1809A4EF00AAD8AD /* PlatformMacOSX.mm in Sources */,
 				42CC597A1809A4EF00AAD8AD /* PlatformMacOSX.mm in Sources */,
+				4204EC451A2F878C0074FCE9 /* Sprite.cpp in Sources */,
 				420BBEAE1817416F00C7B720 /* lua_Transform.cpp in Sources */,
 				420BBEAE1817416F00C7B720 /* lua_Transform.cpp in Sources */,
 				420BBD961817416F00C7B720 /* lua_PhysicsCollisionObject.cpp in Sources */,
 				420BBD961817416F00C7B720 /* lua_PhysicsCollisionObject.cpp in Sources */,
 				420BBDEE1817416F00C7B720 /* lua_PhysicsVehicle.cpp in Sources */,
 				420BBDEE1817416F00C7B720 /* lua_PhysicsVehicle.cpp in Sources */,
@@ -2315,7 +2329,6 @@
 				420BBC761817416F00C7B720 /* lua_Button.cpp in Sources */,
 				420BBC761817416F00C7B720 /* lua_Button.cpp in Sources */,
 				420BBCDE1817416F00C7B720 /* lua_Frustum.cpp in Sources */,
 				420BBCDE1817416F00C7B720 /* lua_Frustum.cpp in Sources */,
 				420BBE2A1817416F00C7B720 /* lua_RenderStateDepthFunction.cpp in Sources */,
 				420BBE2A1817416F00C7B720 /* lua_RenderStateDepthFunction.cpp in Sources */,
-				420BBCD21817416F00C7B720 /* lua_FontText.cpp in Sources */,
 				420BBC1A1817416F00C7B720 /* lua_AIAgentListener.cpp in Sources */,
 				420BBC1A1817416F00C7B720 /* lua_AIAgentListener.cpp in Sources */,
 				42CC59101809A4EF00AAD8AD /* Mesh.cpp in Sources */,
 				42CC59101809A4EF00AAD8AD /* Mesh.cpp in Sources */,
 				42CC55DA1809A4EF00AAD8AD /* FileSystem.cpp in Sources */,
 				42CC55DA1809A4EF00AAD8AD /* FileSystem.cpp in Sources */,
@@ -2324,6 +2337,7 @@
 				420BBECA1817416F00C7B720 /* lua_VertexFormat.cpp in Sources */,
 				420BBECA1817416F00C7B720 /* lua_VertexFormat.cpp in Sources */,
 				420BBC561817416F00C7B720 /* lua_AudioBuffer.cpp in Sources */,
 				420BBC561817416F00C7B720 /* lua_AudioBuffer.cpp in Sources */,
 				420BBDFE1817416F00C7B720 /* lua_Properties.cpp in Sources */,
 				420BBDFE1817416F00C7B720 /* lua_Properties.cpp in Sources */,
+				42ECC3FA1A4EF5A00036C839 /* Text.cpp in Sources */,
 				42CC56121809A4EF00AAD8AD /* ImageControl.cpp in Sources */,
 				42CC56121809A4EF00AAD8AD /* ImageControl.cpp in Sources */,
 				42CC55E21809A4EF00AAD8AD /* Font.cpp in Sources */,
 				42CC55E21809A4EF00AAD8AD /* Font.cpp in Sources */,
 				420BBE8E1817416F00C7B720 /* lua_TextureWrap.cpp in Sources */,
 				420BBE8E1817416F00C7B720 /* lua_TextureWrap.cpp in Sources */,
@@ -2367,6 +2381,7 @@
 				42CC55DF1809A4EF00AAD8AD /* FlowLayout.cpp in Sources */,
 				42CC55DF1809A4EF00AAD8AD /* FlowLayout.cpp in Sources */,
 				420BBE871817416F00C7B720 /* lua_TextureFormat.cpp in Sources */,
 				420BBE871817416F00C7B720 /* lua_TextureFormat.cpp in Sources */,
 				426F831C187F72DF00640CBA /* lua_JoystickControl.cpp in Sources */,
 				426F831C187F72DF00640CBA /* lua_JoystickControl.cpp in Sources */,
+				4204EC421A2EB8310074FCE9 /* TileSet.cpp in Sources */,
 				42CC59F71809A4EF00AAD8AD /* Texture.cpp in Sources */,
 				42CC59F71809A4EF00AAD8AD /* Texture.cpp in Sources */,
 				42CC55CB1809A4EF00AAD8AD /* Curve.cpp in Sources */,
 				42CC55CB1809A4EF00AAD8AD /* Curve.cpp in Sources */,
 				420BBDAF1817416F00C7B720 /* lua_PhysicsCollisionShapeDefinition.cpp in Sources */,
 				420BBDAF1817416F00C7B720 /* lua_PhysicsCollisionShapeDefinition.cpp in Sources */,
@@ -2500,6 +2515,7 @@
 				420BBE5F1817416F00C7B720 /* lua_Slider.cpp in Sources */,
 				420BBE5F1817416F00C7B720 /* lua_Slider.cpp in Sources */,
 				420BBDD71817416F00C7B720 /* lua_PhysicsGhostObject.cpp in Sources */,
 				420BBDD71817416F00C7B720 /* lua_PhysicsGhostObject.cpp in Sources */,
 				420BBCE71817416F00C7B720 /* lua_GameClearFlags.cpp in Sources */,
 				420BBCE71817416F00C7B720 /* lua_GameClearFlags.cpp in Sources */,
+				4204EC461A2F878C0074FCE9 /* Sprite.cpp in Sources */,
 				42CC59271809A4EF00AAD8AD /* Node.cpp in Sources */,
 				42CC59271809A4EF00AAD8AD /* Node.cpp in Sources */,
 				420BBEAF1817416F00C7B720 /* lua_Transform.cpp in Sources */,
 				420BBEAF1817416F00C7B720 /* lua_Transform.cpp in Sources */,
 				420BBD971817416F00C7B720 /* lua_PhysicsCollisionObject.cpp in Sources */,
 				420BBD971817416F00C7B720 /* lua_PhysicsCollisionObject.cpp in Sources */,
@@ -2611,7 +2627,6 @@
 				420BBC771817416F00C7B720 /* lua_Button.cpp in Sources */,
 				420BBC771817416F00C7B720 /* lua_Button.cpp in Sources */,
 				420BBCDF1817416F00C7B720 /* lua_Frustum.cpp in Sources */,
 				420BBCDF1817416F00C7B720 /* lua_Frustum.cpp in Sources */,
 				420BBE2B1817416F00C7B720 /* lua_RenderStateDepthFunction.cpp in Sources */,
 				420BBE2B1817416F00C7B720 /* lua_RenderStateDepthFunction.cpp in Sources */,
-				420BBCD31817416F00C7B720 /* lua_FontText.cpp in Sources */,
 				420BBC1B1817416F00C7B720 /* lua_AIAgentListener.cpp in Sources */,
 				420BBC1B1817416F00C7B720 /* lua_AIAgentListener.cpp in Sources */,
 				42CC59111809A4EF00AAD8AD /* Mesh.cpp in Sources */,
 				42CC59111809A4EF00AAD8AD /* Mesh.cpp in Sources */,
 				42CC55DB1809A4EF00AAD8AD /* FileSystem.cpp in Sources */,
 				42CC55DB1809A4EF00AAD8AD /* FileSystem.cpp in Sources */,
@@ -2620,6 +2635,7 @@
 				420BBECB1817416F00C7B720 /* lua_VertexFormat.cpp in Sources */,
 				420BBECB1817416F00C7B720 /* lua_VertexFormat.cpp in Sources */,
 				420BBC571817416F00C7B720 /* lua_AudioBuffer.cpp in Sources */,
 				420BBC571817416F00C7B720 /* lua_AudioBuffer.cpp in Sources */,
 				420BBDFF1817416F00C7B720 /* lua_Properties.cpp in Sources */,
 				420BBDFF1817416F00C7B720 /* lua_Properties.cpp in Sources */,
+				42ECC3FB1A4EF5A00036C839 /* Text.cpp in Sources */,
 				42CC56131809A4EF00AAD8AD /* ImageControl.cpp in Sources */,
 				42CC56131809A4EF00AAD8AD /* ImageControl.cpp in Sources */,
 				42CC55E31809A4EF00AAD8AD /* Font.cpp in Sources */,
 				42CC55E31809A4EF00AAD8AD /* Font.cpp in Sources */,
 				420BBE8F1817416F00C7B720 /* lua_TextureWrap.cpp in Sources */,
 				420BBE8F1817416F00C7B720 /* lua_TextureWrap.cpp in Sources */,

+ 5 - 0
gameplay/src/AIAgent.cpp

@@ -35,6 +35,11 @@ Node* AIAgent::getNode() const
 {
 {
     return _node;
     return _node;
 }
 }
+    
+void AIAgent::setNode(Node* node)
+{
+    _node = node;
+}
 
 
 AIStateMachine* AIAgent::getStateMachine()
 AIStateMachine* AIAgent::getStateMachine()
 {
 {

+ 5 - 0
gameplay/src/AIAgent.h

@@ -141,6 +141,11 @@ private:
      * Hidden copy assignment operator.
      * Hidden copy assignment operator.
      */
      */
     AIAgent& operator=(const AIAgent&);
     AIAgent& operator=(const AIAgent&);
+    
+    /**
+     * Set the node this agent is attached to.
+     */
+    void setNode(Node* node);
 
 
     /**
     /**
      * Called by the AIController to process a message for the AIAgent.
      * Called by the AIController to process a message for the AIAgent.

+ 3 - 2
gameplay/src/Animation.cpp

@@ -138,9 +138,9 @@ void Animation::createClips(const char* url)
     SAFE_DELETE(properties);
     SAFE_DELETE(properties);
 }
 }
 
 
-AnimationClip* Animation::createClip(const char* id, unsigned long start, unsigned long end)
+AnimationClip* Animation::createClip(const char* id, unsigned long begin, unsigned long end)
 {
 {
-    AnimationClip* clip = new AnimationClip(id, this, start, end);
+    AnimationClip* clip = new AnimationClip(id, this, begin, end);
     addClip(clip);
     addClip(clip);
     return clip;
     return clip;
 }
 }
@@ -238,6 +238,7 @@ bool Animation::targets(AnimationTarget* target) const
     return false;
     return false;
 }
 }
 
 
+
 void Animation::createDefaultClip()
 void Animation::createDefaultClip()
 {
 {
     _defaultClip = new AnimationClip("default_clip", this, 0.0f, _duration);
     _defaultClip = new AnimationClip("default_clip", this, 0.0f, _duration);

+ 3 - 3
gameplay/src/Animation.h

@@ -57,13 +57,13 @@ public:
      * Creates an AnimationClip from the Animation.
      * Creates an AnimationClip from the Animation.
      *
      *
      * @param id The ID to the give the AnimationClip.
      * @param id The ID to the give the AnimationClip.
-     * @param start The time (in milliseconds) that the AnimationClip will begin from.
-     * @param end The time (in milliseconds) that the AnimationClip will end.
+     * @param begin The begin time (in milliseconds) or keyframe(for keyframe animations).
+     * @param end The end time (in milliseconds) or keyframe (for keyframe animations).
      *
      *
      * @return The newly created AnimationClip; NULL if an AnimationClip already exists with the same ID.
      * @return The newly created AnimationClip; NULL if an AnimationClip already exists with the same ID.
      * @script{create}
      * @script{create}
      */
      */
-    AnimationClip* createClip(const char* id, unsigned long start, unsigned long end);
+    AnimationClip* createClip(const char* id, unsigned long begin, unsigned long end);
 
 
     /**
     /**
      * Finds the AnimationClip with the specified name. If NULL, gets the default clip.
      * Finds the AnimationClip with the specified name. If NULL, gets the default clip.

+ 27 - 0
gameplay/src/Curve.cpp

@@ -141,6 +141,33 @@ float Curve::getEndTime() const
     return _points[_pointCount-1].time;
     return _points[_pointCount-1].time;
 }
 }
 
 
+float Curve::getPointTime(unsigned int index) const
+{
+    assert(index < _pointCount);
+    return _points[index].time;
+}
+
+
+Curve::InterpolationType Curve::getPointInterpolation(unsigned int index) const
+{
+    assert(index < _pointCount);
+    return _points[index].type;;
+}
+
+void Curve::getPointValues(unsigned int index, float* value, float* inValue, float* outValue) const
+{
+    assert(index < _pointCount);
+    
+    if (value)
+        memcpy(value, _points[index].value, _componentSize);
+    
+    if (inValue)
+        memcpy(inValue, _points[index].inValue, _componentSize);
+    
+    if (outValue)
+        memcpy(outValue, _points[index].outValue, _componentSize);
+}
+
 void Curve::setPoint(unsigned int index, float time, float* value, InterpolationType type)
 void Curve::setPoint(unsigned int index, float time, float* value, InterpolationType type)
 {
 {
     setPoint(index, time, value, type, NULL, NULL);
     setPoint(index, time, value, type, NULL, NULL);

+ 33 - 5
gameplay/src/Curve.h

@@ -313,7 +313,7 @@ public:
     float getEndTime() const;
     float getEndTime() const;
 
 
     /**
     /**
-     * Sets the given point values on the curve the curve.
+     * Sets the given point values on the curve.
      *
      *
      * @param index The index of the point.
      * @param index The index of the point.
      * @param time The time for the key.
      * @param time The time for the key.
@@ -332,17 +332,45 @@ public:
      * @param inValue The tangent approaching the point.
      * @param inValue The tangent approaching the point.
      * @param outValue The tangent leaving the point.
      * @param outValue The tangent leaving the point.
      */
      */
-    void setPoint(unsigned int index, float time, float* value, InterpolationType type, float* inValue, float* outValue);
+    void setPoint(unsigned int index, float time, float* value, InterpolationType type,
+                  float* inValue, float* outValue);
 
 
     /**
     /**
      * Sets the tangents for a point on the curve specified by the index.
      * Sets the tangents for a point on the curve specified by the index.
      *
      *
      * @param index The index of the point.
      * @param index The index of the point.
-     * @param type The curve interpolation type.
-     * @param inValue The tangent approaching the point.
-     * @param outValue The tangent leaving the point.
+     *
+     *
      */
      */
     void setTangent(unsigned int index, InterpolationType type, float* inValue, float* outValue);
     void setTangent(unsigned int index, InterpolationType type, float* inValue, float* outValue);
+    
+    /**
+     * Gets the time at a specified point.
+     *
+     * @param index The index of the point.
+     *
+     * @return The time for a key point.
+     */
+    float getPointTime(unsigned int index) const;
+    
+    /**
+     * Gets the interpolation type at the specified point
+     *
+     * @param index The index of the point.
+     * 
+     * @return The interpolation type at the specified index.
+     */
+    InterpolationType getPointInterpolation(unsigned int index) const;
+    
+    /**
+     * Gets the values and in/out tangent value at a spedified point.
+     *
+     * @param index The index of the point.
+     * @param value The value at the specified index. Ignored if NULL.
+     * @param inValue The tangent inValue at the specified index. Ignored if NULL.
+     * @param outValue The tangent outValue at the specified index. Ignored if NULL.
+     */
+    void getPointValues(unsigned int index, float* value, float* inValue, float* outValue) const;
 
 
     /**
     /**
      * Evaluates the curve at the given position value.
      * Evaluates the curve at the given position value.

+ 5 - 291
gameplay/src/Font.cpp

@@ -1,5 +1,6 @@
 #include "Base.h"
 #include "Base.h"
 #include "Font.h"
 #include "Font.h"
+#include "Text.h"
 #include "Game.h"
 #include "Game.h"
 #include "FileSystem.h"
 #include "FileSystem.h"
 #include "Bundle.h"
 #include "Bundle.h"
@@ -16,7 +17,7 @@ static std::vector<Font*> __fontCache;
 static Effect* __fontEffect = NULL;
 static Effect* __fontEffect = NULL;
 
 
 Font::Font() :
 Font::Font() :
-    _format(BITMAP), _style(PLAIN), _size(0), _spacing(0.0f), _glyphs(NULL), _glyphCount(0), _texture(NULL), _batch(NULL), _cutoffParam(NULL)
+    _format(BITMAP), _style(PLAIN), _size(0), _spacing(0.0f), _glyphs(NULL), _glyphCount(0), _batch(NULL), _cutoffParam(NULL)
 {
 {
 }
 }
 
 
@@ -31,7 +32,6 @@ Font::~Font()
 
 
     SAFE_DELETE(_batch);
     SAFE_DELETE(_batch);
     SAFE_DELETE_ARRAY(_glyphs);
     SAFE_DELETE_ARRAY(_glyphs);
-    SAFE_RELEASE(_texture);
 
 
     // Free child fonts
     // Free child fonts
     for (size_t i = 0, count = _sizes.size(); i < count; ++i)
     for (size_t i = 0, count = _sizes.size(); i < count; ++i)
@@ -146,7 +146,6 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
     font->_family = family;
     font->_family = family;
     font->_style = style;
     font->_style = style;
     font->_size = size;
     font->_size = size;
-    font->_texture = texture;
     font->_batch = batch;
     font->_batch = batch;
 
 
     // Copy the glyphs array.
     // Copy the glyphs array.
@@ -219,252 +218,6 @@ void Font::finish()
     }
     }
 }
 }
 
 
-Font::Text* Font::createText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size, Justify justify,
-    bool wrap, bool rightToLeft, const Rectangle* clip)
-{
-    GP_ASSERT(text);
-    GP_ASSERT(_glyphs);
-    GP_ASSERT(_batch);
-    GP_ASSERT(_size);
-
-    if (size == 0)
-    {
-        size = _size;
-    }
-    else
-    {
-        // Delegate to closest sized font
-        Font* f = findClosestSize(size);
-        if (f != this)
-        {
-            return f->createText(text, area, color, size, justify, wrap, rightToLeft, clip);
-        }
-    }
-
-    float scale = (float)size / _size;
-    int spacing = (int)(size * _spacing);
-    int yPos = area.y;
-    const float areaHeight = area.height - size;
-    std::vector<int> xPositions;
-    std::vector<unsigned int> lineLengths;
-
-    getMeasurementInfo(text, area, size, justify, wrap, rightToLeft, &xPositions, &yPos, &lineLengths);
-
-    Text* batch = new Text(text);
-    batch->_font = this;
-    batch->_font->addRef();
-
-    GP_ASSERT(batch->_vertices);
-    GP_ASSERT(batch->_indices);
-
-    int xPos = area.x;
-    std::vector<int>::const_iterator xPositionsIt = xPositions.begin();
-    if (xPositionsIt != xPositions.end())
-    {
-        xPos = *xPositionsIt++;
-    }
-
-    const char* token = text;
-    int iteration = 1;
-    unsigned int lineLength;
-    unsigned int currentLineLength = 0;
-    const char* lineStart;
-    std::vector<unsigned int>::const_iterator lineLengthsIt;
-    if (rightToLeft)
-    {
-        lineStart = token;
-        lineLengthsIt = lineLengths.begin();
-        lineLength = *lineLengthsIt++;
-        token += lineLength - 1;
-        iteration = -1;
-    }
-
-    while (token[0] != 0)
-    {
-        // Handle delimiters until next token.
-        if (!handleDelimiters(&token, size, iteration, area.x, &xPos, &yPos, &currentLineLength, &xPositionsIt, xPositions.end()))
-        {
-            break;
-        }
-
-        bool truncated = false;
-        unsigned int tokenLength;
-        unsigned int tokenWidth;
-        unsigned int startIndex;
-        if (rightToLeft)
-        {
-            tokenLength = getReversedTokenLength(token, text);
-            currentLineLength += tokenLength;
-            token -= (tokenLength - 1);
-            tokenWidth = getTokenWidth(token, tokenLength, size, scale);
-            iteration = -1;
-            startIndex = tokenLength - 1;
-        }
-        else
-        {
-            tokenLength = (unsigned int)strcspn(token, " \r\n\t");
-            tokenWidth = getTokenWidth(token, tokenLength, size, scale);
-            iteration = 1;
-            startIndex = 0;
-        }
-
-        // Wrap if necessary.
-        if (wrap && (xPos + (int)tokenWidth > area.x + area.width || (rightToLeft && currentLineLength > lineLength)))
-        {
-            yPos += (int)size;
-            currentLineLength = tokenLength;
-
-            if (xPositionsIt != xPositions.end())
-            {
-                xPos = *xPositionsIt++;
-            }
-            else
-            {
-                xPos = area.x;
-            }
-        }
-
-        bool draw = true;
-        if (yPos < static_cast<int>(area.y))
-        {
-            // Skip drawing until line break or wrap.
-            draw = false;
-        }
-        else if (yPos > area.y + areaHeight)
-        {
-            // Truncate below area's vertical limit.
-            break;
-        }
-
-        for (int i = startIndex; i < (int)tokenLength && i >= 0; i += iteration)
-        {
-            char c = token[i];
-            int glyphIndex = c - 32; // HACK for ASCII
-
-            if (glyphIndex >= 0 && glyphIndex < (int)_glyphCount)
-            {
-                Glyph& g = _glyphs[glyphIndex];
-
-                if (xPos + (int)(g.advance*scale) > area.x + area.width)
-                {
-                    // Truncate this line and go on to the next one.
-                    truncated = true;
-                    break;
-                }
-                else if (xPos >= (int)area.x)
-                {
-                    // Draw this character.
-                    if (draw)
-                    {
-                        if (clip)
-                        {
-                            _batch->addSprite(xPos + (int)(g.bearingX * scale), yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, *clip, &batch->_vertices[batch->_vertexCount]);
-                        }
-                        else
-                        {
-                            _batch->addSprite(xPos + (int)(g.bearingX * scale), yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, &batch->_vertices[batch->_vertexCount]);
-                        }
-
-                        if (batch->_vertexCount == 0)
-                        {
-                            // Simply copy values directly into the start of the index array
-                            batch->_indices[batch->_vertexCount] = batch->_vertexCount;
-                            batch->_indices[batch->_vertexCount + 1] = batch->_vertexCount + 1;
-                            batch->_indices[batch->_vertexCount + 2] = batch->_vertexCount + 2;
-                            batch->_indices[batch->_vertexCount + 3] = batch->_vertexCount + 3;
-                            batch->_vertexCount += 4;
-                            batch->_indexCount += 4;
-                        }
-                        else
-                        {
-                            // Create a degenerate triangle to connect separate triangle strips
-                            // by duplicating the previous and next vertices.
-                            batch->_indices[batch->_indexCount] = batch->_indices[batch->_indexCount - 1];
-                            batch->_indices[batch->_indexCount + 1] = batch->_vertexCount;
-
-                            // Loop through all indices and insert them, their their value offset by
-                            // 'vertexCount' so that they are relative to the first newly insertted vertex
-                            for (unsigned int i = 0; i < 4; ++i)
-                            {
-                                batch->_indices[batch->_indexCount + 2 + i] = i + batch->_vertexCount;
-                            }
-
-                            batch->_indexCount += 6;
-                            batch->_vertexCount += 4;
-                        }
-
-                    }
-                }
-                xPos += (int)(g.advance)*scale + spacing;
-            }
-        }
-
-        if (!truncated)
-        {
-            if (rightToLeft)
-            {
-                if (token == lineStart)
-                {
-                    token += lineLength;
-
-                    // Now handle delimiters going forwards.
-                    if (!handleDelimiters(&token, size, 1, area.x, &xPos, &yPos, &currentLineLength, &xPositionsIt, xPositions.end()))
-                    {
-                        break;
-                    }
-
-                    if (lineLengthsIt != lineLengths.end())
-                    {
-                        lineLength = *lineLengthsIt++;
-                    }
-                    lineStart = token;
-                    token += lineLength-1;
-                }
-                else
-                {
-                    token--;
-                }
-            }
-            else
-            {
-                token += tokenLength;
-            }
-        }
-        else
-        {
-            if (rightToLeft)
-            {
-                token = lineStart + lineLength;
-
-                if (!handleDelimiters(&token, size, 1, area.x, &xPos, &yPos, &currentLineLength, &xPositionsIt, xPositions.end()))
-                {
-                    break;
-                }
-
-                if (lineLengthsIt != lineLengths.end())
-                {
-                    lineLength = *lineLengthsIt++;
-                }
-                lineStart = token;
-                token += lineLength-1;
-            }
-            else
-            {
-                // Skip the rest of this line.
-                size_t tokenLength = strcspn(token, "\n");
-
-                if (tokenLength > 0)
-                {
-                    // Get first token of next line.
-                    token += tokenLength;
-                }
-            }
-        }
-    }
-
-    return batch;
-}
-
 Font* Font::findClosestSize(int size)
 Font* Font::findClosestSize(int size)
 {
 {
     if (size == (int)_size)
     if (size == (int)_size)
@@ -486,26 +239,6 @@ Font* Font::findClosestSize(int size)
     return closest;
     return closest;
 }
 }
 
 
-void Font::drawText(Text* text)
-{
-    GP_ASSERT(text);
-    GP_ASSERT(text->_font);
-
-    if (text->_font != this)
-    {
-        // Make sure we draw using the font/batch the text was created with
-        text->_font->drawText(text);
-        return;
-    }
-
-    GP_ASSERT(_batch);
-    GP_ASSERT(text->_vertices);
-    GP_ASSERT(text->_indices);
-
-    lazyStart();
-    _batch->draw(text->_vertices, text->_vertexCount, text->_indices, text->_indexCount);
-}
-
 void Font::drawText(const char* text, int x, int y, const Vector4& color, unsigned int size, bool rightToLeft)
 void Font::drawText(const char* text, int x, int y, const Vector4& color, unsigned int size, bool rightToLeft)
 {
 {
     GP_ASSERT(_size);
     GP_ASSERT(_size);
@@ -656,7 +389,7 @@ void Font::drawText(const char* text, int x, int y, float red, float green, floa
     drawText(text, x, y, Vector4(red, green, blue, alpha), size, rightToLeft);
     drawText(text, x, y, Vector4(red, green, blue, alpha), size, rightToLeft);
 }
 }
 
 
-void Font::drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size, Justify justify, bool wrap, bool rightToLeft, const Rectangle* clip)
+void Font::drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size, Justify justify, bool wrap, bool rightToLeft, const Rectangle& clip)
 {
 {
     GP_ASSERT(text);
     GP_ASSERT(text);
     GP_ASSERT(_size);
     GP_ASSERT(_size);
@@ -796,9 +529,9 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
                             // TODO: Fix me so that smaller font are much smoother
                             // TODO: Fix me so that smaller font are much smoother
                             _cutoffParam->setVector2(Vector2(1.0, 1.0));
                             _cutoffParam->setVector2(Vector2(1.0, 1.0));
                         }
                         }
-                        if (clip)
+                        if (clip != Rectangle(0, 0, 0, 0))
                         {
                         {
-                            _batch->draw(xPos + (int)(g.bearingX * scale), yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, *clip);
+                            _batch->draw(xPos + (int)(g.bearingX * scale), yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, clip);
                         }
                         }
                         else
                         else
                         {
                         {
@@ -1981,23 +1714,4 @@ Font::Justify Font::getJustify(const char* justify)
     return Font::ALIGN_TOP_LEFT;
     return Font::ALIGN_TOP_LEFT;
 }
 }
 
 
-Font::Text::Text(const char* text) : _text(text ? text : ""), _vertexCount(0), _vertices(NULL), _indexCount(0), _indices(NULL), _font(NULL)
-{
-    const size_t length = strlen(text);
-    _vertices = new SpriteBatch::SpriteVertex[length * 4];
-    _indices = new unsigned short[((length - 1) * 6) + 4];
-}
-
-Font::Text::~Text()
-{
-    SAFE_DELETE_ARRAY(_vertices);
-    SAFE_DELETE_ARRAY(_indices);
-    SAFE_RELEASE(_font);
-}
-
-const char* Font::Text::getText()
-{
-    return _text.c_str();
-}
-
 }
 }

+ 12 - 81
gameplay/src/Font.h

@@ -12,6 +12,7 @@ namespace gameplay
 class Font : public Ref
 class Font : public Ref
 {
 {
     friend class Bundle;
     friend class Bundle;
+    friend class Text;
     friend class TextBox;
     friend class TextBox;
 
 
 public:
 public:
@@ -58,52 +59,6 @@ public:
         DISTANCE_FIELD = 1
         DISTANCE_FIELD = 1
     };
     };
 
 
-    /**
-     * Vertex coordinates, UVs and indices can be computed and stored in a Text object.
-     * For static text labels that do not change frequently, this means these computations
-     * need not be performed every frame.
-     */
-    class Text
-    {
-        friend class Font;
-
-    public:
-        /**
-         * Constructor.
-         */
-        Text(const char* text);
-
-        /**
-         * Destructor.
-         */
-        ~Text();
-
-        /**
-         * Get the string that will be drawn from this Text object.
-         */
-        const char* getText();
-
-    private:
-
-        /**
-         * Hidden copy constructor.
-         */
-        Text(const Text&);
-
-        /**
-         * Hidden copy assignment operator.
-         */
-        Text& operator=(const Text&);
-
-        std::string _text;
-        unsigned int _vertexCount;
-        SpriteBatch::SpriteVertex* _vertices;
-        unsigned int _indexCount;
-        unsigned short* _indices;
-        Vector4 _color;
-        Font* _font;
-    };
-
     /**
     /**
      * Creates a font from the given bundle.
      * Creates a font from the given bundle.
      *
      *
@@ -166,7 +121,8 @@ public:
      * @param size The size to draw text (0 for default size).
      * @param size The size to draw text (0 for default size).
      * @param rightToLeft Whether to draw text from right to left.
      * @param rightToLeft Whether to draw text from right to left.
      */
      */
-    void drawText(const char* text, int x, int y, const Vector4& color, unsigned int size = 0, bool rightToLeft = false);
+    void drawText(const char* text, int x, int y, const Vector4& color, unsigned int size = 0,
+                  bool rightToLeft = false);
 
 
     /**
     /**
      * Draws the specified text in a solid color, with a scaling factor.
      * Draws the specified text in a solid color, with a scaling factor.
@@ -181,7 +137,8 @@ public:
      * @param size The size to draw text (0 for default size).
      * @param size The size to draw text (0 for default size).
      * @param rightToLeft Whether to draw text from right to left.
      * @param rightToLeft Whether to draw text from right to left.
      */
      */
-    void drawText(const char* text, int x, int y, float red, float green, float blue, float alpha, unsigned int size = 0, bool rightToLeft = false);
+    void drawText(const char* text, int x, int y, float red, float green, float blue, float alpha, unsigned int size = 0,
+                  bool rightToLeft = false);
 
 
     /**
     /**
      * Draws the specified text within a rectangular area, with a specified alignment and scale.
      * Draws the specified text within a rectangular area, with a specified alignment and scale.
@@ -197,34 +154,8 @@ public:
      * @param clip A region to clip text within after applying justification to the viewport area.
      * @param clip A region to clip text within after applying justification to the viewport area.
      */
      */
     void drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size = 0,
     void drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size = 0,
-                  Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false, const Rectangle* clip = NULL);
-
-    /**
-     * Draw a string from a precomputed Text object.
-     *
-     * @param text The text to draw.
-     */
-    void drawText(Text* text);
-
-    /**
-     * Create an immutable Text object from a given string.
-     * Vertex coordinates, UVs and indices will be computed and stored in the Text object.
-     * For static text labels that do not change frequently, this means these computations
-     * need not be performed every frame.
-     *
-     * @param text The text to draw.
-     * @param area The viewport area to draw within.  Text will be clipped outside this rectangle.
-     * @param color The color of text.
-     * @param size The size to draw text (0 for default size).
-     * @param justify Justification of text within the viewport.
-     * @param wrap Wraps text to fit within the width of the viewport if true.
-     * @param rightToLeft Whether to draw text from right to left.
-     * @param clip A region to clip text within after applying justification to the viewport area.
-     *
-     * @return A Text object.
-     */
-    Text* createText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size = 0,
-                     Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false, const Rectangle* clip = NULL);
+                  Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false,
+                  const Rectangle& clip = Rectangle(0, 0, 0, 0));
 
 
     /**
     /**
      * Finishes text batching for this font and renders all drawn text.
      * Finishes text batching for this font and renders all drawn text.
@@ -280,14 +211,15 @@ public:
     /**
     /**
      * Get an character index into a string corresponding to the character nearest the given location within the clip region.
      * Get an character index into a string corresponding to the character nearest the given location within the clip region.
      */
      */
-    int getIndexAtLocation(const char* text, const Rectangle& clip, unsigned int size, const Vector2& inLocation, Vector2* outLocation,
-                           Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false);
+    int getIndexAtLocation(const char* text, const Rectangle& clip, unsigned int size, const Vector2& inLocation,
+                           Vector2* outLocation, Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false);
 
 
     /**
     /**
      * Get the location of the character at the given index.
      * Get the location of the character at the given index.
      */
      */
-    void getLocationAtIndex(const char* text, const Rectangle& clip, unsigned int size, Vector2* outLocation, const unsigned int destIndex,
-                            Justify justify = ALIGN_TOP_LEFT, bool wrap = true, bool rightToLeft = false);
+    void getLocationAtIndex(const char* text, const Rectangle& clip, unsigned int size, Vector2* outLocation,
+                            const unsigned int destIndex, Justify justify = ALIGN_TOP_LEFT, bool wrap = true,
+                            bool rightToLeft = false);
 
 
     /**
     /**
      * Gets the sprite batch used to draw this Font.
      * Gets the sprite batch used to draw this Font.
@@ -411,7 +343,6 @@ private:
     float _spacing;
     float _spacing;
     Glyph* _glyphs;
     Glyph* _glyphs;
     unsigned int _glyphCount;
     unsigned int _glyphCount;
-    Texture* _texture;
     SpriteBatch* _batch;
     SpriteBatch* _batch;
     Rectangle _viewport;
     Rectangle _viewport;
     MaterialParameter* _cutoffParam;
     MaterialParameter* _cutoffParam;

+ 1 - 1
gameplay/src/Label.cpp

@@ -125,7 +125,7 @@ unsigned int Label::drawText(Form* form, const Rectangle& clip)
 
 
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         startBatch(form, batch);
         startBatch(form, batch);
-        _font->drawText(_text.c_str(), _textBounds, _textColor, fontSize, getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
+        _font->drawText(_text.c_str(), _textBounds, _textColor, fontSize, getTextAlignment(state), true, getTextRightToLeft(state), _viewportClipBounds);
         finishBatch(form, batch);
         finishBatch(form, batch);
 
 
         return 1;
         return 1;

+ 10 - 10
gameplay/src/Model.h

@@ -137,16 +137,6 @@ public:
      */
      */
     Node* getNode() const;
     Node* getNode() const;
 
 
-    /**
-     * Sets the node that is associated with this model.
-     *
-     * This method is automatically called when a model is attached to a node
-     * and therefore should not normally be called explicitly.
-     *
-     * @param node The node that is associated with this model.
-     */
-    void setNode(Node* node);
-
     /**
     /**
      * Draws this mesh instance.
      * Draws this mesh instance.
      *
      *
@@ -176,6 +166,16 @@ private:
      * Hidden copy assignment operator.
      * Hidden copy assignment operator.
      */
      */
     Model& operator=(const Model&);
     Model& operator=(const Model&);
+    
+    /**
+     * Sets the node that is associated with this model.
+     *
+     * This method is automatically called when a model is attached to a node
+     * and therefore should not normally be called explicitly.
+     *
+     * @param node The node that is associated with this model.
+     */
+    void setNode(Node* node);
 
 
     /**
     /**
      * Sets the MeshSkin for this model.
      * Sets the MeshSkin for this model.

+ 142 - 44
gameplay/src/Node.cpp

@@ -8,8 +8,8 @@
 #include "PhysicsVehicleWheel.h"
 #include "PhysicsVehicleWheel.h"
 #include "PhysicsGhostObject.h"
 #include "PhysicsGhostObject.h"
 #include "PhysicsCharacter.h"
 #include "PhysicsCharacter.h"
-#include "Game.h"
 #include "Terrain.h"
 #include "Terrain.h"
+#include "Game.h"
 
 
 // Node dirty flags
 // Node dirty flags
 #define NODE_DIRTY_WORLD 1
 #define NODE_DIRTY_WORLD 1
@@ -20,9 +20,10 @@ namespace gameplay
 {
 {
 
 
 Node::Node(const char* id)
 Node::Node(const char* id)
-    : _scene(NULL), _firstChild(NULL), _nextSibling(NULL), _prevSibling(NULL), _parent(NULL), _childCount(0), _enabled(true),
-    _tags(NULL), _camera(NULL), _light(NULL), _model(NULL), _terrain(NULL), _form(NULL), _audioSource(NULL), _particleEmitter(NULL),
-    _collisionObject(NULL), _agent(NULL), _dirtyBits(NODE_DIRTY_ALL), _notifyHierarchyChanged(true), _userData(NULL)
+    : _scene(NULL), _firstChild(NULL), _nextSibling(NULL), _prevSibling(NULL), _parent(NULL), _childCount(0),
+       _enabled(true), _tags(NULL), _camera(NULL), _light(NULL), _model(NULL), _sprite(NULL), _tileset(NULL), _text(NULL),
+        _form(NULL), _particleEmitter(NULL), _terrain(NULL), _audioSource(NULL), _collisionObject(NULL), _agent(NULL),
+       _dirtyBits(NODE_DIRTY_ALL), _notifyHierarchyChanged(true), _userData(NULL)
 {
 {
     if (id)
     if (id)
     {
     {
@@ -49,6 +50,9 @@ Node::~Node()
     SAFE_RELEASE(_terrain);
     SAFE_RELEASE(_terrain);
     SAFE_RELEASE(_audioSource);
     SAFE_RELEASE(_audioSource);
     SAFE_RELEASE(_particleEmitter);
     SAFE_RELEASE(_particleEmitter);
+    SAFE_RELEASE(_sprite);
+    SAFE_RELEASE(_tileset);
+    SAFE_RELEASE(_text);
     SAFE_RELEASE(_form);
     SAFE_RELEASE(_form);
     SAFE_DELETE(_collisionObject);
     SAFE_DELETE(_collisionObject);
     SAFE_DELETE(_tags);
     SAFE_DELETE(_tags);
@@ -844,33 +848,81 @@ void Node::setModel(Model* model)
     }
     }
 }
 }
 
 
-Terrain* Node::getTerrain() const
+Sprite* Node::getSprite() const
 {
 {
-    return _terrain;
+    return _sprite;
 }
 }
 
 
-void Node::setTerrain(Terrain* terrain)
+void Node::setSprite(Sprite* sprite)
 {
 {
-    if (_terrain != terrain)
+    if (_sprite != sprite)
     {
     {
-        if (_terrain)
+        if (_sprite)
         {
         {
-            _terrain->setNode(NULL);
-            SAFE_RELEASE(_terrain);
+            _sprite->setNode(NULL);
+            SAFE_RELEASE(_sprite);
+        }
+        
+        _sprite = sprite;
+        
+        if (_sprite)
+        {
+            _sprite->addRef();
+            _sprite->setNode(this);
         }
         }
+    }
+}
 
 
-        _terrain = terrain;
+TileSet* Node::getTileSet() const
+{
+    return _tileset;
+}
 
 
-        if (_terrain)
+void Node::setTileSet(TileSet* tileset)
+{
+    if (_tileset != tileset)
+    {
+        if (_tileset)
         {
         {
-            _terrain->addRef();
-            _terrain->setNode(this);
+            _tileset->setNode(NULL);
+            SAFE_RELEASE(_tileset);
+        }
+        
+        _tileset = tileset;
+        
+        if (_tileset)
+        {
+            _tileset->addRef();
+            _tileset->setNode(this);
         }
         }
-
-        setBoundsDirty();
     }
     }
 }
 }
 
 
+Text* Node::getText() const
+{
+    return _text;
+}
+
+void Node::setText(Text* text)
+{
+    if (_text != text)
+    {
+        if (_text)
+        {
+            _text->setNode(NULL);
+            SAFE_RELEASE(_text);
+        }
+        
+        _text = text;
+        
+        if (_text)
+        {
+            _text->addRef();
+            _text->setNode(this);
+        }
+    }
+}
+    
 Form* Node::getForm() const
 Form* Node::getForm() const
 {
 {
     return _form;
     return _form;
@@ -896,6 +948,58 @@ void Node::setForm(Form* form)
     }
     }
 }
 }
 
 
+ParticleEmitter* Node::getParticleEmitter() const
+{
+    return _particleEmitter;
+}
+
+void Node::setParticleEmitter(ParticleEmitter* emitter)
+{
+    if (_particleEmitter != emitter)
+    {
+        if (_particleEmitter)
+        {
+            _particleEmitter->setNode(NULL);
+            SAFE_RELEASE(_particleEmitter);
+        }
+        
+        _particleEmitter = emitter;
+        
+        if (_particleEmitter)
+        {
+            _particleEmitter->addRef();
+            _particleEmitter->setNode(this);
+        }
+    }
+}
+    
+Terrain* Node::getTerrain() const
+{
+    return _terrain;
+}
+
+void Node::setTerrain(Terrain* terrain)
+{
+    if (_terrain != terrain)
+    {
+        if (_terrain)
+        {
+            _terrain->setNode(NULL);
+            SAFE_RELEASE(_terrain);
+        }
+
+        _terrain = terrain;
+
+        if (_terrain)
+        {
+            _terrain->addRef();
+            _terrain->setNode(this);
+        }
+
+        setBoundsDirty();
+    }
+}
+
 const BoundingSphere& Node::getBoundingSphere() const
 const BoundingSphere& Node::getBoundingSphere() const
 {
 {
     if (_dirtyBits & NODE_DIRTY_BOUNDS)
     if (_dirtyBits & NODE_DIRTY_BOUNDS)
@@ -1073,6 +1177,25 @@ void Node::cloneInto(Node* node, NodeCloneContext &context) const
         node->setParticleEmitter(emitterClone);
         node->setParticleEmitter(emitterClone);
         emitterClone->release();
         emitterClone->release();
     }
     }
+    if (Sprite* sprite = getSprite())
+    {
+        Sprite* spriteClone = sprite->clone(context);
+        node->setSprite(spriteClone);
+        spriteClone->release();
+    }
+    if (TileSet* tileset = getTileSet())
+    {
+        TileSet* tilesetClone = tileset->clone(context);
+        node->setTileSet(tilesetClone);
+        tilesetClone->release();
+    }
+    if (Text* text = getText())
+    {
+        Text* textClone = text->clone(context);
+        node->setText(textClone);
+        textClone->release();
+    }
+    
     node->_world = _world;
     node->_world = _world;
     node->_bounds = _bounds;
     node->_bounds = _bounds;
 
 
@@ -1110,31 +1233,6 @@ void Node::setAudioSource(AudioSource* audio)
     }
     }
 }
 }
 
 
-ParticleEmitter* Node::getParticleEmitter() const
-{
-    return _particleEmitter;
-}
-
-void Node::setParticleEmitter(ParticleEmitter* emitter)
-{
-    if (_particleEmitter != emitter)
-    {
-        if (_particleEmitter)
-        {
-            _particleEmitter->setNode(NULL);
-            SAFE_RELEASE(_particleEmitter);
-        }
-        
-        _particleEmitter = emitter;
-
-        if (_particleEmitter)
-        {
-            _particleEmitter->addRef();
-            _particleEmitter->setNode(this);
-        }
-    }
-}
-
 PhysicsCollisionObject* Node::getCollisionObject() const
 PhysicsCollisionObject* Node::getCollisionObject() const
 {
 {
     return _collisionObject;
     return _collisionObject;
@@ -1277,7 +1375,7 @@ void Node::setAgent(AIAgent* agent)
         if (_agent)
         if (_agent)
         {
         {
             Game::getInstance()->getAIController()->removeAgent(_agent);
             Game::getInstance()->getAIController()->removeAgent(_agent);
-            _agent->_node = NULL;
+            _agent->setNode(NULL);
             SAFE_RELEASE(_agent);
             SAFE_RELEASE(_agent);
         }
         }
 
 
@@ -1286,7 +1384,7 @@ void Node::setAgent(AIAgent* agent)
         if (_agent)
         if (_agent)
         {
         {
             _agent->addRef();
             _agent->addRef();
-            _agent->_node = this;
+            _agent->setNode(this);
             Game::getInstance()->getAIController()->addAgent(_agent);
             Game::getInstance()->getAIController()->addAgent(_agent);
         }
         }
     }
     }

+ 141 - 63
gameplay/src/Node.h

@@ -5,6 +5,9 @@
 #include "Camera.h"
 #include "Camera.h"
 #include "Light.h"
 #include "Light.h"
 #include "Model.h"
 #include "Model.h"
+#include "Sprite.h"
+#include "TileSet.h"
+#include "Text.h"
 #include "Form.h"
 #include "Form.h"
 #include "ParticleEmitter.h"
 #include "ParticleEmitter.h"
 #include "PhysicsRigidBody.h"
 #include "PhysicsRigidBody.h"
@@ -15,11 +18,16 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-class AudioSource;
-class Bundle;
 class Scene;
 class Scene;
+class Model;
+class Sprite;
+class TileSet;
+class Text;
 class Form;
 class Form;
+class ParticleEmitter;
 class Terrain;
 class Terrain;
+class AudioSource;
+class AIAgent;
 
 
 /**
 /**
  * Defines a hierarchical structure of objects in 3D transformation spaces.
  * Defines a hierarchical structure of objects in 3D transformation spaces.
@@ -412,31 +420,31 @@ public:
     Animation* getAnimation(const char* id = NULL) const;
     Animation* getAnimation(const char* id = NULL) const;
 
 
     /**
     /**
-     * Returns the pointer to this node's camera.
+     * Gets the camera attached to this node.
      *
      *
-     * @return The pointer to this node's camera or NULL.
+     * @return Gets the camera attached to this node.
      */
      */
     Camera* getCamera() const;
     Camera* getCamera() const;
 
 
     /**
     /**
-     * Assigns a camera to this node.
+     * Attaches a camera to this node.
      *
      *
      * This will increase the reference count of the new camera and decrease
      * This will increase the reference count of the new camera and decrease
      * the reference count of the old camera.
      * the reference count of the old camera.
      *
      *
-     * @param camera A pointer to a camera. May be NULL.
+     * @param camera The new camera. May be NULL.
      */
      */
     void setCamera(Camera* camera);
     void setCamera(Camera* camera);
 
 
     /**
     /**
-     * Returns the pointer to this node's light.
+     * Get the light attached to this node.
      *
      *
-     * @return The pointer to this node's light or NULL.
+     * @return The light attached to this node.
      */
      */
     Light* getLight() const;
     Light* getLight() const;
 
 
     /**
     /**
-     * Assigns a light to this node.
+     * Attaches a light to this node.
      *
      *
      * This will increase the reference count of the new light and decrease
      * This will increase the reference count of the new light and decrease
      * the reference count of the old light.
      * the reference count of the old light.
@@ -446,14 +454,14 @@ public:
     void setLight(Light* light);
     void setLight(Light* light);
 
 
     /**
     /**
-     * Returns the pointer to this node's model.
+     * Gets the model attached to this node.
      *
      *
-     * @return The pointer to this node's model or NULL.
+     * @return The model attached to this node.
      */
      */
     Model* getModel() const;
     Model* getModel() const;
 
 
     /**
     /**
-     * Assigns a model to this node.
+     * Attaches a model to this node.
      *
      *
      * This will increase the reference count of the new model and decrease
      * This will increase the reference count of the new model and decrease
      * the reference count of the old model.
      * the reference count of the old model.
@@ -461,64 +469,81 @@ public:
      * @param model The new model. May be NULL.
      * @param model The new model. May be NULL.
      */
      */
     void setModel(Model* model);
     void setModel(Model* model);
-
+    
     /**
     /**
-     * Returns the pointer to this node's terrain.
+     * Gets the sprite attached to this node.
      *
      *
-     * @return The pointer to this node's terrain.
+     * @return The sprite attached to this node
      */
      */
-    Terrain* getTerrain() const;
-
+    Sprite* getSprite() const;
+    
     /**
     /**
-     * Assigns a terrain to this node.
+     * Attaches a sprite to this node.
      *
      *
-     * This will increase the reference count of the new terrain and decrease
-     * the reference count of the old terrain.
+     * This will increase the reference count of the new sprite and decrease
+     * the reference count of the old sprite.
      *
      *
-     * @param terrain The new terrain. May be NULL.
+     * @param sprite The new sprite. May be NULL.
      */
      */
-    void setTerrain(Terrain* terrain);
-
+    void setSprite(Sprite* sprite);
+    
     /**
     /**
-     * Returns the pointer to this node's form.
+     * Gets the tileset attached to this node.
      *
      *
-     * @return The pointer to this node's form or NULL.
+     * @return The tileset attached to this node
      */
      */
-    Form* getForm() const;
-
+    TileSet* getTileSet() const;
+    
     /**
     /**
-     * Assigns a form to this node.
+     * Attaches a tileset to this node.
+     *
+     * This will increase the reference count of the new tileset and decrease
+     * the reference count of the old tileset.
      *
      *
-     * @param form The form pointer. May be NULL.
+     * @param tileset The new tileset. May be NULL.
      */
      */
-    void setForm(Form* form);
-
+    void setTileSet(TileSet* tileset);
+    
     /**
     /**
-     * Returns the pointer to this node's audio source.
+     * Gets the tileset attached to this node.
      *
      *
-     * @return The pointer to this node's audio source or NULL.
+     * @return The tileset attached to this node
      */
      */
-    AudioSource* getAudioSource() const;
-
+    Text* getText() const;
+    
     /**
     /**
-     * Assigns an audio source to this node.
+     * Attaches text to this node.
      *
      *
-     * This will increase the reference count of the new audio source and decrease
-     * the reference count of the old audio source.
+     * This will increase the reference count of the new text and decrease
+     * the reference count of the old text.
      *
      *
-     * @param audio The new audio source. May be NULL.
+     * @param tileset The new tileset. May be NULL.
      */
      */
-    void setAudioSource(AudioSource* audio);
+    void setText(Text* text);
+
+    /**
+     * Gets the form attached to this node.
+     *
+     * @return The form attached to this node.
+     */
+    Form* getForm() const;
 
 
+    /**
+     * Attaches a form to this node.
+     *
+     * @param form The new form. May be NULL.
+     */
+    void setForm(Form* form);
+    
     /**
     /**
      * Returns the pointer to this node's particle emitter.
      * Returns the pointer to this node's particle emitter.
      *
      *
      * @return The pointer to this node's particle emitter or NULL.
      * @return The pointer to this node's particle emitter or NULL.
      */
      */
     ParticleEmitter* getParticleEmitter() const;
     ParticleEmitter* getParticleEmitter() const;
-
+    
     /**
     /**
-     * Assigns a particle emitter to this node.
+     * Attaches a particle emitter to this node.
      *
      *
      * This will increase the reference count of the new particle emitter and decrease
      * This will increase the reference count of the new particle emitter and decrease
      * the reference count of the old particle emitter.
      * the reference count of the old particle emitter.
@@ -526,6 +551,40 @@ public:
      * @param emitter The new particle emitter. May be NULL.
      * @param emitter The new particle emitter. May be NULL.
      */
      */
     void setParticleEmitter(ParticleEmitter* emitter);
     void setParticleEmitter(ParticleEmitter* emitter);
+    
+    /**
+     * Gets the terrain attached to this node.
+     *
+     * @return The terrain attached to this node.
+     */
+    Terrain* getTerrain() const;
+    
+    /**
+     * Attaches a terrain to this node.
+     *
+     * This will increase the reference count of the new terrain and decrease
+     * the reference count of the old terrain.
+     *
+     * @param terrain The new terrain. May be NULL.
+     */
+    void setTerrain(Terrain* terrain);
+
+    /**
+     * Gets the audio source attached to this node.
+     *
+     * @return The audio source attached to this node.
+     */
+    AudioSource* getAudioSource() const;
+
+    /**
+     * Attaches an audio source to this node.
+     *
+     * This will increase the reference count of the new audio source and decrease
+     * the reference count of the old audio source.
+     *
+     * @param audio The new audio source. May be NULL.
+     */
+    void setAudioSource(AudioSource* audio);
 
 
     /**
     /**
      * Returns the pointer to this node's physics collision object.
      * Returns the pointer to this node's physics collision object.
@@ -580,8 +639,11 @@ public:
      * @param group Group identifier of the object for collision filtering.
      * @param group Group identifier of the object for collision filtering.
      * @param mask Bitmask to filter groups of objects to collide with this one.
      * @param mask Bitmask to filter groups of objects to collide with this one.
      */
      */
-    PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type, const PhysicsCollisionShape::Definition& shape = PhysicsCollisionShape::box(),
-                                               PhysicsRigidBody::Parameters* rigidBodyParameters = NULL, int group = PHYSICS_COLLISION_GROUP_DEFAULT, int mask = PHYSICS_COLLISION_MASK_DEFAULT);
+    PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type,
+                                               const PhysicsCollisionShape::Definition& shape = PhysicsCollisionShape::box(),
+                                               PhysicsRigidBody::Parameters* rigidBodyParameters = NULL,
+                                               int group = PHYSICS_COLLISION_GROUP_DEFAULT,
+                                               int mask = PHYSICS_COLLISION_MASK_DEFAULT);
 
 
     /**
     /**
      * Sets the physics collision object for this node using the data from the Properties object defined at the specified URL,
      * Sets the physics collision object for this node using the data from the Properties object defined at the specified URL,
@@ -741,27 +803,27 @@ protected:
     Scene* _scene;
     Scene* _scene;
 
 
     /**
     /**
-     * The Node's ID.
+     * Node's ID.
      */
      */
     std::string _id;
     std::string _id;
 
 
     /**
     /**
-     * Pointer to the Node's first child.
+     * Node's first child.
      */
      */
     Node* _firstChild;
     Node* _firstChild;
 
 
     /**
     /**
-     * Pointer to the Node's next child.
+     * Node's next child.
      */
      */
     Node* _nextSibling;
     Node* _nextSibling;
 
 
     /**
     /**
-     * Pointer to the Node's previous sibling.
+     * Node's previous sibling.
      */
      */
     Node* _prevSibling;
     Node* _prevSibling;
 
 
     /**
     /**
-     * Pointer to the Node's parent.
+     * Node's parent.
      */
      */
     Node* _parent;
     Node* _parent;
 
 
@@ -771,49 +833,65 @@ protected:
     unsigned int _childCount;
     unsigned int _childCount;
 
 
     /**
     /**
-     * If this node is enabled in the scene. This may not be enabled in hierarchy if its parents are not enabled.
+     * If this node is enabled in the scene.
+     * This may not be enabled in hierarchy if its parents are not enabled.
      */
      */
     bool _enabled;
     bool _enabled;
 
 
     /**
     /**
-     * List of custom tags for a node.
+     * List of tags for a node.
      */
      */
     std::map<std::string, std::string>* _tags;
     std::map<std::string, std::string>* _tags;
 
 
     /**
     /**
-     * Pointer to the Camera attached to the Node.
+     * Camera attached to the Node.
      */
      */
     Camera* _camera;
     Camera* _camera;
 
 
     /**
     /**
-     * Pointer to the Light attached to the Node.
+     * Light attached to the Node.
      */
      */
     Light* _light;
     Light* _light;
 
 
     /**
     /**
-     * Pointer to the Model attached to the Node.
+     * Model attached to the Node.
      */
      */
     Model* _model;
     Model* _model;
 
 
     /**
     /**
-     * Pointer to the Terrain attached to the Node.
+     * Sprite attached to the Node.
      */
      */
-    Terrain* _terrain;
-
+    Sprite* _sprite;
+    
     /**
     /**
-     * Pointer to the Form attached to the Node.
+     * TileSet attached to the Node.
      */
      */
-    Form* _form;
-
+    TileSet* _tileset;
+    
     /**
     /**
-     * Pointer to the AudioSource attached to the Node.
+     * Text attached to the Node.
      */
      */
-    AudioSource* _audioSource;
-
+    Text* _text;
+    
+    /**
+     * Form attached to the Node.
+     */
+    Form* _form;
+    
     /**
     /**
      * Pointer to the ParticleEmitter attached to the Node.
      * Pointer to the ParticleEmitter attached to the Node.
      */
      */
     ParticleEmitter* _particleEmitter;
     ParticleEmitter* _particleEmitter;
+    
+    /**
+     * Pointer to the Terrain attached to the Node.
+     */
+    Terrain* _terrain;
+
+    /**
+     * Pointer to the AudioSource attached to the Node.
+     */
+    AudioSource* _audioSource;
 
 
     /**
     /**
      * Pointer to the PhysicsCollisionObject attached to the Node.
      * Pointer to the PhysicsCollisionObject attached to the Node.

+ 8 - 1
gameplay/src/ParticleEmitter.cpp

@@ -731,7 +731,6 @@ Node* ParticleEmitter::getNode() const
 
 
 void ParticleEmitter::setNode(Node* node)
 void ParticleEmitter::setNode(Node* node)
 {
 {
-    // Connect the new node.
     _node = node;
     _node = node;
 }
 }
 
 
@@ -843,10 +842,18 @@ ParticleEmitter::BlendMode ParticleEmitter::getBlendModeFromString(const char* s
     {
     {
         return BLEND_NONE;
         return BLEND_NONE;
     }
     }
+    else if (strcmp(str, "BLEND_OPAQUE") == 0 || strcmp(str, "OPAQUE") == 0 )
+    {
+        return BLEND_NONE;
+    }
     else if (strcmp(str, "BLEND_ALPHA") == 0 || strcmp(str, "ALPHA") == 0 )
     else if (strcmp(str, "BLEND_ALPHA") == 0 || strcmp(str, "ALPHA") == 0 )
     {
     {
         return BLEND_ALPHA;
         return BLEND_ALPHA;
     }
     }
+    else if (strcmp(str, "BLEND_TRANSPARENT") == 0 || strcmp(str, "TRANSPARENT") == 0 )
+    {
+        return BLEND_ALPHA;
+    }
     else if (strcmp(str, "BLEND_ADDITIVE") == 0 || strcmp(str, "ADDITIVE") == 0)
     else if (strcmp(str, "BLEND_ADDITIVE") == 0 || strcmp(str, "ADDITIVE") == 0)
     {
     {
         return BLEND_ADDITIVE;
         return BLEND_ADDITIVE;

+ 3 - 0
gameplay/src/PlatformMacOSX.mm

@@ -13,6 +13,7 @@
 #import <OpenGL/OpenGL.h>
 #import <OpenGL/OpenGL.h>
 #import <mach/mach_time.h>
 #import <mach/mach_time.h>
 #import <Foundation/Foundation.h>
 #import <Foundation/Foundation.h>
+#import <Availability.h>
 #import <GameKit/GameKit.h>
 #import <GameKit/GameKit.h>
 
 
 // These should probably be moved to a platform common file
 // These should probably be moved to a platform common file
@@ -849,7 +850,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
         NSOpenGLPFASamples, static_cast<NSOpenGLPixelFormatAttribute>(samples),
         NSOpenGLPFASamples, static_cast<NSOpenGLPixelFormatAttribute>(samples),
         NSOpenGLPFADoubleBuffer,
         NSOpenGLPFADoubleBuffer,
         NSOpenGLPFAScreenMask, (NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()),
         NSOpenGLPFAScreenMask, (NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()),
+    #if (__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7)
         NSOpenGLPFAFullScreen,
         NSOpenGLPFAFullScreen,
+    #endif
         NSOpenGLPFAColorSize, 32,
         NSOpenGLPFAColorSize, 32,
         NSOpenGLPFADepthSize, 24,
         NSOpenGLPFADepthSize, 24,
         NSOpenGLPFAAlphaSize, 8,
         NSOpenGLPFAAlphaSize, 8,

+ 7 - 7
gameplay/src/Quaternion.cpp

@@ -229,15 +229,15 @@ void Quaternion::setIdentity()
 
 
 float Quaternion::toAxisAngle(Vector3* axis) const
 float Quaternion::toAxisAngle(Vector3* axis) const
 {
 {
-    GP_ASSERT(axis);
-
     Quaternion q(x, y, z, w);
     Quaternion q(x, y, z, w);
     q.normalize();
     q.normalize();
-    axis->x = q.x;
-    axis->y = q.y;
-    axis->z = q.z;
-    axis->normalize();
-
+    if (axis)
+    {
+        axis->x = q.x;
+        axis->y = q.y;
+        axis->z = q.z;
+        axis->normalize();
+    }
     return (2.0f * acos(q.w));
     return (2.0f * acos(q.w));
 }
 }
 
 

+ 61 - 2
gameplay/src/SceneLoader.cpp

@@ -91,7 +91,10 @@ Scene* SceneLoader::loadInternal(const char* url)
         SceneNodeProperty::CAMERA |
         SceneNodeProperty::CAMERA |
         SceneNodeProperty::ROTATE |
         SceneNodeProperty::ROTATE |
         SceneNodeProperty::SCALE |
         SceneNodeProperty::SCALE |
-        SceneNodeProperty::TRANSLATE);
+        SceneNodeProperty::TRANSLATE |
+        SceneNodeProperty::SPRITE |
+        SceneNodeProperty::TILESET |
+        SceneNodeProperty::TEXT);
     applyNodeProperties(sceneProperties, SceneNodeProperty::COLLISION_OBJECT);
     applyNodeProperties(sceneProperties, SceneNodeProperty::COLLISION_OBJECT);
 
 
     // Apply node tags
     // Apply node tags
@@ -245,7 +248,10 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
         snp._type == SceneNodeProperty::TERRAIN ||
         snp._type == SceneNodeProperty::TERRAIN ||
         snp._type == SceneNodeProperty::LIGHT ||
         snp._type == SceneNodeProperty::LIGHT ||
         snp._type == SceneNodeProperty::CAMERA ||
         snp._type == SceneNodeProperty::CAMERA ||
-        snp._type == SceneNodeProperty::COLLISION_OBJECT)
+        snp._type == SceneNodeProperty::COLLISION_OBJECT ||
+        snp._type == SceneNodeProperty::SPRITE ||
+        snp._type == SceneNodeProperty::TILESET ||
+        snp._type == SceneNodeProperty::TEXT)
     {
     {
         // Check to make sure the referenced properties object was loaded properly.
         // Check to make sure the referenced properties object was loaded properly.
         Properties* p = _properties[snp._value];
         Properties* p = _properties[snp._value];
@@ -269,6 +275,7 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
             break;
             break;
         }
         }
         case SceneNodeProperty::MATERIAL:
         case SceneNodeProperty::MATERIAL:
+        {
             if (!node->getModel())
             if (!node->getModel())
             {
             {
                 GP_ERROR("Attempting to set a material on node '%s', which has no model.", sceneNode._nodeID);
                 GP_ERROR("Attempting to set a material on node '%s', which has no model.", sceneNode._nodeID);
@@ -281,6 +288,7 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
                 SAFE_RELEASE(material);
                 SAFE_RELEASE(material);
             }
             }
             break;
             break;
+        }
         case SceneNodeProperty::PARTICLE:
         case SceneNodeProperty::PARTICLE:
         {
         {
             ParticleEmitter* particleEmitter = ParticleEmitter::create(p);
             ParticleEmitter* particleEmitter = ParticleEmitter::create(p);
@@ -370,6 +378,27 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
             }
             }
             break;
             break;
         }
         }
+        case SceneNodeProperty::SPRITE:
+        {
+            Sprite* sprite = Sprite::create(p);
+            node->setSprite(sprite);
+            SAFE_RELEASE(sprite);
+            break;
+        }
+        case SceneNodeProperty::TILESET:
+        {
+            TileSet* tileset = TileSet::create(p);
+            node->setTileSet(tileset);
+            SAFE_RELEASE(tileset);
+            break;
+        }
+        case SceneNodeProperty::TEXT:
+        {
+            Text* text = Text::create(p);
+            node->setText(text);
+            SAFE_RELEASE(text);
+            break;
+        }
         default:
         default:
             GP_ERROR("Unsupported node property type (%d).", snp._type);
             GP_ERROR("Unsupported node property type (%d).", snp._type);
             break;
             break;
@@ -704,6 +733,24 @@ void SceneLoader::parseNode(Properties* ns, SceneNode* parent, const std::string
             addSceneNodeProperty(sceneNode, SceneNodeProperty::COLLISION_OBJECT, propertyUrl.c_str());
             addSceneNodeProperty(sceneNode, SceneNodeProperty::COLLISION_OBJECT, propertyUrl.c_str());
             _properties[propertyUrl] = subns;
             _properties[propertyUrl] = subns;
         }
         }
+        else if (strcmp(subns->getNamespace(), "sprite") == 0)
+        {
+            propertyUrl = path + "sprite/" + std::string(subns->getId());
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::SPRITE, propertyUrl.c_str());
+            _properties[propertyUrl] = subns;
+        }
+        else if (strcmp(subns->getNamespace(), "tileset") == 0)
+        {
+            propertyUrl = path + "tileset/" + std::string(subns->getId());
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::TILESET, propertyUrl.c_str());
+            _properties[propertyUrl] = subns;
+        }
+        else if (strcmp(subns->getNamespace(), "text") == 0)
+        {
+            propertyUrl = path + "text/" + std::string(subns->getId());
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::TEXT, propertyUrl.c_str());
+            _properties[propertyUrl] = subns;
+        }
         else if (strcmp(subns->getNamespace(), "tags") == 0)
         else if (strcmp(subns->getNamespace(), "tags") == 0)
         {
         {
             while ((name = subns->getNextProperty()) != NULL)
             while ((name = subns->getNextProperty()) != NULL)
@@ -760,6 +807,18 @@ void SceneLoader::parseNode(Properties* ns, SceneNode* parent, const std::string
         {
         {
             addSceneNodeProperty(sceneNode, SceneNodeProperty::COLLISION_OBJECT, ns->getString(), true);
             addSceneNodeProperty(sceneNode, SceneNodeProperty::COLLISION_OBJECT, ns->getString(), true);
         }
         }
+        else if (strcmp(name, "sprite") == 0)
+        {
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::SPRITE, ns->getString(), true);
+        }
+        else if (strcmp(name, "tileset") == 0)
+        {
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::TILESET, ns->getString(), true);
+        }
+        else if (strcmp(name, "text") == 0)
+        {
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::TEXT, ns->getString(), true);
+        }
         else if (strcmp(name, "rigidBodyModel") == 0)
         else if (strcmp(name, "rigidBodyModel") == 0)
         {
         {
             // Ignore this for now. We process this when we do rigid body creation.
             // Ignore this for now. We process this when we do rigid body creation.

+ 4 - 1
gameplay/src/SceneLoader.h

@@ -57,7 +57,10 @@ private:
             TRANSLATE = 128,
             TRANSLATE = 128,
             ROTATE = 256,
             ROTATE = 256,
             SCALE = 512,
             SCALE = 512,
-            URL = 1024
+            URL = 1024,
+            SPRITE = 2048,
+            TILESET = 4096,
+            TEXT = 8192
         };
         };
 
 
         SceneNodeProperty(Type type, const std::string& value, int index, bool isUrl);
         SceneNodeProperty(Type type, const std::string& value, int index, bool isUrl);

+ 1 - 1
gameplay/src/Slider.cpp

@@ -477,7 +477,7 @@ unsigned int Slider::drawText(Form* form, const Rectangle& clip)
 
 
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         startBatch(form, batch);
         startBatch(form, batch);
-        _font->drawText(_valueText.c_str(), _textBounds, _textColor, fontSize, _valueTextAlignment, true, getTextRightToLeft(state), &_viewportClipBounds);
+        _font->drawText(_valueText.c_str(), _textBounds, _textColor, fontSize, _valueTextAlignment, true, getTextRightToLeft(state), _viewportClipBounds);
         finishBatch(form, batch);
         finishBatch(form, batch);
 
 
         ++drawCalls;
         ++drawCalls;

+ 478 - 0
gameplay/src/Sprite.cpp

@@ -0,0 +1,478 @@
+#include "Base.h"
+#include "Sprite.h"
+#include "Scene.h"
+
+namespace gameplay
+{
+
+Sprite::Sprite()
+    : _width(0), _height(0), _offset(OFFSET_BOTTOM_LEFT), _anchor(Vector2(0.5f, 0.5f)), _flipFlags(FLIP_NONE),
+      _frames(NULL), _frameCount(1), _frameStride(0), _framePadding(1), _frameIndex(0),
+      _opacity(1.0f), _color(Vector4::one()), _blendMode(BLEND_ALPHA), _batch(NULL), _node(NULL)
+{
+}
+
+Sprite::~Sprite()
+{
+    if (_frames)
+        SAFE_DELETE_ARRAY(_frames);
+    if (_batch)
+        SAFE_DELETE(_batch);
+}
+
+Sprite& Sprite::operator=(const Sprite& sprite)
+{
+    return *this;
+}
+    
+Sprite* Sprite::create(const char* imagePath, float width, float height, Effect* effect)
+{
+    return Sprite::create(imagePath, width, height, Rectangle(0, 0, -1, -1), 1, effect);
+}
+    
+Sprite* Sprite::create(const char* imagePath, float width, float height,
+                       const Rectangle& source, unsigned int frameCount, Effect* effect)
+{
+    GP_ASSERT(imagePath != NULL);
+    GP_ASSERT(width >= -1 && height >= -1);
+    GP_ASSERT(source.width >= -1 && source.heigh >= -1);
+    GP_ASSERT(frameCount > 0);
+    
+    SpriteBatch* batch = SpriteBatch::create(imagePath, effect);
+    batch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
+    batch->getSampler()->setFilterMode(Texture::Filter::LINEAR, Texture::Filter::LINEAR);
+    batch->getStateBlock()->setDepthWrite(false);
+    batch->getStateBlock()->setDepthTest(true);
+    
+    unsigned int imageWidth = batch->getSampler()->getTexture()->getWidth();
+    unsigned int imageHeight = batch->getSampler()->getTexture()->getHeight();
+    if (width == -1)
+        width = imageWidth;
+    if (height == -1)
+        height = imageHeight;
+    
+    Sprite* sprite = new Sprite();
+    sprite->_width = width;
+    sprite->_height = height;
+    sprite->_batch = batch;
+    sprite->_frameCount = frameCount;
+    sprite->_frames = new Rectangle[frameCount];
+    sprite->_frames[0] = source;
+    if (sprite->_frames[0].width == -1.0f)
+        sprite->_frames[0].width = imageWidth;
+    if (sprite->_frames[0].height == -1.0f)
+        sprite->_frames[0].height = imageHeight;
+    return sprite;
+}
+
+Sprite* Sprite::create(Properties* properties)
+{    
+    /*
+     sprite spaceship
+     {
+         anchor = 0.5, 0.5
+         color = 0,0,0,1
+         opacity = 1.0f
+         blendMode = BLEND_ALPHA
+         path = res/foo/spaceship.png
+         width = 100
+         height = 100
+         source = 0, 0, 70, 70
+         flip = FLIP_VERTICAL
+         frameCount = 1
+     }
+     */
+    return NULL;
+}
+    
+float Sprite::getWidth() const
+{
+    return _width;
+}
+
+float Sprite::getHeight() const
+{
+    return _height;
+}
+    
+void Sprite::setOffset(Sprite::Offset offset)
+{
+    _offset = offset;
+}
+
+Sprite::Offset Sprite::getOffset() const
+{
+    return _offset;
+}
+    
+void Sprite::setAnchor(const Vector2& anchor)
+{
+    _anchor = anchor;
+}
+
+const Vector2& Sprite::getAnchor() const
+{
+    return _anchor;
+}
+    
+void Sprite::setFlip(int flipFlags)
+{
+    _flipFlags = flipFlags;
+}
+
+int Sprite::getFlip() const
+{
+    return _flipFlags;
+}
+
+void Sprite::setFrameSource(unsigned int frameIndex, const Rectangle& source)
+{
+    GP_ASSERT(frameIndex < _frameCount);
+    
+    _frames[frameIndex] = source;
+}
+
+const Rectangle& Sprite::getFrameSource(unsigned int frameIndex) const
+{
+    GP_ASSERT(frameIndex < _frameCount);
+    
+    return _frames[frameIndex];
+}
+
+void Sprite::computeFrames(unsigned int frameStride, unsigned int framePadding)
+{
+    _frameStride = frameStride;
+    _framePadding = framePadding;
+    
+    if (_frameCount < 2)
+        return;
+    unsigned int imageWidth = _batch->getSampler()->getTexture()->getWidth();
+    unsigned int imageHeight = _batch->getSampler()->getTexture()->getHeight();
+    float textureWidthRatio = 1.0f / imageWidth;
+    float textureHeightRatio = 1.0f / imageHeight;
+    
+    // If we have a stride then compute the wrap width
+    float strideWidth;
+    if (_frameStride > 0)
+        strideWidth = _frameStride * _frames[0].width;
+    else
+        strideWidth = imageWidth;
+    
+    // Mark the start as reference
+    float x = _frames[0].x;
+    float y = _frames[0].y;
+    float width = _frames[0].width;
+    float height = _frames[0].height;
+    
+    // Compute frames 1+
+    for (unsigned int frameIndex = 1; frameIndex < _frameCount; frameIndex++)
+    {
+        _frames[frameIndex].x = x;
+        _frames[frameIndex].y = y;
+        _frames[frameIndex].width = _width;
+        _frames[frameIndex].height = _height;
+        
+        x += _frames[frameIndex].width + (float)_framePadding;
+        if (x >= imageWidth)
+        {
+            y += _frames[frameIndex].height + (float)_framePadding;
+            if (y >= imageHeight)
+            {
+                y = 0.0f;
+            }
+            x = 0.0f;
+        }
+    }
+}
+
+unsigned int Sprite::getFrameCount() const
+{
+    return _frameCount;
+}
+
+unsigned int Sprite::getFramePadding() const
+{
+    return _framePadding;
+}
+
+unsigned int Sprite::getFrameStride() const
+{
+    return _frameStride;
+}
+
+void Sprite::setFrameIndex(unsigned int index)
+{
+    _frameIndex = index;
+}
+
+unsigned int Sprite::getFrameIndex() const
+{
+    return _frameIndex;
+}
+
+void Sprite::setOpacity(float opacity)
+{
+    _opacity = opacity;
+}
+
+float Sprite::getOpacity() const
+{
+    return _opacity;
+}
+
+void Sprite::setColor(const Vector4& color)
+{
+    _color = color;
+}
+
+const Vector4& Sprite::getColor() const
+{
+    return _color;
+}
+    
+Sprite::BlendMode Sprite::getBlendMode() const
+{
+    return _blendMode;
+}
+    
+void Sprite::setBlendMode(BlendMode mode)
+{
+    switch (mode)
+    {
+        case BLEND_NONE:
+            _batch->getStateBlock()->setBlend(false);
+            break;
+        case BLEND_ALPHA:
+            _batch->getStateBlock()->setBlend(true);
+            _batch->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
+            _batch->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
+            break;
+        case BLEND_ADDITIVE:
+            _batch->getStateBlock()->setBlend(true);
+            _batch->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
+            _batch->getStateBlock()->setBlendDst(RenderState::BLEND_ONE);
+            break;
+        case BLEND_MULTIPLIED:
+            _batch->getStateBlock()->setBlend(true);
+            _batch->getStateBlock()->setBlendSrc(RenderState::BLEND_ZERO);
+            _batch->getStateBlock()->setBlendDst(RenderState::BLEND_SRC_COLOR);
+            break;
+        default:
+            GP_ERROR("Unsupported blend mode (%d).", mode);
+            break;
+    }
+}
+
+Texture::Sampler* Sprite::getSampler() const
+{
+    return _batch->getSampler();
+}
+
+RenderState::StateBlock* Sprite::getStateBlock() const
+{
+    return _batch->getStateBlock();
+}
+
+Material* Sprite::getMaterial() const
+{
+    return _batch->getMaterial();
+}
+
+unsigned int Sprite::draw()
+{
+    // Apply scene camera projection and translation offsets
+    Vector3 position = Vector3::zero();
+    if (_node && _node->getScene())
+    {
+        Camera* activeCamera = _node->getScene()->getActiveCamera();
+        if (activeCamera)
+        {
+            Node* cameraNode = _node->getScene()->getActiveCamera()->getNode();
+            if (cameraNode)
+            {
+                // Scene projection
+                Matrix projectionMatrix;
+                projectionMatrix = _node->getProjectionMatrix();
+                _batch->setProjectionMatrix(projectionMatrix);
+                
+                // Camera translation offsets
+                position.x -= cameraNode->getTranslationWorld().x;
+                position.y -= cameraNode->getTranslationWorld().y;
+                
+            }
+        }
+        
+        // Apply node translation offsets
+        Vector3 translation = _node->getTranslationWorld();
+        position.x += translation.x;
+        position.y += translation.y;
+        position.z += translation.z;
+    }
+    
+    // Apply local offset translation offsets
+    if ((_offset & OFFSET_HCENTER) == OFFSET_HCENTER)
+        position.x -= _width * 0.5;
+    if ((_offset & OFFSET_RIGHT) == OFFSET_RIGHT)
+        position.x -= _width;
+    if ((_offset & OFFSET_VCENTER) == OFFSET_VCENTER)
+        position.y -= _height * 0.5f;
+    if ((_offset & OFFSET_TOP) == OFFSET_TOP)
+        position.y -= _height;
+    if ((_offset & OFFSET_ANCHOR) == OFFSET_ANCHOR)
+    {
+        position.x -= _width * _anchor.x;
+        position.y -= _height * _anchor.y;
+    }
+    
+    // Apply node scale and rotation
+    float rotationAngle = 0.0f;
+    Vector2 scale = Vector2(_width, _height);
+    if (_node)
+    {
+        // Apply node rotation
+        const Quaternion& rot = _node->getRotation();
+        if (rot.x != 0.0f || rot.y != 0.0f || rot.z != 0.0f)
+            rotationAngle = rot.toAxisAngle(NULL);
+        
+        // Apply node scale
+        if (_node->getScaleX() != 1.0f)
+            scale.x *= _node->getScaleX();
+        if (_node->getScaleY() != 1.0f)
+            scale.y *= _node->getScaleY();
+    }
+    
+    // Apply flip flags
+    if ((_flipFlags & FLIP_HORIZONTAL) == FLIP_HORIZONTAL)
+    {
+        position.x += scale.x;
+        scale.x = -scale.x;
+    }
+    if ((_flipFlags & FLIP_VERTICAL) == FLIP_VERTICAL)
+    {
+        position.y += scale.y;
+        scale.y = -scale.y;
+    }
+    
+    // TODO: Proper batching from cache based on batching rules (image, layers, etc)
+    _batch->start();
+    _batch->draw(position, _frames[_frameIndex], scale, Vector4(_color.x, _color.y, _color.z, _color.w * _opacity),
+                 _anchor, rotationAngle);
+    _batch->finish();
+    
+    return 1;
+}
+
+Node* Sprite::getNode() const
+{
+    return _node;
+}
+    
+void Sprite::setNode(Node* node)
+{
+    _node = node;
+}
+    
+Sprite* Sprite::clone(NodeCloneContext &context)
+{
+    Sprite* copy = new Sprite();
+    cloneInto(copy, context);
+    return copy;
+}
+
+void Sprite::cloneInto(Sprite* sprite, NodeCloneContext &context) const
+{
+    GP_ASSERT(sprite);
+
+    // Clone animations
+    AnimationTarget::cloneInto(static_cast<AnimationTarget*>(sprite), context);
+
+    // Get copied node if it exists
+    if (Node* node = getNode())
+    {
+        Node* clonedNode = context.findClonedNode(node);
+        if (clonedNode)
+        {
+            sprite->setNode(clonedNode);
+        }
+    }
+
+    // Clone properties
+    sprite->_width = _width;
+    sprite->_height = _height;
+    sprite->_offset = _offset;
+    sprite->_anchor = _anchor;
+    sprite->_flipFlags = _flipFlags;
+    sprite->_opacity = _opacity;
+    sprite->_color = _color;
+    sprite->_blendMode = _blendMode;
+    sprite->_frames = new Rectangle[_frameCount];
+    memcpy(sprite->_frames, _frames, sizeof(Rectangle) * _frameCount);
+    sprite->_frameCount = _frameCount;
+    sprite->_frameStride = _frameStride;
+    sprite->_framePadding = _framePadding;
+    sprite->_frameIndex = _frameIndex;
+    sprite->_batch = _batch;
+}
+
+unsigned int Sprite::getAnimationPropertyComponentCount(int propertyId) const
+{
+    switch (propertyId)
+    {
+        case ANIMATE_OPACITY:
+            return 1;
+        case ANIMATE_COLOR:
+            return 4;
+        case ANIMATE_KEYFRAME:
+            return 1;
+        default:
+            return -1;
+    }
+}
+
+void Sprite::getAnimationPropertyValue(int propertyId, AnimationValue* value)
+{
+    GP_ASSERT(value);
+    
+    switch (propertyId)
+    {
+        case ANIMATE_OPACITY:
+            value->setFloat(0, _opacity);
+            break;
+        case ANIMATE_COLOR:
+            value->setFloat(0, _color.x);
+            value->setFloat(1, _color.y);
+            value->setFloat(2, _color.z);
+            value->setFloat(3, _color.w);
+            break;
+        case ANIMATE_KEYFRAME:
+            value->setFloat(0, (float)_frameIndex);
+            break;
+        default:
+            break;
+    }
+}
+
+void Sprite::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
+{
+    GP_ASSERT(value);
+    
+    switch(propertyId)
+    {
+        case ANIMATE_OPACITY:
+            setOpacity(Curve::lerp(blendWeight, _opacity, value->getFloat(0)));
+            break;
+        case ANIMATE_COLOR:
+            setColor(Vector4(Curve::lerp(blendWeight, _color.x, value->getFloat(0)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(1)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(2)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(3))));
+            break;
+        case ANIMATE_KEYFRAME:
+            _frameIndex = (unsigned int)value->getFloat(0);
+            break;
+        default:
+            break;
+    }
+}
+
+}

+ 404 - 0
gameplay/src/Sprite.h

@@ -0,0 +1,404 @@
+#ifndef SPRITE_H_
+#define SPRITE_H_
+
+#include "Ref.h"
+#include "AnimationTarget.h"
+#include "Properties.h"
+#include "Rectangle.h"
+#include "Vector4.h"
+#include "SpriteBatch.h"
+#include "Effect.h"
+#include "Node.h"
+
+namespace gameplay
+{
+
+/**
+ * Defines a sprite for rendering a 2D region.
+ *
+ * A sprite has alignment for controlling the local offset bounds.
+ * A sprite has an anchor for controlling the origin for rotation and physics.
+ *
+ * You can add transformation and hierarchial by attaching sprites to Nodes within a Scene.
+ *
+ * The active camera in a scene effects the rendering location in the viewport for each sprite.
+ *
+ * Sprites can be animated using the animation system.
+ * Sprites can have physics applied to them via their node binding.
+ */
+class Sprite : public Ref, public AnimationTarget
+{
+    friend class Node;
+    
+public:
+    
+    /**
+     * Opacity property. Data=opacity
+     */
+    static const int ANIMATE_OPACITY = 1;
+    
+    /**
+     * Color property. Data = red, green, blue, alpha
+     */
+    static const int ANIMATE_COLOR = 2;
+    
+    /**
+     * Image keyframe index property. Data=index
+     */
+    static const int ANIMATE_KEYFRAME = 3;
+    
+    /**
+     * Defines the offset for position.
+     */
+    enum Offset
+    {
+        OFFSET_LEFT = 0x01,
+        OFFSET_HCENTER = 0x02,
+        OFFSET_RIGHT = 0x04,
+        OFFSET_TOP = 0x10,
+        OFFSET_VCENTER = 0x20,
+        OFFSET_BOTTOM = 0x40,
+        OFFSET_ANCHOR = 0x80,
+        OFFSET_TOP_LEFT = OFFSET_TOP | OFFSET_LEFT,
+        OFFSET_VCENTER_LEFT = OFFSET_VCENTER | OFFSET_LEFT,
+        OFFSET_BOTTOM_LEFT = OFFSET_BOTTOM | OFFSET_LEFT,
+        OFFSET_TOP_HCENTER = OFFSET_TOP | OFFSET_HCENTER,
+        OFFSET_VCENTER_HCENTER = OFFSET_VCENTER | OFFSET_HCENTER,
+        OFFSET_BOTTOM_HCENTER = OFFSET_BOTTOM | OFFSET_HCENTER,
+        OFFSET_TOP_RIGHT = OFFSET_TOP | OFFSET_RIGHT,
+        OFFSET_VCENTER_RIGHT = OFFSET_VCENTER | OFFSET_RIGHT,
+        OFFSET_BOTTOM_RIGHT = OFFSET_BOTTOM | OFFSET_RIGHT
+    };
+    
+    /**
+     * Defines the flip flags used for rendering the sprite.
+     */
+    enum FlipFlags
+    {
+        FLIP_NONE,
+        FLIP_VERTICAL,
+        FLIP_HORIZONTAL
+    };
+    
+    /**
+     * Defines the blend modes.
+     */
+    enum BlendMode
+    {
+        BLEND_NONE,
+        BLEND_ALPHA,
+        BLEND_ADDITIVE,
+        BLEND_MULTIPLIED
+    };
+    
+    /**
+     * Create a sprite image using
+     *
+     * @param imagePath The path to the image to create the sprite from.
+     * @param width The width of a frame.
+     * @param height The width of a frame.
+     * @param effect The custom effect to render with.
+     * @return The new sprite.
+     */
+    static Sprite* create(const char* imagePath, float width = -1, float height = -1,
+                          Effect* effect = NULL);
+    
+    /**
+     * Creates a sprite from a user specified source region within the image.
+     *
+     * Passing -1 for width/height or source.width/.height,
+     * will default to using the images width/height.
+     *
+     * @param imagePath The path to the image to create the sprite from.
+     * @param width The width of a frame.
+     * @param height The width of a frame.
+     * @param source The starting frame source region used from the image.
+     * @param frameCount The number from frames to source clips from.
+     * @param effect The custom effect to render with.
+     * @return The new sprite.
+     */
+    static Sprite* create(const char* imagePath, float width, float height,
+                          const Rectangle& source, unsigned int frameCount = 1,
+                          Effect* effect = NULL);
+    
+    /**
+     * Creates a sprite from properties.
+     *
+     * @return The new Sprite.
+     */
+    static Sprite* create(Properties* properties);
+    
+    /**
+     * Gets the width of the sprite.
+     *
+     * @return The width of the sprite.
+     */
+    float getWidth() const;
+    
+    /**
+     * Gets the height of the sprite.
+     *
+     * @return The height of the sprite.
+     */
+    float getHeight() const;
+    
+    /**
+     * Sets the offset used for how much to locally adjust the bounds of the sprite.
+     *
+     * Note: The default offset is Offset::OFFSET_BOTTOM_LEFT
+     *
+     * @param offset The offset used for how much to locally adjust the bounds of the sprite.
+     */
+    void setOffset(Offset offset);
+    
+    /**
+     * Gets the offset used for how much to locally adjust the bounds of the sprite.
+     *
+     * Note: The default offset is Offset::OFFSET_BOTTOM_LEFT
+     *
+     * @return The offset used for how much to locally adjust the bounds of the sprite.
+     */
+    Offset getOffset() const;
+    
+    /**
+     * Sets the anchor which is a origin ratio of the sprite width and height from [0.0,1.0].
+     *
+     * @param anchor The anchor which is a origin ratio of the sprite width and height from [0.0,1.0].
+     */
+    void setAnchor(const Vector2& anchor);
+
+    /**
+     * Gets the anchor which is a origin ratio of the sprite width and height from [0.0,1.0].
+     *
+     * @return The anchor which is a origin ratio of the sprite width and height from [0.0,1.0].
+     */
+    const Vector2& getAnchor() const;
+    
+    /**
+     * Sets the flip flags used for rendering the sprite.
+     *
+     * @param flipFlags The flip flags used for rendering the sprite.
+     * @see Sprite::FlipFlags
+     */
+    void setFlip(int flipFlags);
+    
+    /**
+     * Gets the flip flags used for rendering the sprite.
+     *
+     * @return The flip flags used for rendering the sprite.
+     * @see Sprite::FlipFlags
+     */
+    int getFlip() const;
+    
+    /**
+     * Sets the source region from the source image.
+     *
+     * @param sourceClip The source clip region from the source image.
+     */
+    void setFrameSource(unsigned int frameIndex, const Rectangle& source);
+    
+    /**
+     * Gets the source region from the source image.
+     *
+     * @return The source clip region from the source image.
+     */
+    const Rectangle& getFrameSource(unsigned int frameIndex) const;
+    
+    /**
+     * Computes the source frames for sprites with frameCount > 1.
+     *
+     * This walks the image starting from the first source region and traverses
+     * the image moving across the image by the frame stride and then wrapping at the
+     * edges of the image.
+     *
+     * @param frameStride The number of frames to move across before moving down or wrapping to the top.
+     * @param framePadding The number of pixels used as padding between frame.
+     */
+    void computeFrames(unsigned int frameStride = 0, unsigned int framePadding = 1);
+    
+    /**
+     * Gets the number of frames this sprite can render.
+     *
+     * @return The total number of frames this sprite can render.
+     */
+    unsigned int getFrameCount() const;
+    
+    /**
+     * Gets the number of frames to travel across before
+     * wrapping to the next row or column.
+     *
+     * @return The total number of frames this sprite can render.
+     */
+    unsigned int getFrameStride() const;
+    
+    /**
+     * Gets the source padding in pixels around the source region.
+     *
+     * @return The source flip flags from the source image.
+     * @see Sprite::FlipFlags
+     */
+    unsigned int getFramePadding() const;
+    
+    /**
+     * Sets the current frame index to be rendered.
+     *
+     * @param index The current frame index to be rendered.
+     */
+    void setFrameIndex(unsigned int frameIndex);
+    
+    /**
+     * Gets the current frame index to be rendered.
+     *
+     * @return The current frame index to be rendered.
+     */
+    unsigned int getFrameIndex() const;
+    
+    /**
+     * Sets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @param opacity The opacity for the sprite.
+     */
+    void setOpacity(float opacity);
+    
+    /**
+     * Gets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @preturn The opacity for the sprite.
+     */
+    float getOpacity() const;
+    
+    /**
+     * Sets the color (RGBA) for the sprite.
+     *
+     * @param color The color(RGBA) for the sprite.
+     */
+    void setColor(const Vector4& color);
+    
+    /**
+     * Gets the color (RGBA) for the sprite.
+     *
+     * @return The color(RGBA) for the sprite.
+     */
+    const Vector4& getColor() const;
+
+    /**
+     * Sets the blend mode for the sprite.
+     *
+     * @param mode The blend mode for the sprite.
+     * @see Sprite::BlendMode
+     */
+    void setBlendMode(BlendMode mode);
+
+    /**
+     * Gets the blend mode for the sprite.
+     *
+     * @return The blend mode for the sprite.
+     * @see Sprite::BlendMode
+     */
+    BlendMode getBlendMode() const;
+    
+    /**
+     * Gets the texture sampler.
+     *
+     * This return texture sampler is used when sampling the texture in the
+     * effect. This can be modified for controlling sampler setting such as
+     * filtering modes.
+     */
+    Texture::Sampler* getSampler() const;
+    
+    /**
+     * Gets the StateBlock for the SpriteBatch.
+     *
+     * The returned state block controls the renderer state used when drawing items
+     * with this sprite batch. Modification can be made to the returned state block
+     * to change how primitives are rendered.
+     *
+     * @return The StateBlock for this SpriteBatch.
+     */
+    RenderState::StateBlock* getStateBlock() const;
+    
+    /**
+     * Gets the material used by this batch.
+     *
+     * @return The material.
+     */
+    Material* getMaterial() const;
+
+    /**
+     * Gets the node that this sprite is attached to.
+     *
+     * @return The node that this sprite is attached to.
+     */
+    Node* getNode() const;
+
+    /**
+     * Draw the sprite.
+     *
+     * @return The number of draw calls.
+     */
+    unsigned int draw();
+
+protected:
+    
+    /**
+     * Constructor.
+     */
+    Sprite();
+    
+    /**
+     * Destructor.
+     */
+    ~Sprite();
+    
+    /**
+     * operator=
+     */
+    Sprite& operator=(const Sprite& sprite);
+
+    /**
+     * Sets the node this sprite is attached to.
+     */
+    void setNode(Node* node);
+    
+    /**
+     * @see AnimationTarget::getAnimationPropertyComponentCount
+     */
+    unsigned int getAnimationPropertyComponentCount(int propertyId) const;
+    
+    /**
+     * @see AnimationTarget::getAnimationProperty
+     */
+    void getAnimationPropertyValue(int propertyId, AnimationValue* value);
+    
+    /**
+     * @see AnimationTarget::setAnimationProperty
+     */
+    void setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight = 1.0f);
+    
+    Sprite* clone(NodeCloneContext &context);
+    
+    void cloneInto(Sprite* sprite, NodeCloneContext &context) const;
+    
+    float _width;
+    float _height;
+    Offset _offset;
+    Vector2 _anchor;
+    int _flipFlags;
+    Rectangle* _frames;
+    unsigned int _frameCount;
+    unsigned int _frameStride;
+    unsigned int _framePadding;
+    unsigned int _frameIndex;
+    SpriteBatch* _batch;
+    float _opacity;
+    Vector4 _color;
+    BlendMode _blendMode;
+    Node* _node;
+};
+
+}
+#endif

+ 42 - 40
gameplay/src/SpriteBatch.cpp

@@ -100,16 +100,15 @@ SpriteBatch* SpriteBatch::create(Texture* texture,  Effect* effect, unsigned int
     }
     }
 
 
     // Wrap the effect in a material
     // Wrap the effect in a material
-    Material* material = Material::create(effect); // +ref effect
+    Material* material = Material::create(effect);
 
 
     // Set initial material state
     // Set initial material state
     material->getStateBlock()->setBlend(true);
     material->getStateBlock()->setBlend(true);
     material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
     material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
     material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
     material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
-    //material->getStateBlock()->setDepthFunction(RenderState::DEPTH_LEQUAL);
 
 
     // Bind the texture to the material as a sampler
     // Bind the texture to the material as a sampler
-    Texture::Sampler* sampler = Texture::Sampler::create(texture); // +ref texture
+    Texture::Sampler* sampler = Texture::Sampler::create(texture);
     material->getParameter(samplerUniform->getName())->setValue(sampler);
     material->getParameter(samplerUniform->getName())->setValue(sampler);
     
     
     // Define the vertex format for the batch
     // Define the vertex format for the batch
@@ -211,15 +210,18 @@ void SpriteBatch::draw(float x, float y, float z, float width, float height, flo
     Vector2 downRight(x2, y2);
     Vector2 downRight(x2, y2);
 
 
     // Rotate points around rotationAxis by rotationAngle.
     // Rotate points around rotationAxis by rotationAngle.
-    Vector2 pivotPoint(rotationPoint);
-    pivotPoint.x *= width;
-    pivotPoint.y *= height;
-    pivotPoint.x += x;
-    pivotPoint.y += y;
-    upLeft.rotate(pivotPoint, rotationAngle);
-    upRight.rotate(pivotPoint, rotationAngle);
-    downLeft.rotate(pivotPoint, rotationAngle);
-    downRight.rotate(pivotPoint, rotationAngle);
+    if (rotationAngle != 0)
+    {
+        Vector2 pivotPoint(rotationPoint);
+        pivotPoint.x *= width;
+        pivotPoint.y *= height;
+        pivotPoint.x += x;
+        pivotPoint.y += y;
+        upLeft.rotate(pivotPoint, rotationAngle);
+        upRight.rotate(pivotPoint, rotationAngle);
+        downLeft.rotate(pivotPoint, rotationAngle);
+        downRight.rotate(pivotPoint, rotationAngle);
+    }
 
 
     // Write sprite vertex data.
     // Write sprite vertex data.
     static SpriteVertex v[4];
     static SpriteVertex v[4];
@@ -258,34 +260,34 @@ void SpriteBatch::draw(const Vector3& position, const Vector3& right, const Vect
     p3 += tForward;
     p3 += tForward;
 
 
     // Calculate the rotation point.
     // Calculate the rotation point.
-    Vector3 rp = p0;
-    tRight = right;
-    tRight *= width * rotationPoint.x;
-    tForward *= rotationPoint.y;
-    rp += tRight;
-    rp += tForward;
-
-    // Rotate all points the specified amount about the given point (about the up vector).
-    static Vector3 u;
-    Vector3::cross(right, forward, &u);
-    static Matrix rotation;
-    Matrix::createRotation(u, rotationAngle, &rotation);
-
-    p0 -= rp;
-    p0 *= rotation;
-    p0 += rp;
-
-    p1 -= rp;
-    p1 *= rotation;
-    p1 += rp;
-
-    p2 -= rp;
-    p2 *= rotation;
-    p2 += rp;
-
-    p3 -= rp;
-    p3 *= rotation;
-    p3 += rp;
+    if (rotationAngle != 0)
+    {
+        Vector3 rp = p0;
+        tRight = right;
+        tRight *= width * rotationPoint.x;
+        tForward *= rotationPoint.y;
+        rp += tRight;
+        rp += tForward;
+
+        // Rotate all points the specified amount about the given point (about the up vector).
+        static Vector3 u;
+        Vector3::cross(right, forward, &u);
+        static Matrix rotation;
+        Matrix::createRotation(u, rotationAngle, &rotation);
+        p0 -= rp;
+        p0 *= rotation;
+        p0 += rp;
+        p1 -= rp;
+        p1 *= rotation;
+        p1 += rp;
+        p2 -= rp;
+        p2 *= rotation;
+        p2 += rp;
+        p3 -= rp;
+        p3 *= rotation;
+        p3 += rp;
+    }
+
 
 
     // Add the sprite vertex data to the batch.
     // Add the sprite vertex data to the batch.
     static SpriteVertex v[4];
     static SpriteVertex v[4];

+ 29 - 26
gameplay/src/SpriteBatch.h

@@ -26,6 +26,7 @@ class SpriteBatch
 {
 {
     friend class Bundle;
     friend class Bundle;
     friend class Font;
     friend class Font;
+    friend class Text;
 
 
 public:
 public:
 
 
@@ -261,6 +262,34 @@ public:
      */
      */
     void draw(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, bool positionIsCenter = false);
     void draw(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, bool positionIsCenter = false);
 
 
+    /**
+     * Sprite vertex structure used for batching.
+     */
+    struct SpriteVertex
+    {
+        float x;
+        float y;
+        float z;
+        float u;
+        float v;
+        float r;
+        float g;
+        float b;
+        float a;
+    };
+    
+    /**
+     * Draws an array of vertices.
+     *
+     * This is for more advanced usage.
+     *
+     * @param vertices The vertices to draw.
+     * @param vertexCount The number of vertices within the vertex array.
+     * @param indices The vertex indices.
+     * @param indexCount The number of indices within the index array.
+     */
+    void draw(SpriteBatch::SpriteVertex* vertices, unsigned int vertexCount, unsigned short* indices, unsigned int indexCount);
+    
     /**
     /**
      * Finishes sprite drawing.
      * Finishes sprite drawing.
      *
      *
@@ -317,22 +346,6 @@ public:
 
 
 private:
 private:
 
 
-    /**
-     * Sprite vertex structure used for batching.
-     */
-    struct SpriteVertex
-    {
-        float x;        
-        float y;
-        float z;
-        float u;
-        float v;
-        float r;
-        float g;
-        float b;
-        float a;
-    };
-
     /**
     /**
      * Constructor.
      * Constructor.
      */
      */
@@ -378,16 +391,6 @@ private:
      */
      */
     void addSprite(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip, SpriteBatch::SpriteVertex* vertices);
     void addSprite(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip, SpriteBatch::SpriteVertex* vertices);
 
 
-    /**
-     * Draws an array of vertices.
-     *
-     * @param vertices The vertices to draw.
-     * @param vertexCount The number of vertices within the vertex array.
-     * @param indices The vertex indices.
-     * @param indexCount The number of indices within the index array.
-     */
-    void draw(SpriteBatch::SpriteVertex* vertices, unsigned int vertexCount, unsigned short* indices, unsigned int indexCount);
-
     /**
     /**
      * Clip position and size to fit within clip region.
      * Clip position and size to fit within clip region.
      *
      *

+ 289 - 0
gameplay/src/Text.cpp

@@ -0,0 +1,289 @@
+#include "Base.h"
+#include "Text.h"
+#include "Matrix.h"
+#include "Scene.h"
+
+namespace gameplay
+{
+  
+Text::Text() :
+    _font(NULL), _text(""), _size(0), _width(0), _height(0), _wrap(true), _rightToLeft(false),
+    _align(Font::ALIGN_TOP_LEFT), _clip(Rectangle(0, 0, 0, 0)),
+    _opacity(1.0f), _color(Vector4::one()), _node(NULL)
+{
+}
+
+Text::~Text()
+{
+    if (_font)
+        SAFE_RELEASE(_font);
+}
+    
+Text& Text::operator=(const Text& text)
+{
+    return *this;
+}
+    
+Text* Text::create(const char* fontPath, const char* str, const Vector4& color, unsigned int size)
+{
+    GP_ASSERT(fontPath);
+    GP_ASSERT(str);
+
+    Font* font = Font::create(fontPath);
+    
+    if (size == 0)
+    {
+        size = font->_size;
+    }
+    else
+    {
+        // Delegate to closest sized font
+        font = font->findClosestSize(size);
+        size = font->_size;
+    }
+    unsigned int widthOut, heightOut;
+    font->measureText(str, size, &widthOut, &heightOut);
+    Text* text = new Text();
+    text->_font = font;
+    text->_text = str;
+    text->_size = size;
+    text->_width = (float)widthOut + 1;
+    text->_height = (float)heightOut + 1;
+    text->_color = color;
+
+    return text;
+}
+    
+Text* Text::create(Properties* properties)
+{
+    // TODO Load from properties from .scene files
+    /*
+    text level
+    {
+        font = res/arial.gpb
+        size = 18
+        text = Player 1
+     }
+     */
+    return NULL;
+}
+    
+unsigned int Text::getSize() const
+{
+    return _size;
+}
+
+void Text::setWidth(float width)
+{
+    _width = width;
+}
+
+float Text::getWidth() const
+{
+    return _width;
+}
+
+void Text::setHeight(float height)
+{
+    _height = height;
+}
+
+float Text::getHeight() const
+{
+    return _height;
+}
+
+void Text::setWrap(bool wrap)
+{
+    _wrap = wrap;
+}
+
+bool Text::getWrap() const
+{
+    return _wrap;
+}
+    
+void Text::setRightToLeft(bool rightToLeft)
+{
+    _rightToLeft = rightToLeft;
+}
+
+bool Text::getRightToLeft() const
+{
+    return _rightToLeft;
+}
+
+void Text::setJustify(Font::Justify align)
+{
+    _align = align;
+}
+
+Font::Justify Text::getJustify() const
+{
+    return _align;
+}
+    
+void Text::setClip(const Rectangle& clip)
+{
+    _clip = clip;
+}
+
+const Rectangle& Text::getClip() const
+{
+    return _clip;
+}
+
+void Text::setOpacity(float opacity)
+{
+    _opacity = opacity;
+}
+
+float Text::getOpacity() const
+{
+    return _opacity;
+}
+
+void Text::setColor(const Vector4& color)
+{
+    _color = color;
+}
+
+const Vector4& Text::getColor() const
+{
+    return _color;
+}
+    
+unsigned int Text::draw()
+{
+    // Apply scene camera projection and translation offsets
+    Rectangle viewport = Game::getInstance()->getViewport();
+    Vector3 position = Vector3::zero();
+    
+    // Font is always using a offset projection matrix to top-left. So we need to adjust it back to cartesian
+    position.x += viewport.width / 2;
+    position.y += viewport.height / 2;
+    Rectangle clipViewport = _clip;
+    if (_node && _node->getScene())
+    {
+        Camera* activeCamera = _node->getScene()->getActiveCamera();
+        if (activeCamera)
+        {
+            Node* cameraNode = _node->getScene()->getActiveCamera()->getNode();
+            if (cameraNode)
+            {
+                // Camera translation offsets
+                position.x -= cameraNode->getTranslationWorld().x;
+                position.y += cameraNode->getTranslationWorld().y - getHeight();
+            }
+        }
+        
+        // Apply node translation offsets
+        Vector3 translation = _node->getTranslationWorld();
+        position.x += translation.x;
+        position.y -= translation.y;
+    
+        if (!clipViewport.isEmpty())
+        {
+            clipViewport.x += position.x;
+            clipViewport.y += position.y;
+        }
+    }
+    _font->start();
+    _font->drawText(_text.c_str(), Rectangle(position.x, position.y, _width, _height),
+                    Vector4(_color.x, _color.y, _color.z, _color.w * _opacity), _size,
+                    _align, _wrap, _rightToLeft, clipViewport);
+    _font->finish();
+    return 1;
+}
+    
+Node* Text::getNode() const
+{
+    return _node;
+}
+
+void Text::setNode(Node* node)
+{
+    _node = node;
+}
+    
+unsigned int Text::getAnimationPropertyComponentCount(int propertyId) const
+{
+    switch (propertyId)
+    {
+        case ANIMATE_OPACITY:
+            return 1;
+        case ANIMATE_COLOR:
+            return 4;
+        default:
+            return -1;
+    }
+}
+
+void Text::getAnimationPropertyValue(int propertyId, AnimationValue* value)
+{
+    GP_ASSERT(value);
+    
+    switch (propertyId)
+    {
+        case ANIMATE_OPACITY:
+            value->setFloat(0, _opacity);
+            break;
+        case ANIMATE_COLOR:
+            value->setFloat(0, _color.x);
+            value->setFloat(1, _color.y);
+            value->setFloat(2, _color.z);
+            value->setFloat(3, _color.w);
+            break;
+        default:
+            break;
+    }
+}
+
+void Text::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
+{
+    GP_ASSERT(value);
+    
+    switch(propertyId)
+    {
+        case ANIMATE_OPACITY:
+            setOpacity(Curve::lerp(blendWeight, _opacity, value->getFloat(0)));
+            break;
+        case ANIMATE_COLOR:
+            setColor(Vector4(Curve::lerp(blendWeight, _color.x, value->getFloat(0)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(1)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(2)),
+                             Curve::lerp(blendWeight, _color.x, value->getFloat(3))));
+            break;
+        default:
+            break;
+    }
+}
+
+Text* Text::clone(NodeCloneContext &context)
+{
+    Text* copy = new Text();
+    cloneInto(copy, context);
+    return copy;
+}
+
+void Text::cloneInto(Text* text, NodeCloneContext &context) const
+{
+    GP_ASSERT(text);
+    
+    // Clone properties
+    text->_font = _font;
+    _font->addRef();
+    text->_text = _text;
+    text->_size = _size;
+    text->_width = _width;
+    text->_height = _height;
+    text->_wrap = _wrap;
+    text->_rightToLeft = _rightToLeft;
+    text->_align = _align;
+    text->_clip = _clip;
+    text->_opacity = _opacity;
+    text->_color = _color;
+    text->_node = _node;
+}
+
+}

+ 274 - 0
gameplay/src/Text.h

@@ -0,0 +1,274 @@
+#ifndef TEXT_H__
+#define TEXT_H__
+
+#include "Ref.h"
+#include "AnimationTarget.h"
+#include "Properties.h"
+#include "Font.h"
+#include "Vector2.h"
+#include "Vector4.h"
+#include "Effect.h"
+#include "Node.h"
+
+namespace gameplay
+{
+
+/**
+ * Defines a text block of characters to be drawn.
+ *
+ * Text can be attached to a node.
+ */
+class Text : public Ref, public AnimationTarget
+{
+    friend class Node;
+    
+public:
+    
+    /**
+     * Opacity property. Data=opacity
+     */
+    static const int ANIMATE_OPACITY = 1;
+    
+    /**
+     * Color property. Data = red, green, blue, alpha
+     */
+    static const int ANIMATE_COLOR = 2;
+
+    /**
+     * Creates a Text object from a given string.
+     * Vertex coordinates, UVs and indices will be computed and stored in the Text object.
+     * For static text labels that do not change frequently, this means these computations
+     * need not be performed every frame.
+     *
+     * @param fontPath The font path.
+     * @param str The text string to draw.
+     * @param color The text color.
+     * @param size The font size to draw text (0 for default font size).
+     *
+     * @return A Text object.
+     */
+    static Text* create(const char* fontPath, const char* str, const Vector4& color = Vector4::one(), unsigned int size = 0);
+    
+    /**
+     * Creates text from a properties object.
+     *
+     * @param properties The properties object to load from.
+     * @return The tile set created.
+     */
+    static Text* create(Properties* properties);
+    
+    /**
+     * Sets the text to be drawn.
+     *
+     * @param str The text string to be drawn.
+     */
+    void setText(const char* str);
+    
+    /**
+     * Get the string that will be drawn from this Text object.
+     *
+     * @return The text string to be drawn.
+     */
+    const char* getText() const;
+    
+    /**
+     * Gets the size of the text to be drawn.
+     *
+     * @return The size of the text to be drawn.
+     */
+    unsigned int getSize() const;
+    
+    /**
+     * Set the width to draw the text within.
+     *
+     * @param width The width to draw the text.
+     */
+    void setWidth(float width);
+    
+    /**
+     * Gets the width of the text.
+     *
+     * @return The width of the text.
+     */
+    float getWidth() const;
+    
+    /**
+     * Set the height of text to be drawn within.
+     *
+     * @param height The height to draw the text.
+     */
+    void setHeight(float height);
+    
+    /**
+     * Gets the width of the text.
+     *
+     * @return The overall width of the text.
+     */
+    float getHeight() const;
+    
+    /**
+     * Sets if the the text is wrapped by the text width.
+     * 
+     * @param wrap true if the the text is wrapped by the text width.
+     */
+    void setWrap(bool wrap);
+    
+    /**
+     * Gets if the the text is wrapped by the text width.
+     *
+     * Default is true.
+     *
+     * @return true if the the text is wrapped by the text width.
+     */
+    bool getWrap() const;
+    
+    /**
+     * Sets if the text is rendered right-to-left.
+     *
+     * @param rightToLeft true if the text is rendered right-to-left, false if left-to-right.
+     */
+    void setRightToLeft(bool rightToLeft);
+    
+    /**
+     * Sets if the text is rendered right-to-left.
+     *
+     * Default is false (left-to-right)
+     * @return rightToLeft true if the text is rendered right-to-left, false if left-to-right.
+     */
+    bool getRightToLeft() const;
+    
+    /**
+     * Sets the justification to align the text within the text bounds.
+     *
+     * @param align The text justification alignment.
+     */
+    void setJustify(Font::Justify align);
+
+    /**
+     * Gets the justification to align the text within the text bounds.
+     *
+     * @return The text justification alignment.
+     */
+    Font::Justify getJustify() const;
+    
+    /**
+     * Sets the local clipping region for this text.
+     *
+     * This is used for clipping unwanted regions of text.
+     *
+     * @param clip The clipping region for this text.
+     */
+    void setClip(const Rectangle& clip);
+    
+    /**
+     * Gets the local clipping region for this text.
+     *
+     * This is used for clipping unwanted regions of text.
+     *
+     * Default is Rectangle(0, 0, 0, 0) which means no clipping region is applied.
+     *
+     * @param clip The clipping region for this text.
+     */
+    const Rectangle& getClip() const;
+    
+    /**
+     * Sets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @param opacity The opacity for the sprite.
+     */
+    void setOpacity(float opacity);
+    
+    /**
+     * Gets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @preturn The opacity for the sprite.
+     */
+    float getOpacity() const;
+    
+    /**
+     * Sets the color (RGBA) for the sprite.
+     *
+     * @param color The color(RGBA) for the sprite.
+     */
+    void setColor(const Vector4& color);
+    
+    /**
+     * Gets the color (RGBA) for the sprite.
+     *
+     * @return The color(RGBA) for the sprite.
+     */
+    const Vector4& getColor() const;
+    
+    /**
+     * Gets the node that this sprite is attached to.
+     *
+     * @return The node that this sprite is attached to.
+     */
+    Node* getNode() const;
+   
+    /**
+     * Draws the text.
+     */
+    unsigned int draw();
+    
+protected:
+    /**
+     * Constructor
+     */
+    Text();
+
+    /**
+     * Destructor
+     */
+    ~Text();
+
+    /**
+     * operator=
+     */
+    Text& operator=(const Text& text);
+    
+    /**
+     * Sets the node this sprite is attached to.
+     */
+    void setNode(Node* node);
+    
+    /**
+     * @see AnimationTarget::getAnimationPropertyComponentCount
+     */
+    unsigned int getAnimationPropertyComponentCount(int propertyId) const;
+    
+    /**
+     * @see AnimationTarget::getAnimationProperty
+     */
+    void getAnimationPropertyValue(int propertyId, AnimationValue* value);
+    
+    /**
+     * @see AnimationTarget::setAnimationProperty
+     */
+    void setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight = 1.0f);
+    
+    Text* clone(NodeCloneContext &context);
+    
+    void cloneInto(Text* text, NodeCloneContext &context) const;
+
+    Font* _font;
+    std::string _text;
+    unsigned int _size;
+    float _width;
+    float _height;
+    bool _wrap;
+    bool _rightToLeft;
+    Font::Justify _align;
+    Rectangle _clip;
+    float _opacity;
+    Vector4 _color;
+    Node* _node;
+};
+    
+}
+
+#endif

+ 1 - 1
gameplay/src/TextBox.cpp

@@ -380,7 +380,7 @@ unsigned int TextBox::drawText(Form* form, const Rectangle& clip)
 
 
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         SpriteBatch* batch = _font->getSpriteBatch(fontSize);
         startBatch(form, batch);
         startBatch(form, batch);
-        _font->drawText(displayedText.c_str(), _textBounds, _textColor, fontSize, getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
+        _font->drawText(displayedText.c_str(), _textBounds, _textColor, fontSize, getTextAlignment(state), true, getTextRightToLeft(state), _viewportClipBounds);
         finishBatch(form, batch);
         finishBatch(form, batch);
 
 
         return 1;
         return 1;

+ 241 - 0
gameplay/src/TileSet.cpp

@@ -0,0 +1,241 @@
+#include "Base.h"
+#include "TileSet.h"
+#include "Matrix.h"
+#include "Scene.h"
+
+namespace gameplay
+{
+  
+TileSet::TileSet()
+    : _tiles(NULL), _tileWidth(0), _tileHeight(0),
+      _rowCount(0), _columnCount(0), _width(0), _height(0),
+      _opacity(1.0f), _color(Vector4::one()), _batch(NULL), _node(NULL)
+{
+}
+
+TileSet::~TileSet()
+{
+    if (_tiles)
+        SAFE_DELETE_ARRAY(_tiles);
+    if (_batch)
+        SAFE_DELETE(_batch);
+}
+    
+TileSet& TileSet::operator=(const TileSet& set)
+{
+    return *this;
+}
+    
+TileSet* TileSet::create(const char* imagePath,
+                         float tileWidth, float tileHeight,
+                         unsigned int rowCount, unsigned int columnCount)
+{
+    GP_ASSERT(imagePath);
+    GP_ASSERT(tileWidth > 0 && tileHeight > 0);
+    GP_ASSERT(rowCount > 0 && columnCount > 0);
+    
+    SpriteBatch* batch = SpriteBatch::create(imagePath);
+    batch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
+    batch->getSampler()->setFilterMode(Texture::Filter::NEAREST, Texture::Filter::NEAREST);
+    batch->getStateBlock()->setDepthWrite(false);
+    batch->getStateBlock()->setDepthTest(true);
+    
+    TileSet* tileset = new TileSet();
+    tileset->_batch = batch;
+    tileset->_tiles = new Vector2[rowCount * columnCount];
+    memset(tileset->_tiles, -1, sizeof(float) * rowCount * columnCount * 2);
+    tileset->_tileWidth = tileWidth;
+    tileset->_tileHeight = tileHeight;
+    tileset->_rowCount = rowCount;
+    tileset->_columnCount = columnCount;
+    tileset->_width = tileWidth * columnCount;
+    tileset->_height = tileHeight * rowCount;
+    return tileset;
+}
+    
+TileSet* TileSet::create(Properties* properties)
+{
+    // TODO Load from properties
+    /*
+    tileset level
+    {
+        path = res/foo/level.png
+        tileWidth = 72
+        tileHeight = 72
+        tile
+        {
+            cell = col, row
+            source = x, y
+        }
+        tile
+        {
+            ...
+        }
+     }
+     */
+    return NULL;
+}
+
+void TileSet::setTileSource(unsigned int column, unsigned int row, const Vector2& source)
+{
+    GP_ASSERT(column < _columnCount);
+    GP_ASSERT(row < _rowCount);
+    
+    _tiles[row * _columnCount + column] = source;
+}
+
+void TileSet::getTileSource(unsigned int column, unsigned int row, Vector2* source)
+{
+    GP_ASSERT(column < _columnCount);
+    GP_ASSERT(row < _rowCount);
+    GP_ASSERT(source);
+    
+    source->x = _tiles[row * _columnCount + column].x;
+    source->y = _tiles[row * _columnCount + column].y;
+}
+
+float TileSet::getTileWidth() const
+{
+    return _tileWidth;
+}
+
+float TileSet::getTileHeight() const
+{
+    return _tileHeight;
+}
+
+unsigned int TileSet::getRowCount() const
+{
+    return _rowCount;
+}
+    
+unsigned int TileSet::getColumnCount() const
+{
+    return _columnCount;
+}
+
+float TileSet::getWidth() const
+{
+    return _width;
+}
+
+float TileSet::getHeight() const
+{
+    return _height;
+}
+    
+void TileSet::setOpacity(float opacity)
+{
+    _opacity = opacity;
+}
+
+float TileSet::getOpacity() const
+{
+    return _opacity;
+}
+
+void TileSet::setColor(const Vector4& color)
+{
+    _color = color;
+}
+
+const Vector4& TileSet::getColor() const
+{
+    return _color;
+}
+    
+unsigned int TileSet::draw()
+{
+    // Apply scene camera projection and translation offsets
+    Vector3 position = Vector3::zero();
+    if (_node && _node->getScene())
+    {
+        Camera* activeCamera = _node->getScene()->getActiveCamera();
+        if (activeCamera)
+        {
+            Node* cameraNode = _node->getScene()->getActiveCamera()->getNode();
+            if (cameraNode)
+            {
+                // Scene projection
+                Matrix projectionMatrix;
+                projectionMatrix = _node->getProjectionMatrix();
+                _batch->setProjectionMatrix(projectionMatrix);
+
+                position.x -= cameraNode->getTranslationWorld().x;
+                position.y -= cameraNode->getTranslationWorld().y;
+            }
+        }
+        
+        // Apply node translation offsets
+        Vector3 translation = _node->getTranslationWorld();
+        position.x += translation.x;
+        position.y += translation.y;
+        position.z += translation.z;
+    }
+    
+    // Draw each cell in the tile set
+    position.y += _tileHeight * (_rowCount - 1);
+    float xStart = position.x;
+    _batch->start();
+    for (unsigned int row = 0; row < _rowCount; row++)
+    {
+        for (unsigned int col = 0; col < _columnCount; col++)
+        {
+            Vector2 scale = Vector2(_tileWidth, _tileHeight);
+            
+            // Negative values are skipped to allow blank tiles
+            if (_tiles[row * _columnCount + col].x >= 0 &&
+                _tiles[row * _columnCount + col].y >= 0)
+            {
+                Rectangle source = Rectangle(_tiles[row * _columnCount + col].x,
+                                             _tiles[row * _columnCount + col].y, _tileWidth, _tileHeight);
+                _batch->draw(position, source, scale, Vector4(_color.x, _color.y, _color.z, _color.w * _opacity),
+                             Vector2(0.5f, 0.5f), 0);
+            }
+            
+            position.x += _tileWidth;
+        }
+        position.x = xStart;
+        position.y -= _tileHeight;
+    }
+    _batch->finish();
+    return 1;
+}
+    
+Node* TileSet::getNode() const
+{
+    return _node;
+}
+
+void TileSet::setNode(Node* node)
+{
+    _node = node;
+}
+
+TileSet* TileSet::clone(NodeCloneContext &context)
+{
+    TileSet* copy = new TileSet();
+    cloneInto(copy, context);
+    return copy;
+}
+
+void TileSet::cloneInto(TileSet* tileset, NodeCloneContext &context) const
+{
+    GP_ASSERT(tileset);
+    
+    // Clone properties
+    tileset->_tiles = new Vector2[tileset->_rowCount * tileset->_columnCount];
+    memset(tileset->_tiles, -1, sizeof(float) * tileset->_rowCount * tileset->_columnCount * 2);
+    memcpy(tileset->_tiles, _tiles, sizeof(Vector2) * tileset->_rowCount * tileset->_columnCount);
+    tileset->_tileWidth = _tileWidth;
+    tileset->_tileHeight = _tileHeight;
+    tileset->_rowCount = _rowCount;
+    tileset->_columnCount = _columnCount;
+    tileset->_width = _tileWidth * _columnCount;
+    tileset->_height = _tileHeight * _rowCount;
+    tileset->_opacity = _opacity;
+    tileset->_color = _color;
+    tileset->_batch = _batch;
+}
+
+}

+ 203 - 0
gameplay/src/TileSet.h

@@ -0,0 +1,203 @@
+#ifndef TILESET_H__
+#define TILESET_H__
+
+#include "Ref.h"
+#include "Properties.h"
+#include "Vector2.h"
+#include "Vector4.h"
+#include "Effect.h"
+#include "Node.h"
+
+namespace gameplay
+{
+
+/**
+ * Defines a grid of tiles for rendering a 2D planer region.
+ *
+ * The UVs are sourced from the texture atlas image.
+ * The columns(x) and rows(y) are set individually for each
+ * in the tile set. Specifying a source (x,y) of -1, -1 will allow
+ * for tiles in the set to be empty.
+ * The size of all the tiles must be equal to the tileWidth/tileHeight
+ * provided. 
+ *
+ * To avoid seams in the tiles the tile should be padded with
+ * a gutter of duplicate pixels on each side of the region.
+ *
+ * The tile set does not support rotation or scaling.
+ */
+class TileSet : public Ref
+{
+    friend class Node;
+    
+public:
+
+    /**
+     * Creates a tile set.
+     *
+     * @param imagePath The path to the image to create the sprite from.
+     * @param tileWidth The width of each tile in the tile set.
+     * @param tileHeight The height of each tile in the tile set.
+     * @param rowCount The number of tile rows.
+     * @param columnCount The number of tile columns.
+     * @return The tile set created.
+     */
+    static TileSet* create(const char* imagePath, float tileWidth, float tileHeight,
+                           unsigned int rowCount, unsigned int columnCount);
+    
+    /**
+     * Creates a tile set from a properties object.
+     *
+     * @param properties The properties object to load from.
+     * @return The tile set created.
+     */
+    static TileSet* create(Properties* properties);
+    
+    /**
+     * Sets the tile source location for the specified column and row.
+     *
+     * @param column The column to set the source for.
+     * @param row The row to set the source for.
+     * @param source The source top-left corner where the tile is positioned.
+     */
+    void setTileSource(unsigned int column, unsigned int row, const Vector2& source);
+
+    /**
+     * Gets the source clip region and flip flags for the specified column and row.
+     *
+     * @param column The column to get the source clip region and flip flags for.
+     * @param row The row to specify the source clip region and flip flags for.
+     * @param source The source region to be returned back.
+     * @see Sprite::FlipFlags
+     */
+    void getTileSource(unsigned int column, unsigned int row, Vector2* source);
+
+    /**
+     * Gets the width of each tile in the tile set.
+     *
+     * @return The width of each tile in the tile set.
+     */
+    float getTileWidth() const;
+
+    /**
+     * Gets the height of each tile in the tile set.
+     *
+     * @return The height of each tile in the tile set.
+     */
+    float getTileHeight() const;
+
+    /**
+     * Gets the number of tile rows.
+     *
+     * @return The number of tile rows.
+     */
+    unsigned int getRowCount() const;
+
+    /**
+     * Gets the number of tile columns.
+     *
+     * @return The number of tile columns.
+     */
+    unsigned int getColumnCount() const;
+    
+    /**
+     * Gets the overall width of the tileset.
+     *
+     * @return The overall width of the tileset.
+     */
+    float getWidth() const;
+    
+    /**
+     * Gets the overall width of the tileset.
+     *
+     * @return The overall width of the tileset.
+     */
+    float getHeight() const;
+    
+    /**
+     * Sets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @param opacity The opacity for the sprite.
+     */
+    void setOpacity(float opacity);
+    
+    /**
+     * Gets the opacity for the sprite.
+     *
+     * The range is from full transparent to opaque [0.0,1.0].
+     *
+     * @preturn The opacity for the sprite.
+     */
+    float getOpacity() const;
+    
+    /**
+     * Sets the color (RGBA) for the sprite.
+     *
+     * @param color The color(RGBA) for the sprite.
+     */
+    void setColor(const Vector4& color);
+    
+    /**
+     * Gets the color (RGBA) for the sprite.
+     *
+     * @return The color(RGBA) for the sprite.
+     */
+    const Vector4& getColor() const;
+    
+    /**
+     * Gets the node that this sprite is attached to.
+     *
+     * @return The node that this sprite is attached to.
+     */
+    Node* getNode() const;
+   
+    /**
+     * Draws the TileSet.
+     *
+     * @return The number of draw calls made.
+     */
+    unsigned int draw();
+    
+protected:
+    /**
+     * Constructor
+     */
+    TileSet();
+
+    /**
+     * Destructor
+     */
+    ~TileSet();
+
+    /**
+     * operator=
+     */
+    TileSet& operator=(const TileSet& set);
+    
+    /**
+     * Sets the node this sprite is attached to.
+     */
+    void setNode(Node* node);
+    
+    TileSet* clone(NodeCloneContext &context);
+    
+    void cloneInto(TileSet* tileset, NodeCloneContext &context) const;
+
+    Vector2* _tiles;
+    float _tileWidth;
+    float _tileHeight;
+    unsigned int _rowCount;
+    unsigned int _columnCount;
+    float _width;
+    float _height;
+    SpriteBatch* _batch;
+    float _opacity;
+    Vector4 _color;
+    Node* _node;
+};
+    
+}
+
+#endif

+ 4 - 2
gameplay/src/gameplay.h

@@ -28,8 +28,8 @@
 #include "Curve.h"
 #include "Curve.h"
 
 
 // Graphics
 // Graphics
-#include "Texture.h"
 #include "Image.h"
 #include "Image.h"
+#include "Texture.h"
 #include "Mesh.h"
 #include "Mesh.h"
 #include "MeshPart.h"
 #include "MeshPart.h"
 #include "Effect.h"
 #include "Effect.h"
@@ -45,6 +45,9 @@
 #include "Scene.h"
 #include "Scene.h"
 #include "Font.h"
 #include "Font.h"
 #include "SpriteBatch.h"
 #include "SpriteBatch.h"
+#include "Sprite.h"
+#include "Text.h"
+#include "TileSet.h"
 #include "ParticleEmitter.h"
 #include "ParticleEmitter.h"
 #include "FrameBuffer.h"
 #include "FrameBuffer.h"
 #include "RenderTarget.h"
 #include "RenderTarget.h"
@@ -54,7 +57,6 @@
 #include "Terrain.h"
 #include "Terrain.h"
 #include "TerrainPatch.h"
 #include "TerrainPatch.h"
 
 
-
 // Audio
 // Audio
 #include "AudioController.h"
 #include "AudioController.h"
 #include "AudioListener.h"
 #include "AudioListener.h"

+ 2 - 411
gameplay/src/lua/lua_Font.cpp

@@ -18,7 +18,6 @@ void luaRegister_Font()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"addRef", lua_Font_addRef},
         {"addRef", lua_Font_addRef},
-        {"createText", lua_Font_createText},
         {"drawText", lua_Font_drawText},
         {"drawText", lua_Font_drawText},
         {"finish", lua_Font_finish},
         {"finish", lua_Font_finish},
         {"getCharacterSpacing", lua_Font_getCharacterSpacing},
         {"getCharacterSpacing", lua_Font_getCharacterSpacing},
@@ -124,390 +123,6 @@ int lua_Font_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Font_createText(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 4:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 5:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
-                lua_type(state, 5) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 6:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
-                lua_type(state, 5) == LUA_TNUMBER &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                // Get parameter 5 off the stack.
-                Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 7:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
-                lua_type(state, 5) == LUA_TNUMBER &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
-                lua_type(state, 7) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                // Get parameter 5 off the stack.
-                Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
-
-                // Get parameter 6 off the stack.
-                bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 7);
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 8:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
-                lua_type(state, 5) == LUA_TNUMBER &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
-                lua_type(state, 7) == LUA_TBOOLEAN &&
-                lua_type(state, 8) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                // Get parameter 5 off the stack.
-                Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
-
-                // Get parameter 6 off the stack.
-                bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 7);
-
-                // Get parameter 7 off the stack.
-                bool param7 = gameplay::ScriptUtil::luaCheckBool(state, 8);
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6, param7);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 9:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
-                lua_type(state, 5) == LUA_TNUMBER &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
-                lua_type(state, 7) == LUA_TBOOLEAN &&
-                lua_type(state, 8) == LUA_TBOOLEAN &&
-                (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TTABLE || lua_type(state, 9) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", true, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 3 off the stack.
-                bool param3Valid;
-                gameplay::ScriptUtil::LuaArray<Vector4> param3 = gameplay::ScriptUtil::getObjectPointer<Vector4>(4, "Vector4", true, &param3Valid);
-                if (!param3Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector4'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                // Get parameter 5 off the stack.
-                Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
-
-                // Get parameter 6 off the stack.
-                bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 7);
-
-                // Get parameter 7 off the stack.
-                bool param7 = gameplay::ScriptUtil::luaCheckBool(state, 8);
-
-                // Get parameter 8 off the stack.
-                bool param8Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param8 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(9, "Rectangle", false, &param8Valid);
-                if (!param8Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 8 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                Font* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6, param7, param8);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Font_createText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 4, 5, 6, 7, 8 or 9).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Font_drawText(lua_State* state)
 int lua_Font_drawText(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -516,30 +131,6 @@ int lua_Font_drawText(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 2:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Font::Text> param1 = gameplay::ScriptUtil::getObjectPointer<Font::Text>(2, "FontText", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    Font* instance = getInstance(state);
-                    instance->drawText(param1);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Font_drawText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
         case 4:
         case 4:
         {
         {
             do
             do
@@ -982,12 +573,12 @@ int lua_Font_drawText(lua_State* state)
 
 
                     // Get parameter 8 off the stack.
                     // Get parameter 8 off the stack.
                     bool param8Valid;
                     bool param8Valid;
-                    gameplay::ScriptUtil::LuaArray<Rectangle> param8 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(9, "Rectangle", false, &param8Valid);
+                    gameplay::ScriptUtil::LuaArray<Rectangle> param8 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(9, "Rectangle", true, &param8Valid);
                     if (!param8Valid)
                     if (!param8Valid)
                         break;
                         break;
 
 
                     Font* instance = getInstance(state);
                     Font* instance = getInstance(state);
-                    instance->drawText(param1, *param2, *param3, param4, param5, param6, param7, param8);
+                    instance->drawText(param1, *param2, *param3, param4, param5, param6, param7, *param8);
                     
                     
                     return 0;
                     return 0;
                 }
                 }

+ 0 - 1
gameplay/src/lua/lua_Font.h

@@ -7,7 +7,6 @@ namespace gameplay
 // Lua bindings for Font.
 // Lua bindings for Font.
 int lua_Font__gc(lua_State* state);
 int lua_Font__gc(lua_State* state);
 int lua_Font_addRef(lua_State* state);
 int lua_Font_addRef(lua_State* state);
-int lua_Font_createText(lua_State* state);
 int lua_Font_drawText(lua_State* state);
 int lua_Font_drawText(lua_State* state);
 int lua_Font_finish(lua_State* state);
 int lua_Font_finish(lua_State* state);
 int lua_Font_getCharacterSpacing(lua_State* state);
 int lua_Font_getCharacterSpacing(lua_State* state);

+ 0 - 156
gameplay/src/lua/lua_FontText.cpp

@@ -1,156 +0,0 @@
-#include "Base.h"
-#include "ScriptController.h"
-#include "lua_FontText.h"
-#include "Base.h"
-#include "Bundle.h"
-#include "FileSystem.h"
-#include "Font.h"
-#include "Game.h"
-#include "Ref.h"
-#include "lua_FontFormat.h"
-#include "lua_FontJustify.h"
-
-namespace gameplay
-{
-
-void luaRegister_FontText()
-{
-    const luaL_Reg lua_members[] = 
-    {
-        {"getText", lua_FontText_getText},
-        {NULL, NULL}
-    };
-    const luaL_Reg* lua_statics = NULL;
-    std::vector<std::string> scopePath;
-    scopePath.push_back("Font");
-
-    gameplay::ScriptUtil::registerClass("FontText", lua_members, lua_FontText__init, lua_FontText__gc, lua_statics, scopePath);
-}
-
-static Font::Text* getInstance(lua_State* state)
-{
-    void* userdata = luaL_checkudata(state, 1, "FontText");
-    luaL_argcheck(state, userdata != NULL, 1, "'FontText' expected.");
-    return (Font::Text*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
-}
-
-int lua_FontText__gc(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                void* userdata = luaL_checkudata(state, 1, "FontText");
-                luaL_argcheck(state, userdata != NULL, 1, "'FontText' expected.");
-                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
-                if (object->owns)
-                {
-                    Font::Text* instance = (Font::Text*)object->instance;
-                    SAFE_DELETE(instance);
-                }
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_FontText__gc - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_FontText__init(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                const char* param1 = gameplay::ScriptUtil::getString(1, false);
-
-                void* returnPtr = (void*)new Font::Text(param1);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = true;
-                    luaL_getmetatable(state, "FontText");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_FontText__init - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_FontText_getText(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Font::Text* instance = getInstance(state);
-                const char* result = instance->getText();
-
-                // Push the return value onto the stack.
-                lua_pushstring(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_FontText_getText - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-}

+ 0 - 16
gameplay/src/lua/lua_FontText.h

@@ -1,16 +0,0 @@
-#ifndef LUA_FONTTEXT_H_
-#define LUA_FONTTEXT_H_
-
-namespace gameplay
-{
-
-// Lua bindings for Font::Text.
-int lua_FontText__gc(lua_State* state);
-int lua_FontText__init(lua_State* state);
-int lua_FontText_getText(lua_State* state);
-
-void luaRegister_FontText();
-
-}
-
-#endif

+ 0 - 43
gameplay/src/lua/lua_Form.cpp

@@ -147,7 +147,6 @@ void luaRegister_Form()
         {"setImageRegion", lua_Form_setImageRegion},
         {"setImageRegion", lua_Form_setImageRegion},
         {"setLayout", lua_Form_setLayout},
         {"setLayout", lua_Form_setLayout},
         {"setMargin", lua_Form_setMargin},
         {"setMargin", lua_Form_setMargin},
-        {"setNode", lua_Form_setNode},
         {"setOpacity", lua_Form_setOpacity},
         {"setOpacity", lua_Form_setOpacity},
         {"setPadding", lua_Form_setPadding},
         {"setPadding", lua_Form_setPadding},
         {"setPosition", lua_Form_setPosition},
         {"setPosition", lua_Form_setPosition},
@@ -5086,48 +5085,6 @@ int lua_Form_setMargin(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Form_setNode(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
-                    lua_error(state);
-                }
-
-                Form* instance = getInstance(state);
-                instance->setNode(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Form_setNode - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Form_setOpacity(lua_State* state)
 int lua_Form_setOpacity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 0 - 1
gameplay/src/lua/lua_Form.h

@@ -109,7 +109,6 @@ int lua_Form_setImageColor(lua_State* state);
 int lua_Form_setImageRegion(lua_State* state);
 int lua_Form_setImageRegion(lua_State* state);
 int lua_Form_setLayout(lua_State* state);
 int lua_Form_setLayout(lua_State* state);
 int lua_Form_setMargin(lua_State* state);
 int lua_Form_setMargin(lua_State* state);
-int lua_Form_setNode(lua_State* state);
 int lua_Form_setOpacity(lua_State* state);
 int lua_Form_setOpacity(lua_State* state);
 int lua_Form_setPadding(lua_State* state);
 int lua_Form_setPadding(lua_State* state);
 int lua_Form_setPosition(lua_State* state);
 int lua_Form_setPosition(lua_State* state);

+ 0 - 43
gameplay/src/lua/lua_Model.cpp

@@ -29,7 +29,6 @@ void luaRegister_Model()
         {"hasMaterial", lua_Model_hasMaterial},
         {"hasMaterial", lua_Model_hasMaterial},
         {"release", lua_Model_release},
         {"release", lua_Model_release},
         {"setMaterial", lua_Model_setMaterial},
         {"setMaterial", lua_Model_setMaterial},
-        {"setNode", lua_Model_setNode},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
     const luaL_Reg lua_statics[] = 
     const luaL_Reg lua_statics[] = 
@@ -767,48 +766,6 @@ int lua_Model_setMaterial(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Model_setNode(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
-                    lua_error(state);
-                }
-
-                Model* instance = getInstance(state);
-                instance->setNode(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_setNode - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Model_static_create(lua_State* state)
 int lua_Model_static_create(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 0 - 1
gameplay/src/lua/lua_Model.h

@@ -17,7 +17,6 @@ int lua_Model_getSkin(lua_State* state);
 int lua_Model_hasMaterial(lua_State* state);
 int lua_Model_hasMaterial(lua_State* state);
 int lua_Model_release(lua_State* state);
 int lua_Model_release(lua_State* state);
 int lua_Model_setMaterial(lua_State* state);
 int lua_Model_setMaterial(lua_State* state);
-int lua_Model_setNode(lua_State* state);
 int lua_Model_static_create(lua_State* state);
 int lua_Model_static_create(lua_State* state);
 
 
 void luaRegister_Model();
 void luaRegister_Model();

+ 0 - 1
gameplay/src/lua/lua_all_bindings.cpp

@@ -40,7 +40,6 @@ void lua_RegisterAllBindings()
     luaRegister_FileSystem();
     luaRegister_FileSystem();
     luaRegister_FlowLayout();
     luaRegister_FlowLayout();
     luaRegister_Font();
     luaRegister_Font();
-    luaRegister_FontText();
     luaRegister_Form();
     luaRegister_Form();
     luaRegister_FrameBuffer();
     luaRegister_FrameBuffer();
     luaRegister_Frustum();
     luaRegister_Frustum();

+ 0 - 1
gameplay/src/lua/lua_all_bindings.h

@@ -35,7 +35,6 @@
 #include "lua_FileSystem.h"
 #include "lua_FileSystem.h"
 #include "lua_FlowLayout.h"
 #include "lua_FlowLayout.h"
 #include "lua_Font.h"
 #include "lua_Font.h"
-#include "lua_FontText.h"
 #include "lua_Form.h"
 #include "lua_Form.h"
 #include "lua_FrameBuffer.h"
 #include "lua_FrameBuffer.h"
 #include "lua_Frustum.h"
 #include "lua_Frustum.h"

BIN
samples/browser/res/common/sprites/background.png


BIN
samples/browser/res/common/sprites/level.png


+ 143 - 0
samples/browser/res/common/sprites/level.txt

@@ -0,0 +1,143 @@
+bush = 0 0 70 70
+buttonBlue = 71 0 70 70
+buttonBlue_pressed = 142 0 70 70
+buttonGreen = 0 71 70 70
+buttonGreen_pressed = 71 71 70 70
+buttonRed = 0 142 70 70
+buttonRed_pressed = 71 142 70 70
+buttonYellow = 142 71 70 70
+buttonYellow_pressed = 142 142 70 70
+cactus = 213 0 70 70
+chain = 213 71 70 70
+coinBronze = 284 0 70 70
+coinGold = 213 142 70 70
+coinSilver = 284 71 70 70
+fireball = 355 0 70 70
+keyBlue = 426 0 70 70
+keyGreen = 355 71 70 70
+keyRed = 284 142 70 70
+keyYellow = 355 142 70 70
+mushroomBrown = 426 71 70 70
+mushroomRed = 426 142 70 70
+particleBrick1a = 590 781 19 14
+particleBrick1b = 568 781 21 21
+particleBrick2a = 590 796 19 14
+particleBrick2b = 568 803 21 21
+plant = 0 213 70 70
+plantPurple = 0 284 70 70
+rock = 71 213 70 70
+snowhill = 71 284 70 70
+spikes = 0 355 70 70
+star = 142 213 70 70
+weight = 71 355 70 70
+weightChained = 0 426 70 70
+box = 213 213 70 70
+boxAlt = 142 284 70 70
+boxCoin = 142 355 70 70
+boxCoin_disabled = 284 213 70 70
+boxCoinAlt = 71 426 70 70
+boxCoinAlt_disabled = 213 284 70 70
+boxEmpty = 142 426 70 70
+boxItem = 284 284 70 70
+boxItem_disabled = 213 355 70 70
+boxItemAlt = 355 213 70 70
+boxItemAlt_disabled = 284 355 70 70
+boxWarning = 213 426 70 70
+brickWall = 426 213 70 70
+bridge = 355 284 70 70
+bridgeLogs = 426 284 70 70
+door_closedMid = 355 355 70 70
+door_closedTop = 284 426 70 70
+door_openMid = 355 426 70 70
+door_openTop = 426 355 70 70
+fence = 426 426 70 70
+fenceBroken = 497 0 70 70
+grass = 497 71 70 70
+grassCenter = 568 0 70 70
+grassCenter_rounded = 568 71 70 70
+grassCliffLeft = 497 142 70 70
+grassCliffLeftAlt = 639 0 70 70
+grassCliffRight = 639 71 70 70
+grassCliffRightAlt = 568 142 70 70
+grassHalf = 497 213 70 70
+grassHalfLeft = 710 0 70 70
+grassHalfMid = 781 0 70 70
+grassHalfRight = 710 71 70 70
+grassHillLeft = 639 142 70 70
+grassHillLeft2 = 568 213 70 70
+grassHillRight = 497 284 70 70
+grassHillRight2 = 710 142 70 70
+grassLeft = 639 213 70 70
+grassMid = 568 284 70 70
+grassRight = 497 355 70 70
+hill_large = 710 639 48 146
+hill_largeAlt = 639 710 48 146
+hill_small = 759 639 48 106
+hill_smallAlt = 759 746 48 106
+ladder_mid = 781 71 70 70
+ladder_top = 497 426 70 70
+liquidLava = 781 142 70 70
+liquidLavaTop = 639 284 70 70
+liquidLavaTop_mid = 568 355 70 70
+liquidWater = 710 213 70 70
+liquidWaterTop = 639 355 70 70
+liquidWaterTop_mid = 568 426 70 70
+lock_blue = 781 213 70 70
+lock_green = 710 284 70 70
+lock_red = 781 284 70 70
+lock_yellow = 710 355 70 70
+rockHillLeft = 639 426 70 70
+rockHillRight = 710 426 70 70
+sand = 781 355 70 70
+sandCenter = 781 426 70 70
+sandCenter_rounded = 0 497 70 70
+sandCliffLeft = 71 497 70 70
+sandCliffLeftAlt = 0 568 70 70
+sandCliffRight = 71 568 70 70
+sandCliffRightAlt = 0 639 70 70
+sandHalf = 142 497 70 70
+sandHalfLeft = 213 497 70 70
+sandHalfMid = 71 639 70 70
+sandHalfRight = 0 710 70 70
+sandHillLeft = 142 568 70 70
+sandHillLeft2 = 0 781 70 70
+sandHillRight = 142 639 70 70
+sandHillRight2 = 213 568 70 70
+sandLeft = 284 497 70 70
+sandMid = 71 710 70 70
+sandRight = 142 710 70 70
+snow = 284 568 70 70
+snowCenter = 213 639 70 70
+snowCenter_rounded = 71 781 70 70
+snowCliffLeft = 355 497 70 70
+snowCliffLeftAlt = 142 781 70 70
+snowCliffRight = 355 568 70 70
+snowCliffRightAlt = 284 639 70 70
+snowHalf = 213 710 70 70
+snowHalfLeft = 426 497 70 70
+snowHalfMid = 497 497 70 70
+snowHalfRight = 426 568 70 70
+snowHillLeft = 355 639 70 70
+snowHillLeft2 = 284 710 70 70
+snowHillRight = 213 781 70 70
+snowHillRight2 = 568 497 70 70
+snowLeft = 497 568 70 70
+snowMid = 426 639 70 70
+snowRight = 355 710 70 70
+stone = 284 781 70 70
+stoneCenter = 426 710 70 70
+stoneCenter_rounded = 355 781 70 70
+stoneCliffLeft = 639 497 70 70
+stoneCliffLeftAlt = 568 568 70 70
+stoneCliffRight = 497 639 70 70
+stoneCliffRightAlt = 710 497 70 70
+stoneHalf = 639 568 70 70
+stoneHalfLeft = 568 639 70 70
+stoneHalfMid = 497 710 70 70
+stoneHalfRight = 426 781 70 70
+stoneHillLeft2 = 497 781 70 70
+stoneHillRight2 = 568 710 70 70
+stoneLeft = 710 568 70 70
+stoneMid = 639 639 70 70
+stoneRight = 781 497 70 70
+stoneWall = 781 568 70 70

BIN
samples/browser/res/common/sprites/player1.png


+ 16 - 0
samples/browser/res/common/sprites/player1.txt

@@ -0,0 +1,16 @@
+p1_duck = 365 98 69 71
+p1_front = 0 196 66 92
+p1_hurt = 438 0 69 92
+p1_jump = 438 93 67 94
+p1_stand = 67 196 66 92
+p1_walk01 = 0 0 72 97
+p1_walk02 = 73 0 72 97
+p1_walk03 = 146 0 72 97
+p1_walk04 = 0 98 72 97
+p1_walk05 = 73 98 72 97
+p1_walk06 = 146 98 72 97
+p1_walk07 = 219 0 72 97
+p1_walk08 = 292 0 72 97
+p1_walk09 = 219 98 72 97
+p1_walk10 = 365 0 72 97
+p1_walk11 = 292 98 72 97

BIN
samples/browser/res/common/sprites/player2.png


+ 16 - 0
samples/browser/res/common/sprites/player2.txt

@@ -0,0 +1,16 @@
+p2_duck = 355 95 67 72
+p2_front = 0 190 66 92
+p2_hurt = 426 0 67 92
+p2_jump = 423 95 66 94
+p2_stand = 67 190 66 92
+p2_walk01 = 0 0 70 94
+p2_walk02 = 71 0 70 94
+p2_walk03 = 142 0 70 94
+p2_walk04 = 0 95 70 94
+p2_walk05 = 71 95 70 94
+p2_walk06 = 142 95 70 94
+p2_walk07 = 213 0 70 94
+p2_walk08 = 284 0 70 94
+p2_walk09 = 213 95 70 94
+p2_walk10 = 355 0 70 94
+p2_walk11 = 284 95 70 94

BIN
samples/browser/res/common/sprites/player3.png


+ 16 - 0
samples/browser/res/common/sprites/player3.txt

@@ -0,0 +1,16 @@
+p3_duck = 365 98 69 71
+p3_front = 0 196 66 92
+p3_hurt = 438 0 69 92
+p3_jump = 438 93 67 94
+p3_stand = 67 196 66 92
+p3_walk01 = 0 0 72 97
+p3_walk02 = 73 0 72 97
+p3_walk03 = 146 0 72 97
+p3_walk04 = 0 98 72 97
+p3_walk05 = 73 98 72 97
+p3_walk06 = 146 98 72 97
+p3_walk07 = 219 0 72 97
+p3_walk08 = 292 0 72 97
+p3_walk09 = 219 98 72 97
+p3_walk10 = 365 0 72 97
+p3_walk11 = 292 98 72 97

BIN
samples/browser/res/common/sprites/rocket.png


BIN
samples/browser/res/common/sprites/water2d-noise.png


+ 31 - 0
samples/browser/res/common/sprites/water2d.frag

@@ -0,0 +1,31 @@
+#ifdef OPENGL_ES
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif
+
+const float AMPLITUDE = 0.008;
+const float FREQUENCY = 40.0;
+const float SPEED = 0.5;
+
+///////////////////////////////////////////////////////////
+// Uniforms
+uniform sampler2D u_texture;
+uniform sampler2D u_texture_noise;
+uniform float u_time;
+
+///////////////////////////////////////////////////////////
+// Varyings
+varying vec2 v_texCoord;
+varying vec4 v_color;
+
+
+void main()
+{
+    vec2 displacement = texture2D (u_texture_noise, v_texCoord / 6.0).xy;
+    float t = v_texCoord.y + displacement.y * 0.1 - 0.10 + (sin (v_texCoord.x * FREQUENCY + (u_time * SPEED)) * AMPLITUDE);
+    gl_FragColor = v_color * texture2D(u_texture, vec2(v_texCoord.x, t));
+}
+

BIN
samples/browser/res/common/sprites/water2d.png


+ 32 - 24
samples/browser/sample-browser.xcodeproj/project.pbxproj

@@ -7,18 +7,20 @@
 	objects = {
 	objects = {
 
 
 /* Begin PBXBuildFile section */
 /* Begin PBXBuildFile section */
+		42097DF51A28C4B000D0B312 /* SpriteSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42097DF31A28C4B000D0B312 /* SpriteSample.cpp */; };
+		42097DF61A28C4B000D0B312 /* SpriteSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42097DF31A28C4B000D0B312 /* SpriteSample.cpp */; };
 		420D545815FE430D00AD0B91 /* Audio3DSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */; };
 		420D545815FE430D00AD0B91 /* Audio3DSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */; };
 		420D545915FE430D00AD0B91 /* Audio3DSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */; };
 		420D545915FE430D00AD0B91 /* Audio3DSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */; };
-		420D545A15FE430D00AD0B91 /* CreateSceneSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543C15FE430D00AD0B91 /* CreateSceneSample.cpp */; };
-		420D545B15FE430D00AD0B91 /* CreateSceneSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543C15FE430D00AD0B91 /* CreateSceneSample.cpp */; };
+		420D545A15FE430D00AD0B91 /* SceneCreateSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543C15FE430D00AD0B91 /* SceneCreateSample.cpp */; };
+		420D545B15FE430D00AD0B91 /* SceneCreateSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543C15FE430D00AD0B91 /* SceneCreateSample.cpp */; };
 		420D545C15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */; };
 		420D545C15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */; };
 		420D545D15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */; };
 		420D545D15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */; };
 		420D545E15FE430D00AD0B91 /* Grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544015FE430D00AD0B91 /* Grid.cpp */; };
 		420D545E15FE430D00AD0B91 /* Grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544015FE430D00AD0B91 /* Grid.cpp */; };
 		420D545F15FE430D00AD0B91 /* Grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544015FE430D00AD0B91 /* Grid.cpp */; };
 		420D545F15FE430D00AD0B91 /* Grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544015FE430D00AD0B91 /* Grid.cpp */; };
 		420D546015FE430D00AD0B91 /* InputSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544215FE430D00AD0B91 /* InputSample.cpp */; };
 		420D546015FE430D00AD0B91 /* InputSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544215FE430D00AD0B91 /* InputSample.cpp */; };
 		420D546115FE430D00AD0B91 /* InputSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544215FE430D00AD0B91 /* InputSample.cpp */; };
 		420D546115FE430D00AD0B91 /* InputSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544215FE430D00AD0B91 /* InputSample.cpp */; };
-		420D546215FE430D00AD0B91 /* LoadSceneSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544415FE430D00AD0B91 /* LoadSceneSample.cpp */; };
-		420D546315FE430D00AD0B91 /* LoadSceneSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544415FE430D00AD0B91 /* LoadSceneSample.cpp */; };
+		420D546215FE430D00AD0B91 /* SceneLoadSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544415FE430D00AD0B91 /* SceneLoadSample.cpp */; };
+		420D546315FE430D00AD0B91 /* SceneLoadSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544415FE430D00AD0B91 /* SceneLoadSample.cpp */; };
 		420D546415FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */; };
 		420D546415FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */; };
 		420D546515FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */; };
 		420D546515FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */; };
 		420D546615FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */; };
 		420D546615FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */; };
@@ -27,8 +29,8 @@
 		420D546D15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544E15FE430D00AD0B91 /* SpriteBatchSample.cpp */; };
 		420D546D15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D544E15FE430D00AD0B91 /* SpriteBatchSample.cpp */; };
 		420D546E15FE430D00AD0B91 /* Sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545015FE430D00AD0B91 /* Sample.cpp */; };
 		420D546E15FE430D00AD0B91 /* Sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545015FE430D00AD0B91 /* Sample.cpp */; };
 		420D546F15FE430D00AD0B91 /* Sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545015FE430D00AD0B91 /* Sample.cpp */; };
 		420D546F15FE430D00AD0B91 /* Sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545015FE430D00AD0B91 /* Sample.cpp */; };
-		420D547015FE430D00AD0B91 /* TextSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545215FE430D00AD0B91 /* TextSample.cpp */; };
-		420D547115FE430D00AD0B91 /* TextSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545215FE430D00AD0B91 /* TextSample.cpp */; };
+		420D547015FE430D00AD0B91 /* FontSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545215FE430D00AD0B91 /* FontSample.cpp */; };
+		420D547115FE430D00AD0B91 /* FontSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545215FE430D00AD0B91 /* FontSample.cpp */; };
 		420D547215FE430D00AD0B91 /* TextureSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545415FE430D00AD0B91 /* TextureSample.cpp */; };
 		420D547215FE430D00AD0B91 /* TextureSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545415FE430D00AD0B91 /* TextureSample.cpp */; };
 		420D547315FE430D00AD0B91 /* TextureSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545415FE430D00AD0B91 /* TextureSample.cpp */; };
 		420D547315FE430D00AD0B91 /* TextureSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545415FE430D00AD0B91 /* TextureSample.cpp */; };
 		420D547415FE430D00AD0B91 /* TriangleSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545615FE430D00AD0B91 /* TriangleSample.cpp */; };
 		420D547415FE430D00AD0B91 /* TriangleSample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420D545615FE430D00AD0B91 /* TriangleSample.cpp */; };
@@ -96,18 +98,20 @@
 /* End PBXBuildFile section */
 /* End PBXBuildFile section */
 
 
 /* Begin PBXFileReference section */
 /* Begin PBXFileReference section */
+		42097DF31A28C4B000D0B312 /* SpriteSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteSample.cpp; sourceTree = "<group>"; };
+		42097DF41A28C4B000D0B312 /* SpriteSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteSample.h; sourceTree = "<group>"; };
 		420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Audio3DSample.cpp; sourceTree = "<group>"; };
 		420D543A15FE430D00AD0B91 /* Audio3DSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Audio3DSample.cpp; sourceTree = "<group>"; };
 		420D543B15FE430D00AD0B91 /* Audio3DSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Audio3DSample.h; sourceTree = "<group>"; };
 		420D543B15FE430D00AD0B91 /* Audio3DSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Audio3DSample.h; sourceTree = "<group>"; };
-		420D543C15FE430D00AD0B91 /* CreateSceneSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateSceneSample.cpp; sourceTree = "<group>"; };
-		420D543D15FE430D00AD0B91 /* CreateSceneSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateSceneSample.h; sourceTree = "<group>"; };
+		420D543C15FE430D00AD0B91 /* SceneCreateSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SceneCreateSample.cpp; sourceTree = "<group>"; };
+		420D543D15FE430D00AD0B91 /* SceneCreateSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneCreateSample.h; sourceTree = "<group>"; };
 		420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirstPersonCamera.cpp; sourceTree = "<group>"; };
 		420D543E15FE430D00AD0B91 /* FirstPersonCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirstPersonCamera.cpp; sourceTree = "<group>"; };
 		420D543F15FE430D00AD0B91 /* FirstPersonCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FirstPersonCamera.h; sourceTree = "<group>"; };
 		420D543F15FE430D00AD0B91 /* FirstPersonCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FirstPersonCamera.h; sourceTree = "<group>"; };
 		420D544015FE430D00AD0B91 /* Grid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Grid.cpp; sourceTree = "<group>"; };
 		420D544015FE430D00AD0B91 /* Grid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Grid.cpp; sourceTree = "<group>"; };
 		420D544115FE430D00AD0B91 /* Grid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grid.h; sourceTree = "<group>"; };
 		420D544115FE430D00AD0B91 /* Grid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grid.h; sourceTree = "<group>"; };
 		420D544215FE430D00AD0B91 /* InputSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputSample.cpp; sourceTree = "<group>"; };
 		420D544215FE430D00AD0B91 /* InputSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputSample.cpp; sourceTree = "<group>"; };
 		420D544315FE430D00AD0B91 /* InputSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputSample.h; sourceTree = "<group>"; };
 		420D544315FE430D00AD0B91 /* InputSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputSample.h; sourceTree = "<group>"; };
-		420D544415FE430D00AD0B91 /* LoadSceneSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadSceneSample.cpp; sourceTree = "<group>"; };
-		420D544515FE430D00AD0B91 /* LoadSceneSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadSceneSample.h; sourceTree = "<group>"; };
+		420D544415FE430D00AD0B91 /* SceneLoadSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SceneLoadSample.cpp; sourceTree = "<group>"; };
+		420D544515FE430D00AD0B91 /* SceneLoadSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneLoadSample.h; sourceTree = "<group>"; };
 		420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshBatchSample.cpp; sourceTree = "<group>"; };
 		420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshBatchSample.cpp; sourceTree = "<group>"; };
 		420D544715FE430D00AD0B91 /* MeshBatchSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeshBatchSample.h; sourceTree = "<group>"; };
 		420D544715FE430D00AD0B91 /* MeshBatchSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeshBatchSample.h; sourceTree = "<group>"; };
 		420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshPrimitiveSample.cpp; sourceTree = "<group>"; };
 		420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshPrimitiveSample.cpp; sourceTree = "<group>"; };
@@ -116,8 +120,8 @@
 		420D544F15FE430D00AD0B91 /* SpriteBatchSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteBatchSample.h; sourceTree = "<group>"; };
 		420D544F15FE430D00AD0B91 /* SpriteBatchSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteBatchSample.h; sourceTree = "<group>"; };
 		420D545015FE430D00AD0B91 /* Sample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sample.cpp; sourceTree = "<group>"; };
 		420D545015FE430D00AD0B91 /* Sample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sample.cpp; sourceTree = "<group>"; };
 		420D545115FE430D00AD0B91 /* Sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sample.h; sourceTree = "<group>"; };
 		420D545115FE430D00AD0B91 /* Sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sample.h; sourceTree = "<group>"; };
-		420D545215FE430D00AD0B91 /* TextSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextSample.cpp; sourceTree = "<group>"; };
-		420D545315FE430D00AD0B91 /* TextSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextSample.h; sourceTree = "<group>"; };
+		420D545215FE430D00AD0B91 /* FontSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontSample.cpp; sourceTree = "<group>"; };
+		420D545315FE430D00AD0B91 /* FontSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSample.h; sourceTree = "<group>"; };
 		420D545415FE430D00AD0B91 /* TextureSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureSample.cpp; sourceTree = "<group>"; };
 		420D545415FE430D00AD0B91 /* TextureSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureSample.cpp; sourceTree = "<group>"; };
 		420D545515FE430D00AD0B91 /* TextureSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureSample.h; sourceTree = "<group>"; };
 		420D545515FE430D00AD0B91 /* TextureSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureSample.h; sourceTree = "<group>"; };
 		420D545615FE430D00AD0B91 /* TriangleSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriangleSample.cpp; sourceTree = "<group>"; };
 		420D545615FE430D00AD0B91 /* TriangleSample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriangleSample.cpp; sourceTree = "<group>"; };
@@ -323,10 +327,10 @@
 				420D543B15FE430D00AD0B91 /* Audio3DSample.h */,
 				420D543B15FE430D00AD0B91 /* Audio3DSample.h */,
 				F10DEAB516726157006FFFDC /* BillboardSample.cpp */,
 				F10DEAB516726157006FFFDC /* BillboardSample.cpp */,
 				F10DEAB616726157006FFFDC /* BillboardSample.h */,
 				F10DEAB616726157006FFFDC /* BillboardSample.h */,
-				420D543C15FE430D00AD0B91 /* CreateSceneSample.cpp */,
-				420D543D15FE430D00AD0B91 /* CreateSceneSample.h */,
 				9F4C6CFE162735020076E137 /* GestureSample.cpp */,
 				9F4C6CFE162735020076E137 /* GestureSample.cpp */,
 				9F4C6CFF162735020076E137 /* GestureSample.h */,
 				9F4C6CFF162735020076E137 /* GestureSample.h */,
+				420D545215FE430D00AD0B91 /* FontSample.cpp */,
+				420D545315FE430D00AD0B91 /* FontSample.h */,
 				F1E4B3F81671372E007516A7 /* FormsSample.cpp */,
 				F1E4B3F81671372E007516A7 /* FormsSample.cpp */,
 				F1E4B3F91671372E007516A7 /* FormsSample.h */,
 				F1E4B3F91671372E007516A7 /* FormsSample.h */,
 				42BE772E16A68CE3008AFA65 /* GamepadSample.cpp */,
 				42BE772E16A68CE3008AFA65 /* GamepadSample.cpp */,
@@ -335,8 +339,6 @@
 				420D544315FE430D00AD0B91 /* InputSample.h */,
 				420D544315FE430D00AD0B91 /* InputSample.h */,
 				42BE773216A68CF2008AFA65 /* LightSample.cpp */,
 				42BE773216A68CF2008AFA65 /* LightSample.cpp */,
 				42BE773316A68CF2008AFA65 /* LightSample.h */,
 				42BE773316A68CF2008AFA65 /* LightSample.h */,
-				420D544415FE430D00AD0B91 /* LoadSceneSample.cpp */,
-				420D544515FE430D00AD0B91 /* LoadSceneSample.h */,
 				420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */,
 				420D544615FE430D00AD0B91 /* MeshBatchSample.cpp */,
 				420D544715FE430D00AD0B91 /* MeshBatchSample.h */,
 				420D544715FE430D00AD0B91 /* MeshBatchSample.h */,
 				420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */,
 				420D544815FE430D00AD0B91 /* MeshPrimitiveSample.cpp */,
@@ -347,12 +349,16 @@
 				42BE773716A68D07008AFA65 /* PhysicsCollisionObjectSample.h */,
 				42BE773716A68D07008AFA65 /* PhysicsCollisionObjectSample.h */,
 				422FE592169690830062D1FE /* PostProcessSample.cpp */,
 				422FE592169690830062D1FE /* PostProcessSample.cpp */,
 				422FE593169690830062D1FE /* PostProcessSample.h */,
 				422FE593169690830062D1FE /* PostProcessSample.h */,
+				420D543C15FE430D00AD0B91 /* SceneCreateSample.cpp */,
+				420D543D15FE430D00AD0B91 /* SceneCreateSample.h */,
+				420D544415FE430D00AD0B91 /* SceneLoadSample.cpp */,
+				420D544515FE430D00AD0B91 /* SceneLoadSample.h */,
+				42097DF31A28C4B000D0B312 /* SpriteSample.cpp */,
+				42097DF41A28C4B000D0B312 /* SpriteSample.h */,
 				420D544E15FE430D00AD0B91 /* SpriteBatchSample.cpp */,
 				420D544E15FE430D00AD0B91 /* SpriteBatchSample.cpp */,
 				420D544F15FE430D00AD0B91 /* SpriteBatchSample.h */,
 				420D544F15FE430D00AD0B91 /* SpriteBatchSample.h */,
 				42DFABD216AD96F10000F342 /* TerrainSample.cpp */,
 				42DFABD216AD96F10000F342 /* TerrainSample.cpp */,
 				42DFABD316AD96F10000F342 /* TerrainSample.h */,
 				42DFABD316AD96F10000F342 /* TerrainSample.h */,
-				420D545215FE430D00AD0B91 /* TextSample.cpp */,
-				420D545315FE430D00AD0B91 /* TextSample.h */,
 				420D545415FE430D00AD0B91 /* TextureSample.cpp */,
 				420D545415FE430D00AD0B91 /* TextureSample.cpp */,
 				420D545515FE430D00AD0B91 /* TextureSample.h */,
 				420D545515FE430D00AD0B91 /* TextureSample.h */,
 				420D545615FE430D00AD0B91 /* TriangleSample.cpp */,
 				420D545615FE430D00AD0B91 /* TriangleSample.cpp */,
@@ -525,16 +531,17 @@
 				4258369D1A0F2AF400AFDFEB /* WaterSample.cpp in Sources */,
 				4258369D1A0F2AF400AFDFEB /* WaterSample.cpp in Sources */,
 				42C932F11491A5160098216A /* SamplesGame.cpp in Sources */,
 				42C932F11491A5160098216A /* SamplesGame.cpp in Sources */,
 				420D545815FE430D00AD0B91 /* Audio3DSample.cpp in Sources */,
 				420D545815FE430D00AD0B91 /* Audio3DSample.cpp in Sources */,
-				420D545A15FE430D00AD0B91 /* CreateSceneSample.cpp in Sources */,
+				420D545A15FE430D00AD0B91 /* SceneCreateSample.cpp in Sources */,
 				420D545C15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */,
 				420D545C15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */,
+				42097DF51A28C4B000D0B312 /* SpriteSample.cpp in Sources */,
 				420D545E15FE430D00AD0B91 /* Grid.cpp in Sources */,
 				420D545E15FE430D00AD0B91 /* Grid.cpp in Sources */,
 				420D546015FE430D00AD0B91 /* InputSample.cpp in Sources */,
 				420D546015FE430D00AD0B91 /* InputSample.cpp in Sources */,
-				420D546215FE430D00AD0B91 /* LoadSceneSample.cpp in Sources */,
+				420D546215FE430D00AD0B91 /* SceneLoadSample.cpp in Sources */,
 				420D546415FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */,
 				420D546415FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */,
 				420D546615FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */,
 				420D546615FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */,
 				420D546C15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */,
 				420D546C15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */,
 				420D546E15FE430D00AD0B91 /* Sample.cpp in Sources */,
 				420D546E15FE430D00AD0B91 /* Sample.cpp in Sources */,
-				420D547015FE430D00AD0B91 /* TextSample.cpp in Sources */,
+				420D547015FE430D00AD0B91 /* FontSample.cpp in Sources */,
 				42A1BA201A27BCE200BF506D /* ParticlesSample.cpp in Sources */,
 				42A1BA201A27BCE200BF506D /* ParticlesSample.cpp in Sources */,
 				420D547215FE430D00AD0B91 /* TextureSample.cpp in Sources */,
 				420D547215FE430D00AD0B91 /* TextureSample.cpp in Sources */,
 				420D547415FE430D00AD0B91 /* TriangleSample.cpp in Sources */,
 				420D547415FE430D00AD0B91 /* TriangleSample.cpp in Sources */,
@@ -556,16 +563,17 @@
 				4258369E1A0F2AF400AFDFEB /* WaterSample.cpp in Sources */,
 				4258369E1A0F2AF400AFDFEB /* WaterSample.cpp in Sources */,
 				5B61611614CCC24C0073B857 /* SamplesGame.cpp in Sources */,
 				5B61611614CCC24C0073B857 /* SamplesGame.cpp in Sources */,
 				420D545915FE430D00AD0B91 /* Audio3DSample.cpp in Sources */,
 				420D545915FE430D00AD0B91 /* Audio3DSample.cpp in Sources */,
-				420D545B15FE430D00AD0B91 /* CreateSceneSample.cpp in Sources */,
+				420D545B15FE430D00AD0B91 /* SceneCreateSample.cpp in Sources */,
 				420D545D15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */,
 				420D545D15FE430D00AD0B91 /* FirstPersonCamera.cpp in Sources */,
+				42097DF61A28C4B000D0B312 /* SpriteSample.cpp in Sources */,
 				420D545F15FE430D00AD0B91 /* Grid.cpp in Sources */,
 				420D545F15FE430D00AD0B91 /* Grid.cpp in Sources */,
 				420D546115FE430D00AD0B91 /* InputSample.cpp in Sources */,
 				420D546115FE430D00AD0B91 /* InputSample.cpp in Sources */,
-				420D546315FE430D00AD0B91 /* LoadSceneSample.cpp in Sources */,
+				420D546315FE430D00AD0B91 /* SceneLoadSample.cpp in Sources */,
 				420D546515FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */,
 				420D546515FE430D00AD0B91 /* MeshBatchSample.cpp in Sources */,
 				420D546715FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */,
 				420D546715FE430D00AD0B91 /* MeshPrimitiveSample.cpp in Sources */,
 				420D546D15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */,
 				420D546D15FE430D00AD0B91 /* SpriteBatchSample.cpp in Sources */,
 				420D546F15FE430D00AD0B91 /* Sample.cpp in Sources */,
 				420D546F15FE430D00AD0B91 /* Sample.cpp in Sources */,
-				420D547115FE430D00AD0B91 /* TextSample.cpp in Sources */,
+				420D547115FE430D00AD0B91 /* FontSample.cpp in Sources */,
 				42A1BA211A27BCE200BF506D /* ParticlesSample.cpp in Sources */,
 				42A1BA211A27BCE200BF506D /* ParticlesSample.cpp in Sources */,
 				420D547315FE430D00AD0B91 /* TextureSample.cpp in Sources */,
 				420D547315FE430D00AD0B91 /* TextureSample.cpp in Sources */,
 				420D547515FE430D00AD0B91 /* TriangleSample.cpp in Sources */,
 				420D547515FE430D00AD0B91 /* TriangleSample.cpp in Sources */,

+ 1 - 1
samples/browser/src/Audio3DSample.cpp

@@ -3,7 +3,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Media", "Audio Listener", Audio3DSample, 1);
+    ADD_SAMPLE("Media", "Audio 3D", Audio3DSample, 1);
 #endif
 #endif
 
 
 static const unsigned int MOVE_FORWARD = 1;
 static const unsigned int MOVE_FORWARD = 1;

+ 1 - 1
samples/browser/src/BillboardSample.cpp

@@ -3,7 +3,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Billboards", BillboardSample, 10);
+    ADD_SAMPLE("Graphics", "Billboards", BillboardSample, 11);
 #endif
 #endif
 
 
 static const unsigned int MOVE_FORWARD = 1;
 static const unsigned int MOVE_FORWARD = 1;

+ 9 - 9
samples/browser/src/TextSample.cpp → samples/browser/src/FontSample.cpp

@@ -1,8 +1,8 @@
-#include "TextSample.h"
+#include "FontSample.h"
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Text", TextSample, 6);
+    ADD_SAMPLE("Graphics", "Font", FontSample, 7);
 #endif
 #endif
 
 
 #define FONT_COUNT 5
 #define FONT_COUNT 5
@@ -25,13 +25,13 @@ std::string _fontFiles[] =
     "res/common/fonts/neuropol.gpb"
     "res/common/fonts/neuropol.gpb"
 };
 };
 
 
-TextSample::TextSample()
+FontSample::FontSample()
     : _form(NULL), _stateBlock(NULL), _size(18), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
     : _form(NULL), _stateBlock(NULL), _size(18), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
       _fontsCount(FONT_COUNT), _fontIndex(0), _font(NULL), _viewport(250, 100, 512, 200)
       _fontsCount(FONT_COUNT), _fontIndex(0), _font(NULL), _viewport(250, 100, 512, 200)
 {
 {
 }
 }
 
 
-void TextSample::finalize()
+void FontSample::finalize()
 {
 {
     SAFE_RELEASE(_stateBlock);
     SAFE_RELEASE(_stateBlock);
 
 
@@ -43,7 +43,7 @@ void TextSample::finalize()
     SAFE_RELEASE(_form);
     SAFE_RELEASE(_form);
 }
 }
 
 
-void TextSample::initialize()
+void FontSample::initialize()
 {
 {
     // Create our render state block that will be reused across all materials
     // Create our render state block that will be reused across all materials
     _stateBlock = RenderState::StateBlock::create();
     _stateBlock = RenderState::StateBlock::create();
@@ -88,11 +88,11 @@ void TextSample::initialize()
     static_cast<Button*>(_form->getControl("bottomRightButton"))->addListener(this, Control::Listener::CLICK);
     static_cast<Button*>(_form->getControl("bottomRightButton"))->addListener(this, Control::Listener::CLICK);
 }
 }
 
 
-void TextSample::update(float elapsedTime)
+void FontSample::update(float elapsedTime)
 {
 {
 }
 }
 
 
-void TextSample::render(float elapsedTime)
+void FontSample::render(float elapsedTime)
 {
 {
     // Clear the screen.
     // Clear the screen.
     clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
     clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
@@ -147,13 +147,13 @@ void TextSample::render(float elapsedTime)
     _form->draw();
     _form->draw();
 }
 }
 
 
-void TextSample::touchEvent(Touch::TouchEvent event, int x, int y, unsigned int contactIndex)
+void FontSample::touchEvent(Touch::TouchEvent event, int x, int y, unsigned int contactIndex)
 {
 {
     _viewport.width = x - _viewport.x;
     _viewport.width = x - _viewport.x;
     _viewport.height = y - _viewport.y;
     _viewport.height = y - _viewport.y;
 }
 }
 
 
-void TextSample::controlEvent(Control* control, EventType evt)
+void FontSample::controlEvent(Control* control, EventType evt)
 {
 {
     const char* id = control->getId();
     const char* id = control->getId();
 
 

+ 5 - 5
samples/browser/src/TextSample.h → samples/browser/src/FontSample.h

@@ -1,5 +1,5 @@
-#ifndef TEXTSAMPLE_H_
-#define TEXTSAMPLE_H_
+#ifndef FONTSAMPLE_H_
+#define FONTSAMPLE_H_
 
 
 #include "gameplay.h"
 #include "gameplay.h"
 #include "Sample.h"
 #include "Sample.h"
@@ -7,13 +7,13 @@
 using namespace gameplay;
 using namespace gameplay;
 
 
 /**
 /**
- * Sample the text and font class with various text functionality.
+ * Sample testing the font with various functionality.
  */
  */
-class TextSample : public Sample, public Control::Listener
+class FontSample : public Sample, public Control::Listener
 {
 {
 public:
 public:
 
 
-    TextSample();
+    FontSample();
 
 
 protected:
 protected:
     void initialize();
     void initialize();

+ 1 - 1
samples/browser/src/FormsSample.cpp

@@ -1,7 +1,7 @@
 #include "FormsSample.h"
 #include "FormsSample.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Forms", FormsSample, 7);
+    ADD_SAMPLE("Graphics", "Forms", FormsSample, 8);
 #endif
 #endif
 
 
 // Input bit-flags
 // Input bit-flags

+ 1 - 1
samples/browser/src/LightSample.cpp

@@ -2,7 +2,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Light", LightSample, 8);
+    ADD_SAMPLE("Graphics", "Light", LightSample, 10);
 #endif
 #endif
 
 
 LightSample::LightSample()
 LightSample::LightSample()

+ 0 - 5
samples/browser/src/MeshPrimitiveSample.cpp

@@ -200,11 +200,6 @@ void MeshPrimitiveSample::finalize()
     SAFE_RELEASE(_lines);
     SAFE_RELEASE(_lines);
     SAFE_RELEASE(_points);
     SAFE_RELEASE(_points);
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_font);
-    for (std::list<Font::Text*>::iterator it = _text.begin(); it != _text.end(); ++it)
-    {
-        SAFE_DELETE(*it);
-    }
-    _text.clear();
 }
 }
 
 
 void MeshPrimitiveSample::update(float elapsedTime)
 void MeshPrimitiveSample::update(float elapsedTime)

+ 1 - 1
samples/browser/src/MeshPrimitiveSample.h

@@ -42,7 +42,7 @@ private:
     Matrix _viewProjectionMatrix;
     Matrix _viewProjectionMatrix;
     Vector2 _touchPoint;
     Vector2 _touchPoint;
     Vector2 _tilt;
     Vector2 _tilt;
-    std::list<Font::Text*> _text;
+    std::list<Text*> _text;
 };
 };
 
 
 #endif
 #endif

+ 1 - 1
samples/browser/src/PhysicsCollisionObjectSample.cpp

@@ -2,7 +2,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Physics", "Collision Objects", PhysicsCollisionObjectSample, 1);
+    ADD_SAMPLE("Physics", "Collision 3D", PhysicsCollisionObjectSample, 1);
 #endif
 #endif
 
 
 PhysicsCollisionObjectSample::PhysicsCollisionObjectSample()
 PhysicsCollisionObjectSample::PhysicsCollisionObjectSample()

+ 1 - 1
samples/browser/src/PostProcessSample.cpp

@@ -2,7 +2,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Post Process", PostProcessSample, 13);
+    ADD_SAMPLE("Graphics", "Post Process", PostProcessSample, 14);
 #endif
 #endif
 
 
 #define FRAMEBUFFER_WIDTH 1024
 #define FRAMEBUFFER_WIDTH 1024

+ 10 - 10
samples/browser/src/CreateSceneSample.cpp → samples/browser/src/SceneCreateSample.cpp

@@ -1,8 +1,8 @@
-#include "CreateSceneSample.h"
+#include "SceneCreateSample.h"
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Create Scene", CreateSceneSample, 15);
+    ADD_SAMPLE("Graphics", "Scene Creation", SceneCreateSample, 15);
 #endif
 #endif
 
 
 static Mesh* createCubeMesh(float size = 1.0f)
 static Mesh* createCubeMesh(float size = 1.0f)
@@ -59,12 +59,12 @@ static Mesh* createCubeMesh(float size = 1.0f)
     return mesh;
     return mesh;
 }
 }
 
 
-CreateSceneSample::CreateSceneSample()
+SceneCreateSample::SceneCreateSample()
     : _font(NULL), _scene(NULL), _cubeNode(NULL)
     : _font(NULL), _scene(NULL), _cubeNode(NULL)
 {
 {
 }
 }
 
 
-void CreateSceneSample::initialize()
+void SceneCreateSample::initialize()
 {
 {
     // Create the font for drawing the framerate.
     // Create the font for drawing the framerate.
     _font = Font::create("res/ui/arial.gpb");
     _font = Font::create("res/ui/arial.gpb");
@@ -128,30 +128,30 @@ void CreateSceneSample::initialize()
     SAFE_RELEASE(cubeModel);
     SAFE_RELEASE(cubeModel);
 }
 }
 
 
-void CreateSceneSample::finalize()
+void SceneCreateSample::finalize()
 {
 {
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_scene);
     SAFE_RELEASE(_scene);
 }
 }
 
 
-void CreateSceneSample::update(float elapsedTime)
+void SceneCreateSample::update(float elapsedTime)
 {
 {
     // Rotate the directional light.
     // Rotate the directional light.
     _cubeNode->rotateY(elapsedTime * 0.001 * MATH_PI);
     _cubeNode->rotateY(elapsedTime * 0.001 * MATH_PI);
 }
 }
 
 
-void CreateSceneSample::render(float elapsedTime)
+void SceneCreateSample::render(float elapsedTime)
 {
 {
     // Clear the color and depth buffers
     // Clear the color and depth buffers
     clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);
     clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);
 
 
     // Visit all the nodes in the scene, drawing the models.
     // Visit all the nodes in the scene, drawing the models.
-    _scene->visit(this, &CreateSceneSample::drawScene);
+    _scene->visit(this, &SceneCreateSample::drawScene);
 
 
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
 }
 }
 
 
-void CreateSceneSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+void SceneCreateSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
     switch (evt)
     switch (evt)
     {
     {
@@ -169,7 +169,7 @@ void CreateSceneSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned
     };
     };
 }
 }
 
 
-bool CreateSceneSample::drawScene(Node* node)
+bool SceneCreateSample::drawScene(Node* node)
 {
 {
     Model* model = node->getModel();
     Model* model = node->getModel();
     if (model)
     if (model)

+ 4 - 4
samples/browser/src/CreateSceneSample.h → samples/browser/src/SceneCreateSample.h

@@ -1,5 +1,5 @@
-#ifndef CREATESCENESAMPLE_H_
-#define CREATESCENESAMPLE_H_
+#ifndef SCENECREATESAMPLE_H_
+#define SCENECREATESAMPLE_H_
 
 
 #include "gameplay.h"
 #include "gameplay.h"
 #include "Sample.h"
 #include "Sample.h"
@@ -9,11 +9,11 @@ using namespace gameplay;
 /**
 /**
  * Samples programattically contructing a scene.
  * Samples programattically contructing a scene.
  */
  */
-class CreateSceneSample : public Sample
+class SceneCreateSample : public Sample
 {
 {
 public:
 public:
 
 
-    CreateSceneSample();
+    SceneCreateSample();
 
 
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
 
 

+ 13 - 13
samples/browser/src/LoadSceneSample.cpp → samples/browser/src/SceneLoadSample.cpp

@@ -1,17 +1,17 @@
-#include "LoadSceneSample.h"
+#include "SceneLoadSample.h"
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Load Scene", LoadSceneSample, 17);
+    ADD_SAMPLE("Graphics", "Scene Loading", SceneLoadSample, 16);
 #endif
 #endif
 
 
-LoadSceneSample::LoadSceneSample()
+SceneLoadSample::SceneLoadSample()
     : _font(NULL), _scene(NULL), _wireFrame(false)
     : _font(NULL), _scene(NULL), _wireFrame(false)
 {
 {
     
     
 }
 }
 
 
-void LoadSceneSample::initialize()
+void SceneLoadSample::initialize()
 {
 {
     // Create the font for drawing the framerate.
     // Create the font for drawing the framerate.
     _font = Font::create("res/ui/arial.gpb");
     _font = Font::create("res/ui/arial.gpb");
@@ -22,12 +22,12 @@ void LoadSceneSample::initialize()
     _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
     _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
 
 
     // Visit all the nodes in the scene, drawing the models/mesh.
     // Visit all the nodes in the scene, drawing the models/mesh.
-    _scene->visit(this, &LoadSceneSample::initializeMaterials);
+    _scene->visit(this, &SceneLoadSample::initializeMaterials);
 
 
 }
 }
 
 
 
 
-bool LoadSceneSample::initializeMaterials(Node* node)
+bool SceneLoadSample::initializeMaterials(Node* node)
 {
 {
     Model* model = node->getModel();
     Model* model = node->getModel();
     if (model)
     if (model)
@@ -42,29 +42,29 @@ bool LoadSceneSample::initializeMaterials(Node* node)
     return true;
     return true;
 }
 }
 
 
-void LoadSceneSample::finalize()
+void SceneLoadSample::finalize()
 {
 {
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_scene);
     SAFE_RELEASE(_scene);
 }
 }
 
 
-void LoadSceneSample::update(float elapsedTime)
+void SceneLoadSample::update(float elapsedTime)
 {
 {
     
     
 }
 }
 
 
-void LoadSceneSample::render(float elapsedTime)
+void SceneLoadSample::render(float elapsedTime)
 {
 {
     // Clear the color and depth buffers
     // Clear the color and depth buffers
     clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);
     clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);
 
 
     // Visit all the nodes in the scene, drawing the models/mesh.
     // Visit all the nodes in the scene, drawing the models/mesh.
-    _scene->visit(this, &LoadSceneSample::drawScene);
+    _scene->visit(this, &SceneLoadSample::drawScene);
 
 
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
 }
 }
 
 
-void LoadSceneSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+void SceneLoadSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
     switch (evt)
     switch (evt)
     {
     {
@@ -83,7 +83,7 @@ void LoadSceneSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned i
     };
     };
 }
 }
 
 
-void LoadSceneSample::keyEvent(Keyboard::KeyEvent evt, int key)
+void SceneLoadSample::keyEvent(Keyboard::KeyEvent evt, int key)
 {
 {
     if (evt == Keyboard::KEY_PRESS)
     if (evt == Keyboard::KEY_PRESS)
     {
     {
@@ -97,7 +97,7 @@ void LoadSceneSample::keyEvent(Keyboard::KeyEvent evt, int key)
     }
     }
 }
 }
 
 
-bool LoadSceneSample::drawScene(Node* node)
+bool SceneLoadSample::drawScene(Node* node)
 {
 {
     Model* model = node->getModel();
     Model* model = node->getModel();
     if (model)
     if (model)

+ 4 - 4
samples/browser/src/LoadSceneSample.h → samples/browser/src/SceneLoadSample.h

@@ -1,5 +1,5 @@
-#ifndef LOADSCENESAMPLE_H_
-#define LOADSCENESAMPLE_H_
+#ifndef SCENELOADSAMPLE_H_
+#define SCENELOADSAMPLE_H_
 
 
 #include "gameplay.h"
 #include "gameplay.h"
 #include "Sample.h"
 #include "Sample.h"
@@ -9,11 +9,11 @@ using namespace gameplay;
 /**
 /**
  * Sample for loading a scene from a .scene file.
  * Sample for loading a scene from a .scene file.
  */
  */
-class LoadSceneSample : public Sample
+class SceneLoadSample : public Sample
 {
 {
 public:
 public:
 
 
-    LoadSceneSample();
+    SceneLoadSample();
 
 
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
 
 

+ 262 - 0
samples/browser/src/SpriteSample.cpp

@@ -0,0 +1,262 @@
+#include "SpriteSample.h"
+#include "SamplesGame.h"
+
+#if defined(ADD_SAMPLE)
+    ADD_SAMPLE("Graphics", "Sprite", SpriteSample, 6);
+#endif
+
+SpriteSample::SpriteSample()
+    : _font(NULL), _scene(NULL), _cameraNode(NULL),
+      _floorTileSet(NULL), _floorNode(NULL),
+      _backgroundSprite(NULL), _backgroundNode(NULL),
+      _playerSprite(NULL), _playerNode(NULL), _playerAnimation(NULL), _playerMovement(0),
+      _rocketSprite(NULL), _rocketNode(NULL),
+      _waterSprite(NULL), _waterNode(NULL),
+      _text(NULL), _textNode(NULL)
+{
+}
+
+void SpriteSample::initialize()
+{
+    // Create the font for drawing the framerate.
+    _font = Font::create("res/ui/arial.gpb");
+
+    // Create an orthographic projection matrix.
+    float width = (float)getWidth();
+    float height = (float)getHeight();
+    float aspectRatio = width / height;
+    _scene = Scene::create();
+    _cameraNode = _scene->addNode("camera");
+    Camera* camera = Camera::createOrthographic(width, height, aspectRatio, 0, 100);
+    _cameraNode->setCamera(camera);
+    _scene->setActiveCamera(camera);
+    SAFE_RELEASE(camera);
+    _cameraNode->translateX(width / 2);
+    _cameraNode->translateY(height / 2);
+
+    // Background sprite image
+    _backgroundSprite = Sprite::create("res/common/sprites/background.png", getWidth() * 5, getHeight());
+    _backgroundNode = _scene->addNode("background");
+    _backgroundNode->setSprite(_backgroundSprite);
+    
+    // Level floor tile set
+    _floorTileSet = TileSet::create("res/common/sprites/level.png", 70, 70, 3, 7);
+    _floorTileSet->setTileSource(0, 0, Vector2(568, 284));
+    _floorTileSet->setTileSource(1, 0, Vector2(568, 284));
+    _floorTileSet->setTileSource(2, 0, Vector2(568, 284));
+    _floorTileSet->setTileSource(3, 0, Vector2(568, 284));
+    _floorTileSet->setTileSource(4, 0, Vector2(497, 284));
+    
+    _floorTileSet->setTileSource(0, 1, Vector2(568, 0));
+    _floorTileSet->setTileSource(1, 1, Vector2(568, 0));
+    _floorTileSet->setTileSource(2, 1, Vector2(568, 0));
+    _floorTileSet->setTileSource(3, 1, Vector2(568, 0));
+    _floorTileSet->setTileSource(4, 1, Vector2(710, 142));
+    _floorTileSet->setTileSource(5, 1, Vector2(497, 284));
+    
+    _floorTileSet->setTileSource(0, 2, Vector2(568, 0));
+    _floorTileSet->setTileSource(1, 2, Vector2(568, 0));
+    _floorTileSet->setTileSource(2, 2, Vector2(568, 0));
+    _floorTileSet->setTileSource(3, 2, Vector2(568, 0));
+    _floorTileSet->setTileSource(4, 2, Vector2(568, 0));
+    _floorTileSet->setTileSource(5, 2, Vector2(710, 142));
+    _floorTileSet->setTileSource(6, 2, Vector2(497, 284));
+    
+    _floorNode = _scene->addNode("floor");
+    _floorNode->setTileSet(_floorTileSet);
+    
+    // Idle[0]
+    _playerSprite = Sprite::create("res/common/sprites/player1.png", 72.0f, 97.0f, Rectangle(67, 196, 66, 92), 13);
+    //_playerSprite->computeFrames(3, 1);
+    // Walk [1 - 11]
+    _playerSprite->setFrameSource(1, Rectangle( 0, 0, 72, 92));
+    _playerSprite->setFrameSource(2, Rectangle(73, 0, 72, 97));
+    _playerSprite->setFrameSource(3, Rectangle(146, 0, 72, 97));
+    _playerSprite->setFrameSource(4, Rectangle(0, 98, 72, 97));
+    _playerSprite->setFrameSource(5, Rectangle(73, 98, 72, 97));
+    _playerSprite->setFrameSource(6, Rectangle(146, 98, 72, 97));
+    _playerSprite->setFrameSource(7, Rectangle(219, 0, 72, 97));
+    _playerSprite->setFrameSource(8, Rectangle(292, 0, 72, 97));
+    _playerSprite->setFrameSource(9, Rectangle(219, 98, 72, 97));
+    _playerSprite->setFrameSource(10, Rectangle(365, 0, 72, 97));
+    _playerSprite->setFrameSource(11, Rectangle(292, 98, 72, 97));
+    // Jump[12]
+    _playerSprite->setFrameSource(12, Rectangle(438, 93, 67, 94));
+    _playerNode = _scene->addNode("player");
+    _playerNode->setSprite(_playerSprite);
+    _playerNode->translateY(_floorTileSet->getHeight());
+    
+    // The player animation clips
+    unsigned int keyTimes[4] = {0, 1, 11, 12};
+    float keyValues[4] =  { 0, 1, 11, 12 };
+    _playerAnimation = _playerSprite->createAnimation("player-animations", Sprite::ANIMATE_KEYFRAME, 4, keyTimes, keyValues,
+                                                Curve::LINEAR);
+    _playerAnimation->createClip("idle", 0, 0);
+    _playerAnimation->createClip("walk", 1, 11)->setRepeatCount(AnimationClip::REPEAT_INDEFINITE);
+    // Set the speed to 24 FPS
+    _playerAnimation->getClip("walk")->setSpeed(24.0f/1000.0f);
+    _playerAnimation->play("idle");
+    
+    // Rocket
+    _rocketSprite = Sprite::create("res/common/sprites/rocket.png", 128, 128);
+    _rocketSprite->setBlendMode(Sprite::BLEND_ADDITIVE);
+    _rocketSprite->setAnchor(Vector2(0.5f, 0.3f));
+    _rocketSprite->setOffset(Sprite::OFFSET_ANCHOR);
+    _rocketNode = _scene->addNode("rocket");
+    _rocketNode->setSprite(_rocketSprite);
+    _rocketNode->translate(Vector3(getWidth(), 0,  0));
+    _rocketNode->rotateZ(MATH_DEG_TO_RAD(-45));
+    
+    // Custom Effect in sprite
+    Effect* waterEffect = Effect::createFromFile("res/shaders/sprite.vert", "res/common/sprites/water2d.frag");
+    _waterSprite = Sprite::create("res/common/sprites/water2d.png", getWidth() * 5, getHeight() / 3, waterEffect);
+    _waterSprite->setAnchor(Vector2::zero());
+    _waterSprite->setOpacity(0.5f);
+    _waterNode = _scene->addNode("water");
+    _waterNode->setSprite(_waterSprite);
+    Material* waterMaterial = _waterSprite->getMaterial();
+    Texture::Sampler* noiseSampler = Texture::Sampler::create("res/common/sprites/water2d-noise.png");
+    waterMaterial->getParameter("u_texture_noise")->setValue(noiseSampler);
+    SAFE_RELEASE(noiseSampler);
+    waterMaterial->getParameter("u_time")->bindValue(this, &SpriteSample::getTime);
+    _waterNode->translateY(-50);
+    
+    // Text node.
+    _text = Text::create("res/ui/arial.gpb", "P1", Vector4(0, 0, 1, 1), 18);
+    _textNode = Node::create("text");
+    _playerNode->addChild(_textNode);
+    _text->setWidth(_playerNode->getSprite()->getWidth());
+    _textNode->setText(_text);
+    _text->setJustify(Font::ALIGN_TOP_HCENTER);
+    _textNode->translateY(_playerNode->getSprite()->getHeight());
+}
+
+void SpriteSample::finalize()
+{
+    SAFE_RELEASE(_playerSprite);
+    SAFE_RELEASE(_rocketSprite);
+    SAFE_RELEASE(_waterSprite);
+}
+
+void SpriteSample::update(float elapsedTime)
+{
+    if ((_playerMovement & WALK_FORWARD) == WALK_FORWARD)
+    {
+        float moveX = 0.25 * elapsedTime;
+        _cameraNode->translateX(moveX);
+        _playerSprite->setFlip(Sprite::FLIP_NONE);
+        _playerNode->translateX(moveX);
+        if (!_playerAnimation->getClip("walk")->isPlaying())
+        {
+            _playerAnimation->stop("idle");
+            _playerAnimation->play("walk");
+        }
+    }
+    else if ((_playerMovement &  WALK_BACKWARD) == WALK_BACKWARD)
+    {
+        float moveX = -0.25 * elapsedTime;
+        _cameraNode->translateX(moveX);
+        _playerSprite->setFlip(Sprite::FLIP_HORIZONTAL);
+        _playerNode->translateX(moveX);
+        if (!_playerAnimation->getClip("walk")->isPlaying())
+        {
+            _playerAnimation->stop("idle");
+            _playerAnimation->play("walk");
+        }
+    }
+    else
+    {
+        // IDLE
+        if (!_playerAnimation->getClip("idle")->isPlaying())
+        {
+            _playerAnimation->stop("walk");
+            _playerAnimation->play("idle");
+        }
+    }
+}
+
+void SpriteSample::render(float elapsedTime)
+{
+    // Clear the color and depth buffers
+    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
+    
+    // Visit all the nodes in the scene, drawing the sprites
+    _scene->visit(this, &SpriteSample::drawScene);
+    
+    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
+}
+
+void SpriteSample::keyEvent(Keyboard::KeyEvent evt, int key)
+{
+    if (evt == Keyboard::KEY_PRESS)
+    {
+        switch (key)
+        {
+            case Keyboard::KEY_A:
+                _playerMovement |= WALK_BACKWARD;
+                break;
+            case Keyboard::KEY_D:
+                _playerMovement |= WALK_FORWARD;
+                break;
+            case Keyboard::KEY_C:
+                Node* clone = _playerNode->clone();
+                _scene->addNode(clone);
+                clone->translateZ(-1);
+                break;
+        }
+    }
+    else if (evt == Keyboard::KEY_RELEASE)
+    {
+        switch (key)
+        {
+            case Keyboard::KEY_A:
+                _playerMovement &= ~WALK_BACKWARD;
+                break;
+            case Keyboard::KEY_D:
+                _playerMovement &= ~WALK_FORWARD;
+                break;
+        }
+    }
+}
+
+void SpriteSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+{
+    switch (evt)
+    {
+        case Touch::TOUCH_PRESS:
+            if (x < 75 && y < 50)
+            {
+                // Toggle Vsync if the user touches the top left corner
+                setVsync(!isVsync());
+                return;
+            }
+            break;
+        case Touch::TOUCH_RELEASE:
+            break;
+        case Touch::TOUCH_MOVE:
+            break;
+    };
+}
+
+bool SpriteSample::drawScene(Node* node)
+{
+    Sprite* sprite = node->getSprite();
+    if (sprite)
+        sprite->draw();
+    TileSet* tileset = node->getTileSet();
+    if (tileset)
+        tileset->draw();
+    Text* text = node->getText();
+    if (text)
+        text->draw();
+    
+    return true;
+}
+
+float SpriteSample::getTime() const
+{
+    float angle = Game::getGameTime() * 0.001 * MATH_PIX2;
+    if (angle > MATH_PIX2)
+        angle -= MATH_PIX2;
+    return angle;
+}

+ 64 - 0
samples/browser/src/SpriteSample.h

@@ -0,0 +1,64 @@
+#ifndef SPRITESAMPLE_H_
+#define SPRITESAMPLE_H_
+
+#include "gameplay.h"
+#include "Sample.h"
+
+using namespace gameplay;
+
+/**
+ * Sample drawing sprites in a scene with the Sprite class.
+ */
+class SpriteSample : public Sample
+{
+public:
+    
+    enum Movement
+    {
+        WALK_FORWARD    = (1 << 0),
+        WALK_BACKWARD   = (1 << 1),
+    };
+
+    SpriteSample();
+
+    void keyEvent(Keyboard::KeyEvent evt, int key);
+    
+    void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
+
+protected:
+
+    void initialize();
+
+    void finalize();
+
+    void update(float elapsedTime);
+
+    void render(float elapsedTime);
+
+private:
+    
+    bool drawScene(Node* node);
+    
+    float getTime() const;
+
+    Font* _font;
+    Scene* _scene;
+    Node* _cameraNode;
+    TileSet* _floorTileSet;
+    Node* _floorNode;
+    Sprite* _backgroundSprite;
+    Node* _backgroundNode;
+    Sprite* _playerSprite;
+    Node* _playerNode;
+    Animation* _playerAnimation;
+    int _playerMovement;
+    Sprite* _rocketSprite;
+    Node* _rocketNode;
+    Sprite* _waterSprite;
+    Node* _waterNode;
+    Text* _text;
+    Node* _textNode;
+    
+};
+
+#endif

+ 1 - 1
samples/browser/src/TerrainSample.cpp

@@ -2,7 +2,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-    ADD_SAMPLE("Graphics", "Terrain", TerrainSample, 11);
+    ADD_SAMPLE("Graphics", "Terrain", TerrainSample, 12);
 #endif
 #endif
 
 
 struct TerrainHitFilter : public PhysicsController::HitFilter
 struct TerrainHitFilter : public PhysicsController::HitFilter

+ 7 - 18
samples/browser/src/TextureSample.cpp

@@ -75,7 +75,8 @@ void TextureSample::initialize()
         node->setTranslation(-25, cubeSize, 0);
         node->setTranslation(-25, cubeSize, 0);
         // Find the position of the node in screen space
         // Find the position of the node in screen space
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("Quad: Textured", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
+        
+        //_text.push_back(Text::create("res/ui/arial.gpb", "Quad: Textured", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
     }
     }
     // Textured quad points
     // Textured quad points
     {
     {
@@ -85,7 +86,7 @@ void TextureSample::initialize()
         setTextureUnlitMaterial(node->getModel(), "res/png/color-wheel.png");
         setTextureUnlitMaterial(node->getModel(), "res/png/color-wheel.png");
         node->setTranslation(-14, cubeSize, 0);
         node->setTranslation(-14, cubeSize, 0);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("Quad: Points", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
+        //_text.push_back(_font->createText("Quad: Points", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
     }
     }
     // Texture clamp
     // Texture clamp
     {
     {
@@ -94,7 +95,7 @@ void TextureSample::initialize()
         node->setId("clamp");
         node->setId("clamp");
         node->setTranslation(-3, cubeSize, 0);
         node->setTranslation(-3, cubeSize, 0);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("Wrap: Clamp", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
+        //_text.push_back(_font->createText("Wrap: Clamp", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_TOP_HCENTER, false));
     }
     }
     // Texture wrapped+repeat
     // Texture wrapped+repeat
     {
     {
@@ -108,7 +109,7 @@ void TextureSample::initialize()
         }
         }
         node->setTranslation(8, cubeSize, 0);
         node->setTranslation(8, cubeSize, 0);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("Wrap: Repeat", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
+        //_text.push_back(_font->createText("Wrap: Repeat", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
     }
     }
     // Mipmapping Off
     // Mipmapping Off
     {
     {
@@ -117,7 +118,7 @@ void TextureSample::initialize()
         node->setId("mipmap off");
         node->setId("mipmap off");
         node->setTranslation(-25.5f, -2.5f, 0);
         node->setTranslation(-25.5f, -2.5f, 0);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("MipMap: Off", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
+        //_text.push_back(_font->createText("MipMap: Off", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
     }
     }
     // Mipmapping On
     // Mipmapping On
     {
     {
@@ -126,7 +127,7 @@ void TextureSample::initialize()
         node->setId("mipmap on");
         node->setId("mipmap on");
         node->setTranslation(-5.5f, -2.5f, 0);
         node->setTranslation(-5.5f, -2.5f, 0);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
         _scene->getActiveCamera()->project(getViewport(), node->getTranslationWorld(), &x, &y);
-        _text.push_back(_font->createText("MipMap: On", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
+        //_text.push_back(_font->createText("MipMap: On", Rectangle(x, y, textWidth, fontSize), Vector4::one(), fontSize, Font::ALIGN_HCENTER, false));
     }
     }
 }
 }
 
 
@@ -135,11 +136,6 @@ void TextureSample::finalize()
     // Model and font are reference counted and should be released before closing this sample.
     // Model and font are reference counted and should be released before closing this sample.
     SAFE_RELEASE(_scene);
     SAFE_RELEASE(_scene);
     SAFE_RELEASE(_font);
     SAFE_RELEASE(_font);
-    for (std::list<Font::Text*>::iterator it = _text.begin(); it != _text.end(); ++it)
-    {
-        SAFE_DELETE(*it);
-    }
-    _text.clear();
 }
 }
 
 
 void TextureSample::update(float elapsedTime)
 void TextureSample::update(float elapsedTime)
@@ -161,13 +157,6 @@ void TextureSample::render(float elapsedTime)
     _scene->visit(this, &TextureSample::drawScene);
     _scene->visit(this, &TextureSample::drawScene);
 
 
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
     drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
-
-    _font->start();
-    for (std::list<Font::Text*>::const_iterator it = _text.begin(); it != _text.end(); ++it)
-    {
-        _font->drawText(*it);
-    }
-    _font->finish();
 }
 }
 
 
 void TextureSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 void TextureSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)

+ 0 - 1
samples/browser/src/TextureSample.h

@@ -34,7 +34,6 @@ private:
     Font* _font;
     Font* _font;
     Scene* _scene;
     Scene* _scene;
     float _zOffset;
     float _zOffset;
-    std::list<Font::Text*> _text;
 };
 };
 
 
 #endif
 #endif

+ 1 - 1
samples/browser/src/WaterSample.cpp

@@ -2,7 +2,7 @@
 #include "SamplesGame.h"
 #include "SamplesGame.h"
 
 
 #if defined(ADD_SAMPLE)
 #if defined(ADD_SAMPLE)
-ADD_SAMPLE("Graphics", "Water", WaterSample, 12);
+ADD_SAMPLE("Graphics", "Water", WaterSample, 13);
 #endif
 #endif
 
 
 // Camera movement consts
 // Camera movement consts