Преглед изворни кода

Added a way to add basic 3D primitives to the scene
Documentation

BearishSun пре 10 година
родитељ
комит
d8d5034b30

+ 2 - 2
BansheeEditor/Include/BsPlatformInfo.h

@@ -22,8 +22,8 @@ namespace BansheeEngine
 		PlatformInfo();
 		PlatformInfo();
 		virtual ~PlatformInfo();
 		virtual ~PlatformInfo();
 
 
-		PlatformType type;
-		WString defines;
+		PlatformType type; /**< Type of platform this object contains data for. */
+		WString defines; /**< A set of semicolon separated defines to use when compiling scripts for this platform. */
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								RTTI		                     		*/
 		/* 								RTTI		                     		*/

+ 1 - 1
BansheeEditor/Include/BsSceneViewHandler.h

@@ -43,7 +43,7 @@ namespace BansheeEngine
 		void trySelectHandle(const Vector2I& position);
 		void trySelectHandle(const Vector2I& position);
 
 
 		/**
 		/**
-		 * @brief	Is any handle currently active.
+		 * @brief	Checks is any handle currently active.
 		 */
 		 */
 		bool isHandleActive() const;
 		bool isHandleActive() const;
 
 

+ 26 - 0
BansheeEngine/Include/BsBuiltinResources.h

@@ -9,6 +9,14 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/**
+	 * @brief	Types of builtin meshes that are always available in the engine.
+	 */
+	enum class BuiltinMesh
+	{
+		Box, Sphere, Cone, Quad, Disc
+	};
+
 	/**
 	/**
 	 * @brief	Holds references to built-in resources used by the core engine.
 	 * @brief	Holds references to built-in resources used by the core engine.
 	 */
 	 */
@@ -108,11 +116,17 @@ namespace BansheeEngine
 		 */
 		 */
 		HMaterial createDummyMaterial() const;
 		HMaterial createDummyMaterial() const;
 
 
+		/**
+		 * @brief	Retrieves one of the builtin meshes.
+		 */
+		HMesh getMesh(BuiltinMesh mesh) const;
+
 		static const Path BuiltinDataFolder;
 		static const Path BuiltinDataFolder;
 		static const Path EngineSkinFolder;
 		static const Path EngineSkinFolder;
 		static const Path EngineCursorFolder;
 		static const Path EngineCursorFolder;
 		static const Path EngineShaderFolder;
 		static const Path EngineShaderFolder;
 		static const Path EngineShaderIncludeFolder;
 		static const Path EngineShaderIncludeFolder;
+		static const Path EngineMeshFolder;
 
 
 	private:
 	private:
 		/**
 		/**
@@ -128,6 +142,11 @@ namespace BansheeEngine
 		 */
 		 */
 		HGUISkin generateGUISkin();
 		HGUISkin generateGUISkin();
 
 
+		/**
+		 * @brief	Generates the builtin meshes.
+		 */
+		void generateMeshes();
+
 		/**
 		/**
 		 * @brief	Loads a GUI skin texture with the specified filename.
 		 * @brief	Loads a GUI skin texture with the specified filename.
 		 */
 		 */
@@ -176,6 +195,7 @@ namespace BansheeEngine
 		static const Path ShaderFolder;
 		static const Path ShaderFolder;
 		static const Path ShaderIncludeFolder;
 		static const Path ShaderIncludeFolder;
 		static const Path SkinFolder;
 		static const Path SkinFolder;
+		static const Path MeshFolder;
 
 
 		static const Path ResourceManifestPath;
 		static const Path ResourceManifestPath;
 
 
@@ -277,6 +297,12 @@ namespace BansheeEngine
 		static const WString ShaderSpriteImageNoAlphaFile;
 		static const WString ShaderSpriteImageNoAlphaFile;
 		static const WString ShaderDiffuseFile;
 		static const WString ShaderDiffuseFile;
 		static const WString ShaderDummyFile;
 		static const WString ShaderDummyFile;
+
+		static const WString MeshSphereFile;
+		static const WString MeshBoxFile;
+		static const WString MeshConeFile;
+		static const WString MeshQuadFile;
+		static const WString MeshDiscFile;
 	};
 	};
 
 
 	/**
 	/**

+ 20 - 0
BansheeEngine/Include/BsShapeMeshes3D.h

@@ -335,6 +335,16 @@ namespace BansheeEngine
 		static void antialiasedLineList(const Vector<Vector3>& linePoints, const Vector3& up, float width, float borderWidth,
 		static void antialiasedLineList(const Vector<Vector3>& linePoints, const Vector3& up, float width, float borderWidth,
 			const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 			const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 
+		/**
+		 * @brief	Calculates number of vertices and indices required for geometry of a solid axis aligned box.
+		 */
+		static void getNumElementsAABox(UINT32& numVertices, UINT32& numIndices);
+
+		/**
+		 * @brief	Calculates number of vertices and indices required for geometry of a wireframe axis aligned box.
+		 */
+		static void getNumElementsWireAABox(UINT32& numVertices, UINT32& numIndices);
+
 		/**
 		/**
 		 * @brief	Calculates number of vertices and indices required for geometry of a solid sphere
 		 * @brief	Calculates number of vertices and indices required for geometry of a solid sphere
 		 *			of the specified quality.
 		 *			of the specified quality.
@@ -377,6 +387,16 @@ namespace BansheeEngine
 		 */
 		 */
 		static void getNumElementsCone(UINT32 quality, UINT32& numVertices, UINT32& numIndices);
 		static void getNumElementsCone(UINT32 quality, UINT32& numVertices, UINT32& numIndices);
 
 
+		/**
+		 * @brief	Calculates number of vertices and indices required for geometry of a frustum.
+		 */
+		static void getNumElementsFrustum(UINT32& numVertices, UINT32& numIndices);
+
+		/**
+		 * @brief	Calculates number of vertices and indices required for geometry of a quadrirateral.
+		 */
+		static void getNumElementsQuad(UINT32& numVertices, UINT32& numIndices);
+
 		static const UINT32 NUM_VERTICES_AA_LINE;
 		static const UINT32 NUM_VERTICES_AA_LINE;
 		static const UINT32 NUM_INDICES_AA_LINE;
 		static const UINT32 NUM_INDICES_AA_LINE;
 
 

+ 121 - 1
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -29,7 +29,9 @@
 #include "BsDataStream.h"
 #include "BsDataStream.h"
 #include "BsTime.h"
 #include "BsTime.h"
 #include "BsResourceManifest.h"
 #include "BsResourceManifest.h"
-#include "../../BansheeEditor/Include/BsBuiltinEditorResources.h"
+#include "BsVertexDataDesc.h"
+#include "BsShapeMeshes3D.h"
+#include "BsMesh.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -45,6 +47,7 @@ namespace BansheeEngine
 	const Path BuiltinResources::ShaderFolder = L"Shaders\\";
 	const Path BuiltinResources::ShaderFolder = L"Shaders\\";
 	const Path BuiltinResources::SkinFolder = L"Skin\\";
 	const Path BuiltinResources::SkinFolder = L"Skin\\";
 	const Path BuiltinResources::ShaderIncludeFolder = L"Includes\\";
 	const Path BuiltinResources::ShaderIncludeFolder = L"Includes\\";
+	const Path BuiltinResources::MeshFolder = L"Meshes\\";
 
 
 	const Path BuiltinResources::BuiltinRawDataFolder = RUNTIME_DATA_PATH + L"Raw\\Engine\\";
 	const Path BuiltinResources::BuiltinRawDataFolder = RUNTIME_DATA_PATH + L"Raw\\Engine\\";
 	const Path BuiltinResources::EngineRawSkinFolder = BuiltinRawDataFolder + SkinFolder;
 	const Path BuiltinResources::EngineRawSkinFolder = BuiltinRawDataFolder + SkinFolder;
@@ -57,6 +60,7 @@ namespace BansheeEngine
 	const Path BuiltinResources::EngineCursorFolder = BuiltinDataFolder + CursorFolder;
 	const Path BuiltinResources::EngineCursorFolder = BuiltinDataFolder + CursorFolder;
 	const Path BuiltinResources::EngineShaderFolder = BuiltinDataFolder + ShaderFolder;
 	const Path BuiltinResources::EngineShaderFolder = BuiltinDataFolder + ShaderFolder;
 	const Path BuiltinResources::EngineShaderIncludeFolder = BuiltinDataFolder + ShaderIncludeFolder;
 	const Path BuiltinResources::EngineShaderIncludeFolder = BuiltinDataFolder + ShaderIncludeFolder;
+	const Path BuiltinResources::EngineMeshFolder = BuiltinDataFolder + MeshFolder;
 
 
 	const Path BuiltinResources::ResourceManifestPath = BuiltinDataFolder + "ResourceManifest.asset";
 	const Path BuiltinResources::ResourceManifestPath = BuiltinDataFolder + "ResourceManifest.asset";
 
 
@@ -164,6 +168,16 @@ namespace BansheeEngine
 	const WString BuiltinResources::ShaderDiffuseFile = L"Diffuse.bsl";
 	const WString BuiltinResources::ShaderDiffuseFile = L"Diffuse.bsl";
 	const WString BuiltinResources::ShaderDummyFile = L"Dummy.bsl";
 	const WString BuiltinResources::ShaderDummyFile = L"Dummy.bsl";
 
 
+	/************************************************************************/
+	/* 								MESHES							  		*/
+	/************************************************************************/
+
+	const WString BuiltinResources::MeshSphereFile = L"Sphere.asset";
+	const WString BuiltinResources::MeshBoxFile = L"Box.asset";
+	const WString BuiltinResources::MeshConeFile = L"Cone.asset";
+	const WString BuiltinResources::MeshQuadFile = L"Quad.asset";
+	const WString BuiltinResources::MeshDiscFile = L"Disc.asset";
+
 	BuiltinResources::~BuiltinResources()
 	BuiltinResources::~BuiltinResources()
 	{
 	{
 		mCursorArrow = nullptr;
 		mCursorArrow = nullptr;
@@ -268,6 +282,7 @@ namespace BansheeEngine
 		FileSystem::remove(EngineShaderIncludeFolder);
 		FileSystem::remove(EngineShaderIncludeFolder);
 		FileSystem::remove(EngineShaderFolder);
 		FileSystem::remove(EngineShaderFolder);
 		FileSystem::remove(EngineSkinFolder);
 		FileSystem::remove(EngineSkinFolder);
+		FileSystem::remove(EngineMeshFolder);
 
 
 		BuiltinResourcesHelper::importAssets(EngineRawCursorFolder, EngineCursorFolder, mResourceManifest);
 		BuiltinResourcesHelper::importAssets(EngineRawCursorFolder, EngineCursorFolder, mResourceManifest);
 		BuiltinResourcesHelper::importAssets(EngineRawShaderIncludeFolder, EngineShaderIncludeFolder, mResourceManifest); // Hidden dependency: Includes must be imported before shaders
 		BuiltinResourcesHelper::importAssets(EngineRawShaderIncludeFolder, EngineShaderIncludeFolder, mResourceManifest); // Hidden dependency: Includes must be imported before shaders
@@ -287,6 +302,9 @@ namespace BansheeEngine
 			Resources::instance().save(skin, outputPath, true);
 			Resources::instance().save(skin, outputPath, true);
 			mResourceManifest->registerResource(skin.getUUID(), outputPath);
 			mResourceManifest->registerResource(skin.getUUID(), outputPath);
 		}
 		}
+
+		// Generate & save meshes
+		generateMeshes();
 		
 		
 		Resources::instance().unloadAllUnused();
 		Resources::instance().unloadAllUnused();
 	}
 	}
@@ -699,6 +717,81 @@ namespace BansheeEngine
 		return skin;
 		return skin;
 	}
 	}
 
 
+	void BuiltinResources::generateMeshes()
+	{
+		VertexDataDescPtr vertexDesc = bs_shared_ptr_new<VertexDataDesc>();
+		vertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+		vertexDesc->addVertElem(VET_FLOAT3, VES_NORMAL);
+		vertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+
+		UINT32 boxNumVertices = 0;
+		UINT32 boxNumIndices = 0;
+		ShapeMeshes3D::getNumElementsAABox(boxNumVertices, boxNumIndices);
+		MeshDataPtr boxMeshData = bs_shared_ptr_new<MeshData>(boxNumVertices, boxNumIndices, vertexDesc);
+		AABox box(Vector3(-0.5f, -0.5f, -0.5f), Vector3(0.5f, 0.5f, 0.5f));
+
+		ShapeMeshes3D::solidAABox(box, boxMeshData, 0, 0);
+		HMesh boxMesh = Mesh::create(boxMeshData);
+
+		UINT32 sphereNumVertices = 0;
+		UINT32 sphereNumIndices = 0;
+		ShapeMeshes3D::getNumElementsSphere(1, sphereNumVertices, sphereNumIndices);
+		MeshDataPtr sphereMeshData = bs_shared_ptr_new<MeshData>(sphereNumVertices, sphereNumIndices, vertexDesc);
+
+		ShapeMeshes3D::solidSphere(Sphere(Vector3::ZERO, 0.0f), sphereMeshData, 0, 0);
+		HMesh sphereMesh = Mesh::create(sphereMeshData);
+
+		UINT32 coneNumVertices = 0;
+		UINT32 coneNumIndices = 0;
+		ShapeMeshes3D::getNumElementsCone(10, coneNumVertices, coneNumIndices);
+		MeshDataPtr coneMeshData = bs_shared_ptr_new<MeshData>(coneNumVertices, coneNumIndices, vertexDesc);
+
+		ShapeMeshes3D::solidCone(Vector3::ZERO, Vector3::UNIT_Y, 1.0f, 1.0f, coneMeshData, 0, 0);
+		HMesh coneMesh = Mesh::create(coneMeshData);
+
+		UINT32 quadNumVertices = 8;
+		UINT32 quadNumIndices = 12;
+		ShapeMeshes3D::getNumElementsQuad(quadNumVertices, quadNumIndices);
+		MeshDataPtr quadMeshData = bs_shared_ptr_new<MeshData>(quadNumVertices, quadNumIndices, vertexDesc);
+
+		std::array<Vector3, 2> axes = { Vector3::UNIT_X, Vector3::UNIT_Y };
+		std::array<float, 2> sizes = { 1.0f, 1.0f };
+		Rect3 rect(Vector3::ZERO, axes, sizes);
+		ShapeMeshes3D::solidQuad(rect, quadMeshData, 0, 0);
+		HMesh quadMesh = Mesh::create(quadMeshData);
+
+		UINT32 discNumVertices = 0;
+		UINT32 discNumIndices = 0;
+		ShapeMeshes3D::getNumElementsDisc(10, discNumVertices, discNumIndices);
+		MeshDataPtr discMeshData = bs_shared_ptr_new<MeshData>(discNumVertices, discNumIndices, vertexDesc);
+
+		ShapeMeshes3D::solidDisc(Vector3::ZERO, 1.0f, Vector3::UNIT_Y, discMeshData, 0, 0);
+		HMesh discMesh = Mesh::create(discMeshData);
+
+		// Save all meshes
+		Path outputDir = FileSystem::getWorkingDirectoryPath() + EngineMeshFolder;
+
+		Path meshPath = outputDir + MeshBoxFile;
+		Resources::instance().save(boxMesh, meshPath, true);
+		mResourceManifest->registerResource(boxMesh.getUUID(), meshPath);
+
+		Path spherePath = outputDir + MeshSphereFile;
+		Resources::instance().save(sphereMesh, spherePath, true);
+		mResourceManifest->registerResource(sphereMesh.getUUID(), spherePath);
+
+		Path conePath = outputDir + MeshConeFile;
+		Resources::instance().save(coneMesh, conePath, true);
+		mResourceManifest->registerResource(coneMesh.getUUID(), conePath);
+
+		Path quadPath = outputDir + MeshQuadFile;
+		Resources::instance().save(quadMesh, quadPath, true);
+		mResourceManifest->registerResource(quadMesh.getUUID(), quadPath);
+
+		Path discPath = outputDir + MeshDiscFile;
+		Resources::instance().save(discMesh, discPath, true);
+		mResourceManifest->registerResource(discMesh.getUUID(), discPath);
+	}
+
 	HSpriteTexture BuiltinResources::getSkinTexture(const WString& name)
 	HSpriteTexture BuiltinResources::getSkinTexture(const WString& name)
 	{
 	{
 		Path texturePath = FileSystem::getWorkingDirectoryPath();
 		Path texturePath = FileSystem::getWorkingDirectoryPath();
@@ -785,6 +878,33 @@ namespace BansheeEngine
 		return *mCursorArrowLeftRight.get();
 		return *mCursorArrowLeftRight.get();
 	}
 	}
 
 
+	HMesh BuiltinResources::getMesh(BuiltinMesh mesh) const
+	{
+		Path meshPath = FileSystem::getWorkingDirectoryPath();
+		meshPath.append(EngineMeshFolder);
+
+		switch (mesh)
+		{
+		case BuiltinMesh::Box:
+			meshPath.append(MeshBoxFile);
+			break;
+		case BuiltinMesh::Sphere:
+			meshPath.append(MeshSphereFile);
+			break;
+		case BuiltinMesh::Cone:
+			meshPath.append(MeshConeFile);
+			break;
+		case BuiltinMesh::Quad:
+			meshPath.append(MeshQuadFile);
+			break;
+		case BuiltinMesh::Disc:
+			meshPath.append(MeshDiscFile);
+			break;
+		}
+
+		return Resources::instance().load<Mesh>(meshPath);
+	}
+
 	GUIMaterialInfo BuiltinResources::createSpriteTextMaterial() const
 	GUIMaterialInfo BuiltinResources::createSpriteTextMaterial() const
 	{
 	{
 		GUIMaterialInfo info;
 		GUIMaterialInfo info;

+ 8 - 8
BansheeEngine/Source/BsDrawHelper.cpp

@@ -265,8 +265,8 @@ namespace BansheeEngine
 			rawData.meshType = MeshType::Solid;
 			rawData.meshType = MeshType::Solid;
 			rawData.shapeType = ShapeType::Cube;
 			rawData.shapeType = ShapeType::Cube;
 			rawData.distance = shapeData.center.distance(reference);
 			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = 24;
-			rawData.numIndices = 36;
+
+			ShapeMeshes3D::getNumElementsAABox(rawData.numVertices, rawData.numIndices);
 			idx++;
 			idx++;
 		}
 		}
 
 
@@ -343,8 +343,8 @@ namespace BansheeEngine
 			rawData.meshType = MeshType::Solid;
 			rawData.meshType = MeshType::Solid;
 			rawData.shapeType = ShapeType::Rectangle;
 			rawData.shapeType = ShapeType::Rectangle;
 			rawData.distance = shapeData.center.distance(reference);
 			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = 8;
-			rawData.numIndices = 12;
+
+			ShapeMeshes3D::getNumElementsQuad(rawData.numVertices, rawData.numIndices);
 			idx++;
 			idx++;
 		}
 		}
 
 
@@ -357,8 +357,8 @@ namespace BansheeEngine
 			rawData.meshType = MeshType::Wire;
 			rawData.meshType = MeshType::Wire;
 			rawData.shapeType = ShapeType::WireCube;
 			rawData.shapeType = ShapeType::WireCube;
 			rawData.distance = shapeData.center.distance(reference);
 			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = 8;
-			rawData.numIndices = 24;
+
+			ShapeMeshes3D::getNumElementsWireAABox(rawData.numVertices, rawData.numIndices);
 			idx++;
 			idx++;
 		}
 		}
 
 
@@ -401,8 +401,8 @@ namespace BansheeEngine
 			rawData.meshType = MeshType::Wire;
 			rawData.meshType = MeshType::Wire;
 			rawData.shapeType = ShapeType::Frustum;
 			rawData.shapeType = ShapeType::Frustum;
 			rawData.distance = shapeData.center.distance(reference);
 			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = 8;
-			rawData.numIndices = 36;
+
+			ShapeMeshes3D::getNumElementsFrustum(rawData.numVertices, rawData.numIndices);
 			idx++;
 			idx++;
 		}
 		}
 
 

+ 5 - 0
BansheeEngine/Source/BsRenderQueue.cpp

@@ -83,6 +83,11 @@ namespace BansheeEngine
 			break;
 			break;
 		}
 		}
 
 
+		if (mSortableElementIdx.size() > 1)
+		{
+			int a = 5;
+		}
+
 		// Sort only indices since we generate an entirely new data set anyway, it doesn't make sense to move sortable elements
 		// Sort only indices since we generate an entirely new data set anyway, it doesn't make sense to move sortable elements
 		std::sort(mSortableElementIdx.begin(), mSortableElementIdx.end(), std::bind(sortMethod, _1, _2, mSortableElements));
 		std::sort(mSortableElementIdx.begin(), mSortableElementIdx.end(), std::bind(sortMethod, _1, _2, mSortableElements));
 
 

+ 24 - 0
BansheeEngine/Source/BsShapeMeshes3D.cpp

@@ -254,6 +254,18 @@ namespace BansheeEngine
 	/* 								ELEMENT COUNT                      		*/
 	/* 								ELEMENT COUNT                      		*/
 	/************************************************************************/
 	/************************************************************************/
 
 
+	void ShapeMeshes3D::getNumElementsAABox(UINT32& numVertices, UINT32& numIndices)
+	{
+		numVertices = 24;
+		numIndices = 36;
+	}
+
+	void ShapeMeshes3D::getNumElementsWireAABox(UINT32& numVertices, UINT32& numIndices)
+	{
+		numVertices = 8;
+		numIndices = 24;
+	}
+
 	void ShapeMeshes3D::getNumElementsSphere(UINT32 quality, UINT32& numVertices, UINT32& numIndices)
 	void ShapeMeshes3D::getNumElementsSphere(UINT32 quality, UINT32& numVertices, UINT32& numIndices)
 	{
 	{
 		numVertices = 20 * (4 * ((UINT32)std::pow(3, quality)));
 		numVertices = 20 * (4 * ((UINT32)std::pow(3, quality)));
@@ -295,6 +307,18 @@ namespace BansheeEngine
 		numIndices = ((quality + 1) * 4) * 6;
 		numIndices = ((quality + 1) * 4) * 6;
 	}
 	}
 
 
+	void ShapeMeshes3D::getNumElementsQuad(UINT32& numVertices, UINT32& numIndices)
+	{
+		numVertices = 8;
+		numIndices = 12;
+	}
+
+	void ShapeMeshes3D::getNumElementsFrustum(UINT32& numVertices, UINT32& numIndices)
+	{
+		numVertices = 8;
+		numIndices = 36;
+	}
+
 	void ShapeMeshes3D::wireAABox(const AABox& box, UINT8* outVertices, UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
 	void ShapeMeshes3D::wireAABox(const AABox& box, UINT8* outVertices, UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
 	{
 	{
 		outVertices += vertexOffset * vertexStride;
 		outVertices += vertexOffset * vertexStride;

+ 29 - 3
MBansheeEditor/BrowseDialog.cs

@@ -8,18 +8,44 @@ using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
+    /// <summary>
+    /// Contains methods for opening various OS-specific browse, open and save file/folder dialogs.
+    /// </summary>
     public static class BrowseDialog
     public static class BrowseDialog
     {
     {
+        /// <summary>
+        /// Displays a platform specific dialog that allows the user to select file(s).
+        /// </summary>
+        /// <param name="defaultPath">Default path the dialog should point to.</param>
+        /// <param name="filterList">Semi-colon separated list of file names or types to display in the dialog, 
+        ///                          e.g. "exe;txt;png".</param>
+        /// <param name="allowMultiselect">True if user is allowed to select multiple files.</param>
+        /// <param name="outPaths">A list of file paths selected by the user.</param>
+        /// <returns>True if the user selected the file(s), false if the user canceled out of the dialog.</returns>
         public static bool OpenFile(string defaultPath, string filterList, bool allowMultiselect, out string[] outPaths)
         public static bool OpenFile(string defaultPath, string filterList, bool allowMultiselect, out string[] outPaths)
         {
         {
             return Internal_OpenFile(defaultPath, filterList, allowMultiselect, out outPaths);
             return Internal_OpenFile(defaultPath, filterList, allowMultiselect, out outPaths);
         }
         }
 
 
-        public static bool OpenFolder(string defaultPath, string filterList, out string outPath)
+        /// <summary>
+        /// Displays a platform specific dialog that allows the user to select a folder.
+        /// </summary>
+        /// <param name="defaultPath">Default path the dialog should point to.</param>
+        /// <param name="outPath">Path to the selected folder.</param>
+        /// <returns>True if the user selected the folder, false if the user canceled out of the dialog.</returns>
+        public static bool OpenFolder(string defaultPath, out string outPath)
         {
         {
-            return Internal_OpenFolder(defaultPath, filterList, out outPath);
+            return Internal_OpenFolder(defaultPath, out outPath);
         }
         }
 
 
+        /// <summary>
+        /// Displays a platform specific dialog that allows the user to select where to save a file.
+        /// </summary>
+        /// <param name="defaultPath">Default path the dialog should point to.</param>
+        /// <param name="filterList">Semi-colon separated list of file names or types to display in the dialog,
+        ///                          e.g. "exe;txt;png".</param>
+        /// <param name="outPath">File path selected by the user.</param>
+        /// <returns>True if the user selected the file, false if the user canceled out of the dialog.</returns>
         public static bool SaveFile(string defaultPath, string filterList, out string outPath)
         public static bool SaveFile(string defaultPath, string filterList, out string outPath)
         {
         {
             return Internal_SaveFile(defaultPath, filterList, out outPath);
             return Internal_SaveFile(defaultPath, filterList, out outPath);
@@ -29,7 +55,7 @@ namespace BansheeEditor
         private static extern bool Internal_OpenFile(string defaultPath, string filterList, bool allowMultiselect, out string[] outPaths);
         private static extern bool Internal_OpenFile(string defaultPath, string filterList, bool allowMultiselect, out string[] outPaths);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern bool Internal_OpenFolder(string defaultPath, string filterList, out string outPath);
+        private static extern bool Internal_OpenFolder(string defaultPath, out string outPath);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern bool Internal_SaveFile(string defaultPath, string filterList, out string outPath);
         private static extern bool Internal_SaveFile(string defaultPath, string filterList, out string outPath);

+ 72 - 2
MBansheeEditor/BuildManager.cs

@@ -4,23 +4,37 @@ using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
-    // Note: Must match C++ enum PlatformType
-    public enum PlatformType
+    /// <summary>
+    /// Contains a list of valid platforms that can be built for.
+    /// </summary>
+    public enum PlatformType // Note: Must match C++ enum PlatformType
     {
     {
         Windows,
         Windows,
         Count // Keep at end
         Count // Keep at end
     }
     }
 
 
+    /// <summary>
+    /// Contains build data for a specific platform.
+    /// </summary>
     public abstract class PlatformInfo : ScriptObject
     public abstract class PlatformInfo : ScriptObject
     {
     {
+        /// <summary>
+        /// Creates a new platform info. For internal runtime use only.
+        /// </summary>
         protected PlatformInfo()
         protected PlatformInfo()
         { }
         { }
 
 
+        /// <summary>
+        /// Returns the platform that this object contains data for.
+        /// </summary>
         public PlatformType Type
         public PlatformType Type
         {
         {
             get { return Internal_GetType(mCachedPtr); }
             get { return Internal_GetType(mCachedPtr); }
         }
         }
 
 
+        /// <summary>
+        /// A set of semicolon separated defines to use when compiling scripts for this platform.
+        /// </summary>
         public string Defines
         public string Defines
         {
         {
             get { return Internal_GetDefines(mCachedPtr); }
             get { return Internal_GetDefines(mCachedPtr); }
@@ -37,6 +51,9 @@ namespace BansheeEditor
         private static extern void Internal_SetDefines(IntPtr thisPtr, string value);
         private static extern void Internal_SetDefines(IntPtr thisPtr, string value);
     }
     }
 
 
+    /// <summary>
+    /// Supported icon sizes for Windows platform.
+    /// </summary>
     public enum WinIconSizes
     public enum WinIconSizes
     {
     {
         Icon16 = 16,
         Icon16 = 16,
@@ -49,19 +66,35 @@ namespace BansheeEditor
         Icon256 = 256
         Icon256 = 256
     }
     }
 
 
+    /// <summary>
+    /// Platform data specific to Windows.
+    /// </summary>
     public class WinPlatformInfo : PlatformInfo
     public class WinPlatformInfo : PlatformInfo
     {
     {
+        /// <summary>
+        /// Determines should the executable be 32 or 64-bit.
+        /// </summary>
         public bool Is32Bit
         public bool Is32Bit
         {
         {
             get { return Internal_GetIs32Bit(mCachedPtr); }
             get { return Internal_GetIs32Bit(mCachedPtr); }
             set { Internal_SetIs32Bit(mCachedPtr, value); }
             set { Internal_SetIs32Bit(mCachedPtr, value); }
         }
         }
 
 
+        /// <summary>
+        /// Returns a texture of a specific icon size that will be added to the executable.
+        /// </summary>
+        /// <param name="size">Type of icon to retrieve the texture for.</param>
+        /// <returns>Texture for the specified icon size.</returns>
         public Texture2D GetIcon(WinIconSizes size)
         public Texture2D GetIcon(WinIconSizes size)
         {
         {
             return Internal_GetIcon(mCachedPtr, (int)size);
             return Internal_GetIcon(mCachedPtr, (int)size);
         }
         }
 
 
+        /// <summary>
+        /// Sets a texture of a specific icon size that will be added to the executable.
+        /// </summary>
+        /// <param name="size">Type of icon to set the texture for.</param>
+        /// <param name="texture">Texture for the specified icon size.</param>
         public void SetIcon(WinIconSizes size, Texture2D texture)
         public void SetIcon(WinIconSizes size, Texture2D texture)
         {
         {
             IntPtr texturePtr = IntPtr.Zero;
             IntPtr texturePtr = IntPtr.Zero;
@@ -84,44 +117,81 @@ namespace BansheeEditor
         private static extern void Internal_SetIcon(IntPtr thisPtr, int size, IntPtr texturePtr);
         private static extern void Internal_SetIcon(IntPtr thisPtr, int size, IntPtr texturePtr);
     }
     }
 
 
+    /// <summary>
+    /// Handles building of the game executable and packaging of all necessary resources, making the game be ready to ran
+    /// as a standalone product.
+    /// </summary>
     public static class BuildManager
     public static class BuildManager
     {
     {
+        /// <summary>
+        /// Returns a list of all available platforms that can be built for.
+        /// </summary>
         public static PlatformType[] AvailablePlatforms
         public static PlatformType[] AvailablePlatforms
         {
         {
             get { return Internal_GetAvailablePlatforms(); }
             get { return Internal_GetAvailablePlatforms(); }
         }
         }
 
 
+        /// <summary>
+        /// Returns the currently active platform.
+        /// </summary>
         public static PlatformType ActivePlatform
         public static PlatformType ActivePlatform
         {
         {
             get { return Internal_GetActivePlatform(); }
             get { return Internal_GetActivePlatform(); }
             set { Internal_SetActivePlatform(value); }
             set { Internal_SetActivePlatform(value); }
         }
         }
 
 
+        /// <summary>
+        /// Returns the data about the currently active platform.
+        /// </summary>
         public static PlatformInfo ActivePlatformInfo
         public static PlatformInfo ActivePlatformInfo
         {
         {
             get { return Internal_GetActivePlatformInfo(); }
             get { return Internal_GetActivePlatformInfo(); }
         }
         }
 
 
+        /// <summary>
+        /// Builds the executable and packages the game.
+        /// </summary>
         public static void Build()
         public static void Build()
         {
         {
             // TODO
             // TODO
         }
         }
 
 
+        /// <summary>
+        /// Returns a list of .NET framework managed assemblies to be included for the specified platform.
+        /// </summary>
+        /// <param name="type">Platform type to retrieve the list of assemblies for.</param>
+        /// <returns>A list of .NET framework managed assemblies that will be included with the build.</returns>
         internal static string[] GetFrameworkAssemblies(PlatformType type)
         internal static string[] GetFrameworkAssemblies(PlatformType type)
         {
         {
             return Internal_GetFrameworkAssemblies(type);
             return Internal_GetFrameworkAssemblies(type);
         }
         }
 
 
+        /// <summary>
+        /// Returns the location of the executable for the provided platform.
+        /// </summary>
+        /// <param name="type">Platform type to retrieve the executable location for.</param>
+        /// <returns>Path to the executable in the editor install folder.</returns>
         internal static string GetMainExecutable(PlatformType type)
         internal static string GetMainExecutable(PlatformType type)
         {
         {
             return Internal_GetMainExecutable(type);
             return Internal_GetMainExecutable(type);
         }
         }
 
 
+        /// <summary>
+        /// Returns a list of semicolon separated defines that will be used when compiling scripts for the specified 
+        /// platform.
+        /// </summary>
+        /// <param name="type">Platfrom type to retrieve the defines for.</param>
+        /// <returns>Semicolor separated defines that will be passed along to the script compiler.</returns>
         internal static string GetDefines(PlatformType type)
         internal static string GetDefines(PlatformType type)
         {
         {
             return Internal_GetDefines(type);
             return Internal_GetDefines(type);
         }
         }
 
 
+        /// <summary>
+        /// Returns an object containing all platform specific build data.
+        /// </summary>
+        /// <param name="type">Platform type to retrieve the data for.</param>
+        /// <returns>An object containing all platform specific build data</returns>
         internal static PlatformInfo GetPlatformInfo(PlatformType type)
         internal static PlatformInfo GetPlatformInfo(PlatformType type)
         {
         {
             return Internal_GetPlatformInfo(type);
             return Internal_GetPlatformInfo(type);

+ 1 - 107
MBansheeEditor/EditorApplication.cs

@@ -53,7 +53,7 @@ namespace BansheeEditor
 
 
         public static Camera SceneViewCamera
         public static Camera SceneViewCamera
         {
         {
-            get { return EditorWindow.GetWindow<SceneWindow>().GetCamera(); }
+            get { return EditorWindow.GetWindow<SceneWindow>().Camera; }
         }
         }
 
 
         public static EditorPlatformType EditorPlatform
         public static EditorPlatformType EditorPlatform
@@ -342,112 +342,6 @@ namespace BansheeEditor
                 continueUnload();
                 continueUnload();
         }
         }
 
 
-        [MenuItem("Components/Camera")]
-        private static void AddCamera()
-        {
-            SceneObject so = Selection.sceneObject;
-            if (so == null)
-                return;
-
-            UndoRedo.RecordSO(so, "Added a Camera component");
-            so.AddComponent<Camera>();
-        }
-
-        [MenuItem("Components/Renderable")]
-        private static void AddRenderable()
-        {
-            SceneObject so = Selection.sceneObject;
-            if (so == null)
-                return;
-
-            UndoRedo.RecordSO(so, "Added a Renderable component");
-            so.AddComponent<Renderable>();
-        }
-
-        [MenuItem("Components/Point light")]
-        private static void AddPointLight()
-        {
-            SceneObject so = Selection.sceneObject;
-            if (so == null)
-                return;
-
-            UndoRedo.RecordSO(so, "Added a Light component");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Point;
-        }
-
-        [MenuItem("Components/Spot light")]
-        private static void AddSpotLight()
-        {
-            SceneObject so = Selection.sceneObject;
-            if (so == null)
-                return;
-
-            UndoRedo.RecordSO(so, "Added a Light component");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Spot;
-        }
-
-        [MenuItem("Components/Directional light")]
-        private static void AddDirectionalLight()
-        {
-            SceneObject so = Selection.sceneObject;
-            if (so == null)
-                return;
-
-            UndoRedo.RecordSO(so, "Added a Light component");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Directional;
-        }
-
-        [MenuItem("Scene Objects/Camera")]
-        private static void AddCameraSO()
-        {
-            SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
-            so.AddComponent<Camera>();
-
-            Selection.sceneObject = so;
-        }
-
-        [MenuItem("Scene Objects/Renderable")]
-        private static void AddRenderableSO()
-        {
-            SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
-            so.AddComponent<Renderable>();
-
-            Selection.sceneObject = so;
-        }
-
-        [MenuItem("Scene Objects/Point light")]
-        private static void AddPointLightSO()
-        {
-            SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Point;
-
-            Selection.sceneObject = so;
-        }
-
-        [MenuItem("Scene Objects/Spot light")]
-        private static void AddSpotLightSO()
-        {
-            SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Spot;
-
-            Selection.sceneObject = so;
-        }
-
-        [MenuItem("Scene Objects/Directional light")]
-        private static void AddDirectionalLightSO()
-        {
-            SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
-            Light light = so.AddComponent<Light>();
-            light.Type = LightType.Directional;
-
-            Selection.sceneObject = so;
-        }
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern string Internal_GetProjectPath();
         private static extern string Internal_GetProjectPath();
 
 

+ 1 - 0
MBansheeEditor/MBansheeEditor.csproj

@@ -57,6 +57,7 @@
     <Compile Include="LibraryMenu.cs" />
     <Compile Include="LibraryMenu.cs" />
     <Compile Include="LibraryUtility.cs" />
     <Compile Include="LibraryUtility.cs" />
     <Compile Include="LocEdString.cs" />
     <Compile Include="LocEdString.cs" />
+    <Compile Include="MenuItems.cs" />
     <Compile Include="PrefabUtility.cs" />
     <Compile Include="PrefabUtility.cs" />
     <Compile Include="LibraryDropTarget.cs" />
     <Compile Include="LibraryDropTarget.cs" />
     <Compile Include="OSDropTarget.cs" />
     <Compile Include="OSDropTarget.cs" />

+ 171 - 0
MBansheeEditor/MenuItems.cs

@@ -0,0 +1,171 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Contains various menu item callbacks for the main editor menu bar.
+    /// </summary>
+    static class MenuItems
+    {
+        [MenuItem("Components/Camera", 50)]
+        private static void AddCamera()
+        {
+            SceneObject so = Selection.sceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, "Added a Camera component");
+            so.AddComponent<Camera>();
+        }
+
+        [MenuItem("Components/Renderable", 49)]
+        private static void AddRenderable()
+        {
+            SceneObject so = Selection.sceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, "Added a Renderable component");
+            so.AddComponent<Renderable>();
+        }
+
+        [MenuItem("Components/Point light", 48)]
+        private static void AddPointLight()
+        {
+            SceneObject so = Selection.sceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, "Added a Light component");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Point;
+        }
+
+        [MenuItem("Components/Spot light", 47)]
+        private static void AddSpotLight()
+        {
+            SceneObject so = Selection.sceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, "Added a Light component");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Spot;
+        }
+
+        [MenuItem("Components/Directional light", 46)]
+        private static void AddDirectionalLight()
+        {
+            SceneObject so = Selection.sceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, "Added a Light component");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Directional;
+        }
+
+        [MenuItem("Scene Objects/Camera", 50)]
+        private static void AddCameraSO()
+        {
+            SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
+            so.AddComponent<Camera>();
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/Renderable", 49)]
+        private static void AddRenderableSO()
+        {
+            SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
+            so.AddComponent<Renderable>();
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/Point light", 48)]
+        private static void AddPointLightSO()
+        {
+            SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Point;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/Spot light", 47)]
+        private static void AddSpotLightSO()
+        {
+            SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Spot;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/Directional light", 46)]
+        private static void AddDirectionalLightSO()
+        {
+            SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
+            Light light = so.AddComponent<Light>();
+            light.Type = LightType.Directional;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/3D primitives/Box", 100)]
+        private static void Add3DBox()
+        {
+            SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
+            Renderable renderable = so.AddComponent<Renderable>();
+            renderable.Mesh = Builtin.Box;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/3D primitives/Sphere", 99)]
+        private static void Add3DSphere()
+        {
+            SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
+            Renderable renderable = so.AddComponent<Renderable>();
+            renderable.Mesh = Builtin.Sphere;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/3D primitives/Cone", 98)]
+        private static void Add3DCone()
+        {
+            SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
+            Renderable renderable = so.AddComponent<Renderable>();
+            renderable.Mesh = Builtin.Cone;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/3D primitives/Quad", 97)]
+        private static void Add3DQuad()
+        {
+            SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
+            Renderable renderable = so.AddComponent<Renderable>();
+            renderable.Mesh = Builtin.Quad;
+
+            Selection.sceneObject = so;
+        }
+
+        [MenuItem("Scene Objects/3D primitives/Disc", 96)]
+        private static void Add3DDisc()
+        {
+            SceneObject so = UndoRedo.CreateSO("Disc", "Created a disc");
+            Renderable renderable = so.AddComponent<Renderable>();
+            renderable.Mesh = Builtin.Disc;
+
+            Selection.sceneObject = so;
+        }
+    }
+}

+ 3 - 0
MBansheeEditor/Scene/SceneCamera.cs

@@ -7,6 +7,9 @@ using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
+    /// <summary>
+    /// Handles camera movement in the scene view.
+    /// </summary>
     public class SceneCamera : Component
     public class SceneCamera : Component
     {
     {
         public const string MoveForwardBinding = "SceneForward";
         public const string MoveForwardBinding = "SceneForward";

+ 35 - 0
MBansheeEditor/Scene/SceneViewHandler.cs

@@ -8,43 +8,78 @@ using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
+    /// <summary>
+    /// Handles scene view handle interactions, object picking and gizmos.
+    /// </summary>
     internal sealed class SceneViewHandler : ScriptObject
     internal sealed class SceneViewHandler : ScriptObject
     {
     {
+        /// <summary>
+        /// Creates a new scene view handler.
+        /// </summary>
+        /// <param name="parent">Editor window in which the scene view is displayed.</param>
+        /// <param name="sceneCamera">Camera through which the scene view is displayed.</param>
         internal SceneViewHandler(EditorWindow parent, Camera sceneCamera)
         internal SceneViewHandler(EditorWindow parent, Camera sceneCamera)
         {
         {
             Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Native.GetCachedPtr());
             Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Native.GetCachedPtr());
         }
         }
 
 
+        /// <summary>
+        /// Called every frame. Updates gizmos and scene grid.
+        /// </summary>
         internal void Update()
         internal void Update()
         {
         {
             Internal_Update(mCachedPtr);
             Internal_Update(mCachedPtr);
         }
         }
 
 
+        /// <summary>
+        /// Updates currently active handles.
+        /// </summary>
+        /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
+        /// <param name="inputDelta">Movement of the pointer since last frame.</param>
         internal void UpdateHandle(Vector2I pointerPos, Vector2I inputDelta)
         internal void UpdateHandle(Vector2I pointerPos, Vector2I inputDelta)
         {
         {
             Internal_UpdateHandle(mCachedPtr, pointerPos, inputDelta);
             Internal_UpdateHandle(mCachedPtr, pointerPos, inputDelta);
         }
         }
 
 
+        /// <summary>
+        /// Updates the selection overlay for currently selected object(s).
+        /// </summary>
         internal void UpdateSelection()
         internal void UpdateSelection()
         {
         {
             Internal_UpdateSelection(mCachedPtr);
             Internal_UpdateSelection(mCachedPtr);
         }
         }
 
 
+        /// <summary>
+        /// Selects a handle under the pointer position.
+        /// </summary>
+        /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         internal void TrySelectHandle(Vector2I pointerPos)
         internal void TrySelectHandle(Vector2I pointerPos)
         {
         {
             Internal_TrySelectHandle(mCachedPtr, pointerPos);
             Internal_TrySelectHandle(mCachedPtr, pointerPos);
         }
         }
 
 
+        /// <summary>
+        /// Checks is any handle currently active.
+        /// </summary>
+        /// <returns>True if a handle is active.</returns>
         internal bool IsHandleActive()
         internal bool IsHandleActive()
         {
         {
             return Internal_IsHandleActive(mCachedPtr);
             return Internal_IsHandleActive(mCachedPtr);
         }
         }
 
 
+        /// <summary>
+        /// Deselects any currently active handles.
+        /// </summary>
         internal void ClearHandleSelection()
         internal void ClearHandleSelection()
         {
         {
             Internal_ClearHandleSelection(mCachedPtr);
             Internal_ClearHandleSelection(mCachedPtr);
         }
         }
 
 
+        /// <summary>
+        /// Attempts to select a scene object under the pointer position.
+        /// </summary>
+        /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
+        /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
         internal void PickObject(Vector2I pointerPos, bool controlHeld)
         internal void PickObject(Vector2I pointerPos, bool controlHeld)
         {
         {
             Internal_PickObject(mCachedPtr, pointerPos, controlHeld);
             Internal_PickObject(mCachedPtr, pointerPos, controlHeld);

+ 71 - 4
MBansheeEditor/Scene/SceneWindow.cs

@@ -8,6 +8,9 @@ using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
+    /// <summary>
+    /// Displays the scene view camera and various scene controls.
+    /// </summary>
     internal sealed class SceneWindow : EditorWindow
     internal sealed class SceneWindow : EditorWindow
     {
     {
         internal const string ToggleProfilerOverlayBinding = "ToggleProfilerOverlay";
         internal const string ToggleProfilerOverlayBinding = "ToggleProfilerOverlay";
@@ -66,20 +69,30 @@ namespace BansheeEditor
         private bool dragActive;
         private bool dragActive;
         private SceneObject draggedSO;
         private SceneObject draggedSO;
 
 
-        public Camera GetCamera()
+        /// <summary>
+        /// Returns the scene camera.
+        /// </summary>
+        public Camera Camera
         {
         {
-            return camera;
+            get { return camera; }
         }
         }
 
 
+        /// <summary>
+        /// Constructs a new scene window.
+        /// </summary>
         internal SceneWindow()
         internal SceneWindow()
         { }
         { }
 
 
+        /// <summary>
+        /// Opens a scene window if its not open already.
+        /// </summary>
         [MenuItem("Windows/Scene", ButtonModifier.CtrlAlt, ButtonCode.S)]
         [MenuItem("Windows/Scene", ButtonModifier.CtrlAlt, ButtonCode.S)]
         private static void OpenSceneWindow()
         private static void OpenSceneWindow()
         {
         {
             OpenWindow<SceneWindow>();
             OpenWindow<SceneWindow>();
         }
         }
 
 
+        /// <inheritdoc/>
         protected override LocString GetDisplayName()
         protected override LocString GetDisplayName()
         {
         {
             return new LocEdString("Scene");
             return new LocEdString("Scene");
@@ -163,7 +176,13 @@ namespace BansheeEditor
                 camera = null;
                 camera = null;
             }
             }
         }
         }
-
+        
+        /// <summary>
+        /// Converts screen coordinates into coordinates relative to the scene view render texture.
+        /// </summary>
+        /// <param name="screenPos">Coordinates relative to the screen.</param>
+        /// <param name="scenePos">Output coordinates relative to the scene view texture.</param>
+        /// <returns>True if the coordinates are within the scene view texture, false otherwise.</returns>
         private bool ScreenToScenePos(Vector2I screenPos, out Vector2I scenePos)
         private bool ScreenToScenePos(Vector2I screenPos, out Vector2I scenePos)
         {
         {
             scenePos = screenPos;
             scenePos = screenPos;
@@ -347,6 +366,7 @@ namespace BansheeEditor
             sceneViewHandler.UpdateSelection();
             sceneViewHandler.UpdateSelection();
         }
         }
 
 
+        /// <inheritdoc/>
         protected override void WindowResized(int width, int height)
         protected override void WindowResized(int width, int height)
         {
         {
             UpdateRenderTexture(width, height - HeaderHeight);
             UpdateRenderTexture(width, height - HeaderHeight);
@@ -354,6 +374,7 @@ namespace BansheeEditor
             base.WindowResized(width, height);
             base.WindowResized(width, height);
         }
         }
 
 
+        /// <inheritdoc/>
         protected override void FocusChanged(bool inFocus)
         protected override void FocusChanged(bool inFocus)
         {
         {
             if (!inFocus)
             if (!inFocus)
@@ -362,48 +383,80 @@ namespace BansheeEditor
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// Triggered when one of the scene tool buttons is clicked, changing the active scene handle.
+        /// </summary>
+        /// <param name="tool">Clicked scene tool to activate.</param>
         private void OnSceneToolButtonClicked(SceneViewTool tool)
         private void OnSceneToolButtonClicked(SceneViewTool tool)
         {
         {
             EditorApplication.ActiveSceneTool = tool;
             EditorApplication.ActiveSceneTool = tool;
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when one of the coordinate mode buttons is clicked, changing the active coordinate mode.
+        /// </summary>
+        /// <param name="mode">Clicked coordinate mode to activate.</param>
         private void OnCoordinateModeButtonClicked(HandleCoordinateMode mode)
         private void OnCoordinateModeButtonClicked(HandleCoordinateMode mode)
         {
         {
             EditorApplication.ActiveCoordinateMode = mode;
             EditorApplication.ActiveCoordinateMode = mode;
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when one of the pivot buttons is clicked, changing the active pivot mode.
+        /// </summary>
+        /// <param name="mode">Clicked pivot mode to activate.</param>
         private void OnPivotModeButtonClicked(HandlePivotMode mode)
         private void OnPivotModeButtonClicked(HandlePivotMode mode)
         {
         {
             EditorApplication.ActivePivotMode = mode;
             EditorApplication.ActivePivotMode = mode;
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when the move snap button is toggled.
+        /// </summary>
+        /// <param name="active">Determins should be move snap be activated or deactivated.</param>
         private void OnMoveSnapToggled(bool active)
         private void OnMoveSnapToggled(bool active)
         {
         {
             Handles.MoveHandleSnapActive = active;
             Handles.MoveHandleSnapActive = active;
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when the move snap increment value changes.
+        /// </summary>
+        /// <param name="value">Value that determines in what increments to perform move snapping.</param>
         private void OnMoveSnapValueChanged(float value)
         private void OnMoveSnapValueChanged(float value)
         {
         {
             Handles.MoveSnapAmount = MathEx.Clamp(value, 0.01f, 1000.0f);
             Handles.MoveSnapAmount = MathEx.Clamp(value, 0.01f, 1000.0f);
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when the rotate snap button is toggled.
+        /// </summary>
+        /// <param name="active">Determins should be rotate snap be activated or deactivated.</param>
         private void OnRotateSnapToggled(bool active)
         private void OnRotateSnapToggled(bool active)
         {
         {
             Handles.RotateHandleSnapActive = active;
             Handles.RotateHandleSnapActive = active;
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Triggered when the rotate snap increment value changes.
+        /// </summary>
+        /// <param name="value">Value that determines in what increments to perform rotate snapping.</param>
         private void OnRotateSnapValueChanged(float value)
         private void OnRotateSnapValueChanged(float value)
         {
         {
             Handles.RotateSnapAmount = MathEx.Clamp(value, 0.01f, 360.0f);
             Handles.RotateSnapAmount = MathEx.Clamp(value, 0.01f, 360.0f);
             editorSettingsHash = EditorSettings.Hash;
             editorSettingsHash = EditorSettings.Hash;
         }
         }
 
 
+        /// <summary>
+        /// Updates toggle button states according to current editor options. This is useful if tools, coordinate mode,
+        /// pivot or other scene view options have been modified externally.
+        /// </summary>
         private void UpdateButtonStates()
         private void UpdateButtonStates()
         {
         {
             switch (EditorApplication.ActiveSceneTool)
             switch (EditorApplication.ActiveSceneTool)
@@ -457,6 +510,9 @@ namespace BansheeEditor
             moveSnapInput.Value = Handles.RotateSnapAmount.Degrees;
             moveSnapInput.Value = Handles.RotateSnapAmount.Degrees;
         }
         }
 
 
+        /// <summary>
+        /// Activates or deactivates the profiler overlay according to current editor settings.
+        /// </summary>
         private void UpdateProfilerOverlay()
         private void UpdateProfilerOverlay()
         {
         {
             if (EditorSettings.GetBool(ProfilerOverlayActiveKey))
             if (EditorSettings.GetBool(ProfilerOverlayActiveKey))
@@ -484,6 +540,12 @@ namespace BansheeEditor
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// Creates the scene camera and updates the render texture. Should be called at least once before using the
+        /// scene view. Should be called whenver the window is resized.
+        /// </summary>
+        /// <param name="width">Width of the scene render target, in pixels.</param>
+        /// <param name="height">Height of the scene render target, in pixels.</param>
         private void UpdateRenderTexture(int width, int height)
         private void UpdateRenderTexture(int width, int height)
 	    {
 	    {
             width = MathEx.Max(20, width);
             width = MathEx.Max(20, width);
@@ -529,6 +591,11 @@ namespace BansheeEditor
                 profilerCamera.Target = renderTexture;
                 profilerCamera.Target = renderTexture;
 	    }
 	    }
 
 
+        /// <summary>
+        /// Parses an array of scene objects and removes elements that are children of elements that are also in the array.
+        /// </summary>
+        /// <param name="objects">Array containing duplicate objects as input, and array without duplicate objects as
+        ///                       output.</param>
         private void CleanDuplicates(ref SceneObject[] objects)
         private void CleanDuplicates(ref SceneObject[] objects)
 	    {
 	    {
 		    List<SceneObject> cleanList = new List<SceneObject>();
 		    List<SceneObject> cleanList = new List<SceneObject>();
@@ -542,7 +609,7 @@ namespace BansheeEditor
                     while (elem != null && elem != objects[j])
                     while (elem != null && elem != objects[j])
                         elem = objects[i].Parent;
                         elem = objects[i].Parent;
 
 
-                    bool isChildOf =  elem == objects[j];
+                    bool isChildOf = elem == objects[j];
 
 
 				    if (i != j && isChildOf)
 				    if (i != j && isChildOf)
 				    {
 				    {

+ 51 - 0
MBansheeEngine/Builtin.cs

@@ -7,6 +7,14 @@ namespace BansheeEngine
     /// </summary>
     /// </summary>
     public static class Builtin
     public static class Builtin
     {
     {
+        /// <summary>
+        /// Types of builtin meshes that are always available in the engine.
+        /// </summary>
+        private enum BuiltinMesh // Note: Must match C++ enum BuiltinMesh
+        {
+            Box, Sphere, Cone, Quad, Disc
+        }
+
         /// <summary>
         /// <summary>
         /// Returns a pure white texture.
         /// Returns a pure white texture.
         /// </summary>
         /// </summary>
@@ -23,10 +31,53 @@ namespace BansheeEngine
             get { return Internal_GetDiffuseShader(); }
             get { return Internal_GetDiffuseShader(); }
         }
         }
 
 
+        /// <summary>
+        /// Returns a axis aligned box of unit size.
+        /// </summary>
+        public static Mesh Box
+        {
+            get { return Internal_GetMesh(BuiltinMesh.Box); }
+        }
+
+        /// <summary>
+        /// Returns a unit sphere mesh.
+        /// </summary>
+        public static Mesh Sphere
+        {
+            get { return Internal_GetMesh(BuiltinMesh.Sphere); }
+        }
+
+        /// <summary>
+        /// Returns a cone mesh.
+        /// </summary>
+        public static Mesh Cone
+        {
+            get { return Internal_GetMesh(BuiltinMesh.Cone); }
+        }
+
+        /// <summary>
+        /// Returns a quad mesh with unit size edges.
+        /// </summary>
+        public static Mesh Quad
+        {
+            get { return Internal_GetMesh(BuiltinMesh.Quad); }
+        }
+
+        /// <summary>
+        /// Returns a disc mesh with unit radius.
+        /// </summary>
+        public static Mesh Disc
+        {
+            get { return Internal_GetMesh(BuiltinMesh.Disc); }
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern SpriteTexture Internal_GetWhiteTexture();
         private static extern SpriteTexture Internal_GetWhiteTexture();
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern Shader Internal_GetDiffuseShader();
         private static extern Shader Internal_GetDiffuseShader();
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Mesh Internal_GetMesh(BuiltinMesh mesh);
     }
     }
 }
 }

+ 1 - 1
SBansheeEditor/Include/BsScriptBrowseDialog.h

@@ -19,7 +19,7 @@ namespace BansheeEngine
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
 		/************************************************************************/
 		static bool internal_OpenFile(MonoString* defaultFolder, MonoString* filterList, bool allowMultiselect, MonoArray** outPaths);
 		static bool internal_OpenFile(MonoString* defaultFolder, MonoString* filterList, bool allowMultiselect, MonoArray** outPaths);
-		static bool internal_OpenFolder(MonoString* defaultFolder, MonoString* filterList, MonoString** outPath);
+		static bool internal_OpenFolder(MonoString* defaultFolder, MonoString** outPath);
 		static bool internal_SaveFile(MonoString* defaultFolder, MonoString* filterList, MonoString** outPath);
 		static bool internal_SaveFile(MonoString* defaultFolder, MonoString* filterList, MonoString** outPath);
 	};
 	};
 }
 }

+ 2 - 3
SBansheeEditor/Source/BsScriptBrowseDialog.cpp

@@ -44,15 +44,14 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	bool ScriptBrowseDialog::internal_OpenFolder(MonoString* defaultFolder, MonoString* filterList, MonoString** outPath)
+	bool ScriptBrowseDialog::internal_OpenFolder(MonoString* defaultFolder, MonoString** outPath)
 	{
 	{
 		Path defaultFolderNative = MonoUtil::monoToWString(defaultFolder);
 		Path defaultFolderNative = MonoUtil::monoToWString(defaultFolder);
-		WString filterListNative = MonoUtil::monoToWString(filterList);
 
 
 		FileDialogType type = FileDialogType::OpenFolder;
 		FileDialogType type = FileDialogType::OpenFolder;
 
 
 		Vector<Path> paths;
 		Vector<Path> paths;
-		if (Platform::openBrowseDialog(type, defaultFolderNative, filterListNative, paths))
+		if (Platform::openBrowseDialog(type, defaultFolderNative, L"", paths))
 		{
 		{
 			if (paths.size() > 0)
 			if (paths.size() > 0)
 				*outPath = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), paths[0].toWString());
 				*outPath = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), paths[0].toWString());

+ 2 - 0
SBansheeEngine/Include/BsScriptBuiltin.h

@@ -2,6 +2,7 @@
 
 
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptObject.h"
 #include "BsScriptObject.h"
+#include "BsBuiltinResources.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -21,5 +22,6 @@ namespace BansheeEngine
 		/************************************************************************/
 		/************************************************************************/
 		static MonoObject* internal_GetWhiteTexture();
 		static MonoObject* internal_GetWhiteTexture();
 		static MonoObject* internal_GetDiffuseShader();
 		static MonoObject* internal_GetDiffuseShader();
+		static MonoObject* internal_GetMesh(BuiltinMesh meshType);
 	};
 	};
 }
 }

+ 12 - 0
SBansheeEngine/Source/BsScriptBuiltin.cpp

@@ -6,6 +6,7 @@
 #include "BsBuiltinResources.h"
 #include "BsBuiltinResources.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptShader.h"
 #include "BsScriptShader.h"
+#include "BsScriptMesh.h"
 #include "BsScriptResourceManager.h"
 #include "BsScriptResourceManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -18,6 +19,7 @@ namespace BansheeEngine
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_GetWhiteTexture", &ScriptBuiltin::internal_GetWhiteTexture);
 		metaData.scriptClass->addInternalCall("Internal_GetWhiteTexture", &ScriptBuiltin::internal_GetWhiteTexture);
 		metaData.scriptClass->addInternalCall("Internal_GetDiffuseShader", &ScriptBuiltin::internal_GetDiffuseShader);
 		metaData.scriptClass->addInternalCall("Internal_GetDiffuseShader", &ScriptBuiltin::internal_GetDiffuseShader);
+		metaData.scriptClass->addInternalCall("Internal_GetMesh", &ScriptBuiltin::internal_GetMesh);
 	}
 	}
 
 
 	MonoObject* ScriptBuiltin::internal_GetWhiteTexture()
 	MonoObject* ScriptBuiltin::internal_GetWhiteTexture()
@@ -39,4 +41,14 @@ namespace BansheeEngine
 
 
 		return scriptShader->getManagedInstance();
 		return scriptShader->getManagedInstance();
 	}
 	}
+
+	MonoObject* ScriptBuiltin::internal_GetMesh(BuiltinMesh meshType)
+	{
+		HMesh mesh = BuiltinResources::instance().getMesh(meshType);
+
+		ScriptMesh* scriptMesh;
+		ScriptResourceManager::instance().getScriptResource(mesh, &scriptMesh, true);
+
+		return scriptMesh->getManagedInstance();
+	}
 }
 }

+ 2 - 0
TODO.txt

@@ -53,6 +53,8 @@ Code quality improvements:
 Polish
 Polish
 
 
 Ribek use:
 Ribek use:
+ - Test game object helper objects
+ - Render queue sorting methods are invalid
  - Hook up color picker to guicolor field
  - Hook up color picker to guicolor field
  - Test release mode
  - Test release mode