Sean Paul Taylor преди 14 години
родител
ревизия
c4b4aac6fd
променени са 50 файла, в които са добавени 1219 реда и са изтрити 315 реда
  1. 546 0
      gameplay-encoder/gameplay-encoder.xcodeproj/project.pbxproj
  2. 32 18
      gameplay-encoder/src/Base.h
  3. 1 1
      gameplay-encoder/src/DAEOptimizer.cpp
  4. 2 2
      gameplay-encoder/src/DAESceneEncoder.cpp
  5. 1 1
      gameplay-encoder/src/DAEUtil.cpp
  6. 2 8
      gameplay-encoder/src/EncoderArguments.h
  7. 3 3
      gameplay-encoder/src/FileIO.cpp
  8. 4 8
      gameplay-encoder/src/FileIO.h
  9. 2 3
      gameplay-encoder/src/Mesh.cpp
  10. 1 0
      gameplay-encoder/src/Mesh.h
  11. 1 1
      gameplay-encoder/src/MeshSkin.cpp
  12. 2 1
      gameplay-encoder/src/MeshSubSet.cpp
  13. 10 7
      gameplay-encoder/src/MeshSubSet.h
  14. 2 7
      gameplay-encoder/src/Object.h
  15. 13 0
      gameplay.sln
  16. 3 0
      gameplay.xcworkspace/contents.xcworkspacedata
  17. 41 0
      gameplay/gameplay.vcxproj
  18. 7 1
      gameplay/gameplay.vcxproj.filters
  19. 0 2
      gameplay/src/Animation.cpp
  20. 8 24
      gameplay/src/AnimationClip.cpp
  21. 3 1
      gameplay/src/AnimationController.cpp
  22. 1 2
      gameplay/src/AudioSource.cpp
  23. 8 2
      gameplay/src/Base.h
  24. 1 6
      gameplay/src/Camera.cpp
  25. 1 0
      gameplay/src/Curve.cpp
  26. 162 0
      gameplay/src/DebugNew.cpp
  27. 42 0
      gameplay/src/DebugNew.h
  28. 32 13
      gameplay/src/Game.cpp
  29. 4 8
      gameplay/src/Game.h
  30. 2 13
      gameplay/src/Light.cpp
  31. 2 0
      gameplay/src/MaterialParameter.h
  32. 12 10
      gameplay/src/Matrix.cpp
  33. 0 11
      gameplay/src/MeshSkin.cpp
  34. 1 11
      gameplay/src/Model.cpp
  35. 23 35
      gameplay/src/Node.cpp
  36. 0 21
      gameplay/src/Node.h
  37. 6 0
      gameplay/src/Package.cpp
  38. 10 23
      gameplay/src/ParticleEmitter.cpp
  39. 5 5
      gameplay/src/Platform.h
  40. 1 1
      gameplay/src/PlatformQNX.cpp
  41. 4 4
      gameplay/src/Quaternion.cpp
  42. 86 0
      gameplay/src/Ref.cpp
  43. 14 0
      gameplay/src/Ref.h
  44. 43 30
      gameplay/src/RenderState.cpp
  45. 12 3
      gameplay/src/RenderState.h
  46. 37 7
      gameplay/src/Scene.cpp
  47. 8 8
      gameplay/src/Vector2.cpp
  48. 12 12
      gameplay/src/Vector4.cpp
  49. 3 1
      gameplay/src/gameplay-main-qnx.cpp
  50. 3 1
      gameplay/src/gameplay-main-win32.cpp

+ 546 - 0
gameplay-encoder/gameplay-encoder.xcodeproj/project.pbxproj

@@ -0,0 +1,546 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		42475D7C14720ECE00610A6A /* libdom.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42475D7B14720ECE00610A6A /* libdom.a */; };
+		42C8EE0A14724CD700E43619 /* Animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDB714724CD700E43619 /* Animation.cpp */; };
+		42C8EE0B14724CD700E43619 /* AnimationChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDB914724CD700E43619 /* AnimationChannel.cpp */; };
+		42C8EE0C14724CD700E43619 /* Animations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDBB14724CD700E43619 /* Animations.cpp */; };
+		42C8EE0D14724CD700E43619 /* Base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDBD14724CD700E43619 /* Base.cpp */; };
+		42C8EE0E14724CD700E43619 /* Camera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDBF14724CD700E43619 /* Camera.cpp */; };
+		42C8EE0F14724CD700E43619 /* CameraInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDC114724CD700E43619 /* CameraInstance.cpp */; };
+		42C8EE1014724CD700E43619 /* DAEChannelTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDC314724CD700E43619 /* DAEChannelTarget.cpp */; };
+		42C8EE1114724CD700E43619 /* DAEOptimizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDC514724CD700E43619 /* DAEOptimizer.cpp */; };
+		42C8EE1214724CD700E43619 /* DAESceneEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDC714724CD700E43619 /* DAESceneEncoder.cpp */; };
+		42C8EE1314724CD700E43619 /* DAEUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDC914724CD700E43619 /* DAEUtil.cpp */; };
+		42C8EE1414724CD700E43619 /* Effect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDCB14724CD700E43619 /* Effect.cpp */; };
+		42C8EE1514724CD700E43619 /* EncoderArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDCD14724CD700E43619 /* EncoderArguments.cpp */; };
+		42C8EE1614724CD700E43619 /* FileIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDCF14724CD700E43619 /* FileIO.cpp */; };
+		42C8EE1714724CD700E43619 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDD114724CD700E43619 /* Font.cpp */; };
+		42C8EE1814724CD700E43619 /* Glyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDD314724CD700E43619 /* Glyph.cpp */; };
+		42C8EE1914724CD700E43619 /* GPBDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDD514724CD700E43619 /* GPBDecoder.cpp */; };
+		42C8EE1A14724CD700E43619 /* GPBFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDD714724CD700E43619 /* GPBFile.cpp */; };
+		42C8EE1B14724CD700E43619 /* Light.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDD914724CD700E43619 /* Light.cpp */; };
+		42C8EE1C14724CD700E43619 /* LightInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDDB14724CD700E43619 /* LightInstance.cpp */; };
+		42C8EE1D14724CD700E43619 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDDD14724CD700E43619 /* main.cpp */; };
+		42C8EE1E14724CD700E43619 /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDDE14724CD700E43619 /* Material.cpp */; };
+		42C8EE1F14724CD700E43619 /* MaterialParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDE014724CD700E43619 /* MaterialParameter.cpp */; };
+		42C8EE2014724CD700E43619 /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDE214724CD700E43619 /* Matrix.cpp */; };
+		42C8EE2114724CD700E43619 /* Mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDE414724CD700E43619 /* Mesh.cpp */; };
+		42C8EE2214724CD700E43619 /* MeshPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDE614724CD700E43619 /* MeshPart.cpp */; };
+		42C8EE2314724CD700E43619 /* MeshSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDE814724CD700E43619 /* MeshSkin.cpp */; };
+		42C8EE2414724CD700E43619 /* MeshSubSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDEA14724CD700E43619 /* MeshSubSet.cpp */; };
+		42C8EE2514724CD700E43619 /* Model.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDEC14724CD700E43619 /* Model.cpp */; };
+		42C8EE2614724CD700E43619 /* Node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDEE14724CD700E43619 /* Node.cpp */; };
+		42C8EE2714724CD700E43619 /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDF014724CD700E43619 /* Object.cpp */; };
+		42C8EE2814724CD700E43619 /* Quaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDF214724CD700E43619 /* Quaternion.cpp */; };
+		42C8EE2914724CD700E43619 /* Reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDF414724CD700E43619 /* Reference.cpp */; };
+		42C8EE2A14724CD700E43619 /* ReferenceTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDF614724CD700E43619 /* ReferenceTable.cpp */; };
+		42C8EE2B14724CD700E43619 /* Scene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDF814724CD700E43619 /* Scene.cpp */; };
+		42C8EE2C14724CD700E43619 /* StringUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDFA14724CD700E43619 /* StringUtil.cpp */; };
+		42C8EE2D14724CD700E43619 /* Transform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDFC14724CD700E43619 /* Transform.cpp */; };
+		42C8EE2E14724CD700E43619 /* TTFFontEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EDFE14724CD700E43619 /* TTFFontEncoder.cpp */; };
+		42C8EE2F14724CD700E43619 /* Vector2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EE0014724CD700E43619 /* Vector2.cpp */; };
+		42C8EE3014724CD700E43619 /* Vector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EE0214724CD700E43619 /* Vector3.cpp */; };
+		42C8EE3114724CD700E43619 /* Vector4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EE0414724CD700E43619 /* Vector4.cpp */; };
+		42C8EE3214724CD700E43619 /* Vertex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EE0614724CD700E43619 /* Vertex.cpp */; };
+		42C8EE3314724CD700E43619 /* VertexElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42C8EE0814724CD700E43619 /* VertexElement.cpp */; };
+		42C8EE351472B60100E43619 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42C8EE341472B60100E43619 /* libfreetype.a */; };
+		42C8EE371472D7E700E43619 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 42C8EE361472D7E700E43619 /* libxml2.dylib */; };
+		42C8EE391472DAA300E43619 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 42C8EE381472DAA300E43619 /* libz.dylib */; };
+		42C8EE3B1472DAAE00E43619 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 42C8EE3A1472DAAE00E43619 /* libbz2.dylib */; };
+		42D277591472EFA700D867A4 /* libpcre.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D277571472EFA700D867A4 /* libpcre.a */; };
+		42D2775A1472EFA700D867A4 /* libpcrecpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D277581472EFA700D867A4 /* libpcrecpp.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		42475CE4147208A000610A6A /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		42475CE6147208A000610A6A /* gameplay-encoder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "gameplay-encoder"; sourceTree = BUILT_PRODUCTS_DIR; };
+		42475D7B14720ECE00610A6A /* libdom.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdom.a; path = "../external-deps/collada-dom/lib/macosx/libdom.a"; sourceTree = "<group>"; };
+		42C8EDB714724CD700E43619 /* Animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Animation.cpp; path = src/Animation.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDB814724CD700E43619 /* Animation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Animation.h; path = src/Animation.h; sourceTree = SOURCE_ROOT; };
+		42C8EDB914724CD700E43619 /* AnimationChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AnimationChannel.cpp; path = src/AnimationChannel.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDBA14724CD700E43619 /* AnimationChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationChannel.h; path = src/AnimationChannel.h; sourceTree = SOURCE_ROOT; };
+		42C8EDBB14724CD700E43619 /* Animations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Animations.cpp; path = src/Animations.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDBC14724CD700E43619 /* Animations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Animations.h; path = src/Animations.h; sourceTree = SOURCE_ROOT; };
+		42C8EDBD14724CD700E43619 /* Base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Base.cpp; path = src/Base.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDBE14724CD700E43619 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Base.h; path = src/Base.h; sourceTree = SOURCE_ROOT; };
+		42C8EDBF14724CD700E43619 /* Camera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Camera.cpp; path = src/Camera.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDC014724CD700E43619 /* Camera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Camera.h; path = src/Camera.h; sourceTree = SOURCE_ROOT; };
+		42C8EDC114724CD700E43619 /* CameraInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CameraInstance.cpp; path = src/CameraInstance.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDC214724CD700E43619 /* CameraInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CameraInstance.h; path = src/CameraInstance.h; sourceTree = SOURCE_ROOT; };
+		42C8EDC314724CD700E43619 /* DAEChannelTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DAEChannelTarget.cpp; path = src/DAEChannelTarget.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDC414724CD700E43619 /* DAEChannelTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DAEChannelTarget.h; path = src/DAEChannelTarget.h; sourceTree = SOURCE_ROOT; };
+		42C8EDC514724CD700E43619 /* DAEOptimizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DAEOptimizer.cpp; path = src/DAEOptimizer.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDC614724CD700E43619 /* DAEOptimizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DAEOptimizer.h; path = src/DAEOptimizer.h; sourceTree = SOURCE_ROOT; };
+		42C8EDC714724CD700E43619 /* DAESceneEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DAESceneEncoder.cpp; path = src/DAESceneEncoder.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDC814724CD700E43619 /* DAESceneEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DAESceneEncoder.h; path = src/DAESceneEncoder.h; sourceTree = SOURCE_ROOT; };
+		42C8EDC914724CD700E43619 /* DAEUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DAEUtil.cpp; path = src/DAEUtil.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDCA14724CD700E43619 /* DAEUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DAEUtil.h; path = src/DAEUtil.h; sourceTree = SOURCE_ROOT; };
+		42C8EDCB14724CD700E43619 /* Effect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Effect.cpp; path = src/Effect.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDCC14724CD700E43619 /* Effect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Effect.h; path = src/Effect.h; sourceTree = SOURCE_ROOT; };
+		42C8EDCD14724CD700E43619 /* EncoderArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EncoderArguments.cpp; path = src/EncoderArguments.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDCE14724CD700E43619 /* EncoderArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EncoderArguments.h; path = src/EncoderArguments.h; sourceTree = SOURCE_ROOT; };
+		42C8EDCF14724CD700E43619 /* FileIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileIO.cpp; path = src/FileIO.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDD014724CD700E43619 /* FileIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileIO.h; path = src/FileIO.h; sourceTree = SOURCE_ROOT; };
+		42C8EDD114724CD700E43619 /* Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Font.cpp; path = src/Font.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDD214724CD700E43619 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Font.h; path = src/Font.h; sourceTree = SOURCE_ROOT; };
+		42C8EDD314724CD700E43619 /* Glyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Glyph.cpp; path = src/Glyph.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDD414724CD700E43619 /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Glyph.h; path = src/Glyph.h; sourceTree = SOURCE_ROOT; };
+		42C8EDD514724CD700E43619 /* GPBDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GPBDecoder.cpp; path = src/GPBDecoder.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDD614724CD700E43619 /* GPBDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBDecoder.h; path = src/GPBDecoder.h; sourceTree = SOURCE_ROOT; };
+		42C8EDD714724CD700E43619 /* GPBFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GPBFile.cpp; path = src/GPBFile.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDD814724CD700E43619 /* GPBFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBFile.h; path = src/GPBFile.h; sourceTree = SOURCE_ROOT; };
+		42C8EDD914724CD700E43619 /* Light.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Light.cpp; path = src/Light.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDDA14724CD700E43619 /* Light.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Light.h; path = src/Light.h; sourceTree = SOURCE_ROOT; };
+		42C8EDDB14724CD700E43619 /* LightInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LightInstance.cpp; path = src/LightInstance.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDDC14724CD700E43619 /* LightInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LightInstance.h; path = src/LightInstance.h; sourceTree = SOURCE_ROOT; };
+		42C8EDDD14724CD700E43619 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDDE14724CD700E43619 /* Material.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Material.cpp; path = src/Material.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDDF14724CD700E43619 /* Material.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Material.h; path = src/Material.h; sourceTree = SOURCE_ROOT; };
+		42C8EDE014724CD700E43619 /* MaterialParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MaterialParameter.cpp; path = src/MaterialParameter.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDE114724CD700E43619 /* MaterialParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MaterialParameter.h; path = src/MaterialParameter.h; sourceTree = SOURCE_ROOT; };
+		42C8EDE214724CD700E43619 /* Matrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Matrix.cpp; path = src/Matrix.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDE314724CD700E43619 /* Matrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Matrix.h; path = src/Matrix.h; sourceTree = SOURCE_ROOT; };
+		42C8EDE414724CD700E43619 /* Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mesh.cpp; path = src/Mesh.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDE514724CD700E43619 /* Mesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mesh.h; path = src/Mesh.h; sourceTree = SOURCE_ROOT; };
+		42C8EDE614724CD700E43619 /* MeshPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MeshPart.cpp; path = src/MeshPart.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDE714724CD700E43619 /* MeshPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MeshPart.h; path = src/MeshPart.h; sourceTree = SOURCE_ROOT; };
+		42C8EDE814724CD700E43619 /* MeshSkin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MeshSkin.cpp; path = src/MeshSkin.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDE914724CD700E43619 /* MeshSkin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MeshSkin.h; path = src/MeshSkin.h; sourceTree = SOURCE_ROOT; };
+		42C8EDEA14724CD700E43619 /* MeshSubSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MeshSubSet.cpp; path = src/MeshSubSet.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDEB14724CD700E43619 /* MeshSubSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MeshSubSet.h; path = src/MeshSubSet.h; sourceTree = SOURCE_ROOT; };
+		42C8EDEC14724CD700E43619 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Model.cpp; path = src/Model.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDED14724CD700E43619 /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Model.h; path = src/Model.h; sourceTree = SOURCE_ROOT; };
+		42C8EDEE14724CD700E43619 /* Node.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Node.cpp; path = src/Node.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDEF14724CD700E43619 /* Node.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Node.h; path = src/Node.h; sourceTree = SOURCE_ROOT; };
+		42C8EDF014724CD700E43619 /* Object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Object.cpp; path = src/Object.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDF114724CD700E43619 /* Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Object.h; path = src/Object.h; sourceTree = SOURCE_ROOT; };
+		42C8EDF214724CD700E43619 /* Quaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Quaternion.cpp; path = src/Quaternion.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDF314724CD700E43619 /* Quaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Quaternion.h; path = src/Quaternion.h; sourceTree = SOURCE_ROOT; };
+		42C8EDF414724CD700E43619 /* Reference.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Reference.cpp; path = src/Reference.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDF514724CD700E43619 /* Reference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reference.h; path = src/Reference.h; sourceTree = SOURCE_ROOT; };
+		42C8EDF614724CD700E43619 /* ReferenceTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ReferenceTable.cpp; path = src/ReferenceTable.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDF714724CD700E43619 /* ReferenceTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ReferenceTable.h; path = src/ReferenceTable.h; sourceTree = SOURCE_ROOT; };
+		42C8EDF814724CD700E43619 /* Scene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Scene.cpp; path = src/Scene.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDF914724CD700E43619 /* Scene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Scene.h; path = src/Scene.h; sourceTree = SOURCE_ROOT; };
+		42C8EDFA14724CD700E43619 /* StringUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringUtil.cpp; path = src/StringUtil.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDFB14724CD700E43619 /* StringUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringUtil.h; path = src/StringUtil.h; sourceTree = SOURCE_ROOT; };
+		42C8EDFC14724CD700E43619 /* Transform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Transform.cpp; path = src/Transform.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDFD14724CD700E43619 /* Transform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Transform.h; path = src/Transform.h; sourceTree = SOURCE_ROOT; };
+		42C8EDFE14724CD700E43619 /* TTFFontEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TTFFontEncoder.cpp; path = src/TTFFontEncoder.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EDFF14724CD700E43619 /* TTFFontEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTFFontEncoder.h; path = src/TTFFontEncoder.h; sourceTree = SOURCE_ROOT; };
+		42C8EE0014724CD700E43619 /* Vector2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vector2.cpp; path = src/Vector2.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EE0114724CD700E43619 /* Vector2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Vector2.h; path = src/Vector2.h; sourceTree = SOURCE_ROOT; };
+		42C8EE0214724CD700E43619 /* Vector3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vector3.cpp; path = src/Vector3.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EE0314724CD700E43619 /* Vector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Vector3.h; path = src/Vector3.h; sourceTree = SOURCE_ROOT; };
+		42C8EE0414724CD700E43619 /* Vector4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vector4.cpp; path = src/Vector4.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EE0514724CD700E43619 /* Vector4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Vector4.h; path = src/Vector4.h; sourceTree = SOURCE_ROOT; };
+		42C8EE0614724CD700E43619 /* Vertex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vertex.cpp; path = src/Vertex.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EE0714724CD700E43619 /* Vertex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Vertex.h; path = src/Vertex.h; sourceTree = SOURCE_ROOT; };
+		42C8EE0814724CD700E43619 /* VertexElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VertexElement.cpp; path = src/VertexElement.cpp; sourceTree = SOURCE_ROOT; };
+		42C8EE0914724CD700E43619 /* VertexElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VertexElement.h; path = src/VertexElement.h; sourceTree = SOURCE_ROOT; };
+		42C8EE341472B60100E43619 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = "../external-deps/freetype2/lib/macosx/libfreetype.a"; sourceTree = "<group>"; };
+		42C8EE361472D7E700E43619 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
+		42C8EE381472DAA300E43619 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
+		42C8EE3A1472DAAE00E43619 /* libbz2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbz2.dylib; path = usr/lib/libbz2.dylib; sourceTree = SDKROOT; };
+		42D277571472EFA700D867A4 /* libpcre.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpcre.a; path = "../external-deps/pcre/lib/macosx/libpcre.a"; sourceTree = "<group>"; };
+		42D277581472EFA700D867A4 /* libpcrecpp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpcrecpp.a; path = "../external-deps/pcre/lib/macosx/libpcrecpp.a"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		42475CE3147208A000610A6A /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				42D277591472EFA700D867A4 /* libpcre.a in Frameworks */,
+				42D2775A1472EFA700D867A4 /* libpcrecpp.a in Frameworks */,
+				42C8EE351472B60100E43619 /* libfreetype.a in Frameworks */,
+				42475D7C14720ECE00610A6A /* libdom.a in Frameworks */,
+				42C8EE3B1472DAAE00E43619 /* libbz2.dylib in Frameworks */,
+				42C8EE391472DAA300E43619 /* libz.dylib in Frameworks */,
+				42C8EE371472D7E700E43619 /* libxml2.dylib in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		42475CDB147208A000610A6A = {
+			isa = PBXGroup;
+			children = (
+				42D277571472EFA700D867A4 /* libpcre.a */,
+				42D277581472EFA700D867A4 /* libpcrecpp.a */,
+				42C8EE3A1472DAAE00E43619 /* libbz2.dylib */,
+				42C8EE381472DAA300E43619 /* libz.dylib */,
+				42C8EE361472D7E700E43619 /* libxml2.dylib */,
+				42C8EE341472B60100E43619 /* libfreetype.a */,
+				42475D7B14720ECE00610A6A /* libdom.a */,
+				42475CE9147208A000610A6A /* gameplay-encoder */,
+				42475CE7147208A000610A6A /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		42475CE7147208A000610A6A /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				42475CE6147208A000610A6A /* gameplay-encoder */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		42475CE9147208A000610A6A /* gameplay-encoder */ = {
+			isa = PBXGroup;
+			children = (
+				42C8EDB714724CD700E43619 /* Animation.cpp */,
+				42C8EDB814724CD700E43619 /* Animation.h */,
+				42C8EDB914724CD700E43619 /* AnimationChannel.cpp */,
+				42C8EDBA14724CD700E43619 /* AnimationChannel.h */,
+				42C8EDBB14724CD700E43619 /* Animations.cpp */,
+				42C8EDBC14724CD700E43619 /* Animations.h */,
+				42C8EDBD14724CD700E43619 /* Base.cpp */,
+				42C8EDBE14724CD700E43619 /* Base.h */,
+				42C8EDBF14724CD700E43619 /* Camera.cpp */,
+				42C8EDC014724CD700E43619 /* Camera.h */,
+				42C8EDC114724CD700E43619 /* CameraInstance.cpp */,
+				42C8EDC214724CD700E43619 /* CameraInstance.h */,
+				42C8EDC314724CD700E43619 /* DAEChannelTarget.cpp */,
+				42C8EDC414724CD700E43619 /* DAEChannelTarget.h */,
+				42C8EDC514724CD700E43619 /* DAEOptimizer.cpp */,
+				42C8EDC614724CD700E43619 /* DAEOptimizer.h */,
+				42C8EDC714724CD700E43619 /* DAESceneEncoder.cpp */,
+				42C8EDC814724CD700E43619 /* DAESceneEncoder.h */,
+				42C8EDC914724CD700E43619 /* DAEUtil.cpp */,
+				42C8EDCA14724CD700E43619 /* DAEUtil.h */,
+				42C8EDCB14724CD700E43619 /* Effect.cpp */,
+				42C8EDCC14724CD700E43619 /* Effect.h */,
+				42C8EDCD14724CD700E43619 /* EncoderArguments.cpp */,
+				42C8EDCE14724CD700E43619 /* EncoderArguments.h */,
+				42C8EDCF14724CD700E43619 /* FileIO.cpp */,
+				42C8EDD014724CD700E43619 /* FileIO.h */,
+				42C8EDD114724CD700E43619 /* Font.cpp */,
+				42C8EDD214724CD700E43619 /* Font.h */,
+				42C8EDD314724CD700E43619 /* Glyph.cpp */,
+				42C8EDD414724CD700E43619 /* Glyph.h */,
+				42C8EDD514724CD700E43619 /* GPBDecoder.cpp */,
+				42C8EDD614724CD700E43619 /* GPBDecoder.h */,
+				42C8EDD714724CD700E43619 /* GPBFile.cpp */,
+				42C8EDD814724CD700E43619 /* GPBFile.h */,
+				42C8EDD914724CD700E43619 /* Light.cpp */,
+				42C8EDDA14724CD700E43619 /* Light.h */,
+				42C8EDDB14724CD700E43619 /* LightInstance.cpp */,
+				42C8EDDC14724CD700E43619 /* LightInstance.h */,
+				42C8EDDD14724CD700E43619 /* main.cpp */,
+				42C8EDDE14724CD700E43619 /* Material.cpp */,
+				42C8EDDF14724CD700E43619 /* Material.h */,
+				42C8EDE014724CD700E43619 /* MaterialParameter.cpp */,
+				42C8EDE114724CD700E43619 /* MaterialParameter.h */,
+				42C8EDE214724CD700E43619 /* Matrix.cpp */,
+				42C8EDE314724CD700E43619 /* Matrix.h */,
+				42C8EDE414724CD700E43619 /* Mesh.cpp */,
+				42C8EDE514724CD700E43619 /* Mesh.h */,
+				42C8EDE614724CD700E43619 /* MeshPart.cpp */,
+				42C8EDE714724CD700E43619 /* MeshPart.h */,
+				42C8EDE814724CD700E43619 /* MeshSkin.cpp */,
+				42C8EDE914724CD700E43619 /* MeshSkin.h */,
+				42C8EDEA14724CD700E43619 /* MeshSubSet.cpp */,
+				42C8EDEB14724CD700E43619 /* MeshSubSet.h */,
+				42C8EDEC14724CD700E43619 /* Model.cpp */,
+				42C8EDED14724CD700E43619 /* Model.h */,
+				42C8EDEE14724CD700E43619 /* Node.cpp */,
+				42C8EDEF14724CD700E43619 /* Node.h */,
+				42C8EDF014724CD700E43619 /* Object.cpp */,
+				42C8EDF114724CD700E43619 /* Object.h */,
+				42C8EDF214724CD700E43619 /* Quaternion.cpp */,
+				42C8EDF314724CD700E43619 /* Quaternion.h */,
+				42C8EDF414724CD700E43619 /* Reference.cpp */,
+				42C8EDF514724CD700E43619 /* Reference.h */,
+				42C8EDF614724CD700E43619 /* ReferenceTable.cpp */,
+				42C8EDF714724CD700E43619 /* ReferenceTable.h */,
+				42C8EDF814724CD700E43619 /* Scene.cpp */,
+				42C8EDF914724CD700E43619 /* Scene.h */,
+				42C8EDFA14724CD700E43619 /* StringUtil.cpp */,
+				42C8EDFB14724CD700E43619 /* StringUtil.h */,
+				42C8EDFC14724CD700E43619 /* Transform.cpp */,
+				42C8EDFD14724CD700E43619 /* Transform.h */,
+				42C8EDFE14724CD700E43619 /* TTFFontEncoder.cpp */,
+				42C8EDFF14724CD700E43619 /* TTFFontEncoder.h */,
+				42C8EE0014724CD700E43619 /* Vector2.cpp */,
+				42C8EE0114724CD700E43619 /* Vector2.h */,
+				42C8EE0214724CD700E43619 /* Vector3.cpp */,
+				42C8EE0314724CD700E43619 /* Vector3.h */,
+				42C8EE0414724CD700E43619 /* Vector4.cpp */,
+				42C8EE0514724CD700E43619 /* Vector4.h */,
+				42C8EE0614724CD700E43619 /* Vertex.cpp */,
+				42C8EE0714724CD700E43619 /* Vertex.h */,
+				42C8EE0814724CD700E43619 /* VertexElement.cpp */,
+				42C8EE0914724CD700E43619 /* VertexElement.h */,
+			);
+			path = "gameplay-encoder";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		42475CE5147208A000610A6A /* gameplay-encoder */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 42475CF0147208A100610A6A /* Build configuration list for PBXNativeTarget "gameplay-encoder" */;
+			buildPhases = (
+				42475CE2147208A000610A6A /* Sources */,
+				42475CE3147208A000610A6A /* Frameworks */,
+				42475CE4147208A000610A6A /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = "gameplay-encoder";
+			productName = "gameplay-encoder";
+			productReference = 42475CE6147208A000610A6A /* gameplay-encoder */;
+			productType = "com.apple.product-type.tool";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		42475CDD147208A000610A6A /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0420;
+			};
+			buildConfigurationList = 42475CE0147208A000610A6A /* Build configuration list for PBXProject "gameplay-encoder" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = 42475CDB147208A000610A6A;
+			productRefGroup = 42475CE7147208A000610A6A /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				42475CE5147208A000610A6A /* gameplay-encoder */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+		42475CE2147208A000610A6A /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				42C8EE0A14724CD700E43619 /* Animation.cpp in Sources */,
+				42C8EE0B14724CD700E43619 /* AnimationChannel.cpp in Sources */,
+				42C8EE0C14724CD700E43619 /* Animations.cpp in Sources */,
+				42C8EE0D14724CD700E43619 /* Base.cpp in Sources */,
+				42C8EE0E14724CD700E43619 /* Camera.cpp in Sources */,
+				42C8EE0F14724CD700E43619 /* CameraInstance.cpp in Sources */,
+				42C8EE1014724CD700E43619 /* DAEChannelTarget.cpp in Sources */,
+				42C8EE1114724CD700E43619 /* DAEOptimizer.cpp in Sources */,
+				42C8EE1214724CD700E43619 /* DAESceneEncoder.cpp in Sources */,
+				42C8EE1314724CD700E43619 /* DAEUtil.cpp in Sources */,
+				42C8EE1414724CD700E43619 /* Effect.cpp in Sources */,
+				42C8EE1514724CD700E43619 /* EncoderArguments.cpp in Sources */,
+				42C8EE1614724CD700E43619 /* FileIO.cpp in Sources */,
+				42C8EE1714724CD700E43619 /* Font.cpp in Sources */,
+				42C8EE1814724CD700E43619 /* Glyph.cpp in Sources */,
+				42C8EE1914724CD700E43619 /* GPBDecoder.cpp in Sources */,
+				42C8EE1A14724CD700E43619 /* GPBFile.cpp in Sources */,
+				42C8EE1B14724CD700E43619 /* Light.cpp in Sources */,
+				42C8EE1C14724CD700E43619 /* LightInstance.cpp in Sources */,
+				42C8EE1D14724CD700E43619 /* main.cpp in Sources */,
+				42C8EE1E14724CD700E43619 /* Material.cpp in Sources */,
+				42C8EE1F14724CD700E43619 /* MaterialParameter.cpp in Sources */,
+				42C8EE2014724CD700E43619 /* Matrix.cpp in Sources */,
+				42C8EE2114724CD700E43619 /* Mesh.cpp in Sources */,
+				42C8EE2214724CD700E43619 /* MeshPart.cpp in Sources */,
+				42C8EE2314724CD700E43619 /* MeshSkin.cpp in Sources */,
+				42C8EE2414724CD700E43619 /* MeshSubSet.cpp in Sources */,
+				42C8EE2514724CD700E43619 /* Model.cpp in Sources */,
+				42C8EE2614724CD700E43619 /* Node.cpp in Sources */,
+				42C8EE2714724CD700E43619 /* Object.cpp in Sources */,
+				42C8EE2814724CD700E43619 /* Quaternion.cpp in Sources */,
+				42C8EE2914724CD700E43619 /* Reference.cpp in Sources */,
+				42C8EE2A14724CD700E43619 /* ReferenceTable.cpp in Sources */,
+				42C8EE2B14724CD700E43619 /* Scene.cpp in Sources */,
+				42C8EE2C14724CD700E43619 /* StringUtil.cpp in Sources */,
+				42C8EE2D14724CD700E43619 /* Transform.cpp in Sources */,
+				42C8EE2E14724CD700E43619 /* TTFFontEncoder.cpp in Sources */,
+				42C8EE2F14724CD700E43619 /* Vector2.cpp in Sources */,
+				42C8EE3014724CD700E43619 /* Vector3.cpp in Sources */,
+				42C8EE3114724CD700E43619 /* Vector4.cpp in Sources */,
+				42C8EE3214724CD700E43619 /* Vertex.cpp in Sources */,
+				42C8EE3314724CD700E43619 /* VertexElement.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		42475CEE147208A100610A6A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					DOM_INCLUDE_LIBXML,
+					NO_BOOST,
+					NO_ZAE,
+					"DEBUG=1",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				HEADER_SEARCH_PATHS = (
+					"../external-deps/freetype/include",
+					"../external-deps/collada-dom/include",
+					"../external-deps/collada-dom/include/1.4",
+				);
+				INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				ONLY_ACTIVE_ARCH = YES;
+				OTHER_TEST_FLAGS = "";
+				PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
+				SDKROOT = macosx;
+				WARNING_CFLAGS = "";
+			};
+			name = Debug;
+		};
+		42475CEF147208A100610A6A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					DOM_INCLUDE_LIBXML,
+					NO_BOOST,
+					NO_ZAE,
+				);
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				HEADER_SEARCH_PATHS = (
+					"../external-deps/freetype/include",
+					"../external-deps/collada-dom/include",
+					"../external-deps/collada-dom/include/1.4",
+				);
+				INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				OTHER_TEST_FLAGS = "";
+				PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
+				SDKROOT = macosx;
+				WARNING_CFLAGS = "";
+			};
+			name = Release;
+		};
+		42475CF1147208A100610A6A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
+				CLANG_CXX_LIBRARY = "compiler-default";
+				GCC_C_LANGUAGE_STANDARD = "compiler-default";
+				GCC_ENABLE_CPP_EXCEPTIONS = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
+				HEADER_SEARCH_PATHS = (
+					"../external-deps/freetype2/include",
+					"../external-deps/collada-dom/include",
+					"../external-deps/collada-dom/include/1.4",
+				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../external-deps/freetype2/lib/macosx\"",
+					"\"$(SRCROOT)/../external-deps/collada-dom/lib/macosx\"",
+					"\"$(SRCROOT)/../../../collada-dom/dom/external-libs/minizip/mac\"",
+					"\"$(SRCROOT)/../../../collada-dom/dom/external-libs/pcre/lib/mac\"",
+					"\"$(SRCROOT)/../external-deps/pcre/lib/macosx\"",
+				);
+				MACH_O_TYPE = mh_execute;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		42475CF2147208A100610A6A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
+				CLANG_CXX_LIBRARY = "compiler-default";
+				GCC_C_LANGUAGE_STANDARD = "compiler-default";
+				GCC_ENABLE_CPP_EXCEPTIONS = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
+				HEADER_SEARCH_PATHS = (
+					"../external-deps/freetype2/include",
+					"../external-deps/collada-dom/include",
+					"../external-deps/collada-dom/include/1.4",
+				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../external-deps/freetype2/lib/macosx\"",
+					"\"$(SRCROOT)/../external-deps/collada-dom/lib/macosx\"",
+					"\"$(SRCROOT)/../../../collada-dom/dom/external-libs/minizip/mac\"",
+					"\"$(SRCROOT)/../../../collada-dom/dom/external-libs/pcre/lib/mac\"",
+					"\"$(SRCROOT)/../external-deps/pcre/lib/macosx\"",
+				);
+				MACH_O_TYPE = mh_execute;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		42475CE0147208A000610A6A /* Build configuration list for PBXProject "gameplay-encoder" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				42475CEE147208A100610A6A /* Debug */,
+				42475CEF147208A100610A6A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		42475CF0147208A100610A6A /* Build configuration list for PBXNativeTarget "gameplay-encoder" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				42475CF1147208A100610A6A /* Debug */,
+				42475CF2147208A100610A6A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 42475CDD147208A000610A6A /* Project object */;
+}

+ 32 - 18
gameplay-encoder/src/Base.h

@@ -1,26 +1,40 @@
-#ifndef COMMON_H_
-#define COMMON_H_
+#ifndef BASE_H_
+#define BASE_H_
 
-#include <assert.h>
+#include <cmath>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <list>
 #include <map>
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string>
+#include <sys/stat.h>
+#include <vector>
+#include <assert.h>
+#include <math.h>
+#include <float.h>
+
 
 #ifndef M_1_PI        
-#define M_1_PI                    0.31830988618379067154
+#define M_1_PI                      0.31830988618379067154
 #endif
-#define MATH_FLOAT_SMALL        1.0e-37f
-#define MATH_TOLERANCE            2e-37f
-#define MATH_E                     2.71828182845904523536f
-#define MATH_LOG10E                0.4342944819032518f
-#define MATH_LOG2E                1.442695040888963387f
-#define MATH_PI                    3.14159265358979323846f
-#define MATH_PIOOVER2            1.57079632679489661923f
-#define MATH_PIOOVER4             M_PI_4
-#define MATH_PIX2                 6.28318530717958647693f
-#define MATH_EPSILON            0.000001f
-#define MATH_DEG_TO_RAD(x)         ((x) * 0.0174532925f)
-#define MATH_RAD_TO_DEG(x)        ((x)* 57.29577951f)
-#define MATH_RANDOM_MINUS1_1()  ((2.0f*((float)rand()/RAND_MAX))-1.0f) // Returns a random float between -1 and 1.
-#define MATH_RANDOM_0_1()       ((float)rand()/RAND_MAX) // Returns a random float between 0 and 1.
+#define MATH_FLOAT_SMALL            1.0e-37f
+#define MATH_TOLERANCE              2e-37f
+#define MATH_E                      2.71828182845904523536f
+#define MATH_LOG10E                 0.4342944819032518f
+#define MATH_LOG2E                  1.442695040888963387f
+#define MATH_PI                     3.14159265358979323846f
+#define MATH_PIOOVER2               1.57079632679489661923f
+#define MATH_PIOOVER4               M_PI_4
+#define MATH_PIX2                   6.28318530717958647693f
+#define MATH_EPSILON                0.000001f
+#define MATH_DEG_TO_RAD(x)          ((x) * 0.0174532925f)
+#define MATH_RAD_TO_DEG(x)          ((x)* 57.29577951f)
+#define MATH_RANDOM_MINUS1_1()      ((2.0f*((float)rand()/RAND_MAX))-1.0f) // Returns a random float between -1 and 1.
+#define MATH_RANDOM_0_1()           ((float)rand()/RAND_MAX) // Returns a random float between 0 and 1.
 
 namespace gameplay
 {

+ 1 - 1
gameplay-encoder/src/DAEOptimizer.cpp

@@ -81,7 +81,7 @@ void DAEOptimizer::getAnimationChannels(const domNodeRef& node, std::list<domCha
     }
 
     // Recursively do the same for all nodes
-    daeTArray<daeSmartRef<daeElement>> children;
+    daeTArray< daeSmartRef<daeElement> > children;
     node->getChildren(children);
     size_t childCount = children.getCount();
     for (size_t i = 0; i < childCount; i++)

+ 2 - 2
gameplay-encoder/src/DAESceneEncoder.cpp

@@ -831,7 +831,7 @@ void DAESceneEncoder::transformNode(domNode* domNode, Node* node)
 
 void DAESceneEncoder::calcTransform(domNode* domNode, Matrix& dstTransform)
 {
-    daeTArray<daeSmartRef<daeElement>> children;
+    daeTArray<daeSmartRef<daeElement> > children;
     domNode->getChildren(children);
     size_t childCount = children.getCount();
     for (size_t i = 0; i < childCount; i++)
@@ -1653,7 +1653,7 @@ Mesh* DAESceneEncoder::loadMesh(const domMesh* meshElement, const std::string& g
                     delete polygonInputs[j];
                 }
                 warning(std::string("Triangles do not all have the same number of input sources for geometry mesh: ") + geometryId);
-                return false;
+                return NULL;
             }
             else
             {

+ 1 - 1
gameplay-encoder/src/DAEUtil.cpp

@@ -148,7 +148,7 @@ const domName_arrayRef getSourceNameArray(const domSourceRef& source)
     {
         return nameArray;
     }
-    daeTArray<daeSmartRef<daeElement>> children;
+    daeTArray<daeSmartRef<daeElement> > children;
     source->getChildren(children);
     size_t childCount = children.getCount();
     for (size_t i = 0; i < childCount; i++)

+ 2 - 8
gameplay-encoder/src/EncoderArguments.h

@@ -1,12 +1,6 @@
 #ifndef ENCODERARGUMENTS_H_
 #define ENCODERARGUMENTS_H_
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <iostream>
-#include <string>
-#include <sys/stat.h>
-#include <vector>
 
 #include "Base.h"
 
@@ -48,12 +42,12 @@ public:
     /**
      * Returns the char pointer to the file path string.
      */
-    const char* EncoderArguments::getFilePathPointer() const;
+    const char* getFilePathPointer() const;
 
     /**
      * Returns the path to where the DAE output should be written to.
      */
-    const std::string& EncoderArguments::getDAEOutputPath() const;
+    const std::string& getDAEOutputPath() const;
 
     const std::vector<std::string>& getGroupAnimationNodeId() const;
     const std::vector<std::string>& getGroupAnimationAnimationId() const;

+ 3 - 3
gameplay-encoder/src/FileIO.cpp

@@ -1,10 +1,10 @@
 #include "FileIO.h"
-#include <assert.h>
 
 namespace gameplay
 {
 
-// Writing ot a binary file //
+
+// Writing out a binary file //
 
 void write(unsigned char value, FILE* file)
 {
@@ -102,7 +102,7 @@ void fprintfElement(FILE* file, const char* elementName, unsigned int value)
 }
 void fprintfElement(FILE* file, const char* elementName, unsigned char value)
 {
-    fprintf(file, "<%s>%u</%s>\n", elementName, value, (unsigned int)elementName);
+    fprintf(file, "<%s>%u</%s>\n", elementName, value, elementName);
 }
 
 void fprintfMatrix4f(FILE* file, const float* m)

+ 4 - 8
gameplay-encoder/src/FileIO.h

@@ -1,10 +1,6 @@
 #ifndef FILEIO_H_
 #define FILEIO_H_
 
-#include <iostream>
-#include <list>
-#include <vector>
-
 #include "Base.h"
 
 namespace gameplay
@@ -27,7 +23,7 @@ template <class T>
 void fprintfElement(FILE* file, const char* format, const char* elementName, std::vector<T> list)
 {
     fprintf(file, "<%s>", elementName);
-    std::vector<T>::const_iterator i;
+    typename std::vector<T>::const_iterator i;
     for (i = list.begin(); i != list.end(); i++)
     {
         fprintf(file, format, *i);
@@ -39,7 +35,7 @@ template <class T>
 void fprintfElement(FILE* file, const char* format, const char* elementName, std::list<T> list)
 {
     fprintf(file, "<%s>", elementName);
-    std::list<T>::const_iterator i;
+    typename std::list<T>::const_iterator i;
     for (i = list.begin(); i != list.end(); i++)
     {
         fprintf(file, format, *i);
@@ -81,7 +77,7 @@ void write(std::list<T> list, FILE* file)
     // First write the size of the list
     write(list.size(), file);
     // Then write each element
-    std::list<T>::const_iterator i;
+    typename std::list<T>::const_iterator i;
     for (i = list.begin(); i != list.end(); i++)
     {
         write(*i, file);
@@ -99,7 +95,7 @@ void write(std::vector<T> vector, FILE* file)
     // First write the size of the vector
     write(vector.size(), file);
     // Then write each element
-    std::vector<T>::const_iterator i;
+    typename std::vector<T>::const_iterator i;
     for (i = vector.begin(); i != vector.end(); i++)
     {
         write(*i, file);

+ 2 - 3
gameplay-encoder/src/Mesh.cpp

@@ -1,5 +1,4 @@
 #include "Mesh.h"
-#include <cmath>
 
 namespace gameplay
 {
@@ -81,7 +80,7 @@ void Mesh::writeText(FILE* file)
     }
 
     // for each Vertex
-    fprintf(file, "<vertices count=\"%u\">\n", vertices.size());
+    fprintf(file, "<vertices count=\"%lu\">\n", vertices.size());
     for (std::vector<Vertex>::iterator i = vertices.begin(); i != vertices.end(); i++)
     {
         i->writeText(file);
@@ -200,7 +199,7 @@ void Mesh::computeBounds()
     }
 
     // Convert squared distance to distance for radius
-    bounds.radius = std::sqrtf(bounds.radius);
+    bounds.radius = sqrtf(bounds.radius);
 }
 
 }

+ 1 - 0
gameplay-encoder/src/Mesh.h

@@ -1,6 +1,7 @@
 #ifndef MESH_H_
 #define MESH_H_
 
+#include "Base.h"
 #include "Object.h"
 #include "MeshPart.h"
 #include "VertexElement.h"

+ 1 - 1
gameplay-encoder/src/MeshSkin.cpp

@@ -49,7 +49,7 @@ void MeshSkin::writeText(FILE* file)
         fprintf(file, "%s ", i->c_str());
     }
     fprintf(file, "</joints>\n");
-    fprintf(file, "<bindPoses count=\"%u\">", _bindPoses.size());
+    fprintf(file, "<bindPoses count=\"%lu\">", _bindPoses.size());
     for (std::list<float>::const_iterator i = _bindPoses.begin(); i != _bindPoses.end(); i++)
     {
         fprintf(file, "%f ", *i);

+ 2 - 1
gameplay-encoder/src/MeshSubSet.cpp

@@ -13,10 +13,11 @@ MeshSubSet::~MeshSubSet(void)
 {
 }
 
-byte MeshSubSet::getTypeId(void)
+unsigned int MeshSubSet::getTypeId(void)
 {
     return MESHPART_ID;
 }
+    
 const char* MeshSubSet::getElementName(void)
 {
     return "MeshSubSet";

+ 10 - 7
gameplay-encoder/src/MeshSubSet.h

@@ -1,19 +1,20 @@
-#ifndef MESHSUBSET_H_

+#ifndef MESHSUBSET_H_
 #define MESHSUBSET_H_
 
-#include <vector>
-
-#include "Common.h"
+#include "Base.h"
 #include "Object.h"
 #include "Vertex.h"
 
+namespace gameplay 
+{
+
 class MeshSubSet : public Object
 {
 public:
     MeshSubSet(void);
     virtual ~MeshSubSet(void);
 
-    virtual byte getTypeId(void);
+    virtual unsigned int getTypeId(void);
     virtual const char* getElementName(void);
     virtual void writeBinary(FILE* file);
     virtual void writeText(FILE* file);
@@ -24,5 +25,7 @@ public:
     std::map<Vertex, int> vertexLookupTable;
 };
 
-

-#endif

+}
+
+#endif
+

+ 2 - 7
gameplay-encoder/src/Object.h

@@ -1,11 +1,6 @@
 #ifndef OBJ_H_
 #define OBJ_H_
 
-#include <iostream>
-#include <string>
-#include <list>
-#include <vector>
-
 #include "Base.h"
 #include "FileIO.h"
 
@@ -118,7 +113,7 @@ public:
         // First write the size of the list
         write(list.size(), file);
         // Then write each element
-        std::list<T>::const_iterator i;
+        typename std::list<T>::const_iterator i;
         for (i = list.begin(); i != list.end(); i++)
         {
             (*i)->writeBinary(file);
@@ -134,7 +129,7 @@ public:
         // First write the size of the vector
         write(vector.size(), file);
         // Then write each element
-        std::vector<T>::const_iterator i;
+        typename std::vector<T>::const_iterator i;
         for (i = vector.begin(); i != vector.end(); i++)
         {
             (*i)->writeBinary(file);

+ 13 - 0
gameplay.sln

@@ -28,31 +28,44 @@ EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
+		DebugMem|Win32 = DebugMem|Win32
 		Release|Win32 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.Debug|Win32.ActiveCfg = Debug|Win32
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.Debug|Win32.Build.0 = Debug|Win32
+		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.Release|Win32.ActiveCfg = Release|Win32
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A}.Release|Win32.Build.0 = Release|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Debug|Win32.ActiveCfg = Debug|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Debug|Win32.Build.0 = Debug|Win32
+		{D672DC66-3CE0-4878-B0D2-813CA731012F}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{D672DC66-3CE0-4878-B0D2-813CA731012F}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Release|Win32.ActiveCfg = Release|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Release|Win32.Build.0 = Release|Win32
 		{9A515C8B-3320-4C5C-9754-211E91206C9D}.Debug|Win32.ActiveCfg = Debug|Win32
 		{9A515C8B-3320-4C5C-9754-211E91206C9D}.Debug|Win32.Build.0 = Debug|Win32
+		{9A515C8B-3320-4C5C-9754-211E91206C9D}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{9A515C8B-3320-4C5C-9754-211E91206C9D}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{9A515C8B-3320-4C5C-9754-211E91206C9D}.Release|Win32.ActiveCfg = Release|Win32
 		{9A515C8B-3320-4C5C-9754-211E91206C9D}.Release|Win32.Build.0 = Release|Win32
 		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.Debug|Win32.ActiveCfg = Debug|Win32
 		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.Debug|Win32.Build.0 = Debug|Win32
+		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.Release|Win32.ActiveCfg = Release|Win32
 		{CC37B8E9-6402-4841-8D6A-5D908A5909B3}.Release|Win32.Build.0 = Release|Win32
 		{87388E8B-F3CF-428F-BC2C-C1886248C111}.Debug|Win32.ActiveCfg = Debug|Win32
 		{87388E8B-F3CF-428F-BC2C-C1886248C111}.Debug|Win32.Build.0 = Debug|Win32
+		{87388E8B-F3CF-428F-BC2C-C1886248C111}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{87388E8B-F3CF-428F-BC2C-C1886248C111}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{87388E8B-F3CF-428F-BC2C-C1886248C111}.Release|Win32.ActiveCfg = Release|Win32
 		{87388E8B-F3CF-428F-BC2C-C1886248C111}.Release|Win32.Build.0 = Release|Win32
 		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Debug|Win32.ActiveCfg = Debug|Win32
 		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Debug|Win32.Build.0 = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.DebugMem|Win32.ActiveCfg = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.DebugMem|Win32.Build.0 = Debug|Win32
 		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Release|Win32.ActiveCfg = Release|Win32
 		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection

+ 3 - 0
gameplay.xcworkspace/contents.xcworkspacedata

@@ -4,6 +4,9 @@
    <FileRef
       location = "group:gameplay/gameplay.xcodeproj">
    </FileRef>
+   <FileRef
+      location = "group:gameplay-encoder/gameplay-encoder.xcodeproj">
+   </FileRef>
    <FileRef
       location = "group:gameplay-samples/sample00-mesh/sample00-mesh.xcodeproj">
    </FileRef>

+ 41 - 0
gameplay/gameplay.vcxproj

@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="DebugMem|Win32">
+      <Configuration>DebugMem</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
     <ProjectConfiguration Include="Debug|Win32">
       <Configuration>Debug</Configuration>
       <Platform>Win32</Platform>
@@ -24,6 +28,7 @@
     <ClCompile Include="src\BoundingSphere.cpp" />
     <ClCompile Include="src\Camera.cpp" />
     <ClCompile Include="src\Curve.cpp" />
+    <ClCompile Include="src\DebugNew.cpp" />
     <ClCompile Include="src\Effect.cpp" />
     <ClCompile Include="src\FileSystem.cpp" />
     <ClCompile Include="src\Font.cpp" />
@@ -81,6 +86,7 @@
     <ClInclude Include="src\BoundingSphere.h" />
     <ClInclude Include="src\Camera.h" />
     <ClInclude Include="src\Curve.h" />
+    <ClInclude Include="src\DebugNew.h" />
     <ClInclude Include="src\Effect.h" />
     <ClInclude Include="src\FileSystem.h" />
     <ClInclude Include="src\Font.h" />
@@ -155,6 +161,11 @@
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMem|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>StaticLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
@@ -167,6 +178,9 @@
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugMem|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
@@ -174,9 +188,15 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <OutDir>$(Configuration)\</OutDir>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMem|Win32'">
+    <OutDir>$(Configuration)\</OutDir>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <IntDir>$(Configuration)\</IntDir>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMem|Win32'">
+    <IntDir>$(Configuration)\</IntDir>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <OutDir>$(Configuration)\</OutDir>
   </PropertyGroup>
@@ -191,11 +211,32 @@
       <Optimization>Disabled</Optimization>
       <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>..\external-deps\openal\include\AL;..\external-deps\alut\include\AL;..\external-deps\glew\include;..\external-deps\libpng\include;..\external-deps\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <RuntimeTypeInfo>
+      </RuntimeTypeInfo>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugMem|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;GAMEPLAY_MEM_LEAK_DETECTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\external-deps\openal\include\AL;..\external-deps\alut\include\AL;..\external-deps\glew\include;..\external-deps\libpng\include;..\external-deps\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <RuntimeTypeInfo>true</RuntimeTypeInfo>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
+    <Lib>
+      <Verbose>
+      </Verbose>
+    </Lib>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>

+ 7 - 1
gameplay/gameplay.vcxproj.filters

@@ -172,7 +172,10 @@
       <Filter>src</Filter>
     </ClCompile>
     <ClCompile Include="src\gameplay-main-win32.cpp">
-      <Filter>src</Filter>
+		<Filter>src</Filter>
+    </ClCompile>
+    <ClCompile Include="src\DebugNew.cpp">
+		<Filter>src</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
@@ -335,6 +338,9 @@
     <ClInclude Include="src\RenderState.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="src\DebugNew.h">
+      <Filter>src</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="res\shaders\bumped-specular.vsh">

+ 0 - 2
gameplay/src/Animation.cpp

@@ -64,7 +64,6 @@ Animation::Channel::Channel(AnimationTarget* target, int propertyId, Curve* curv
     assert(target->getAnimationPropertyComponentCount(propertyId));
 
     _target = target;
-    _target->addRef();
     _propertyId = propertyId;
     _curve = curve;
     _duration = duration;
@@ -72,7 +71,6 @@ Animation::Channel::Channel(AnimationTarget* target, int propertyId, Curve* curv
 
 Animation::Channel::~Channel()
 {
-    SAFE_RELEASE(_target);
     SAFE_DELETE(_curve);
 }
 

+ 8 - 24
gameplay/src/AnimationClip.cpp

@@ -28,37 +28,21 @@ AnimationClip::AnimationClip(const char* id, Animation* animation, unsigned long
 
 AnimationClip::~AnimationClip()
 {
+    // Explicitly stop this clip if it's currently playing so it gets removed from the controller
+    if (_isPlaying)
+    {
+        stop();
+    }
+
     std::vector<AnimationValue*>::iterator valueIter = _values.begin();
     while (valueIter != _values.end())
     {
         SAFE_DELETE(*valueIter);
         valueIter++;
     }
-    _values.clear();
-
-    if (_beginListeners)
-    {
-        std::vector<Listener*>::iterator bIter = _beginListeners->begin();
-        while (bIter != _beginListeners->end())
-        {
-            SAFE_DELETE(*bIter);
-            bIter++;
-        }
-        _beginListeners->clear();
-        SAFE_DELETE(_beginListeners);
-    }
 
-    if (_endListeners)
-    {
-        std::vector<Listener*>::iterator eIter = _endListeners->begin();
-        while (eIter != _endListeners->end())
-        {
-            SAFE_DELETE(*eIter);
-            eIter++;
-        }
-        _endListeners->clear();
-        SAFE_DELETE(_endListeners);
-    }
+    SAFE_DELETE(_beginListeners);
+    SAFE_DELETE(_endListeners);
 }
 
 const char* AnimationClip::getID() const

+ 3 - 1
gameplay/src/AnimationController.cpp

@@ -112,11 +112,11 @@ void AnimationController::stopAllAnimations()
     while (clipIter != _runningClips.end())
     {
         AnimationClip* clip = *clipIter;
-        clipIter = _runningClips.erase(clipIter);
         clip->_isPlaying = false;
         SAFE_RELEASE(clip);
         clipIter++;
     }
+    _runningClips.clear();
 
     _state = IDLE;
 }
@@ -228,6 +228,8 @@ void AnimationController::destroyAnimation(Animation* animation)
 
 void AnimationController::destroyAllAnimations()
 {
+    stopAllAnimations();
+
     std::vector<Animation*>::iterator itr = _animations.begin();
     
     while (itr != _animations.end())

+ 1 - 2
gameplay/src/AudioSource.cpp

@@ -167,14 +167,13 @@ void AudioSource::setNode(Node* node)
         if (_node)
         {
             _node->removeListener(this);
-            SAFE_RELEASE(_node);
         }
 
         // Connect the new node.
         _node = node;
+
         if (_node)
         {
-            _node->addRef();
             _node->addListener(this);
         }
     }

+ 8 - 2
gameplay/src/Base.h

@@ -5,6 +5,8 @@
 #define BASE_H_
 
 // C/C++
+#include <new>
+#include <cstdio>
 #include <cassert>
 #include <memory>
 #include <iostream>
@@ -19,7 +21,6 @@
 #include <map>
 #include <algorithm>
 #include <ctime>
-#include <cstdio>
 #include <limits>
 #include <functional>
 #include <assert.h>
@@ -62,6 +63,11 @@ extern void printError(const char* format, ...);
 #define WARN(x) printError(x)
 #define WARN_VARG(x, ...) printError(x, __VA_ARGS__)
 
+// Debug new for memory leak detection
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+#include "DebugNew.h"
+#endif
+
 // Object deletion macro
 #define SAFE_DELETE(x) \
     if (x) \
@@ -250,4 +256,4 @@ extern GLenum __gl_error_code;
     #pragma warning( disable : 4996 )
 #endif
 
-#endif 
+#endif

+ 1 - 6
gameplay/src/Camera.cpp

@@ -36,7 +36,6 @@ Camera::Camera(float zoomX, float zoomY, float aspectRatio, float nearPlane, flo
 
 Camera::~Camera()
 {
-    SAFE_RELEASE(_node);
 }
 
 Camera* Camera::createPerspective(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
@@ -144,17 +143,13 @@ void Camera::setNode(Node* node)
         if (_node)
         {
             _node->removeListener(this);
-
-            // Disconnect our current node.
-            SAFE_RELEASE(_node);
         }
 
         // Connect the new node.
         _node = node;
+
         if (_node)
         {
-            _node->addRef();
-
             _node->addListener(this);
         }
 

+ 1 - 0
gameplay/src/Curve.cpp

@@ -31,6 +31,7 @@ Curve::Curve(unsigned int pointCount, unsigned int componentCount)
 Curve::~Curve()
 {
     SAFE_DELETE_ARRAY(_points);
+    SAFE_DELETE_ARRAY(_quaternionOffsets);
 }
 
 Curve::Point::Point()

+ 162 - 0
gameplay/src/DebugNew.cpp

@@ -0,0 +1,162 @@
+/**
+ * DebugNew.cpp
+ */
+
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+
+#include <new>
+#include <exception>
+#include <cstdio>
+#include <cstdarg>
+
+struct MemoryAllocationRecord
+{
+    unsigned long address;          // address returned to the caller after allocation
+    unsigned int size;              // size of the allocation request
+    const char* file;               // source file of allocation request
+    int line;                       // source line of the allocation request
+    MemoryAllocationRecord* next;
+    MemoryAllocationRecord* prev;
+};
+
+MemoryAllocationRecord* __memoryAllocations = 0;
+int __memoryAllocationCount = 0;
+
+void* debugAlloc(std::size_t size, const char* file, int line);
+void debugFree(void* p);
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+void* operator new (std::size_t size, const char* file, int line)
+{
+    return debugAlloc(size, file, line);
+}
+
+void* operator new[] (std::size_t size, const char* file, int line)
+{
+    return operator new (size, file, line);
+}
+
+void* operator new (std::size_t size) throw(std::bad_alloc)
+{
+    return operator new (size, "", 0);
+}
+
+void* operator new[] (std::size_t size) throw(std::bad_alloc)
+{
+    return operator new (size, "", 0);
+}
+
+void* operator new (std::size_t size, const std::nothrow_t&) throw()
+{
+    return operator new (size, "", 0);
+}
+
+void* operator new[] (std::size_t size, const std::nothrow_t&) throw()
+{
+    return operator new (size, "", 0);
+}
+
+void operator delete (void* p) throw()
+{
+    debugFree(p);
+}
+
+void operator delete[] (void* p) throw()
+{
+    operator delete (p);
+}
+
+void operator delete (void* p, const char* file, int line) throw()
+{
+    operator delete (p);
+}
+
+void operator delete[] (void* p, const char* file, int line) throw()
+{
+    operator delete (p);
+}
+
+#ifdef _MSC_VER
+#pragma warning( default : 4290 )
+#endif
+
+// Include Base.h (needed for logging macros) AFTER new operator impls
+#include "Base.h"
+
+void* debugAlloc(size_t size, const char* file, int line)
+{
+    // Allocate memory + size for a MemoryAlloctionRecord
+    unsigned char* mem = (unsigned char*)malloc(size + sizeof(MemoryAllocationRecord));
+
+    MemoryAllocationRecord* rec = (MemoryAllocationRecord*)mem;
+
+    // Move memory pointer past record
+    mem += sizeof(MemoryAllocationRecord);
+
+    rec->address = (unsigned long)mem;
+    rec->size = size;
+    rec->file = file;
+    rec->line = line;
+    rec->next = __memoryAllocations;
+    rec->prev = 0;
+
+    if (__memoryAllocations)
+        __memoryAllocations->prev = rec;
+    __memoryAllocations = rec;
+    ++__memoryAllocationCount;
+
+    return mem;
+}
+
+void debugFree(void* p)
+{
+    assert(p);
+
+    // Backup passed in pointer to access memory allocation record
+    void* mem = ((unsigned char*)p) - sizeof(MemoryAllocationRecord);
+
+    MemoryAllocationRecord* rec = (MemoryAllocationRecord*)mem;
+
+    // Sanity check: ensure that address in record matches passed in address
+    if (rec->address != (unsigned long)p)
+    {
+        gameplay::printError("[memory] CORRUPTION: Attempting to free memory address with invalid memory allocation record.");
+        return;
+    }
+
+    // Link this item out
+    if (__memoryAllocations == rec)
+        __memoryAllocations = rec->next;
+    if (rec->prev)
+        rec->prev->next = rec->next;
+    if (rec->next)
+        rec->next->prev = rec->prev;
+    --__memoryAllocationCount;
+
+    // Free the address from the original alloc location (before mem allocation record)
+    free(mem);
+}
+
+extern void printMemoryLeaks()
+{
+    // Dump general heap memory leaks
+    if (__memoryAllocationCount == 0)
+    {
+        gameplay::printError("[memory] All HEAP allocations successfully cleaned up (no leaks detected).");
+    }
+    else
+    {
+        gameplay::printError("[memory] WARNING: %d HEAP allocations still active in memory.", __memoryAllocationCount);
+        MemoryAllocationRecord* rec = __memoryAllocations;
+        while (rec)
+        {
+            gameplay::printError("[memory] LEAK: HEAP allocation leak of size %d leak from line %d in file '%s'.", rec->size, rec->line, rec->file);
+            rec = rec->next;
+        }
+    }
+}
+
+#endif

+ 42 - 0
gameplay/src/DebugNew.h

@@ -0,0 +1,42 @@
+/**
+ * DebugNew.h
+ *
+ * Global overrides of the new and delete operators for memory tracking.
+ * This file is only included when memory leak detection is explicitly
+ * request via the pre-processor defintion GAMEPLAY_MEM_LEAK_DETECTION.
+ */
+
+#ifndef DEBUGNEW_H_
+#define DEBUGNEW_H_
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+
+#include <new>
+#include <exception>
+
+// Prints all heap and reference leaks to stderr.
+extern void printMemoryLeaks();
+
+// global new/delete operator overloads
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 ) // C++ exception specification ignored.
+#endif
+void* operator new (std::size_t size, const char* file, int line);
+void* operator new[] (std::size_t size, const char* file, int line);
+void* operator new (std::size_t size) throw(std::bad_alloc);
+void* operator new[] (std::size_t size) throw(std::bad_alloc);
+void* operator new (std::size_t size, const std::nothrow_t&) throw();
+void* operator new[] (std::size_t size, const std::nothrow_t&) throw();
+void operator delete (void* p) throw();
+void operator delete[] (void* p) throw();
+void operator delete (void* p, const char* file, int line) throw();
+void operator delete[] (void* p, const char* file, int line) throw();
+#ifdef _MSC_VER
+#pragma warning( default : 4290 )
+#endif
+
+// Re-define new to use versions with file and line number
+#define DEBUG_NEW new (__FILE__, __LINE__)
+#define new DEBUG_NEW
+
+#endif
+#endif

+ 32 - 13
gameplay/src/Game.cpp

@@ -5,6 +5,7 @@
 #include "Base.h"
 #include "Game.h"
 #include "Platform.h"
+#include "RenderState.h"
 
 // Extern global variables
 GLenum __gl_error_code = GL_NO_ERROR;
@@ -19,7 +20,8 @@ long Game::_pausedTimeTotal = 0L;
 Game::Game() 
     : _state(UNINITIALIZED), 
       _frameLastFPS(0), _frameCount(0), _frameRate(0), 
-      _clearColor(Vector4::zero()), _clearDepth(1.0f), _clearStencil(0)
+      _clearDepth(1.0f), _clearStencil(0),
+      _animationController(NULL), _audioController(NULL)
 {
     assert(__gameInstance == NULL);
     __gameInstance = this;
@@ -33,6 +35,11 @@ Game::~Game()
 {
     // Do not call any virtual functions from the destructor.
     // Finalization is done from outside this class.
+
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+    Ref::printLeaks();
+    printMemoryLeaks();
+#endif
 }
 
 Game* Game::getInstance()
@@ -92,8 +99,13 @@ bool Game::startup()
     if (_state != UNINITIALIZED)
         return false;
 
-    _animationController.initialize();
-    _audioController.initialize();
+    RenderState::initialize();
+
+    _animationController = new AnimationController();
+    _animationController->initialize();
+
+    _audioController = new AudioController();
+    _audioController->initialize();
 
     // Call user initialization.
     initialize();
@@ -109,8 +121,15 @@ void Game::shutdown()
     {
         finalize();
 
-        _animationController.finalize();
-        _audioController.finalize();
+        _animationController->finalize();
+        delete _animationController;
+        _animationController = NULL;
+
+        _audioController->finalize();
+        delete _audioController;
+        _audioController = NULL;
+
+        RenderState::finalize();
     }
 
     _state = UNINITIALIZED;
@@ -122,8 +141,8 @@ void Game::pause()
     {
         _state = PAUSED;
         _pausedTimeLast = Platform::getAbsoluteTime();
-        _animationController.pause();
-        _audioController.pause();
+        _animationController->pause();
+        _audioController->pause();
     }
 }
 
@@ -133,8 +152,8 @@ void Game::resume()
     {
         _state = RUNNING;
         _pausedTimeTotal += Platform::getAbsoluteTime() - _pausedTimeLast;
-        _animationController.resume();
-        _audioController.resume();
+        _animationController->resume();
+        _audioController->resume();
     }
 }
 
@@ -155,12 +174,12 @@ void Game::frame()
     lastFrameTime = frameTime;
 
     // Update the schedule and running animations.
-    _animationController.update(elapsedTime);
+    _animationController->update(elapsedTime);
     // Application Update.
     update(elapsedTime);
 
     // Audio Rendering.
-    _audioController.update(elapsedTime);
+    _audioController->update(elapsedTime);
     // Graphics Rendering.
     render(elapsedTime);
 
@@ -224,10 +243,10 @@ void Game::clear(ClearFlags flags, const Vector4& clearColor, float clearDepth,
 
 AnimationController* Game::getAnimationController()
 {
-    return &_animationController;
+    return _animationController;
 }
 
-const AudioController& Game::getAudioController() const
+const AudioController* Game::getAudioController() const
 {
     return _audioController;
 }

+ 4 - 8
gameplay/src/Game.h

@@ -18,7 +18,6 @@ namespace gameplay
  */
 class Game
 {
-
 public:
 
     /**
@@ -34,8 +33,7 @@ public:
     /**
      * Flags used when clearing the active frame buffer targets.
      */
-
-     enum ClearFlags
+    enum ClearFlags
     {
         CLEAR_COLOR = GL_COLOR_BUFFER_BIT,
         CLEAR_DEPTH = GL_DEPTH_BUFFER_BIT,
@@ -46,8 +44,6 @@ public:
         CLEAR_COLOR_DEPTH_STENCIL = CLEAR_COLOR | CLEAR_DEPTH | CLEAR_STENCIL
     };
 
-
-
     /**
      * Destructor.
      */
@@ -168,7 +164,7 @@ public:
      *
      * @return The audio controller for this game.
      */
-    const AudioController& getAudioController() const;
+    const AudioController* getAudioController() const;
 
     /**
      * Gets the animation controller for managing control of animations
@@ -279,8 +275,8 @@ private:
     Vector4 _clearColor;                        // The clear color value last used for clearing the color buffer.
     float _clearDepth;                          // The clear depth value last used for clearing the depth buffer.
     int _clearStencil;                          // The clear stencil value last used for clearing the stencil buffer.
-    AnimationController _animationController;   // Controls the scheduling and running of animations.
-    AudioController _audioController;           // Controls audio sources that are playing in the game.
+    AnimationController* _animationController;  // Controls the scheduling and running of animations.
+    AudioController* _audioController;          // Controls audio sources that are playing in the game.
 };
 
 }

+ 2 - 13
gameplay/src/Light.cpp

@@ -70,19 +70,8 @@ Node* Light::getNode() const
 
 void Light::setNode(Node* node)
 {
-    if (_node != node)
-    {
-        // Disconnect our current node.
-        SAFE_RELEASE(_node);
-
-        // Connect the new node.
-        _node = node;
-
-        if (_node)
-        {
-            _node->addRef();
-        }
-    }
+    // Connect the new node.
+    _node = node;
 }
 
 const Vector3& Light::getColor() const

+ 2 - 0
gameplay/src/MaterialParameter.h

@@ -269,6 +269,7 @@ void MaterialParameter::bindValue(ClassType* classInstance, ParameterType (Class
     clearValue();
 
     _value.method = new MethodValueBinding<ClassType, ParameterType>(this, classInstance, valueMethod);
+    _dynamic = true;
     _type = MaterialParameter::METHOD;
 }
 
@@ -278,6 +279,7 @@ void MaterialParameter::bindValue(ClassType* classInstance, ParameterType (Class
     clearValue();
 
     _value.method = new MethodArrayBinding<ClassType, ParameterType>(this, classInstance, valueMethod, countMethod);
+    _dynamic = true;
     _type = MaterialParameter::METHOD;
 }
 

+ 12 - 10
gameplay/src/Matrix.cpp

@@ -44,20 +44,22 @@ Matrix::~Matrix()
 
 const Matrix& Matrix::identity()
 {
-    static Matrix* m = new Matrix( 1, 0, 0, 0,
-                                   0, 1, 0, 0,
-                                   0, 0, 1, 0,
-                                   0, 0, 0, 1 );
-    return *m;
+    static Matrix m(
+        1, 0, 0, 0,
+        0, 1, 0, 0,
+        0, 0, 1, 0,
+        0, 0, 0, 1 );
+    return m;
 }
 
 const Matrix& Matrix::zero()
 {
-    static Matrix* m = new Matrix( 0, 0, 0, 0,
-                                   0, 0, 0, 0,
-                                   0, 0, 0, 0,
-                                   0, 0, 0, 0 );
-    return *m;
+    static Matrix m(
+        0, 0, 0, 0,
+        0, 0, 0, 0,
+        0, 0, 0, 0,
+        0, 0, 0, 0 );
+    return m;
 }
 
 void Matrix::createLookAt(const Vector3& eyePosition, const Vector3& targetPosition, const Vector3& up, Matrix* dst)

+ 0 - 11
gameplay/src/MeshSkin.cpp

@@ -80,13 +80,7 @@ void MeshSkin::setJoint(Joint* joint, unsigned int index)
 {
     assert(index < _joints.size());
 
-    if (_joints[index])
-    {
-        SAFE_RELEASE(_joints[index]);
-    }
-
     _joints[index] = joint;
-    joint->addRef();
 }
 
 Vector4* MeshSkin::getMatrixPalette() const
@@ -112,11 +106,6 @@ Joint* MeshSkin::getJoint(unsigned int index) const
 
 void MeshSkin::clearJoints()
 {
-    unsigned int prevCount = _joints.size();
-    for (unsigned int i = 0; i < prevCount; i++)
-    {
-        SAFE_RELEASE(_joints[i]);
-    }
     _joints.clear();
 }
 

+ 1 - 11
gameplay/src/Model.cpp

@@ -197,17 +197,7 @@ Node* Model::getNode() const
 
 void Model::setNode(Node* node)
 {
-    if (_node != node)
-    {
-        SAFE_RELEASE(_node);
-
-        _node = node;
-
-        if (_node)
-        {
-            node->addRef();
-        }
-    }
+    _node = node;
 
     // Re-bind node related material parameters
     if (node)

+ 23 - 35
gameplay/src/Node.cpp

@@ -80,11 +80,22 @@ void Node::addChild(Node* child)
 {
     assert(child);
 
+    if (child->_parent == this)
+    {
+        // This node is already present in our hierarchy
+        return;
+    }
+
+    child->addRef();
+
     // If the item belongs to another hierarchy, remove it first.
-    Node* parent = child->_parent;
-    if (parent)
+    if (child->_parent)
     {
-        parent->removeChild(child);
+        child->_parent->removeChild(child);
+    }
+    else if (child->_scene)
+    {
+        child->_scene->removeNode(child);
     }
 
     // Order is irrelevant, so add to the beginning of the list.
@@ -103,9 +114,10 @@ void Node::addChild(Node* child)
 
     ++_childCount;
 
-    // Fire events.
-    child->parentChanged(parent);
-    childAdded(child);
+    if (_notifyHierarchyChanged)
+    {
+        hierarchyChanged();
+    }
 }
 
 void Node::removeChild(Node* child)
@@ -118,6 +130,8 @@ void Node::removeChild(Node* child)
 
     // Call remove on the child.
     child->remove();
+
+    SAFE_RELEASE(child);
 }
 
 void Node::removeAllChildren()
@@ -133,7 +147,7 @@ void Node::removeAllChildren()
     hierarchyChanged();
 }
 
-void Node   ::remove()
+void Node::remove()
 {
     // Re-link our neighbours.
     if (_prevSibling)
@@ -161,11 +175,9 @@ void Node   ::remove()
     _prevSibling = NULL;
     _parent = NULL;
 
-    // Fire events.
-    if (parent)
+    if (parent && parent->_notifyHierarchyChanged)
     {
-        parentChanged(parent);
-        parent->childRemoved(this);
+        parent->hierarchyChanged();
     }
 }
 
@@ -788,28 +800,4 @@ void Node::setParticleEmitter(ParticleEmitter* emitter)
     }
 }
 
-void Node::childAdded(Node* child)
-{
-    child->addRef();
-
-    if (_notifyHierarchyChanged)
-    {
-        hierarchyChanged();
-    }
-}
-
-void Node::childRemoved(Node* child)
-{
-    SAFE_RELEASE(child);
-
-    if (_notifyHierarchyChanged)
-    {
-        hierarchyChanged();
-    }
-}
-
-void Node::parentChanged(Node* oldParent)
-{
-}
-
 }

+ 0 - 21
gameplay/src/Node.h

@@ -414,27 +414,6 @@ protected:
      */
     void remove();
 
-    /**
-     * Called when a child is added to this item in the tree.
-     * 
-     * @param child The child that was added.
-     */
-    virtual void childAdded(Node* child);
-
-    /**
-     * Called when a child is removed from this item in the tree.
-     *
-     * @param child The child that was removed.
-     */
-    virtual void childRemoved(Node* child);
-
-    /**
-     * Called when the parent of this node changes.
-     *
-     * @param oldParent The previous parent for this node.
-     */
-    virtual void parentChanged(Node* oldParent);
-
     void transformChanged();
 
     void hierarchyChanged();

+ 6 - 0
gameplay/src/Package.cpp

@@ -488,6 +488,7 @@ Node* Package::readNode(Scene* sceneContext, Node* nodeContext)
     if (camera)
     {
         node->setCamera(camera);
+        SAFE_RELEASE(camera);
     }
 
     // Read light
@@ -495,6 +496,7 @@ Node* Package::readNode(Scene* sceneContext, Node* nodeContext)
     if (light)
     {
         node->setLight(light);
+        SAFE_RELEASE(light);
     }
 
     // Read model
@@ -502,6 +504,7 @@ Node* Package::readNode(Scene* sceneContext, Node* nodeContext)
     if (model)
     {
         node->setModel(model);
+        SAFE_RELEASE(model);
     }
 
     return node;
@@ -639,6 +642,7 @@ Model* Package::readModel(Scene* sceneContext, Node* nodeContext)
         if (mesh)
         {
             Model* model = Model::create(mesh);
+            SAFE_RELEASE(mesh);
 
             // Read skin
             unsigned char hasSkin;
@@ -1075,10 +1079,12 @@ Mesh* Package::loadMesh(const char* id)
         if (part == NULL)
         {
             LOG_ERROR_VARG("Failed to create mesh part (i=%d): %s", i, id);
+            SAFE_DELETE_ARRAY(indexData);
             SAFE_RELEASE(mesh);
             return NULL;
         }
         part->setIndexData(indexData, 0, indexCount);
+        SAFE_DELETE_ARRAY(indexData);
     }
 
     fseek(_file, position, SEEK_SET);

+ 10 - 23
gameplay/src/ParticleEmitter.cpp

@@ -34,11 +34,12 @@ ParticleEmitter::ParticleEmitter(SpriteBatch* batch, unsigned int particleCountM
     _timePerEmission(EMISSION_RATE_TIME_INTERVAL), _timeLast(0L), _timeRunning(0L)
 {
     _particles = new Particle[particleCountMax];
+
+    _spriteBatch->getStateBlock()->setDepthWrite(false);
 }
 
 ParticleEmitter::~ParticleEmitter()
 {
-    SAFE_RELEASE(_node);
     SAFE_DELETE(_spriteBatch);
     SAFE_DELETE_ARRAY(_particles);
     SAFE_DELETE_ARRAY(_spriteTextureCoords);
@@ -60,6 +61,7 @@ ParticleEmitter* ParticleEmitter::create(const char* textureFile, TextureBlendin
 
     // Use default SpriteBatch material.
     SpriteBatch* batch =  SpriteBatch::create(texture, NULL, particleCountMax);
+    texture->release(); // batch owns the texture
     assert(batch);
 
     ParticleEmitter* emitter = new ParticleEmitter(batch, particleCountMax);
@@ -71,7 +73,9 @@ ParticleEmitter* ParticleEmitter::create(const char* textureFile, TextureBlendin
     emitter->_spriteTextureHeight = texture->getHeight();
     emitter->_spriteTextureWidthRatio = 1.0f / (float)texture->getWidth();
     emitter->_spriteTextureHeightRatio = 1.0f / (float)texture->getHeight();
-    emitter->setSpriteFrameCoords(1, new Rectangle((float)texture->getWidth(), (float)texture->getHeight()));
+
+    Rectangle texCoord((float)texture->getWidth(), (float)texture->getHeight());
+    emitter->setSpriteFrameCoords(1, &texCoord);
 
     return emitter;
 }
@@ -618,6 +622,8 @@ void ParticleEmitter::setSpriteFrameCoords(unsigned int frameCount, int width, i
     }
 
     setSpriteFrameCoords(frameCount, frameCoords);
+
+    SAFE_DELETE_ARRAY(frameCoords);
 }
 
 Node* ParticleEmitter::getNode() const
@@ -627,19 +633,8 @@ Node* ParticleEmitter::getNode() const
 
 void ParticleEmitter::setNode(Node* node)
 {
-    if (_node != node)
-    {
-        // Disconnect our current node.
-        SAFE_RELEASE(_node);
-
-        // Connect the new node.
-        _node = node;
-
-        if (_node)
-        {
-            _node->addRef();
-        }
-    }
+    // Connect the new node.
+    _node = node;
 }
 
 void ParticleEmitter::setOrbit(bool orbitPosition, bool orbitVelocity, bool orbitAcceleration)
@@ -889,16 +884,8 @@ void ParticleEmitter::draw()
             }
         }
 
-        // Disable writing to the depth buffer.
-        GLboolean depthMask;
-        glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
-        glDepthMask(GL_FALSE);
-
         // Render.
         _spriteBatch->end();
-
-        // Turn the depth mask back on if it was on before.
-        glDepthMask(depthMask);
     }
 }
 

+ 5 - 5
gameplay/src/Platform.h

@@ -17,6 +17,11 @@ class Platform
 {
 public:
 
+    /**
+     * Destructor.
+     */
+    ~Platform();
+
     /**
      * Creates a platform for the specified game which is will interacte with.
      *
@@ -98,11 +103,6 @@ private:
      */
     Platform(const Platform& copy);
 
-    /**
-     * Destructor.
-     */
-    ~Platform();
-
     Game* _game;
 
 };

+ 1 - 1
gameplay/src/PlatformQNX.cpp

@@ -324,7 +324,7 @@ Platform* Platform::create(Game* game)
     {
         // Disable VAO extension for now.
         glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
-        glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glBindVertexArrayOES");
+        glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArrays");
         glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
         glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
     }

+ 4 - 4
gameplay/src/Quaternion.cpp

@@ -35,14 +35,14 @@ Quaternion::~Quaternion()
 
 const Quaternion& Quaternion::identity()
 {
-    static Quaternion* value = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
-    return *value;
+    static Quaternion value(0.0f, 0.0f, 0.0f, 1.0f);
+    return value;
 }
 
 const Quaternion& Quaternion::zero()
 {
-    static Quaternion* value = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
-    return *value;
+    static Quaternion value(0.0f, 0.0f, 0.0f, 0.0f);
+    return value;
 }
 
 bool Quaternion::isIdentity() const

+ 86 - 0
gameplay/src/Ref.cpp

@@ -4,13 +4,22 @@
 
 #include "Base.h"
 #include "Ref.h"
+#include "Game.h"
 
 namespace gameplay
 {
 
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+void* trackRef(Ref* ref);
+void untrackRef(Ref* ref, void* record);
+#endif
+
 Ref::Ref() :
     _refCount(1)
 {
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+    __record = trackRef(this);
+#endif
 }
 
 Ref::~Ref()
@@ -26,8 +35,85 @@ void Ref::release()
 {
     if ((--_refCount) <= 0)
     {
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+        untrackRef(this, __record);
+#endif
         delete this;
     }
 }
 
+unsigned int Ref::getRefCount() const
+{
+    return _refCount;
+}
+
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+
+struct RefAllocationRecord
+{
+    Ref* ref;
+    RefAllocationRecord* next;
+    RefAllocationRecord* prev;
+};
+
+RefAllocationRecord* __refAllocations = 0;
+int __refAllocationCount = 0;
+
+void Ref::printLeaks()
+{
+    // Dump Ref object memory leaks
+    if (__refAllocationCount == 0)
+    {
+        printError("[memory] All Ref objects successfully cleaned up (no leaks detected).");
+    }
+    else
+    {
+        printError("[memory] WARNING: %d Ref objects still active in memory.", __refAllocationCount);
+        for (RefAllocationRecord* rec = __refAllocations; rec != NULL; rec = rec->next)
+        {
+            Ref* ref = rec->ref;
+            const char* type = typeid(*ref).name();
+            printError("[memory] LEAK: Ref object '%s' still active with reference count %d.", (type ? type : ""), ref->getRefCount());
+        }
+    }
+}
+
+void* trackRef(Ref* ref)
+{
+    // Create memory allocation record
+    RefAllocationRecord* rec = (RefAllocationRecord*)malloc(sizeof(RefAllocationRecord));
+    rec->ref = ref;
+    rec->next = __refAllocations;
+    rec->prev = 0;
+
+    if (__refAllocations)
+        __refAllocations->prev = rec;
+    __refAllocations = rec;
+    ++__refAllocationCount;
+
+    return rec;
+}
+
+void untrackRef(Ref* ref, void* record)
+{
+    RefAllocationRecord* rec = (RefAllocationRecord*)record;
+    if (rec->ref != ref)
+    {
+        printError("[memory] CORRUPTION: Attempting to free Ref with invalid ref tracking record.");
+        return;
+    }
+
+    // Link this item out
+    if (__refAllocations == rec)
+        __refAllocations = rec->next;
+    if (rec->prev)
+        rec->prev->next = rec->next;
+    if (rec->next)
+        rec->next->prev = rec->prev;
+    free((void*)rec);
+    --__refAllocationCount;
+}
+
+#endif
+
 }

+ 14 - 0
gameplay/src/Ref.h

@@ -40,6 +40,13 @@ public:
      */
     void release();
 
+    /**
+     * Returns the current reference count of this object.
+     *
+     * @return This object's reference count.
+     */
+    unsigned int getRefCount() const;
+
 protected:
 
     /**
@@ -55,6 +62,13 @@ protected:
 private:
 
     unsigned int _refCount;
+
+    // Memory leak diagnostic data (only included when GAMEPLAY_MEM_LEAK_DETECTION is defined)
+#ifdef GAMEPLAY_MEM_LEAK_DETECTION
+    friend class Game;
+    static void printLeaks();
+    void* __record;
+#endif
 };
 
 }

+ 43 - 30
gameplay/src/RenderState.cpp

@@ -18,7 +18,7 @@
 namespace gameplay
 {
 
-RenderState::StateBlock RenderState::StateBlock::_defaultState;
+RenderState::StateBlock* RenderState::StateBlock::_defaultState = NULL;
 
 RenderState::RenderState()
     : _nodeBinding(NULL), _state(NULL), _parent(NULL)
@@ -44,6 +44,19 @@ RenderState::~RenderState()
     }
 }
 
+void RenderState::initialize()
+{
+    if (StateBlock::_defaultState == NULL)
+    {
+        StateBlock::_defaultState = StateBlock::create();
+    }
+}
+
+void RenderState::finalize()
+{
+    SAFE_RELEASE(StateBlock::_defaultState);
+}
+
 MaterialParameter* RenderState::getParameter(const char* name) const
 {
     assert(name);
@@ -305,75 +318,75 @@ void RenderState::StateBlock::bind()
 void RenderState::StateBlock::bindNoRestore()
 {
     // Update any state that differs from _defaultState and flip _defaultState bits
-    if ((_bits & RS_BLEND) && (_blendEnabled != _defaultState._blendEnabled))
+    if ((_bits & RS_BLEND) && (_blendEnabled != _defaultState->_blendEnabled))
     {
         _blendEnabled ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
-        _defaultState._blendEnabled = _blendEnabled;
+        _defaultState->_blendEnabled = _blendEnabled;
     }
-    if ((_bits & RS_BLEND_FUNC) && (_srcBlend != _defaultState._srcBlend || _dstBlend != _defaultState._dstBlend))
+    if ((_bits & RS_BLEND_FUNC) && (_srcBlend != _defaultState->_srcBlend || _dstBlend != _defaultState->_dstBlend))
     {
         glBlendFunc((GLenum)_srcBlend, (GLenum)_dstBlend);
-        _defaultState._srcBlend = _srcBlend;
-        _defaultState._dstBlend = _dstBlend;
+        _defaultState->_srcBlend = _srcBlend;
+        _defaultState->_dstBlend = _dstBlend;
     }
-    if ((_bits & RS_CULL_FACE) && (_cullFaceEnabled != _defaultState._cullFaceEnabled))
+    if ((_bits & RS_CULL_FACE) && (_cullFaceEnabled != _defaultState->_cullFaceEnabled))
     {
         _cullFaceEnabled ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE);
-        _defaultState._cullFaceEnabled = _cullFaceEnabled;
+        _defaultState->_cullFaceEnabled = _cullFaceEnabled;
     }
-    if ((_bits & RS_DEPTH_TEST) && (_depthTestEnabled != _defaultState._depthTestEnabled))
+    if ((_bits & RS_DEPTH_TEST) && (_depthTestEnabled != _defaultState->_depthTestEnabled))
     {
         _depthTestEnabled ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
-        _defaultState._depthTestEnabled = _depthTestEnabled;
+        _defaultState->_depthTestEnabled = _depthTestEnabled;
     }
-    if ((_bits & RS_DEPTH_WRITE) && (_depthWriteEnabled != _defaultState._depthWriteEnabled))
+    if ((_bits & RS_DEPTH_WRITE) && (_depthWriteEnabled != _defaultState->_depthWriteEnabled))
     {
         glDepthMask(_depthWriteEnabled);
-        _defaultState._depthWriteEnabled = _depthWriteEnabled;
+        _defaultState->_depthWriteEnabled = _depthWriteEnabled;
     }
 
-    _defaultState._bits |= _bits;
+    _defaultState->_bits |= _bits;
 }
 
 void RenderState::StateBlock::restore(long stateOverrideBits)
 {
     // If there is no state to restore (i.e. no non-default state), do nothing
-    if (_defaultState._bits == 0)
+    if (_defaultState->_bits == 0)
     {
         return;
     }
 
     // Restore any state that is not overridden and is not default
-    if (!(stateOverrideBits & RS_BLEND) && (_defaultState._bits & RS_BLEND))
+    if (!(stateOverrideBits & RS_BLEND) && (_defaultState->_bits & RS_BLEND))
     {
         glDisable(GL_BLEND);
-        _defaultState._bits &= ~RS_BLEND;
-        _defaultState._blendEnabled = false;
+        _defaultState->_bits &= ~RS_BLEND;
+        _defaultState->_blendEnabled = false;
     }
-    if (!(stateOverrideBits & RS_BLEND_FUNC) && (_defaultState._bits & RS_BLEND_FUNC))
+    if (!(stateOverrideBits & RS_BLEND_FUNC) && (_defaultState->_bits & RS_BLEND_FUNC))
     {
         glBlendFunc(GL_ONE, GL_ONE);
-        _defaultState._bits &= ~RS_BLEND_FUNC;
-        _defaultState._srcBlend = RenderState::BLEND_ONE;
-        _defaultState._dstBlend = RenderState::BLEND_ONE;
+        _defaultState->_bits &= ~RS_BLEND_FUNC;
+        _defaultState->_srcBlend = RenderState::BLEND_ONE;
+        _defaultState->_dstBlend = RenderState::BLEND_ONE;
     }
-    if (!(stateOverrideBits & RS_CULL_FACE) && (_defaultState._bits & RS_CULL_FACE))
+    if (!(stateOverrideBits & RS_CULL_FACE) && (_defaultState->_bits & RS_CULL_FACE))
     {
         glDisable(GL_CULL_FACE);
-        _defaultState._bits &= ~RS_CULL_FACE;
-        _defaultState._cullFaceEnabled = false;
+        _defaultState->_bits &= ~RS_CULL_FACE;
+        _defaultState->_cullFaceEnabled = false;
     }
-    if (!(stateOverrideBits & RS_DEPTH_TEST) && (_defaultState._bits & RS_DEPTH_TEST))
+    if (!(stateOverrideBits & RS_DEPTH_TEST) && (_defaultState->_bits & RS_DEPTH_TEST))
     {
         glDisable(GL_DEPTH_TEST);
-        _defaultState._bits &= ~RS_DEPTH_TEST;
-        _defaultState._depthTestEnabled = false;
+        _defaultState->_bits &= ~RS_DEPTH_TEST;
+        _defaultState->_depthTestEnabled = false;
     }
-    if (!(stateOverrideBits & RS_DEPTH_WRITE) && (_defaultState._bits & RS_DEPTH_WRITE))
+    if (!(stateOverrideBits & RS_DEPTH_WRITE) && (_defaultState->_bits & RS_DEPTH_WRITE))
     {
         glDepthMask(GL_TRUE);
-        _defaultState._bits &= ~RS_DEPTH_WRITE;
-        _defaultState._depthWriteEnabled = true;
+        _defaultState->_bits &= ~RS_DEPTH_WRITE;
+        _defaultState->_depthWriteEnabled = true;
     }
 }
 

+ 12 - 3
gameplay/src/RenderState.h

@@ -16,6 +16,7 @@ class Pass;
 
 class RenderState : public Ref
 {
+    friend class Game;
     friend class Material;
     friend class Technique;
     friend class Pass;
@@ -198,7 +199,7 @@ public:
         // State bits
         long _bits;
 
-        static StateBlock _defaultState;
+        static StateBlock* _defaultState;
     };
 
     /**
@@ -279,6 +280,16 @@ protected:
      */
     virtual ~RenderState();
 
+    /**
+     * Static initializer that is called during game startup.
+     */
+    static void initialize();
+
+    /**
+     * Static finalizer that is called during game shutdown.
+     */
+    static void finalize();
+
     /**
      * Sets the node that this render state is bound to.
      *
@@ -311,8 +322,6 @@ protected:
     Node* _nodeBinding;
     mutable StateBlock* _state;
     RenderState* _parent;
-   
-    static StateBlock* _restoreState;
 };
 
 }

+ 37 - 7
gameplay/src/Scene.cpp

@@ -21,6 +21,19 @@ Scene::Scene(const Scene& copy)
 
 Scene::~Scene()
 {
+    // Unbind our active camera from the audio listener
+    if (_activeCamera)
+    {
+        AudioListener* audioListener = AudioListener::getInstance();
+        if (audioListener && (audioListener->getCamera() == _activeCamera))
+        {
+            audioListener->setCamera(NULL);
+        }
+
+        SAFE_RELEASE(_activeCamera);
+    }
+
+    // Remove all nodes from the scene
     removeAllNodes();
 }
 
@@ -116,6 +129,14 @@ void Scene::addNode(Node* node)
 {
     assert(node);
 
+    if (node->_scene == this)
+    {
+        // The node is already a member of this scene.
+        return;
+    }
+
+    node->addRef();
+
     // If the node is part of another scene, remove it.
     if (node->_scene && node->_scene != this)
     {
@@ -125,7 +146,7 @@ void Scene::addNode(Node* node)
     // If the node is part of another node hierarchy, remove it.
     if (node->getParent())
     {
-        node->remove();
+        node->getParent()->removeChild(node);
     }
 
     // Link the new node into our list.
@@ -142,8 +163,6 @@ void Scene::addNode(Node* node)
 
     node->_scene = this;
 
-    node->addRef();
-
     ++_nodeCount;
 
     // If we don't have an active camera set, then check for one and set it.
@@ -164,9 +183,6 @@ void Scene::removeNode(Node* node)
     if (node->_scene != this)
         return;
 
-    node->remove();
-    node->_scene = NULL;
-
     if (node == _firstNode)
     {
         _firstNode = node->_nextSibling;
@@ -176,6 +192,9 @@ void Scene::removeNode(Node* node)
         _lastNode = node->_prevSibling;
     }
 
+    node->remove();
+    node->_scene = NULL;
+
     SAFE_RELEASE(node);
 
     --_nodeCount;
@@ -209,16 +228,26 @@ void Scene::setActiveCamera(Camera* camera)
     // Make sure we don't release the camera if the same camera is set twice.
     if (_activeCamera != camera)
     {
+        AudioListener* audioListener = AudioListener::getInstance();
+
         if (_activeCamera)
         {
+            // Unbind the active camera from the audio listener
+            if (audioListener && (audioListener->getCamera() == _activeCamera))
+            {
+                AudioListener::getInstance()->setCamera(NULL);
+            }
+
             SAFE_RELEASE(_activeCamera);
         }
 
         _activeCamera = camera;
+
         if (_activeCamera)
         {
             _activeCamera->addRef();
-            if (_bindAudioListenerToCamera && AudioListener::getInstance())
+
+            if (audioListener && _bindAudioListenerToCamera)
             {
                 AudioListener::getInstance()->setCamera(_activeCamera);
             }
@@ -231,6 +260,7 @@ void Scene::bindAudioListenerToCamera(bool bind)
     if (_bindAudioListenerToCamera != bind)
     {
         _bindAudioListenerToCamera = bind;
+
         if (AudioListener::getInstance())
         {
             AudioListener::getInstance()->setCamera(bind ? _activeCamera : NULL);

+ 8 - 8
gameplay/src/Vector2.cpp

@@ -39,26 +39,26 @@ Vector2::~Vector2()
 
 const Vector2& Vector2::zero()
 {
-    static Vector2* value = new Vector2(0.0f, 0.0f);
-    return *value;
+    static Vector2 value(0.0f, 0.0f);
+    return value;
 }
 
 const Vector2& Vector2::one()
 {
-    static Vector2* value = new Vector2(1.0f, 1.0f);
-    return *value;
+    static Vector2 value(1.0f, 1.0f);
+    return value;
 }
 
 const Vector2& Vector2::unitX()
 {
-    static Vector2* value = new Vector2(1.0f, 0.0f);
-    return *value;
+    static Vector2 value(1.0f, 0.0f);
+    return value;
 }
 
 const Vector2& Vector2::unitY()
 {
-    static Vector2* value = new Vector2(0.0f, 1.0f);
-    return *value;
+    static Vector2 value(0.0f, 1.0f);
+    return value;
 }
 
 bool Vector2::isZero() const

+ 12 - 12
gameplay/src/Vector4.cpp

@@ -54,38 +54,38 @@ Vector4::~Vector4()
 
 const Vector4& Vector4::zero()
 {
-    static Vector4* value = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
-    return *value;
+    static Vector4 value(0.0f, 0.0f, 0.0f, 0.0f);
+    return value;
 }
 
 const Vector4& Vector4::one()
 {
-    static Vector4* value = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
-    return *value;
+    static Vector4 value(1.0f, 1.0f, 1.0f, 1.0f);
+    return value;
 }
 
 const Vector4& Vector4::unitX()
 {
-    static Vector4* value = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
-    return *value;
+    static Vector4 value(1.0f, 0.0f, 0.0f, 0.0f);
+    return value;
 }
 
 const Vector4& Vector4::unitY()
 {
-    static Vector4* value = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
-    return *value;
+    static Vector4 value(0.0f, 1.0f, 0.0f, 0.0f);
+    return value;
 }
 
 const Vector4& Vector4::unitZ()
 {
-    static Vector4* value = new Vector4(0.0f, 0.0f, 1.0f, 0.0f);
-    return *value;
+    static Vector4 value(0.0f, 0.0f, 1.0f, 0.0f);
+    return value;
 }
 
 const Vector4& Vector4::unitW()
 {
-    static Vector4* value = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
-    return *value;
+    static Vector4 value(0.0f, 0.0f, 0.0f, 1.0f);
+    return value;
 }
 
 bool Vector4::isZero() const

+ 3 - 1
gameplay/src/gameplay-main-qnx.cpp

@@ -15,7 +15,9 @@ int main(int argc, char** argv)
     Game* game = Game::getInstance();
     assert(game != NULL);
     Platform* platform = Platform::create(game);
-    return platform->enterMessagePump();
+    int result = platform->enterMessagePump();
+    delete platform;
+    return result;
 }
 
 #endif

+ 3 - 1
gameplay/src/gameplay-main-win32.cpp

@@ -22,7 +22,9 @@ extern "C" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LP
     Game* game = Game::getInstance();
     assert(game != NULL);
     Platform* platform = Platform::create(game);
-    return platform->enterMessagePump();
+    int result = platform->enterMessagePump();
+    delete platform;
+    return result;
 }