Преглед на файлове

Started work on C# camera
Matrix4.multiply3x4 renamed to Matrix4.multiplyAffine to be consistent with other math methods

Marko Pintera преди 11 години
родител
ревизия
fb655afe7f

+ 1 - 1
BansheeCore/Source/BsCameraProxy.cpp

@@ -8,7 +8,7 @@ namespace BansheeEngine
 		Vector<Plane> worldPlanes;
 		Vector<Plane> worldPlanes;
 		for (auto& plane : frustumPlanes)
 		for (auto& plane : frustumPlanes)
 		{
 		{
-			worldPlanes.push_back(worldMatrix.multiply3x4(plane));
+			worldPlanes.push_back(worldMatrix.multiplyAffine(plane));
 		}
 		}
 
 
 		worldFrustum = ConvexVolume(worldPlanes);
 		worldFrustum = ConvexVolume(worldPlanes);

+ 2 - 2
BansheeEditor/Source/BsDockManager.cpp

@@ -925,7 +925,7 @@ namespace BansheeEngine
 
 
 			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
 			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
 
 
-			Vector4 tfrmdPos = worldTfrm.multiply3x4(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
+			Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 
 
@@ -983,7 +983,7 @@ namespace BansheeEngine
 			const Vector2I& widgetRelPos = event.getPosition();
 			const Vector2I& widgetRelPos = event.getPosition();
 			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
 			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
 
 
-			Vector4 tfrmdPos = worldTfrm.multiply3x4(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
+			Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 
 

+ 1 - 1
BansheeEngine/Source/BsCamera.cpp

@@ -36,7 +36,7 @@ namespace BansheeEngine
 		UINT32 i = 0;
 		UINT32 i = 0;
 		for (auto& plane : frustumPlanes)
 		for (auto& plane : frustumPlanes)
 		{
 		{
-			worldPlanes[i] = worldMatrix.multiply3x4(plane);
+			worldPlanes[i] = worldMatrix.multiplyAffine(plane);
 			i++;
 			i++;
 		}
 		}
 
 

+ 3 - 3
BansheeEngine/Source/BsCameraHandler.cpp

@@ -115,7 +115,7 @@ namespace BansheeEngine
 		UINT32 i = 0;
 		UINT32 i = 0;
 		for (auto& plane : frustumPlanes)
 		for (auto& plane : frustumPlanes)
 		{
 		{
-			worldPlanes[i] = worldMatrix.multiply3x4(plane);
+			worldPlanes[i] = worldMatrix.multiplyAffine(plane);
 			i++;
 			i++;
 		}
 		}
 
 
@@ -512,7 +512,7 @@ namespace BansheeEngine
 
 
 	Vector3 CameraHandler::worldToViewPoint(const Vector3& worldPoint) const
 	Vector3 CameraHandler::worldToViewPoint(const Vector3& worldPoint) const
 	{
 	{
-		return getViewMatrix().multiply3x4(worldPoint);
+		return getViewMatrix().multiplyAffine(worldPoint);
 	}
 	}
 
 
 	Vector3 CameraHandler::screenToWorldPoint(const Vector2I& screenPoint) const
 	Vector3 CameraHandler::screenToWorldPoint(const Vector2I& screenPoint) const
@@ -538,7 +538,7 @@ namespace BansheeEngine
 
 
 	Vector3 CameraHandler::viewToWorldPoint(const Vector3& viewPoint) const
 	Vector3 CameraHandler::viewToWorldPoint(const Vector3& viewPoint) const
 	{
 	{
-		return getViewMatrix().inverseAffine().multiply3x4(viewPoint);
+		return getViewMatrix().inverseAffine().multiplyAffine(viewPoint);
 	}
 	}
 
 
 	Vector2I CameraHandler::viewToScreenPoint(const Vector3& viewPoint) const
 	Vector2I CameraHandler::viewToScreenPoint(const Vector3& viewPoint) const

+ 15 - 15
BansheeEngine/Source/BsDrawHelper.cpp

@@ -52,7 +52,7 @@ namespace BansheeEngine
 		cubeData.extents = extents;
 		cubeData.extents = extents;
 		cubeData.color = mColor;
 		cubeData.color = mColor;
 		cubeData.transform = mTransform;
 		cubeData.transform = mTransform;
-		cubeData.center = mTransform.multiply3x4(position);
+		cubeData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::sphere(const Vector3& position, float radius, UINT32 quality)
 	void DrawHelper::sphere(const Vector3& position, float radius, UINT32 quality)
@@ -65,7 +65,7 @@ namespace BansheeEngine
 		sphereData.quality = quality;
 		sphereData.quality = quality;
 		sphereData.color = mColor;
 		sphereData.color = mColor;
 		sphereData.transform = mTransform;
 		sphereData.transform = mTransform;
-		sphereData.center = mTransform.multiply3x4(position);
+		sphereData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::wireCube(const Vector3& position, const Vector3& extents)
 	void DrawHelper::wireCube(const Vector3& position, const Vector3& extents)
@@ -77,7 +77,7 @@ namespace BansheeEngine
 		cubeData.extents = extents;
 		cubeData.extents = extents;
 		cubeData.color = mColor;
 		cubeData.color = mColor;
 		cubeData.transform = mTransform;
 		cubeData.transform = mTransform;
-		cubeData.center = mTransform.multiply3x4(position);
+		cubeData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::wireSphere(const Vector3& position, float radius, UINT32 quality)
 	void DrawHelper::wireSphere(const Vector3& position, float radius, UINT32 quality)
@@ -90,7 +90,7 @@ namespace BansheeEngine
 		sphereData.quality = quality;
 		sphereData.quality = quality;
 		sphereData.color = mColor;
 		sphereData.color = mColor;
 		sphereData.transform = mTransform;
 		sphereData.transform = mTransform;
-		sphereData.center = mTransform.multiply3x4(position);
+		sphereData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::line(const Vector3& start, const Vector3& end)
 	void DrawHelper::line(const Vector3& start, const Vector3& end)
@@ -102,7 +102,7 @@ namespace BansheeEngine
 		lineData.end = end;
 		lineData.end = end;
 		lineData.color = mColor;
 		lineData.color = mColor;
 		lineData.transform = mTransform;
 		lineData.transform = mTransform;
-		lineData.center = mTransform.multiply3x4((start + end) * 0.5f);
+		lineData.center = mTransform.multiplyAffine((start + end) * 0.5f);
 	}
 	}
 
 
 	void DrawHelper::frustum(const Vector3& position, float aspect, Degree FOV, float near, float far)
 	void DrawHelper::frustum(const Vector3& position, float aspect, Degree FOV, float near, float far)
@@ -117,7 +117,7 @@ namespace BansheeEngine
 		frustumData.far = far;
 		frustumData.far = far;
 		frustumData.color = mColor;
 		frustumData.color = mColor;
 		frustumData.transform = mTransform;
 		frustumData.transform = mTransform;
-		frustumData.center = mTransform.multiply3x4(position);
+		frustumData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality)
 	void DrawHelper::cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality)
@@ -132,7 +132,7 @@ namespace BansheeEngine
 		coneData.quality = quality;
 		coneData.quality = quality;
 		coneData.color = mColor;
 		coneData.color = mColor;
 		coneData.transform = mTransform;
 		coneData.transform = mTransform;
-		coneData.center = mTransform.multiply3x4(base + normal * height * 0.5f);
+		coneData.center = mTransform.multiplyAffine(base + normal * height * 0.5f);
 	}
 	}
 
 
 	void DrawHelper::disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
 	void DrawHelper::disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
@@ -146,7 +146,7 @@ namespace BansheeEngine
 		discData.quality = quality;
 		discData.quality = quality;
 		discData.color = mColor;
 		discData.color = mColor;
 		discData.transform = mTransform;
 		discData.transform = mTransform;
-		discData.center = mTransform.multiply3x4(position);
+		discData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
 	void DrawHelper::wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
@@ -160,7 +160,7 @@ namespace BansheeEngine
 		discData.quality = quality;
 		discData.quality = quality;
 		discData.color = mColor;
 		discData.color = mColor;
 		discData.transform = mTransform;
 		discData.transform = mTransform;
-		discData.center = mTransform.multiply3x4(position);
+		discData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::arc(const Vector3& position, const Vector3& normal, float radius, 
 	void DrawHelper::arc(const Vector3& position, const Vector3& normal, float radius, 
@@ -177,7 +177,7 @@ namespace BansheeEngine
 		arcData.quality = quality;
 		arcData.quality = quality;
 		arcData.color = mColor;
 		arcData.color = mColor;
 		arcData.transform = mTransform;
 		arcData.transform = mTransform;
-		arcData.center = mTransform.multiply3x4(position);
+		arcData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::wireArc(const Vector3& position, const Vector3& normal, float radius, 
 	void DrawHelper::wireArc(const Vector3& position, const Vector3& normal, float radius, 
@@ -194,7 +194,7 @@ namespace BansheeEngine
 		arcData.quality = quality;
 		arcData.quality = quality;
 		arcData.color = mColor;
 		arcData.color = mColor;
 		arcData.transform = mTransform;
 		arcData.transform = mTransform;
-		arcData.center = mTransform.multiply3x4(position);
+		arcData.center = mTransform.multiplyAffine(position);
 	}
 	}
 
 
 	void DrawHelper::rectangle(const Rect3& area)
 	void DrawHelper::rectangle(const Rect3& area)
@@ -205,7 +205,7 @@ namespace BansheeEngine
 		rectData.area = area;
 		rectData.area = area;
 		rectData.color = mColor;
 		rectData.color = mColor;
 		rectData.transform = mTransform;
 		rectData.transform = mTransform;
-		rectData.center = mTransform.multiply3x4(area.getCenter());
+		rectData.center = mTransform.multiplyAffine(area.getCenter());
 	}
 	}
 
 
 	void DrawHelper::clear()
 	void DrawHelper::clear()
@@ -599,8 +599,8 @@ namespace BansheeEngine
 					Matrix4 transformIT = transform->inverseAffine().transpose();
 					Matrix4 transformIT = transform->inverseAffine().transpose();
 					for (UINT32 i = 0; i < shapeData.numVertices; i++)
 					for (UINT32 i = 0; i < shapeData.numVertices; i++)
 					{
 					{
-						Vector3 worldPos = transform->multiply3x4(positionIter.getValue());
-						Vector3 worldNormal = transformIT.multiply3x4(normalIter.getValue());
+						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
+						Vector3 worldNormal = transformIT.multiplyAffine(normalIter.getValue());
 
 
 						positionIter.addValue(worldPos);
 						positionIter.addValue(worldPos);
 						normalIter.addValue(worldNormal);
 						normalIter.addValue(worldNormal);
@@ -705,7 +705,7 @@ namespace BansheeEngine
 
 
 					for (UINT32 i = 0; i < shapeData.numVertices; i++)
 					for (UINT32 i = 0; i < shapeData.numVertices; i++)
 					{
 					{
-						Vector3 worldPos = transform->multiply3x4(positionIter.getValue());
+						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
 
 
 						positionIter.addValue(worldPos);
 						positionIter.addValue(worldPos);
 						colorIter.addValue(color);
 						colorIter.addValue(color);

+ 2 - 2
BansheeEngine/Source/BsGUIManager.cpp

@@ -1404,7 +1404,7 @@ namespace BansheeEngine
 
 
 		const Matrix4& worldTfrm = widget.SO()->getWorldTfrm();
 		const Matrix4& worldTfrm = widget.SO()->getWorldTfrm();
 
 
-		Vector4 vecLocalPos = worldTfrm.inverse().multiply3x4(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
+		Vector4 vecLocalPos = worldTfrm.inverse().multiplyAffine(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
 		Vector2I curLocalPos(Math::roundToInt(vecLocalPos.x), Math::roundToInt(vecLocalPos.y));
 		Vector2I curLocalPos(Math::roundToInt(vecLocalPos.x), Math::roundToInt(vecLocalPos.y));
 
 
 		return curLocalPos;
 		return curLocalPos;
@@ -1425,7 +1425,7 @@ namespace BansheeEngine
 
 
 			const Matrix4& worldTfrm = bridgeElement->_getParentWidget()->SO()->getWorldTfrm();
 			const Matrix4& worldTfrm = bridgeElement->_getParentWidget()->SO()->getWorldTfrm();
 
 
-			Vector4 vecLocalPos = worldTfrm.inverse().multiply3x4(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
+			Vector4 vecLocalPos = worldTfrm.inverse().multiplyAffine(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
 			Rect2I bridgeBounds = bridgeElement->_getCachedBounds();
 			Rect2I bridgeBounds = bridgeElement->_getCachedBounds();
 
 
 			// Find coordinates relative to the bridge element
 			// Find coordinates relative to the bridge element

+ 1 - 1
BansheeEngine/Source/BsGUIWidget.cpp

@@ -244,7 +244,7 @@ namespace BansheeEngine
 
 
 		const Matrix4& worldTfrm = SO()->getWorldTfrm();
 		const Matrix4& worldTfrm = SO()->getWorldTfrm();
 		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
 		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
-		vecPos = worldTfrm.inverse().multiply3x4(vecPos);
+		vecPos = worldTfrm.inverse().multiplyAffine(vecPos);
 
 
 		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
 		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
 		return mBounds.contains(localPos);
 		return mBounds.contains(localPos);

+ 7 - 7
BansheeUtility/Include/BsMatrix4.h

@@ -335,7 +335,7 @@ namespace BansheeEngine
          * 			
          * 			
          * @note	Matrix must be affine, if it is not use "multiply" method.
          * @note	Matrix must be affine, if it is not use "multiply" method.
          */
          */
-        Vector3 multiply3x4(const Vector3& v) const
+        Vector3 multiplyAffine(const Vector3& v) const
         {
         {
             return Vector3(
             return Vector3(
                     m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3], 
                     m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3], 
@@ -348,7 +348,7 @@ namespace BansheeEngine
          * 			
          * 			
          * @note	Matrix must be affine, if it is not use "multiply" method.
          * @note	Matrix must be affine, if it is not use "multiply" method.
          */
          */
-        Vector4 multiply3x4(const Vector4& v) const
+        Vector4 multiplyAffine(const Vector4& v) const
         {
         {
             return Vector4(
             return Vector4(
                 m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, 
                 m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, 
@@ -362,15 +362,15 @@ namespace BansheeEngine
          * 			
          * 			
          * @note	Matrix must be affine.
          * @note	Matrix must be affine.
          */
          */
-        Plane multiply3x4(const Plane& p) const
+        Plane multiplyAffine(const Plane& p) const
         {
         {
 			Vector4 localNormal(p.normal.x, p.normal.y, p.normal.z, 0.0f);
 			Vector4 localNormal(p.normal.x, p.normal.y, p.normal.z, 0.0f);
 			Vector4 localPoint = localNormal * p.d;
 			Vector4 localPoint = localNormal * p.d;
 			localPoint.w = 1.0f;
 			localPoint.w = 1.0f;
 
 
 			Matrix4 itMat = inverse().transpose();
 			Matrix4 itMat = inverse().transpose();
-			Vector4 worldNormal = itMat.multiply3x4(localNormal);
-			Vector4 worldPoint = multiply3x4(localPoint);
+			Vector4 worldNormal = itMat.multiplyAffine(localNormal);
+			Vector4 worldPoint = multiplyAffine(localPoint);
 
 
 			float d = worldNormal.dot(worldPoint);
 			float d = worldNormal.dot(worldPoint);
 
 
@@ -383,7 +383,7 @@ namespace BansheeEngine
          * @note	w component of the vector is assumed to be 1. After transformation all components
          * @note	w component of the vector is assumed to be 1. After transformation all components
          * 			are projected back so that w remains 1.
          * 			are projected back so that w remains 1.
          * 			
          * 			
-		 *			If your matrix doesn't contain projection components use "multiply3x4" method as it is faster.
+		 *			If your matrix doesn't contain projection components use "multiplyAffine" method as it is faster.
          */
          */
         Vector3 multiply(const Vector3 &v) const
         Vector3 multiply(const Vector3 &v) const
         {
         {
@@ -401,7 +401,7 @@ namespace BansheeEngine
         /**
         /**
          * @brief	Transform a 4D vector by this matrix.  
          * @brief	Transform a 4D vector by this matrix.  
          *
          *
-         * @note	If your matrix doesn't contain projection components use "multiply3x4" method as it is faster.
+         * @note	If your matrix doesn't contain projection components use "multiplyAffine" method as it is faster.
          */
          */
         Vector4 multiply(const Vector4& v) const
         Vector4 multiply(const Vector4& v) const
         {
         {

+ 9 - 9
BansheeUtility/Source/BsAABox.cpp

@@ -111,35 +111,35 @@ namespace BansheeEngine
 		// First corner 
 		// First corner 
 		// min min min
 		// min min min
 		currentCorner = oldMin;
 		currentCorner = oldMin;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// min,min,max
 		// min,min,max
 		currentCorner.z = oldMax.z;
 		currentCorner.z = oldMax.z;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// min max max
 		// min max max
 		currentCorner.y = oldMax.y;
 		currentCorner.y = oldMax.y;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// min max min
 		// min max min
 		currentCorner.z = oldMin.z;
 		currentCorner.z = oldMin.z;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// max max min
 		// max max min
 		currentCorner.x = oldMax.x;
 		currentCorner.x = oldMax.x;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// max max max
 		// max max max
 		currentCorner.z = oldMax.z;
 		currentCorner.z = oldMax.z;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// max min max
 		// max min max
 		currentCorner.y = oldMin.y;
 		currentCorner.y = oldMin.y;
-		merge(matrix.multiply3x4(currentCorner));
+		merge(matrix.multiplyAffine(currentCorner));
 
 
 		// max min min
 		// max min min
 		currentCorner.z = oldMin.z;
 		currentCorner.z = oldMin.z;
-		merge(matrix.multiply3x4(currentCorner)); 
+		merge(matrix.multiplyAffine(currentCorner)); 
 	}
 	}
 
 
 	void AABox::transformAffine(const Matrix4& m)
 	void AABox::transformAffine(const Matrix4& m)
@@ -149,7 +149,7 @@ namespace BansheeEngine
 		Vector3 centre = getCenter();
 		Vector3 centre = getCenter();
 		Vector3 halfSize = getHalfSize();
 		Vector3 halfSize = getHalfSize();
 
 
-		Vector3 newCentre = m.multiply3x4(centre);
+		Vector3 newCentre = m.multiplyAffine(centre);
 		Vector3 newHalfSize(
 		Vector3 newHalfSize(
 			Math::abs(m[0][0]) * halfSize.x + Math::abs(m[0][1]) * halfSize.y + Math::abs(m[0][2]) * halfSize.z, 
 			Math::abs(m[0][0]) * halfSize.x + Math::abs(m[0][1]) * halfSize.y + Math::abs(m[0][2]) * halfSize.z, 
 			Math::abs(m[1][0]) * halfSize.x + Math::abs(m[1][1]) * halfSize.y + Math::abs(m[1][2]) * halfSize.z,
 			Math::abs(m[1][0]) * halfSize.x + Math::abs(m[1][1]) * halfSize.y + Math::abs(m[1][2]) * halfSize.z,

+ 2 - 2
BansheeUtility/Source/BsRay.cpp

@@ -19,8 +19,8 @@ namespace BansheeEngine
 	{
 	{
 		Vector3 end = getPoint(1.0f);
 		Vector3 end = getPoint(1.0f);
 
 
-		mOrigin = matrix.multiply3x4(mOrigin);
-		end = matrix.multiply3x4(end);
+		mOrigin = matrix.multiplyAffine(mOrigin);
+		end = matrix.multiplyAffine(end);
 
 
 		mDirection = Vector3::normalize(end - mOrigin);
 		mDirection = Vector3::normalize(end - mOrigin);
 	}
 	}

+ 2 - 2
BansheeUtility/Source/BsSphere.cpp

@@ -25,8 +25,8 @@ namespace BansheeEngine
 	void Sphere::transform(const Matrix4& matrix)
 	void Sphere::transform(const Matrix4& matrix)
 	{
 	{
 		Vector3 edge = mCenter + Vector3::UNIT_X * mRadius;
 		Vector3 edge = mCenter + Vector3::UNIT_X * mRadius;
-		mCenter = matrix.multiply3x4(mCenter);
-		edge = matrix.multiply3x4(edge);
+		mCenter = matrix.multiplyAffine(mCenter);
+		edge = matrix.multiplyAffine(edge);
 
 
 		mRadius = mCenter.distance(edge);
 		mRadius = mCenter.distance(edge);
 	}
 	}

+ 265 - 2
MBansheeEngine/Camera.cs

@@ -1,12 +1,275 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Text;
 using System.Text;
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-    public class Camera
+    public enum ProjectionType
     {
     {
-        // TODO
+        Orthographic, Perspective
+    }
+
+    [Flags]
+    public enum ClearFlags
+    {
+        Color = 0x01, Depth = 0x02, Stencil = 0x04
+    }
+
+    public class Camera : Component
+    {
+        public float aspectRatio
+        {
+            get { return Internal_GetAspect(mCachedPtr); }
+            set { Internal_SetAspect(mCachedPtr, value); }
+        }
+
+        public float nearClipPlane
+        {
+            get { return Internal_GetNearClip(mCachedPtr); }
+            set { Internal_SetNearClip(mCachedPtr, value); }
+        }
+
+        public float farClipPlane
+        {
+            get { return Internal_GetFarClip(mCachedPtr); }
+            set { Internal_SetFarClip(mCachedPtr, value); }
+        }
+
+        public Degree fieldOfView
+        {
+            get { return Internal_GetFieldOfView(mCachedPtr); }
+            set { Internal_SetFieldOfView(mCachedPtr, value); }
+        }
+
+        public Rect2 viewportRect
+        {
+            get { return Internal_GetViewportRect(mCachedPtr); }
+            set { Internal_SetViewportRect(mCachedPtr, value); }
+        }
+
+        public ProjectionType projectionType
+        {
+            get { return Internal_GetProjectionType(mCachedPtr); }
+            set { Internal_SetProjectionType(mCachedPtr, value); }
+        }
+
+        public float orthoHeight
+        {
+            get { return Internal_GetOrthographicHeight(mCachedPtr); }
+            set { Internal_SetOrthographicHeight(mCachedPtr, value); }
+        }
+
+        public float orthoWidth
+        {
+            get { return Internal_GetOrthographicWidth(mCachedPtr); }
+        }
+
+        public Color clearColor
+        {
+            get { return Internal_GetClearColor(mCachedPtr); }
+            set { Internal_SetClearColor(mCachedPtr, value); }
+        }
+
+        public int clearDepth
+        {
+            get { return Internal_GetDepthClearValue(mCachedPtr); }
+            set { Internal_SetDepthClearValue(mCachedPtr, value); }
+        }
+
+        public byte clearStencil
+        {
+            get { return Internal_GetStencilClearValue(mCachedPtr); }
+            set { Internal_SetStencilClearValue(mCachedPtr, value); }
+        }
+
+        public ClearFlags clearFlags
+        {
+            get { return Internal_GetClearFlags(mCachedPtr); }
+            set { Internal_SetClearFlags(mCachedPtr, value); }
+        }
+
+        public int priority
+        {
+            get { return Internal_GetPriority(mCachedPtr); }
+            set { Internal_SetPriority(mCachedPtr, value); }
+        }
+
+        public UInt64 layers
+        {
+            get { return Internal_GetLayers(mCachedPtr); }
+            set { Internal_SetLayers(mCachedPtr, value); }
+        }
+
+        public Matrix4 projMatrix
+        {
+            get { return Internal_GetProjMatrix(mCachedPtr); }
+        }
+
+        public Matrix4 projMatrixInv
+        {
+            get { return Internal_GetProjMatrixInv(mCachedPtr); }
+        }
+
+        public Matrix4 viewMatrix
+        {
+            get { return Internal_GetViewMatrix(mCachedPtr); }
+        }
+
+        public Matrix4 viewMatrixInv
+        {
+            get { return Internal_GetViewMatrixInv(mCachedPtr); }
+        }
+
+        public int widthPixels
+        {
+            get { return Internal_GetWidthPixels(mCachedPtr); }
+        }
+
+        public int heightPixels
+        {
+            get { return Internal_GetHeightPixels(mCachedPtr); }
+        }
+
+        public Vector2I WorldToScreen(Vector3 value) { return Internal_WorldToScreen(mCachedPtr, value); }
+        public Vector2 WorldToClip(Vector3 value) { return Internal_WorldToClip(mCachedPtr, value); }
+        public Vector3 WorldToView(Vector3 value) { return Internal_WorldToView(mCachedPtr, value); }
+
+        public Vector3 ScreenToWorld(Vector2I value) { return Internal_ScreenToWorld(mCachedPtr, value); }
+        public Vector3 ScreenToView(Vector2I value) { return Internal_ScreenToView(mCachedPtr, value); }
+        public Vector2 ScreenToClip(Vector2I value) { return Internal_ScreenToClip(mCachedPtr, value); }
+
+        public Vector3 ViewToWorld(Vector3 value) { return Internal_ViewToWorld(mCachedPtr, value); }
+        public Vector2I ViewToScreen(Vector3 value) { return Internal_ViewToScreen(mCachedPtr, value); }
+        public Vector2 ViewToClip(Vector3 value) { return Internal_ViewToClip(mCachedPtr, value); }
+
+        public Vector3 ClipToWorld(Vector2 value) { return Internal_ClipToWorld(mCachedPtr, value); }
+        public Vector3 ClipToView(Vector2 value) { return Internal_ClipToView(mCachedPtr, value); }
+        public Vector2I ClipToScreen(Vector2 value) { return Internal_ClipToScreen(mCachedPtr, value); }
+
+        public Ray ScreenToWorldRay(Vector2I value) { return Internal_ScreenToWorldRay(mCachedPtr, value); }
+        public Vector3 ProjectPoint(Vector3 value) { return Internal_ProjectPoint(mCachedPtr, value); }
+        public Vector3 UnprojectPoint(Vector3 value) { return Internal_UnprojectPoint(mCachedPtr, value); }
+
+        // TODO - Add RenderTexture
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetAspect(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetAspect(IntPtr instance, float value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetNearClip(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetNearClip(IntPtr instance, float value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetFarClip(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetFarClip(IntPtr instance, float value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Degree Internal_GetFieldOfView(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetFieldOfView(IntPtr instance, Degree value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Rect2 Internal_GetViewportRect(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetViewportRect(IntPtr instance, Rect2 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern ProjectionType Internal_GetProjectionType(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetProjectionType(IntPtr instance, ProjectionType value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetOrthographicHeight(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetOrthographicHeight(IntPtr instance, float value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetOrthographicWidth(IntPtr instance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Color Internal_GetClearColor(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetClearColor(IntPtr instance, Color value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetDepthClearValue(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetDepthClearValue(IntPtr instance, int value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern byte Internal_GetStencilClearValue(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetStencilClearValue(IntPtr instance, byte value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern ClearFlags Internal_GetClearFlags(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetClearFlags(IntPtr instance, ClearFlags value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetPriority(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPriority(IntPtr instance, int value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern UInt64 Internal_GetLayers(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetLayers(IntPtr instance, UInt64 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Matrix4 Internal_GetProjMatrix(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Matrix4 Internal_GetProjMatrixInv(IntPtr instance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Matrix4 Internal_GetViewMatrix(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Matrix4 Internal_GetViewMatrixInv(IntPtr instance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetWidthPixels(IntPtr instance);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetHeightPixels(IntPtr instance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2I Internal_WorldToScreen(IntPtr instance, Vector3 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2 Internal_WorldToClip(IntPtr instance, Vector3 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_WorldToView(IntPtr instance, Vector3 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ScreenToWorld(IntPtr instance, Vector2I value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ScreenToView(IntPtr instance, Vector2I value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2 Internal_ScreenToClip(IntPtr instance, Vector2I value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ViewToWorld(IntPtr instance, Vector3 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2I Internal_ViewToScreen(IntPtr instance, Vector3 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2 Internal_ViewToClip(IntPtr instance, Vector3 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ClipToWorld(IntPtr instance, Vector2 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ClipToView(IntPtr instance, Vector2 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector2I Internal_ClipToScreen(IntPtr instance, Vector2 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Ray Internal_ScreenToWorldRay(IntPtr instance, Vector2I value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_ProjectPoint(IntPtr instance, Vector3 value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Vector3 Internal_UnprojectPoint(IntPtr instance, Vector3 value);
     }
     }
 }
 }

+ 2 - 0
MBansheeEngine/MBansheeEngine.csproj

@@ -85,6 +85,8 @@
     <Compile Include="Math\Matrix3.cs" />
     <Compile Include="Math\Matrix3.cs" />
     <Compile Include="Math\Matrix4.cs" />
     <Compile Include="Math\Matrix4.cs" />
     <Compile Include="Math\Radian.cs" />
     <Compile Include="Math\Radian.cs" />
+    <Compile Include="Math\Ray.cs" />
+    <Compile Include="Math\Rect2.cs" />
     <Compile Include="Math\Rect2I.cs" />
     <Compile Include="Math\Rect2I.cs" />
     <Compile Include="Math\Vector2I.cs" />
     <Compile Include="Math\Vector2I.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Program.cs" />

+ 4 - 4
MBansheeEngine/Math/Matrix4.cs

@@ -388,7 +388,7 @@ namespace BansheeEngine
          * 			
          * 			
          * @note	Matrix must be affine, if it is not use "Multiply" method.
          * @note	Matrix must be affine, if it is not use "Multiply" method.
          */
          */
-        public Vector3 Multiply3x4(Vector3 v)
+        public Vector3 MultiplyAffine(Vector3 v)
         {
         {
             return new Vector3(
             return new Vector3(
                     m00 * v.x + m01 * v.y + m02 * v.z + m03, 
                     m00 * v.x + m01 * v.y + m02 * v.z + m03, 
@@ -401,7 +401,7 @@ namespace BansheeEngine
          * 			
          * 			
          * @note	Matrix must be affine, if it is not use "Multiply" method.
          * @note	Matrix must be affine, if it is not use "Multiply" method.
          */
          */
-        public Vector4 Multiply3x4(Vector4 v)
+        public Vector4 MultiplyAffine(Vector4 v)
         {
         {
             return new Vector4(
             return new Vector4(
                 m00 * v.x + m01 * v.y + m02 * v.z + m03 * v.w, 
                 m00 * v.x + m01 * v.y + m02 * v.z + m03 * v.w, 
@@ -416,7 +416,7 @@ namespace BansheeEngine
          * @note	w component of the vector is assumed to be 1. After transformation all components
          * @note	w component of the vector is assumed to be 1. After transformation all components
          * 			are projected back so that w remains 1.
          * 			are projected back so that w remains 1.
          * 			
          * 			
-		 *			If your matrix doesn't contain projection components use "Multiply3x4" method as it is faster.
+		 *			If your matrix doesn't contain projection components use "MultiplyAffine" method as it is faster.
          */
          */
         public Vector3 Multiply(Vector3 v)
         public Vector3 Multiply(Vector3 v)
         {
         {
@@ -436,7 +436,7 @@ namespace BansheeEngine
          *
          *
          * @note	After transformation all components are projected back so that w remains 1.
          * @note	After transformation all components are projected back so that w remains 1.
          * 			
          * 			
-		 *			If your matrix doesn't contain projection components use "Multiply3x4" method as it is faster.
+		 *			If your matrix doesn't contain projection components use "MultiplyAffine" method as it is faster.
          */
          */
         public Vector4 Multiply(Vector4 v)
         public Vector4 Multiply(Vector4 v)
         {
         {

+ 6 - 12
MBansheeEngine/Math/Rect2I.cs

@@ -27,17 +27,6 @@ namespace BansheeEngine
 			return !(lhs == rhs);
 			return !(lhs == rhs);
 		}
 		}
 
 
-        public override int GetHashCode()
-        {
-            int hash = 23;
-            hash = hash * 31 + x.GetHashCode();
-            hash = hash * 31 + y.GetHashCode();
-            hash = hash * 31 + width.GetHashCode();
-            hash = hash * 31 + height.GetHashCode();
-
-            return hash;
-        }
-
         public override bool Equals(object other)
         public override bool Equals(object other)
         {
         {
             if (!(other is Rect2I))
             if (!(other is Rect2I))
@@ -50,6 +39,11 @@ namespace BansheeEngine
             return false;
             return false;
         }
         }
 
 
-        int x, y, width, height;
+        public override int GetHashCode()
+        {
+            return base.GetHashCode();
+        }
+
+        public int x, y, width, height;
     }
     }
 }
 }

+ 96 - 0
SBansheeEngine/Include/BsScriptCamera.h

@@ -0,0 +1,96 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+#include "BsVector2.h"
+#include "BsVector3.h"
+#include "BsVector2I.h"
+#include "BsRay.h"
+#include "BsDegree.h"
+#include "BsMatrix4.h"
+#include "BsRect2.h"
+#include "BsColor.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BE_EXPORT ScriptCamera : public ScriptObject<ScriptCamera>
+	{
+	public:
+		SCRIPT_OBJ(BansheeEngineAssemblyName, "BansheeEngine", "Camera")
+
+	private:
+		ScriptCamera(MonoObject* managedInstance);
+		~ScriptCamera();
+
+		static float internal_GetAspect(ScriptCamera* instance);
+		static void internal_SetAspect(ScriptCamera* instance, float value);
+		static float internal_GetNearClip(ScriptCamera* instance);
+		static void internal_SetNearClip(ScriptCamera* instance, float value);
+
+		static float internal_GetFarClip(ScriptCamera* instance);
+		static void internal_SetFarClip(ScriptCamera* instance, float value);
+
+		static Degree internal_GetFieldOfView(ScriptCamera* instance);
+		static void internal_SetFieldOfView(ScriptCamera* instance, Degree value);
+
+		static Rect2 internal_GetViewportRect(ScriptCamera* instance);
+		static void internal_SetViewportRect(ScriptCamera* instance, Rect2 value);
+
+		static UINT32 internal_GetProjectionType(ScriptCamera* instance);
+		static void internal_SetProjectionType(ScriptCamera* instance, UINT32 value);
+
+		static float internal_GetOrthographicHeight(ScriptCamera* instance);
+		static void internal_SetOrthographicHeight(ScriptCamera* instance, float value);
+
+		static float internal_GetOrthographicWidth(ScriptCamera* instance);
+
+		static Color internal_GetClearColor(ScriptCamera* instance);
+		static void internal_SetClearColor(ScriptCamera* instance, Color value);
+
+		static int internal_GetDepthClearValue(ScriptCamera* instance);
+		static void internal_SetDepthClearValue(ScriptCamera* instance, int value);
+
+		static UINT8 internal_GetStencilClearValue(ScriptCamera* instance);
+		static void internal_SetStencilClearValue(ScriptCamera* instance, UINT8 value);
+
+		static UINT32 internal_GetClearFlags(ScriptCamera* instance);
+		static void internal_SetClearFlags(ScriptCamera* instance, UINT32 value);
+
+		static int internal_GetPriority(ScriptCamera* instance);
+		static void internal_SetPriority(ScriptCamera* instance, int value);
+
+		static UINT64 internal_GetLayers(ScriptCamera* instance);
+		static void internal_SetLayers(ScriptCamera* instance, UINT64 value);
+
+		static Matrix4 internal_GetProjMatrix(ScriptCamera* instance);
+		static Matrix4 internal_GetProjMatrixInv(ScriptCamera* instance);
+
+		static Matrix4 internal_GetViewMatrix(ScriptCamera* instance);
+		static Matrix4 internal_GetViewMatrixInv(ScriptCamera* instance);
+
+		static int internal_GetWidthPixels(ScriptCamera* instance);
+		static int internal_GetHeightPixels(ScriptCamera* instance);
+
+		static Vector2I internal_WorldToScreen(ScriptCamera* instance, Vector3 value);
+		static Vector2 internal_WorldToClip(ScriptCamera* instance, Vector3 value);
+		static Vector3 internal_WorldToView(ScriptCamera* instance, Vector3 value);
+
+		static Vector3 internal_ScreenToWorld(ScriptCamera* instance, Vector2I value);
+		static Vector3 internal_ScreenToView(ScriptCamera* instance, Vector2I value);
+		static Vector2 internal_ScreenToClip(ScriptCamera* instance, Vector2I value);
+
+		static Vector3 internal_ViewToWorld(ScriptCamera* instance, Vector3 value);
+		static Vector2I internal_ViewToScreen(ScriptCamera* instance, Vector3 value);
+		static Vector2 internal_ViewToClip(ScriptCamera* instance, Vector3 value);
+
+		static Vector3 internal_ClipToWorld(ScriptCamera* instance, Vector2 value);
+		static Vector3 internal_ClipToView(ScriptCamera* instance, Vector2 value);
+		static Vector2I internal_ClipToScreen(ScriptCamera* instance, Vector2 value);
+
+		static Ray internal_ScreenToWorldRay(ScriptCamera* instance, Vector2I value);
+		static Vector3 internal_ProjectPoint(ScriptCamera* instance, Vector3 value);
+		static Vector3 internal_UnprojectPoint(ScriptCamera* instance, Vector3 value);
+
+		CameraHandler* mCameraHandler;
+	};
+}

+ 2 - 0
SBansheeEngine/SBansheeEngine.vcxproj

@@ -243,6 +243,7 @@
     <ClInclude Include="Include\BsManagedSerializableListRTTI.h" />
     <ClInclude Include="Include\BsManagedSerializableListRTTI.h" />
     <ClInclude Include="Include\BsManagedSerializableObject.h" />
     <ClInclude Include="Include\BsManagedSerializableObject.h" />
     <ClInclude Include="Include\BsRuntimeScriptObjects.h" />
     <ClInclude Include="Include\BsRuntimeScriptObjects.h" />
+    <ClInclude Include="Include\BsScriptCamera.h" />
     <ClInclude Include="Include\BsScriptComponent.h" />
     <ClInclude Include="Include\BsScriptComponent.h" />
     <ClInclude Include="Include\BsScriptDebug.h" />
     <ClInclude Include="Include\BsScriptDebug.h" />
     <ClInclude Include="Include\BsScriptEnginePrerequisites.h" />
     <ClInclude Include="Include\BsScriptEnginePrerequisites.h" />
@@ -294,6 +295,7 @@
     <ClCompile Include="Source\BsManagedResourceManager.cpp" />
     <ClCompile Include="Source\BsManagedResourceManager.cpp" />
     <ClCompile Include="Source\BsManagedResourceMetaData.cpp" />
     <ClCompile Include="Source\BsManagedResourceMetaData.cpp" />
     <ClCompile Include="Source\BsRuntimeScriptObjects.cpp" />
     <ClCompile Include="Source\BsRuntimeScriptObjects.cpp" />
+    <ClCompile Include="Source\BsScriptCamera.cpp" />
     <ClCompile Include="Source\BsScriptComponent.cpp" />
     <ClCompile Include="Source\BsScriptComponent.cpp" />
     <ClCompile Include="Source\BsScriptDebug.cpp" />
     <ClCompile Include="Source\BsScriptDebug.cpp" />
     <ClCompile Include="Source\BsScriptEnginePlugin.cpp" />
     <ClCompile Include="Source\BsScriptEnginePlugin.cpp" />

+ 6 - 0
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -216,6 +216,9 @@
     <ClInclude Include="Include\BsScriptSerializableDictionary.h">
     <ClInclude Include="Include\BsScriptSerializableDictionary.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptCamera.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -365,5 +368,8 @@
     <ClCompile Include="Source\BsScriptSerializableDictionary.cpp">
     <ClCompile Include="Source\BsScriptSerializableDictionary.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptCamera.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 332 - 0
SBansheeEngine/Source/BsScriptCamera.cpp

@@ -0,0 +1,332 @@
+#include "BsScriptCamera.h"
+#include "BsScriptMeta.h"
+#include "BsMonoField.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoUtil.h"
+
+namespace BansheeEngine
+{
+	ScriptCamera::ScriptCamera(MonoObject* managedInstance)
+		:ScriptObject(managedInstance)
+	{ 
+		// TODO - Create handler
+	}
+
+	ScriptCamera::~ScriptCamera()
+	{
+		// TODO - Delete handler
+	}
+
+	void ScriptCamera::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_GetAspect", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetAspect", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_GetNearClip", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetNearClip", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetFarClip", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetFarClip", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetFieldOfView", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetFieldOfView", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetViewportRect", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetViewportRect", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetProjectionType", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetProjectionType", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetOrthographicHeight", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetOrthographicHeight", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetOrthographicWidth", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetClearColor", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetClearColor", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetDepthClearValue", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetDepthClearValue", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetStencilClearValue", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetStencilClearValue", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetClearFlags", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetClearFlags", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetPriority", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetPriority", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetLayers", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_SetLayers", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetProjMatrix", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_GetProjMatrixInv", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetViewMatrix", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_GetViewMatrixInv", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_GetWidthPixels", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_GetHeightPixels", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_WorldToScreen", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_WorldToClip", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_WorldToView", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_ScreenToWorld", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ScreenToView", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ScreenToClip", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_ViewToWorld", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ViewToScreen", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ViewToClip", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_ClipToWorld", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ClipToView", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ClipToScreen", &ScriptCamera::internal_GetAspect);
+
+		metaData.scriptClass->addInternalCall("Internal_ScreenToWorldRay", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_ProjectPoint", &ScriptCamera::internal_GetAspect);
+		metaData.scriptClass->addInternalCall("Internal_UnprojectPoint", &ScriptCamera::internal_GetAspect);
+	}
+
+	float ScriptCamera::internal_GetAspect(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetAspect(ScriptCamera* instance, float value)
+	{
+
+	}
+
+	float ScriptCamera::internal_GetNearClip(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetNearClip(ScriptCamera* instance, float value)
+	{
+
+	}
+
+	float ScriptCamera::internal_GetFarClip(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetFarClip(ScriptCamera* instance, float value)
+	{
+
+	}
+
+	Degree ScriptCamera::internal_GetFieldOfView(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetFieldOfView(ScriptCamera* instance, Degree value)
+	{
+
+	}
+
+	Rect2 ScriptCamera::internal_GetViewportRect(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetViewportRect(ScriptCamera* instance, Rect2 value)
+	{
+
+	}
+
+	UINT32 ScriptCamera::internal_GetProjectionType(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetProjectionType(ScriptCamera* instance, UINT32 value)
+	{
+
+	}
+
+	float ScriptCamera::internal_GetOrthographicHeight(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetOrthographicHeight(ScriptCamera* instance, float value)
+	{
+
+	}
+
+	float ScriptCamera::internal_GetOrthographicWidth(ScriptCamera* instance)
+	{
+
+	}
+
+	Color ScriptCamera::internal_GetClearColor(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetClearColor(ScriptCamera* instance, Color value)
+	{
+
+	}
+
+	int ScriptCamera::internal_GetDepthClearValue(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetDepthClearValue(ScriptCamera* instance, int value)
+	{
+
+	}
+
+	UINT8 ScriptCamera::internal_GetStencilClearValue(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetStencilClearValue(ScriptCamera* instance, UINT8 value)
+	{
+
+	}
+
+	UINT32 ScriptCamera::internal_GetClearFlags(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetClearFlags(ScriptCamera* instance, UINT32 value)
+	{
+
+	}
+
+	int ScriptCamera::internal_GetPriority(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetPriority(ScriptCamera* instance, int value)
+	{
+
+	}
+
+	UINT64 ScriptCamera::internal_GetLayers(ScriptCamera* instance)
+	{
+
+	}
+
+	void ScriptCamera::internal_SetLayers(ScriptCamera* instance, UINT64 value)
+	{
+
+	}
+
+	Matrix4 ScriptCamera::internal_GetProjMatrix(ScriptCamera* instance)
+	{
+
+	}
+
+	Matrix4 ScriptCamera::internal_GetProjMatrixInv(ScriptCamera* instance)
+	{
+
+	}
+
+	Matrix4 ScriptCamera::internal_GetViewMatrix(ScriptCamera* instance)
+	{
+
+	}
+
+	Matrix4 ScriptCamera::internal_GetViewMatrixInv(ScriptCamera* instance)
+	{
+
+	}
+
+	int ScriptCamera::internal_GetWidthPixels(ScriptCamera* instance)
+	{
+
+	}
+
+	int ScriptCamera::internal_GetHeightPixels(ScriptCamera* instance)
+	{
+
+	}
+
+	Vector2I ScriptCamera::internal_WorldToScreen(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector2 ScriptCamera::internal_WorldToClip(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_WorldToView(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ScreenToWorld(ScriptCamera* instance, Vector2I value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ScreenToView(ScriptCamera* instance, Vector2I value)
+	{
+
+	}
+
+	Vector2 ScriptCamera::internal_ScreenToClip(ScriptCamera* instance, Vector2I value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ViewToWorld(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector2I ScriptCamera::internal_ViewToScreen(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector2 ScriptCamera::internal_ViewToClip(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ClipToWorld(ScriptCamera* instance, Vector2 value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ClipToView(ScriptCamera* instance, Vector2 value)
+	{
+
+	}
+
+	Vector2I ScriptCamera::internal_ClipToScreen(ScriptCamera* instance, Vector2 value)
+	{
+
+	}
+
+	Ray ScriptCamera::internal_ScreenToWorldRay(ScriptCamera* instance, Vector2I value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_ProjectPoint(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+
+	Vector3 ScriptCamera::internal_UnprojectPoint(ScriptCamera* instance, Vector3 value)
+	{
+
+	}
+}

+ 25 - 11
SceneView.txt

@@ -8,18 +8,21 @@ When dragging a handle make sure it works when cursor leaves the scene view
 Also make sure that handle manager receives mouse up event if its done outside of scene view
 Also make sure that handle manager receives mouse up event if its done outside of scene view
 When selecting/deselecting stuff handle display is delayed
 When selecting/deselecting stuff handle display is delayed
 
 
-Add C# methods for retrieving handle size and snap amounts
-Actually make use of snapping in MoveHandle
-Test if fixed size handles & snapping work
+Create the scene widget completely in C#?
+ - Port Camera/viewport, RenderTexture, SceneCameraController, Input, ProjectSettings, SceneGrid
+ - Will need to track when widget resizes so I can resize the render target
+ - Handle manager update will originate from the widget
+  - Actually it could still be done from C++
+ - How will scene grid rendering be handled? Currently it's done from a render() callback
+  - It's still going to have a C++ representation, just call the callback there
+ - I will still need a C++ version of scene widget (not in script code but in editor code) because handle/gizmo manager reference it
+ 
+AFTER I have scene widget in C#:
+ - Finish up C# Handles class so it returns proper values
+ - Ensure fixed handle size and handle snapping works
+ - Implement free move handle and remaining handles
+ - Test custom handles from C#
 
 
------------
-
-Start work on C# Camera, and C# EditorApplication.sceneCamera
-  - I'll need to replace all current uses of scene camera with CameraHandler?? Since this camera will have to be a ManagedComponent...
-
-Test handles
- - Test a custom handle from C#
- - FINISH HANDLE IMPLEMENTATION AND GLUE EVERYTHING TOGHETHER
 
 
 IMPLEMENT SELECTION RENDERING
 IMPLEMENT SELECTION RENDERING
 
 
@@ -83,6 +86,17 @@ Find ones with Renderable components
 Retrieve Meshes, and world transforms from them
 Retrieve Meshes, and world transforms from them
 Draw that same mesh with either a wireframe or a grayed out shader with a slight depth bias
 Draw that same mesh with either a wireframe or a grayed out shader with a slight depth bias
 
 
+---------------------------------------------------------------------
+Render textures in C#:
+ - Extend C++ code so I can render to a 2D texture, face of a cube map, slice of a volume texture or entry in a 2D texture array.
+ - In C# have Texture2D, TextureCube, TextureVolume, Texture2DArray. They should have a common Texture base.
+   - Each of those can be created with a Renderable flag
+ - Render textures mirror what we have in C++
+   - RenderTexture and MultiRenderTexture (since we have these separate representation we don't need RenderBuffer that Unity has)
+   - You can provide an existing texture from types listed above, or create a new render target and
+      create a basic 2D texture (multiple constructors)
+ - Both RT types should have their color buffer (s) and depth buffer accessible as a texture to be used for rendering, or for reading
+
 ---------------------------------------------------------------------
 ---------------------------------------------------------------------
 Multi-resources
 Multi-resources