Просмотр исходного кода

WIP: Script bindings
- Ported Shader, Material, Renderable, Animation and Bone to automatic
script binding generator (SBGen)

BearishSun 8 лет назад
Родитель
Сommit
8b8713b054
46 измененных файлов с 1118 добавлено и 3850 удалено
  1. 6 19
      Source/BansheeCore/Animation/BsAnimation.cpp
  2. 8 14
      Source/BansheeCore/Animation/BsAnimation.h
  3. 241 33
      Source/BansheeCore/Components/BsCAnimation.cpp
  4. 112 14
      Source/BansheeCore/Components/BsCAnimation.h
  5. 7 0
      Source/BansheeCore/Components/BsCBone.cpp
  6. 10 8
      Source/BansheeCore/Components/BsCBone.h
  7. 7 7
      Source/BansheeCore/Components/BsCCamera.cpp
  8. 24 8
      Source/BansheeCore/Components/BsCRenderable.h
  9. 23 23
      Source/BansheeCore/Image/BsTexture.h
  10. 20 1
      Source/BansheeCore/Material/BsMaterial.h
  11. 9 2
      Source/BansheeCore/Material/BsShader.h
  12. 8 14
      Source/BansheeCore/Renderer/BsRenderable.h
  13. 6 1
      Source/BansheeCore/Scene/BsComponent.h
  14. 36 0
      Source/BansheeCore/Scene/BsSceneObject.cpp
  15. 13 5
      Source/BansheeCore/Scene/BsSceneObject.h
  16. 17 8
      Source/BansheeCore/Utility/BsCommonTypes.h
  17. 2 2
      Source/BansheeD3D11RenderAPI/BsD3D11RenderAPI.cpp
  18. 174 174
      Source/BansheeUtility/Math/BsQuaternion.cpp
  19. 104 104
      Source/BansheeUtility/Math/BsQuaternion.h
  20. 1 1
      Source/CMakeLists.txt
  21. 30 30
      Source/MBansheeEditor/Inspectors/MaterialInspector.cs
  22. 33 1010
      Source/MBansheeEngine/Animation/Animation.cs
  23. 0 125
      Source/MBansheeEngine/Animation/Bone.cs
  24. 0 246
      Source/MBansheeEngine/Animation/Interop/NativeAnimation.cs
  25. 0 170
      Source/MBansheeEngine/Interop/NativeRenderable.cs
  26. 1 6
      Source/MBansheeEngine/MBansheeEngine.csproj
  27. 3 0
      Source/MBansheeEngine/Math/Bounds.cs
  28. 19 283
      Source/MBansheeEngine/Rendering/Material.cs
  29. 0 219
      Source/MBansheeEngine/Rendering/Renderable.cs
  30. 0 102
      Source/MBansheeEngine/Rendering/Shader.cs
  31. 1 1
      Source/RenderBeast/BsShadowRendering.cpp
  32. 4 8
      Source/SBansheeEngine/CMakeSources.cmake
  33. 18 0
      Source/SBansheeEngine/Extensions/BsMaterialEx.cpp
  34. 30 0
      Source/SBansheeEngine/Extensions/BsMaterialEx.h
  35. 101 0
      Source/SBansheeEngine/Extensions/BsShaderEx.cpp
  36. 48 0
      Source/SBansheeEngine/Extensions/BsShaderEx.h
  37. 2 3
      Source/SBansheeEngine/Serialization/BsScriptAssemblyManager.cpp
  38. 0 336
      Source/SBansheeEngine/Wrappers/BsScriptAnimation.cpp
  39. 0 134
      Source/SBansheeEngine/Wrappers/BsScriptAnimation.h
  40. 0 1
      Source/SBansheeEngine/Wrappers/BsScriptBuiltin.cpp
  41. 0 233
      Source/SBansheeEngine/Wrappers/BsScriptMaterial.cpp
  42. 0 68
      Source/SBansheeEngine/Wrappers/BsScriptMaterial.h
  43. 0 174
      Source/SBansheeEngine/Wrappers/BsScriptRenderable.cpp
  44. 0 58
      Source/SBansheeEngine/Wrappers/BsScriptRenderable.h
  45. 0 167
      Source/SBansheeEngine/Wrappers/BsScriptShader.cpp
  46. 0 38
      Source/SBansheeEngine/Wrappers/BsScriptShader.h

+ 6 - 19
Source/BansheeCore/Animation/BsAnimation.cpp

@@ -19,19 +19,6 @@ namespace bs
 		, curveVersion(0), layerIdx((UINT32)-1), stateIdx((UINT32)-1)
 		, curveVersion(0), layerIdx((UINT32)-1), stateIdx((UINT32)-1)
 	{ }
 	{ }
 
 
-	Blend1DInfo::Blend1DInfo(UINT32 numClips)
-		: numClips(numClips), clips(nullptr)
-	{
-		if (numClips > 0)
-			clips = bs_newN<BlendClipInfo>(numClips);
-	}
-
-	Blend1DInfo::~Blend1DInfo()
-	{
-		if(clips != nullptr)
-			bs_deleteN(clips, numClips);
-	}
-
 	AnimationProxy::AnimationProxy(UINT64 id)
 	AnimationProxy::AnimationProxy(UINT64 id)
 		: id(id), layers(nullptr), numLayers(0), numSceneObjects(0), sceneObjectInfos(nullptr)
 		: id(id), layers(nullptr), numLayers(0), numSceneObjects(0), sceneObjectInfos(nullptr)
 		, sceneObjectTransforms(nullptr), morphChannelInfos(nullptr), morphShapeInfos(nullptr), numMorphChannels(0)
 		, sceneObjectTransforms(nullptr), morphChannelInfos(nullptr), morphShapeInfos(nullptr), numMorphChannels(0)
@@ -794,21 +781,21 @@ namespace bs
 
 
 	void Animation::blend1D(const Blend1DInfo& info, float t)
 	void Animation::blend1D(const Blend1DInfo& info, float t)
 	{
 	{
-		if (info.numClips == 0)
+		if (info.clips.size() == 0)
 			return;
 			return;
 
 
 		// Find valid range
 		// Find valid range
 		float startPos = 0.0f;
 		float startPos = 0.0f;
 		float endPos = 0.0f;
 		float endPos = 0.0f;
 
 
-		for (UINT32 i = 0; i < info.numClips; i++)
+		for (UINT32 i = 0; i < (UINT32)info.clips.size(); i++)
 		{
 		{
 			startPos = std::min(startPos, info.clips[i].position);
 			startPos = std::min(startPos, info.clips[i].position);
 			endPos = std::min(endPos, info.clips[i].position);
 			endPos = std::min(endPos, info.clips[i].position);
 		}
 		}
 
 
 		float length = endPos - startPos;
 		float length = endPos - startPos;
-		if(Math::approxEquals(length, 0.0f) || info.numClips < 2)
+		if(Math::approxEquals(length, 0.0f) || info.clips.size() < 2)
 		{
 		{
 			play(info.clips[0].clip);
 			play(info.clips[0].clip);
 			return;
 			return;
@@ -837,7 +824,7 @@ namespace bs
 		UINT32 rightKey = 0;
 		UINT32 rightKey = 0;
 
 
 		INT32 start = 0;
 		INT32 start = 0;
-		INT32 searchLength = (INT32)info.numClips;
+		INT32 searchLength = (INT32)info.clips.size();
 
 
 		while (searchLength > 0)
 		while (searchLength > 0)
 		{
 		{
@@ -856,13 +843,13 @@ namespace bs
 		}
 		}
 
 
 		leftKey = std::max(0, start - 1);
 		leftKey = std::max(0, start - 1);
-		rightKey = std::min(start, (INT32)info.numClips - 1);
+		rightKey = std::min(start, (INT32)info.clips.size() - 1);
 
 
 		float interpLength = info.clips[rightKey].position - info.clips[leftKey].position;
 		float interpLength = info.clips[rightKey].position - info.clips[leftKey].position;
 		t = (t - info.clips[leftKey].position) / interpLength;
 		t = (t - info.clips[leftKey].position) / interpLength;
 
 
 		// Add clips and set weights
 		// Add clips and set weights
-		for(UINT32 i = 0; i < info.numClips; i++)
+		for(UINT32 i = 0; i < (UINT32)info.clips.size(); i++)
 		{
 		{
 			AnimationClipInfo* clipInfo = addClip(info.clips[i].clip, (UINT32)-1, i == 0);
 			AnimationClipInfo* clipInfo = addClip(info.clips[i].clip, (UINT32)-1, i == 0);
 			if (clipInfo != nullptr)
 			if (clipInfo != nullptr)

+ 8 - 14
Source/BansheeCore/Animation/BsAnimation.h

@@ -18,7 +18,7 @@ namespace bs
 	 */
 	 */
 
 
 	/** Determines how an animation clip behaves when it reaches the end. */
 	/** Determines how an animation clip behaves when it reaches the end. */
-	enum class AnimWrapMode
+	enum class BS_SCRIPT_EXPORT(m:Animation) AnimWrapMode
 	{
 	{
 		Loop, /**< Loop around to the beginning/end when the last/first frame is reached. */
 		Loop, /**< Loop around to the beginning/end when the last/first frame is reached. */
 		Clamp /**< Clamp to end/beginning, keeping the last/first frame active. */
 		Clamp /**< Clamp to end/beginning, keeping the last/first frame active. */
@@ -39,7 +39,7 @@ namespace bs
 	BS_FLAGS_OPERATORS(AnimDirtyStateFlag)
 	BS_FLAGS_OPERATORS(AnimDirtyStateFlag)
 
 
 	/** Contains information about a currently playing animation clip. */
 	/** Contains information about a currently playing animation clip. */
-	struct AnimationClipState
+	struct BS_SCRIPT_EXPORT(pl:true,m:Animation) AnimationClipState
 	{
 	{
 		AnimationClipState() { }
 		AnimationClipState() { }
 
 
@@ -92,7 +92,7 @@ namespace bs
 	};
 	};
 
 
 	/** Represents an animation clip used in 1D blending. Each clip has a position on the number line. */
 	/** Represents an animation clip used in 1D blending. Each clip has a position on the number line. */
-	struct BS_CORE_EXPORT BlendClipInfo
+	struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(pl:true,m:Animation) BlendClipInfo
 	{
 	{
 		BlendClipInfo() { }
 		BlendClipInfo() { }
 
 
@@ -101,17 +101,13 @@ namespace bs
 	};
 	};
 
 
 	/** Defines a 1D blend where multiple animation clips are blended between each other using linear interpolation. */
 	/** Defines a 1D blend where multiple animation clips are blended between each other using linear interpolation. */
-	struct BS_CORE_EXPORT Blend1DInfo
+	struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(pl:true,m:Animation) Blend1DInfo
 	{
 	{
-		Blend1DInfo(UINT32 numClips);
-		~Blend1DInfo();
-
-		UINT32 numClips;
-		BlendClipInfo* clips;
+		Vector<BlendClipInfo> clips;
 	};
 	};
 
 
 	/** Defines a 2D blend where two animation clips are blended between each other using bilinear interpolation. */
 	/** Defines a 2D blend where two animation clips are blended between each other using bilinear interpolation. */
-	struct Blend2DInfo
+	struct BS_SCRIPT_EXPORT(pl:true,m:Animation) Blend2DInfo
 	{
 	{
 		HAnimationClip topLeftClip;
 		HAnimationClip topLeftClip;
 		HAnimationClip topRightClip;
 		HAnimationClip topRightClip;
@@ -299,14 +295,12 @@ namespace bs
 		void setMask(const SkeletonMask& mask);
 		void setMask(const SkeletonMask& mask);
 
 
 		/** 
 		/** 
-		 * Changes the wrap mode for all active animations. Wrap mode determines what happens when animation reaches the 
+		 * Determines the wrap mode for all active animations. Wrap mode determines what happens when animation reaches the 
 		 * first or last frame. 
 		 * first or last frame. 
-		 *
-		 * @see	AnimWrapMode
 		 */
 		 */
 		void setWrapMode(AnimWrapMode wrapMode);
 		void setWrapMode(AnimWrapMode wrapMode);
 
 
-		/** Changes the speed for all animations. The default value is 1.0f. Use negative values to play-back in reverse. */
+		/** Determines the speed for all animations. The default value is 1.0f. Use negative values to play-back in reverse. */
 		void setSpeed(float speed);
 		void setSpeed(float speed);
 
 
 		/** Sets bounds that will be used for animation culling, if enabled. Bounds must be in world space. */
 		/** Sets bounds that will be used for animation culling, if enabled. Bounds must be in world space. */

+ 241 - 33
Source/BansheeCore/Components/BsCAnimation.cpp

@@ -4,20 +4,28 @@
 #include "Scene/BsSceneObject.h"
 #include "Scene/BsSceneObject.h"
 #include "Components/BsCRenderable.h"
 #include "Components/BsCRenderable.h"
 #include "Components/BsCBone.h"
 #include "Components/BsCBone.h"
+#include "Mesh/BsMesh.h"
+#include "Animation/BsMorphShapes.h"
+#include "Animation/BsAnimationClip.h"
 #include "RTTI/BsCAnimationRTTI.h"
 #include "RTTI/BsCAnimationRTTI.h"
+#include "Scene/BsSceneManager.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
 namespace bs
 namespace bs
 {
 {
 	CAnimation::CAnimation()
 	CAnimation::CAnimation()
-		:mWrapMode(AnimWrapMode::Loop), mSpeed(1.0f), mEnableCull(true), mUseBounds(false)
-	{ }
+		:mWrapMode(AnimWrapMode::Loop), mSpeed(1.0f), mEnableCull(true), mUseBounds(false), mPreviewMode(false)
+	{
+		mNotifyFlags = TCF_Transform;
+		setFlag(ComponentFlag::AlwaysRun, true);
+	}
 
 
 	CAnimation::CAnimation(const HSceneObject& parent)
 	CAnimation::CAnimation(const HSceneObject& parent)
-		: Component(parent), mWrapMode(AnimWrapMode::Loop), mSpeed(1.0f), mEnableCull(true), mUseBounds(false)
+		: Component(parent), mWrapMode(AnimWrapMode::Loop), mSpeed(1.0f), mEnableCull(true), mUseBounds(false), mPreviewMode(false)
 	{
 	{
 		mNotifyFlags = TCF_Transform;
 		mNotifyFlags = TCF_Transform;
+		setFlag(ComponentFlag::AlwaysRun, true);
 
 
 		setName("Animation");
 		setName("Animation");
 	}
 	}
@@ -26,17 +34,15 @@ namespace bs
 	{
 	{
 		mDefaultClip = clip;
 		mDefaultClip = clip;
 
 
-		if(clip.isLoaded() && mInternal != nullptr)
-		{
+		if(clip.isLoaded() && mInternal != nullptr && !mPreviewMode)
 			mInternal->play(clip);
 			mInternal->play(clip);
-		}
 	}
 	}
 
 
 	void CAnimation::setWrapMode(AnimWrapMode wrapMode)
 	void CAnimation::setWrapMode(AnimWrapMode wrapMode)
 	{
 	{
 		mWrapMode = wrapMode;
 		mWrapMode = wrapMode;
 
 
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->setWrapMode(wrapMode);
 			mInternal->setWrapMode(wrapMode);
 	}
 	}
 
 
@@ -44,37 +50,37 @@ namespace bs
 	{
 	{
 		mSpeed = speed;
 		mSpeed = speed;
 
 
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->setSpeed(speed);
 			mInternal->setSpeed(speed);
 	}
 	}
 
 
 	void CAnimation::play(const HAnimationClip& clip)
 	void CAnimation::play(const HAnimationClip& clip)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->play(clip);
 			mInternal->play(clip);
 	}
 	}
 
 
 	void CAnimation::blendAdditive(const HAnimationClip& clip, float weight, float fadeLength, UINT32 layer)
 	void CAnimation::blendAdditive(const HAnimationClip& clip, float weight, float fadeLength, UINT32 layer)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->play(clip);
 			mInternal->play(clip);
 	}
 	}
 
 
 	void CAnimation::blend1D(const Blend1DInfo& info, float t)
 	void CAnimation::blend1D(const Blend1DInfo& info, float t)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->blend1D(info, t);
 			mInternal->blend1D(info, t);
 	}
 	}
 
 
 	void CAnimation::blend2D(const Blend2DInfo& info, const Vector2& t)
 	void CAnimation::blend2D(const Blend2DInfo& info, const Vector2& t)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->blend2D(info, t);
 			mInternal->blend2D(info, t);
 	}
 	}
 
 
 	void CAnimation::crossFade(const HAnimationClip& clip, float fadeLength)
 	void CAnimation::crossFade(const HAnimationClip& clip, float fadeLength)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->crossFade(clip, fadeLength);
 			mInternal->crossFade(clip, fadeLength);
 	}
 	}
 
 
@@ -86,13 +92,13 @@ namespace bs
 
 
 	void CAnimation::stop(UINT32 layer)
 	void CAnimation::stop(UINT32 layer)
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->stop(layer);
 			mInternal->stop(layer);
 	}
 	}
 
 
 	void CAnimation::stopAll()
 	void CAnimation::stopAll()
 	{
 	{
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->stopAll();
 			mInternal->stopAll();
 	}
 	}
 
 
@@ -118,10 +124,31 @@ namespace bs
 			return mInternal->setState(clip, state);
 			return mInternal->setState(clip, state);
 	}
 	}
 
 
-	void CAnimation::setMorphChannelWeight(UINT32 idx, float weight)
+	void CAnimation::setMorphChannelWeight(const String& name, float weight)
 	{
 	{
-		if (mInternal != nullptr)
-			return mInternal->setMorphChannelWeight(idx, weight);
+		if (mInternal == nullptr)
+			return;
+
+		if (mAnimatedRenderable == nullptr)
+			return;
+
+		HMesh mesh = mAnimatedRenderable->getMesh();
+		if (!mesh.isLoaded())
+			return;
+
+		SPtr<MorphShapes> morphShapes = mesh->getMorphShapes();
+		if (morphShapes == nullptr)
+			return;
+
+		const Vector<SPtr<MorphChannel>>& channels = morphShapes->getChannels();
+		for (UINT32 i = 0; i < (UINT32)channels.size(); i++)
+		{
+			if (channels[i]->getName() == name)
+			{
+				mInternal->setMorphChannelWeight(i, weight);
+				break;
+			}
+		}
 	}
 	}
 
 
 	void CAnimation::setBounds(const AABox& bounds)
 	void CAnimation::setBounds(const AABox& bounds)
@@ -136,11 +163,17 @@ namespace bs
 				if (renderable != nullptr)
 				if (renderable != nullptr)
 					renderable->setOverrideBounds(bounds);
 					renderable->setOverrideBounds(bounds);
 
 
-				if(mInternal != nullptr)
+				if(mInternal != nullptr && !mPreviewMode)
 				{
 				{
 					AABox bounds = mBounds;
 					AABox bounds = mBounds;
-					bounds.transformAffine(SO()->getWorldTfrm());
 
 
+					Matrix4 parentTfrm;
+					if (SO()->getParent() != nullptr)
+						parentTfrm = SO()->getParent()->getWorldTfrm();
+					else
+						parentTfrm = Matrix4::IDENTITY;
+
+					bounds.transformAffine(parentTfrm); 
 					mInternal->setBounds(bounds);
 					mInternal->setBounds(bounds);
 				}
 				}
 			}
 			}
@@ -158,10 +191,26 @@ namespace bs
 	{
 	{
 		mEnableCull = enable;
 		mEnableCull = enable;
 
 
-		if (mInternal != nullptr)
+		if (mInternal != nullptr && !mPreviewMode)
 			mInternal->setCulling(enable);
 			mInternal->setCulling(enable);
 	}
 	}
 
 
+	UINT32 CAnimation::getNumClips() const
+	{
+		if (mInternal != nullptr)
+			return mInternal->getNumClips();
+
+		return 0;
+	}
+
+	HAnimationClip CAnimation::getClip(UINT32 idx) const
+	{
+		if (mInternal != nullptr)
+			return mInternal->getClip(idx);
+
+		return HAnimationClip();
+	}
+
 	void CAnimation::onInitialized()
 	void CAnimation::onInitialized()
 	{
 	{
 		
 		
@@ -179,7 +228,27 @@ namespace bs
 
 
 	void CAnimation::onEnabled()
 	void CAnimation::onEnabled()
 	{
 	{
-		restoreInternal();
+		if(mPreviewMode)
+		{
+			destroyInternal();
+			mPreviewMode = false;
+		}
+
+		restoreInternal(false);
+	}
+
+	void CAnimation::update()
+	{
+		bool isRunning = SceneManager::instance().isRunning();
+		if (mInternal == nullptr || !isRunning)
+			return;
+
+		HAnimationClip newPrimaryClip = mInternal->getClip(0);
+		if (newPrimaryClip != mPrimaryPlayingClip)
+			_refreshClipMappings();
+
+		if (_scriptUpdateFloatProperties)
+			_scriptUpdateFloatProperties();
 	}
 	}
 
 
 	void CAnimation::onTransformChanged(TransformChangedFlags flags)
 	void CAnimation::onTransformChanged(TransformChangedFlags flags)
@@ -191,27 +260,44 @@ namespace bs
 			_updateBounds(false);
 			_updateBounds(false);
 	}
 	}
 
 
-	void CAnimation::restoreInternal()
+	void CAnimation::restoreInternal(bool previewMode)
 	{
 	{
-		if (mInternal == nullptr)
-		{
-			mInternal = Animation::create();
-			mInternal->onEventTriggered.connect(std::bind(&CAnimation::eventTriggered, this, _1, _2));
-		}
+		if (mInternal != nullptr)
+			destroyInternal();
+
+		mInternal = Animation::create();
 
 
 		mAnimatedRenderable = SO()->getComponent<CRenderable>();
 		mAnimatedRenderable = SO()->getComponent<CRenderable>();
 
 
-		mInternal->setWrapMode(mWrapMode);
-		mInternal->setSpeed(mSpeed);
-		mInternal->setCulling(mEnableCull);
+		if (!previewMode)
+		{
+			mInternal->onEventTriggered.connect(std::bind(&CAnimation::eventTriggered, this, _1, _2));
+
+			mInternal->setWrapMode(mWrapMode);
+			mInternal->setSpeed(mSpeed);
+			mInternal->setCulling(mEnableCull);
+		}
 
 
 		_updateBounds();
 		_updateBounds();
 
 
-		if (mDefaultClip.isLoaded())
-			mInternal->play(mDefaultClip);
+		if (!previewMode)
+		{
+			if (mDefaultClip.isLoaded())
+				mInternal->play(mDefaultClip);
+
+			mPrimaryPlayingClip = mInternal->getClip(0);
+			if (mPrimaryPlayingClip.isLoaded())
+			{
+				if (_scriptRebuildFloatProperties)
+					_scriptRebuildFloatProperties(mPrimaryPlayingClip);
+			}
+		}
 
 
 		setBoneMappings();
 		setBoneMappings();
 
 
+		if(!previewMode)
+			updateSceneObjectMapping();
+
 		if (mAnimatedRenderable != nullptr)
 		if (mAnimatedRenderable != nullptr)
 			mAnimatedRenderable->_registerAnimation(mThisHandle);
 			mAnimatedRenderable->_registerAnimation(mThisHandle);
 	}
 	}
@@ -221,10 +307,62 @@ namespace bs
 		if (mAnimatedRenderable != nullptr)
 		if (mAnimatedRenderable != nullptr)
 			mAnimatedRenderable->_unregisterAnimation();
 			mAnimatedRenderable->_unregisterAnimation();
 
 
+		mPrimaryPlayingClip = nullptr;
+		mMappingInfos.clear();
+
 		// This should release the last reference and destroy the internal listener
 		// This should release the last reference and destroy the internal listener
 		mInternal = nullptr;
 		mInternal = nullptr;
 	}
 	}
 
 
+	bool CAnimation::_togglePreviewMode(bool enabled)
+	{
+		bool isRunning = SceneManager::instance().isRunning();
+
+		if(enabled)
+		{
+			// Cannot enable preview while running
+			if (isRunning)
+				return false;
+
+			restoreInternal(true);
+			mPreviewMode = true;
+
+			return true;
+		}
+		else
+		{
+			if (!isRunning)
+				destroyInternal();
+
+			mPreviewMode = false;
+			return false;
+		}
+	}
+
+	bool CAnimation::_getGenericCurveValue(UINT32 curveIdx, float& value)
+	{
+		if (mInternal == nullptr)
+			return false;
+
+		return mInternal->getGenericCurveValue(curveIdx, value);
+	}
+
+	void CAnimation::mapCurveToSceneObject(const String& curve, const HSceneObject& so)
+	{
+		if (mInternal == nullptr)
+			return;
+
+		mInternal->mapCurveToSceneObject(curve, so);
+	}
+
+	void CAnimation::unmapSceneObject(const HSceneObject& so)
+	{
+		if (mInternal == nullptr)
+			return;
+
+		mInternal->unmapSceneObject(so);
+	}
+
 	void CAnimation::_addBone(const HBone& bone)
 	void CAnimation::_addBone(const HBone& bone)
 	{
 	{
 		if (mInternal == nullptr)
 		if (mInternal == nullptr)
@@ -340,6 +478,73 @@ namespace bs
 			_addBone(entry);
 			_addBone(entry);
 	}
 	}
 
 
+	void CAnimation::updateSceneObjectMapping()
+	{
+		Vector<SceneObjectMappingInfo> newMappingInfos;
+		for(auto& entry : mMappingInfos)
+		{
+			if (entry.isMappedToBone)
+				newMappingInfos.push_back(entry);
+			else
+				unmapSceneObject(entry.sceneObject);
+		}
+
+		if (mPrimaryPlayingClip.isLoaded())
+		{
+			HSceneObject root = SO();
+
+			auto& findMappings = [&](const String& name, AnimationCurveFlags flags)
+			{
+				if (flags.isSet(AnimationCurveFlag::ImportedCurve))
+					return;
+
+				HSceneObject currentSO = root->findPath( name);
+
+				bool found = false;
+				for (UINT32 i = 0; i < (UINT32)newMappingInfos.size(); i++)
+				{
+					if (newMappingInfos[i].sceneObject == currentSO)
+					{
+						found = true;
+						break;
+					}
+				}
+
+				if (!found)
+				{
+					SceneObjectMappingInfo newMappingInfo;
+					newMappingInfo.isMappedToBone = false;
+					newMappingInfo.sceneObject = currentSO;
+
+					newMappingInfos.push_back(newMappingInfo);
+					mapCurveToSceneObject(name, currentSO);
+				}
+			};
+
+			SPtr<AnimationCurves> curves = mPrimaryPlayingClip->getCurves();
+			for(auto& curve : curves->position)
+				findMappings(curve.name, curve.flags);
+
+			for(auto& curve : curves->rotation)
+				findMappings(curve.name, curve.flags);
+
+			for(auto& curve : curves->scale)
+				findMappings(curve.name, curve.flags);
+		}
+
+		mMappingInfos = newMappingInfos;
+	}
+
+	void CAnimation::_refreshClipMappings()
+	{
+		mPrimaryPlayingClip = mInternal->getClip(0);
+
+		if (_scriptRebuildFloatProperties)
+			_scriptRebuildFloatProperties(mPrimaryPlayingClip);
+
+		updateSceneObjectMapping();		
+	}
+
 	Vector<HBone> CAnimation::findChildBones()
 	Vector<HBone> CAnimation::findChildBones()
 	{
 	{
 		Stack<HSceneObject> todo;
 		Stack<HSceneObject> todo;
@@ -375,6 +580,9 @@ namespace bs
 	void CAnimation::eventTriggered(const HAnimationClip& clip, const String& name)
 	void CAnimation::eventTriggered(const HAnimationClip& clip, const String& name)
 	{
 	{
 		onEventTriggered(clip, name);
 		onEventTriggered(clip, name);
+
+		if(_scriptOnEventTriggered)
+			_scriptOnEventTriggered(clip, name);
 	}
 	}
 
 
 	RTTITypeBase* CAnimation::getRTTIStatic()
 	RTTITypeBase* CAnimation::getRTTIStatic()

+ 112 - 14
Source/BansheeCore/Components/BsCAnimation.h

@@ -15,10 +15,10 @@ namespace bs
 	/**
 	/**
 	 * @copydoc	Animation
 	 * @copydoc	Animation
 	 *
 	 *
-	 * Wraps Animation as a Component.
+	 * @note	Wraps Animation as a Component.
 	 */
 	 */
-    class BS_CORE_EXPORT CAnimation : public Component
-    {
+	class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Animation,n:Animation) CAnimation : public Component
+	{
 		/** Information about scene objects bound to a specific animation curve. */
 		/** Information about scene objects bound to a specific animation curve. */
 		struct SceneObjectMappingInfo
 		struct SceneObjectMappingInfo
 		{
 		{
@@ -27,80 +27,127 @@ namespace bs
 			HBone bone;
 			HBone bone;
 		};
 		};
 
 
-    public:
+	public:
 		CAnimation(const HSceneObject& parent);
 		CAnimation(const HSceneObject& parent);
 		virtual ~CAnimation() {}
 		virtual ~CAnimation() {}
 		
 		
 		/** 
 		/** 
-		 * Sets the default clip to play as soon as the component is enabled. If more control over playing clips is needed
+		 * Determines the default clip to play as soon as the component is enabled. If more control over playing clips is needed
 		 * use the play(), blend() and crossFade() methods to queue clips for playback manually, and setState() method for
 		 * use the play(), blend() and crossFade() methods to queue clips for playback manually, and setState() method for
 		 * modify their states individually.
 		 * modify their states individually.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:DefaultClip,pr:setter)
 		void setDefaultClip(const HAnimationClip& clip);
 		void setDefaultClip(const HAnimationClip& clip);
 
 
+		/** @copydoc setDefaultClip */
+		BS_SCRIPT_EXPORT(n:DefaultClip,pr:getter)
+		HAnimationClip getDefaultClip() const { return mDefaultClip; }
+
 		/** @copydoc Animation::setWrapMode */
 		/** @copydoc Animation::setWrapMode */
+		BS_SCRIPT_EXPORT(n:WrapMode,pr:setter)
 		void setWrapMode(AnimWrapMode wrapMode);
 		void setWrapMode(AnimWrapMode wrapMode);
 
 
+		/** @copydoc setWrapMode */
+		BS_SCRIPT_EXPORT(n:WrapMode,pr:getter)
+		AnimWrapMode getWrapMode() const { return mWrapMode; }
+
 		/** @copydoc Animation::setSpeed */
 		/** @copydoc Animation::setSpeed */
+		BS_SCRIPT_EXPORT(n:Speed,pr:setter)
 		void setSpeed(float speed);
 		void setSpeed(float speed);
 
 
+		/** @copydoc setSpeed */
+		BS_SCRIPT_EXPORT(n:Speed,pr:getter)
+		float getSpeed() const { return mSpeed; }
+
 		/** @copydoc Animation::play */
 		/** @copydoc Animation::play */
+		BS_SCRIPT_EXPORT(n:Play)
 		void play(const HAnimationClip& clip);
 		void play(const HAnimationClip& clip);
 
 
 		/** @copydoc Animation::blendAdditive */
 		/** @copydoc Animation::blendAdditive */
+		BS_SCRIPT_EXPORT(n:BlendAdditive)
 		void blendAdditive(const HAnimationClip& clip, float weight, float fadeLength = 0.0f, UINT32 layer = 0);
 		void blendAdditive(const HAnimationClip& clip, float weight, float fadeLength = 0.0f, UINT32 layer = 0);
 
 
 		/** @copydoc Animation::blend1D */
 		/** @copydoc Animation::blend1D */
+		BS_SCRIPT_EXPORT(n:Blend1D)
 		void blend1D(const Blend1DInfo& info, float t);
 		void blend1D(const Blend1DInfo& info, float t);
 
 
 		/** @copydoc Animation::blend2D */
 		/** @copydoc Animation::blend2D */
+		BS_SCRIPT_EXPORT(n:Blend2D)
 		void blend2D(const Blend2DInfo& info, const Vector2& t);
 		void blend2D(const Blend2DInfo& info, const Vector2& t);
 
 
 		/** @copydoc Animation::crossFade */
 		/** @copydoc Animation::crossFade */
+		BS_SCRIPT_EXPORT(n:CrossFade)
 		void crossFade(const HAnimationClip& clip, float fadeLength);
 		void crossFade(const HAnimationClip& clip, float fadeLength);
 
 
 		/** @copydoc Animation::sample */
 		/** @copydoc Animation::sample */
+		BS_SCRIPT_EXPORT(n:Sample)
 		void sample(const HAnimationClip& clip, float time);
 		void sample(const HAnimationClip& clip, float time);
 
 
 		/** @copydoc Animation::stop */
 		/** @copydoc Animation::stop */
+		BS_SCRIPT_EXPORT(n:Stop)
 		void stop(UINT32 layer);
 		void stop(UINT32 layer);
 
 
 		/** @copydoc Animation::stopAll */
 		/** @copydoc Animation::stopAll */
+		BS_SCRIPT_EXPORT(n:StopAll)
 		void stopAll();
 		void stopAll();
 		
 		
 		/** @copydoc Animation::isPlaying */
 		/** @copydoc Animation::isPlaying */
+		BS_SCRIPT_EXPORT(n:IsPlaying,pr:getter)
 		bool isPlaying() const;
 		bool isPlaying() const;
 
 
 		/** @copydoc Animation::getState */
 		/** @copydoc Animation::getState */
+		BS_SCRIPT_EXPORT(n:GetState)
 		bool getState(const HAnimationClip& clip, AnimationClipState& state);
 		bool getState(const HAnimationClip& clip, AnimationClipState& state);
 
 
 		/** @copydoc Animation::setState */
 		/** @copydoc Animation::setState */
+		BS_SCRIPT_EXPORT(n:SetState)
 		void setState(const HAnimationClip& clip, AnimationClipState state);
 		void setState(const HAnimationClip& clip, AnimationClipState state);
 
 
-		/** @copydoc Animation::setMorphChannelWeight */
-		void setMorphChannelWeight(UINT32 idx, float weight);
+		/**
+		 * Changes a weight of a single morph channel, determining how much of it to apply on top of the base mesh.
+		 *
+		 * @param name		Name of the morph channel to modify. This depends on the mesh the animation is currently
+		 *					animating. 
+		 * @param weight	Weight that determines how much of the channel to apply to the mesh, in range [0, 1]. 	
+		 */
+		BS_SCRIPT_EXPORT(n:SetMorphChannelWeight)
+		void setMorphChannelWeight(const String& name, float weight);
 
 
-		/** Sets bounds that will be used for animation and mesh culling. Only relevant if setUseBounds() is set to true. */
+		/** Determines bounds that will be used for animation and mesh culling. Only relevant if setUseBounds() is set to true. */
+		BS_SCRIPT_EXPORT(n:Bounds,pr:setter)
 		void setBounds(const AABox& bounds);
 		void setBounds(const AABox& bounds);
 
 
-		/** Gets animation bounds. @see setBounds. */
+		/** @copydoc setBounds */
+		BS_SCRIPT_EXPORT(n:Bounds,pr:getter)
 		const AABox& getBounds() const { return mBounds; }
 		const AABox& getBounds() const { return mBounds; }
 
 
 		/** 
 		/** 
 		 * Determines should animation bounds be used for visibility determination (culling). If false the bounds of the
 		 * Determines should animation bounds be used for visibility determination (culling). If false the bounds of the
-         * mesh attached to the relevant CRenderable component will be used instead.
+		 * mesh attached to the relevant CRenderable component will be used instead.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:UseBounds,pr:setter)
 		void setUseBounds(bool enable);
 		void setUseBounds(bool enable);
 
 
-		/** Checks whether animation bounds are enabled. @see setUseBounds. */
+		/** @copydoc setUseBounds */
+		BS_SCRIPT_EXPORT(n:UseBounds,pr:getter)
 		bool getUseBounds() const { return mUseBounds; }
 		bool getUseBounds() const { return mUseBounds; }
 
 
 		/** Enables or disables culling of the animation when out of view. Culled animation will not be evaluated. */
 		/** Enables or disables culling of the animation when out of view. Culled animation will not be evaluated. */
+		BS_SCRIPT_EXPORT(n:Cull,pr:setter)
 		void setEnableCull(bool enable);
 		void setEnableCull(bool enable);
 
 
 		/** Checks whether the animation will be evaluated when it is out of view. */
 		/** Checks whether the animation will be evaluated when it is out of view. */
+		BS_SCRIPT_EXPORT(n:Cull,pr:getter)
 		bool getEnableCull() const { return mEnableCull; }
 		bool getEnableCull() const { return mEnableCull; }
 
 
+		/** @copydoc Animation::getNumClips */
+		BS_SCRIPT_EXPORT(in:true)
+		UINT32 getNumClips() const;
+
+		/** @copydoc Animation::getClip */
+		BS_SCRIPT_EXPORT(in:true)
+		HAnimationClip getClip(UINT32 idx) const;
+
 		/** Triggered whenever an animation event is reached. */
 		/** Triggered whenever an animation event is reached. */
 		Event<void(const HAnimationClip&, const String&)> onEventTriggered;
 		Event<void(const HAnimationClip&, const String&)> onEventTriggered;
 
 
@@ -138,6 +185,40 @@ namespace bs
 		/** Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists. */
 		/** Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists. */
 		void _updateBounds(bool updateRenderable = true);
 		void _updateBounds(bool updateRenderable = true);
 
 
+		/**
+		 * Rebuilds internal curve -> property mapping about the currently playing animation clip. This mapping allows the
+		 * animation component to know which property to assign which values from an animation curve. This Should be called
+		 * whenever playback for a new clip starts, or when clip curves change.
+		 */
+		BS_SCRIPT_EXPORT(in:true)
+		void _refreshClipMappings();
+
+		/** @copydoc Animation::getGenericCurveValue */
+		BS_SCRIPT_EXPORT(in:true)
+		bool _getGenericCurveValue(UINT32 curveIdx, float& value);
+
+		/** 
+		 * Preview mode allows certain operations on the component to be allowed (like basic animation playback), 
+		 * even when the component is not actively running. This is intended for use primarily by the animation editor. 
+		 * Preview mode ends automatically when the component is enabled (i.e. starts running normally), or when 
+		 * explicitly disabled. Returns true if the preview mode was enabled (which could fail if the component is
+		 * currently running).
+		 */
+		BS_SCRIPT_EXPORT(in:true)
+		bool _togglePreviewMode(bool enabled);
+
+		/** Triggered when the list of properties animated via generic animation curves needs to be recreated (script only). */
+		BS_SCRIPT_EXPORT(n:RebuildFloatProperties)
+		std::function<void(const HAnimationClip&)> _scriptRebuildFloatProperties;
+
+		/** Triggered when generic animation curves values need be applied to the properties they effect (script only). */
+		BS_SCRIPT_EXPORT(n:_UpdateFloatProperties)
+		std::function<void()> _scriptUpdateFloatProperties;
+
+		/** Triggers a callback in script code when animation event is triggered (script only). */
+		BS_SCRIPT_EXPORT(n:EventTriggered)
+		std::function<void(const HAnimationClip&, const String&)> _scriptOnEventTriggered;
+
 		/** @} */
 		/** @} */
 
 
 		/************************************************************************/
 		/************************************************************************/
@@ -152,6 +233,9 @@ namespace bs
 		/** @copydoc Component::onDestroyed() */
 		/** @copydoc Component::onDestroyed() */
 		void onDestroyed() override;
 		void onDestroyed() override;
 
 
+		/** @copydoc Component::update() */
+		void update() override;
+
 		/** @copydoc Component::onDisabled() */
 		/** @copydoc Component::onDisabled() */
 		void onDisabled() override;
 		void onDisabled() override;
 
 
@@ -160,11 +244,11 @@ namespace bs
 
 
 		/** @copydoc Component::onTransformChanged() */
 		/** @copydoc Component::onTransformChanged() */
 		void onTransformChanged(TransformChangedFlags flags) override;
 		void onTransformChanged(TransformChangedFlags flags) override;
-    protected:
+	protected:
 		using Component::destroyInternal;
 		using Component::destroyInternal;
 
 
 		/** Creates the internal representation of the Animation and restores the values saved by the Component. */
 		/** Creates the internal representation of the Animation and restores the values saved by the Component. */
-		void restoreInternal();
+		void restoreInternal(bool previewMode);
 
 
 		/** Destroys the internal Animation representation. */
 		/** Destroys the internal Animation representation. */
 		void destroyInternal();
 		void destroyInternal();
@@ -178,6 +262,18 @@ namespace bs
 		 */
 		 */
 		void setBoneMappings();
 		void setBoneMappings();
 
 
+		/**
+		 * Finds any curves that affect a transform of a specific scene object, and ensures that animation properly updates
+		 * those transforms. This does not include curves referencing bones.
+		 */
+		void updateSceneObjectMapping();
+
+		/** @copydoc Animation::mapCurveToSceneObject */
+		void mapCurveToSceneObject(const String& curve, const HSceneObject& so);
+
+		/** @copydoc Animation::unmapSceneObject */
+		void unmapSceneObject(const HSceneObject& so);
+		
 		/** Searches child scene objects for Bone components and returns any found ones. */
 		/** Searches child scene objects for Bone components and returns any found ones. */
 		Vector<HBone> findChildBones();
 		Vector<HBone> findChildBones();
 
 
@@ -185,10 +281,12 @@ namespace bs
 		HRenderable mAnimatedRenderable;
 		HRenderable mAnimatedRenderable;
 
 
 		HAnimationClip mDefaultClip;
 		HAnimationClip mDefaultClip;
+		HAnimationClip mPrimaryPlayingClip;
 		AnimWrapMode mWrapMode;
 		AnimWrapMode mWrapMode;
 		float mSpeed;
 		float mSpeed;
 		bool mEnableCull;
 		bool mEnableCull;
 		bool mUseBounds;
 		bool mUseBounds;
+		bool mPreviewMode;
 		AABox mBounds;
 		AABox mBounds;
 
 
 		Vector<SceneObjectMappingInfo> mMappingInfos;
 		Vector<SceneObjectMappingInfo> mMappingInfos;
@@ -203,7 +301,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		CAnimation(); // Serialization only
 		CAnimation(); // Serialization only
-     };
+	 };
 
 
 	 /** @} */
 	 /** @} */
 }
 }

+ 7 - 0
Source/BansheeCore/Components/BsCBone.cpp

@@ -9,6 +9,13 @@ using namespace std::placeholders;
 
 
 namespace bs
 namespace bs
 {
 {
+	CBone::CBone()
+	{
+		setName("Bone");
+
+		mNotifyFlags = TCF_Parent;
+	}
+
 	CBone::CBone(const HSceneObject& parent)
 	CBone::CBone(const HSceneObject& parent)
 		: Component(parent)
 		: Component(parent)
 	{
 	{

+ 10 - 8
Source/BansheeCore/Components/BsCBone.h

@@ -15,16 +15,18 @@ namespace bs
 	 * Component that maps animation for specific bone also be applied to the SceneObject this component is attached to. 
 	 * Component that maps animation for specific bone also be applied to the SceneObject this component is attached to. 
 	 * The component will attach to the first found parent Animation component.
 	 * The component will attach to the first found parent Animation component.
 	 */
 	 */
-    class BS_CORE_EXPORT CBone : public Component
-    {
-    public:
+	class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Animation,n:Bone) CBone : public Component
+	{
+	public:
 		CBone(const HSceneObject& parent);
 		CBone(const HSceneObject& parent);
 		virtual ~CBone() {}
 		virtual ~CBone() {}
 		
 		
-		/** Changes the name of the bone the component is referencing. */
+		/** Determines the name of the bone the component is referencing. */
+		BS_SCRIPT_EXPORT(n:Name,pr:setter)
 		void setBoneName(const String& name);
 		void setBoneName(const String& name);
 
 
-		/** Returns the name of the bone the component is referencing. */
+		/** @copydoc setBoneName */
+		BS_SCRIPT_EXPORT(n:Name,pr:getter)
 		const String& getBoneName() const { return mBoneName; }
 		const String& getBoneName() const { return mBoneName; }
 
 
 		/** @name Internal
 		/** @name Internal
@@ -62,7 +64,7 @@ namespace bs
 
 
 		/** @copydoc Component::onTransformChanged() */
 		/** @copydoc Component::onTransformChanged() */
 		void onTransformChanged(TransformChangedFlags flags) override;
 		void onTransformChanged(TransformChangedFlags flags) override;
-    protected:
+	protected:
 		using Component::destroyInternal;
 		using Component::destroyInternal;
 
 
 		String mBoneName;
 		String mBoneName;
@@ -77,8 +79,8 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 		RTTITypeBase* getRTTI() const override;
 
 
 	protected:
 	protected:
-		CBone() {} // Serialization only
-     };
+		CBone(); // Serialization only
+	 };
 
 
 	 /** @} */
 	 /** @} */
 }
 }

+ 7 - 7
Source/BansheeCore/Components/BsCCamera.cpp

@@ -9,21 +9,21 @@ namespace bs
 {
 {
 	CCamera::CCamera()
 	CCamera::CCamera()
 	{
 	{
-		Component::setFlag(ComponentFlag::AlwaysRun, true);
+		setFlag(ComponentFlag::AlwaysRun, true);
 		setName("Camera");
 		setName("Camera");
 	}
 	}
 
 
 	CCamera::CCamera(const HSceneObject& parent, SPtr<RenderTarget> target, float left, float top, float width, float height)
 	CCamera::CCamera(const HSceneObject& parent, SPtr<RenderTarget> target, float left, float top, float width, float height)
 		: Component(parent), mTarget(target), mLeft(left), mTop(top), mWidth(width), mHeight(height)
 		: Component(parent), mTarget(target), mLeft(left), mTop(top), mWidth(width), mHeight(height)
-    {
-		Component::setFlag(ComponentFlag::AlwaysRun, true);
+	{
+		setFlag(ComponentFlag::AlwaysRun, true);
 		setName("Camera");
 		setName("Camera");
-    }
+	}
 
 
-    CCamera::~CCamera()
-    {
+	CCamera::~CCamera()
+	{
 		mInternal->destroy();
 		mInternal->destroy();
-    }
+	}
 
 
 	ConvexVolume CCamera::getWorldFrustum() const
 	ConvexVolume CCamera::getWorldFrustum() const
 	{
 	{

+ 24 - 8
Source/BansheeCore/Components/BsCRenderable.h

@@ -16,33 +16,49 @@ namespace bs
 	/**
 	/**
 	 * @copydoc	Renderable
 	 * @copydoc	Renderable
 	 * 			
 	 * 			
-	 * Wraps a TRenderable as a Component.
+	 * @note Wraps a TRenderable as a Component.
 	 */
 	 */
-	class BS_CORE_EXPORT CRenderable : public Component
+	class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Rendering,n:Renderable) CRenderable : public Component
 	{
 	{
 	public:
 	public:
 		/** @copydoc Renderable::setMesh */
 		/** @copydoc Renderable::setMesh */
+		BS_SCRIPT_EXPORT(n:Mesh,pr:setter)
 		void setMesh(HMesh mesh);
 		void setMesh(HMesh mesh);
 
 
+		/** @copydoc Renderable::getMesh */
+		BS_SCRIPT_EXPORT(n:Mesh,pr:getter)
+		HMesh getMesh() const { return mInternal->getMesh(); }
+
 		/** @copydoc Renderable::setMaterial */
 		/** @copydoc Renderable::setMaterial */
+		BS_SCRIPT_EXPORT(n:SetMaterial)
 		void setMaterial(UINT32 idx, HMaterial material) { mInternal->setMaterial(idx, material); }
 		void setMaterial(UINT32 idx, HMaterial material) { mInternal->setMaterial(idx, material); }
 
 
 		/** @copydoc Renderable::setMaterial */
 		/** @copydoc Renderable::setMaterial */
+		BS_SCRIPT_EXPORT(n:SetMaterial)
 		void setMaterial(HMaterial material) { mInternal->setMaterial(material); }
 		void setMaterial(HMaterial material) { mInternal->setMaterial(material); }
 
 
+		/** @copydoc Renderable::getMaterial */
+		BS_SCRIPT_EXPORT(n:GetMaterial)
+		HMaterial getMaterial(UINT32 idx) const { return mInternal->getMaterial(idx); }
+
+		/** @copydoc Renderable::setMaterials */
+		BS_SCRIPT_EXPORT(n:Materials,pr:setter)
+		void setMaterials(const Vector<HMaterial>& materials) { mInternal->setMaterials(materials); }
+
+		/** @copydoc Renderable::getMaterials */
+		BS_SCRIPT_EXPORT(n:Materials,pr:getter)
+		const Vector<HMaterial>& getMaterials() { return mInternal->getMaterials(); }
+
 		/** @copydoc Renderable::setLayer */
 		/** @copydoc Renderable::setLayer */
+		BS_SCRIPT_EXPORT(n:Layers,pr:setter)
 		void setLayer(UINT64 layer) { mInternal->setLayer(layer); }
 		void setLayer(UINT64 layer) { mInternal->setLayer(layer); }
 
 
 		/** @copydoc Renderable::getLayer */
 		/** @copydoc Renderable::getLayer */
+		BS_SCRIPT_EXPORT(n:Layers,pr:getter)
 		UINT64 getLayer() const { return mInternal->getLayer(); }
 		UINT64 getLayer() const { return mInternal->getLayer(); }
 
 
-		/** @copydoc Renderable::getMesh */
-		HMesh getMesh() const { return mInternal->getMesh(); }
-
-		/** @copydoc Renderable::getMaterial */
-		HMaterial getMaterial(UINT32 idx) const { return mInternal->getMaterial(idx); }
-
 		/**	Gets world bounds of the mesh rendered by this object. */
 		/**	Gets world bounds of the mesh rendered by this object. */
+		BS_SCRIPT_EXPORT(n:Bounds,pr:getter)
 		Bounds getBounds() const;
 		Bounds getBounds() const;
 
 
 		/** @copydoc Component::calculateBounds */
 		/** @copydoc Component::calculateBounds */

+ 23 - 23
Source/BansheeCore/Image/BsTexture.h

@@ -15,8 +15,8 @@ namespace bs
 	 */
 	 */
 
 
 	/**	Flags that describe how is a texture used. */
 	/**	Flags that describe how is a texture used. */
-    enum BS_SCRIPT_EXPORT(m:Rendering) TextureUsage
-    {
+	enum BS_SCRIPT_EXPORT(m:Rendering) TextureUsage
+	{
 		/** A regular texture that is not often or ever updated from the CPU. */
 		/** A regular texture that is not often or ever updated from the CPU. */
 		TU_STATIC			BS_SCRIPT_EXPORT(n:Default)			= GBU_STATIC, 
 		TU_STATIC			BS_SCRIPT_EXPORT(n:Default)			= GBU_STATIC, 
 		/** A regular texture that is often updated by the CPU. */
 		/** A regular texture that is often updated by the CPU. */
@@ -33,7 +33,7 @@ namespace bs
 		TU_CPUREADABLE		BS_SCRIPT_EXPORT(n:CPUReadable)		= 0x2000,
 		TU_CPUREADABLE		BS_SCRIPT_EXPORT(n:CPUReadable)		= 0x2000,
 		/** Default (most common) texture usage. */
 		/** Default (most common) texture usage. */
 		TU_DEFAULT			BS_SCRIPT_EXPORT(ex:true)			= TU_STATIC
 		TU_DEFAULT			BS_SCRIPT_EXPORT(ex:true)			= TU_STATIC
-    };
+	};
 
 
 	/**	Texture mipmap options. */
 	/**	Texture mipmap options. */
 	enum TextureMipmap
 	enum TextureMipmap
@@ -86,13 +86,13 @@ namespace bs
 		TextureProperties(const TEXTURE_DESC& desc);
 		TextureProperties(const TEXTURE_DESC& desc);
 
 
 		/**	Gets the type of texture. */
 		/**	Gets the type of texture. */
-        TextureType getTextureType() const { return mDesc.type; }
+		TextureType getTextureType() const { return mDesc.type; }
 
 
-        /**
+		/**
 		 * Gets the number of mipmaps to be used for this texture. This number excludes the top level map (which is always
 		 * Gets the number of mipmaps to be used for this texture. This number excludes the top level map (which is always
 		 * assumed to be present).
 		 * assumed to be present).
-         */
-        UINT32 getNumMipmaps() const {return mDesc.numMips;}
+		 */
+		UINT32 getNumMipmaps() const { return mDesc.numMips; }
 
 
 		/** 
 		/** 
 		 * Determines does the texture contain gamma corrected data. If true then the GPU will automatically convert the 
 		 * Determines does the texture contain gamma corrected data. If true then the GPU will automatically convert the 
@@ -104,29 +104,29 @@ namespace bs
 		/**	Gets the number of samples used for multisampling (0 or 1 if multisampling is not used). */
 		/**	Gets the number of samples used for multisampling (0 or 1 if multisampling is not used). */
 		UINT32 getNumSamples() const { return mDesc.numSamples; }
 		UINT32 getNumSamples() const { return mDesc.numSamples; }
 
 
-        /**	Returns the height of the texture.  */
-        UINT32 getHeight() const { return mDesc.height; }
+		/**	Returns the height of the texture.  */
+		UINT32 getHeight() const { return mDesc.height; }
 
 
-        /**	Returns the width of the texture. */
-        UINT32 getWidth() const { return mDesc.width; }
+		/**	Returns the width of the texture. */
+		UINT32 getWidth() const { return mDesc.width; }
 
 
-        /**	Returns the depth of the texture (only applicable for 3D textures). */
-        UINT32 getDepth() const { return mDesc.depth; }
+		/**	Returns the depth of the texture (only applicable for 3D textures). */
+		UINT32 getDepth() const { return mDesc.depth; }
 
 
-        /**	Returns a value that signals the engine in what way is the texture expected to be used. */
-        int getUsage() const { return mDesc.usage; }
+		/**	Returns a value that signals the engine in what way is the texture expected to be used. */
+		int getUsage() const { return mDesc.usage; }
 
 
 		/**	Returns the pixel format for the texture surface. */
 		/**	Returns the pixel format for the texture surface. */
 		PixelFormat getFormat() const { return mDesc.format; }
 		PixelFormat getFormat() const { return mDesc.format; }
 
 
-        /**	Returns true if the texture has an alpha layer. */
-        bool hasAlpha() const;
+		/**	Returns true if the texture has an alpha layer. */
+		bool hasAlpha() const;
 
 
-        /**	
-         * Returns the number of faces this texture has. This includes array slices (if texture is an array texture),
-         * as well as cube-map faces.
-         */
-        UINT32 getNumFaces() const;
+		/**
+		 * Returns the number of faces this texture has. This includes array slices (if texture is an array texture),
+		 * as well as cube-map faces.
+		 */
+		UINT32 getNumFaces() const;
 
 
 		/** Returns the number of array slices of the texture (if the texture is an array texture). */
 		/** Returns the number of array slices of the texture (if the texture is an array texture). */
 		UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
 		UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
@@ -164,7 +164,7 @@ namespace bs
 	 *
 	 *
 	 * @note	Sim thread.
 	 * @note	Sim thread.
 	 */
 	 */
-    class BS_CORE_EXPORT BS_SCRIPT_EXPORT() Texture : public Resource
+    class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Rendering) Texture : public Resource
     {
     {
     public:
     public:
 		/**
 		/**

+ 20 - 1
Source/BansheeCore/Material/BsMaterial.h

@@ -117,6 +117,7 @@ namespace bs
 		virtual ~TMaterial() { }
 		virtual ~TMaterial() { }
 
 
 		/** Returns the currently active shader. */
 		/** Returns the currently active shader. */
+		BS_SCRIPT_EXPORT(n:Shader,pr:getter)
 		ShaderType getShader() const { return mShader; }
 		ShaderType getShader() const { return mShader; }
 
 
 		/** Returns the total number of techniques supported by this material. */
 		/** Returns the total number of techniques supported by this material. */
@@ -171,6 +172,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetFloat)
 		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)	{ return getParamFloat(name).set(value, arrayIdx); }
 		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)	{ return getParamFloat(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -178,6 +180,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetColor)
 		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0) { return getParamColor(name).set(value, arrayIdx); }
 		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0) { return getParamColor(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -185,6 +188,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetVector2)
 		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)	{ return getParamVec2(name).set(value, arrayIdx); }
 		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)	{ return getParamVec2(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -192,6 +196,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetVector3)
 		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)	{ return getParamVec3(name).set(value, arrayIdx); }
 		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)	{ return getParamVec3(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -199,6 +204,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetVector4)
 		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)	{ return getParamVec4(name).set(value, arrayIdx); }
 		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)	{ return getParamVec4(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -206,6 +212,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetMatrix3)
 		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)	{ return getParamMat3(name).set(value, arrayIdx); }
 		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)	{ return getParamMat3(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -213,6 +220,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:SetMatrix4)
 		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)	{ return getParamMat4(name).set(value, arrayIdx); }
 		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)	{ return getParamMat4(name).set(value, arrayIdx); }
 
 
 		/**   
 		/**   
@@ -247,6 +255,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetFloat)
 		float getFloat(const String& name, UINT32 arrayIdx = 0) const { return getParamFloat(name).get(arrayIdx); }
 		float getFloat(const String& name, UINT32 arrayIdx = 0) const { return getParamFloat(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -254,6 +263,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetColor)
 		Color getColor(const String& name, UINT32 arrayIdx = 0) const { return getParamColor(name).get(arrayIdx); }
 		Color getColor(const String& name, UINT32 arrayIdx = 0) const { return getParamColor(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -261,6 +271,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetVector2)
 		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const { return getParamVec2(name).get(arrayIdx); }
 		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const { return getParamVec2(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -268,6 +279,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetVector3)
 		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const { return getParamVec3(name).get(arrayIdx); }
 		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const { return getParamVec3(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -275,6 +287,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetVector4)
 		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const { return getParamVec4(name).get(arrayIdx); }
 		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const { return getParamVec4(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -282,6 +295,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetMatrix3)
 		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const { return getParamMat3(name).get(arrayIdx); }
 		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const { return getParamMat3(name).get(arrayIdx); }
 
 
 		/**
 		/**
@@ -289,6 +303,7 @@ namespace bs
 		 *
 		 *
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:GetMatrix4)
 		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const { return getParamMat4(name).get(arrayIdx); }
 		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const { return getParamMat4(name).get(arrayIdx); }
 
 
 		/** Returns a texture assigned with the parameter with the specified name. */
 		/** Returns a texture assigned with the parameter with the specified name. */
@@ -555,7 +570,7 @@ namespace bs
 	 */
 	 */
 
 
 	/** @copydoc MaterialBase */
 	/** @copydoc MaterialBase */
-	class BS_CORE_EXPORT Material : public Resource, public TMaterial<false>, public IResourceListener
+	class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Rendering) Material: public Resource, public TMaterial<false>, public IResourceListener
 	{
 	{
 	public:
 	public:
 		~Material() { }
 		~Material() { }
@@ -571,6 +586,7 @@ namespace bs
 		 * (render system, renderer, etc), you will need to call this method again on all your Materials to make sure
 		 * (render system, renderer, etc), you will need to call this method again on all your Materials to make sure
 		 * technique used is updated.
 		 * technique used is updated.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(n:Shader,pr:setter)
 		void setShader(const HShader& shader);
 		void setShader(const HShader& shader);
 
 
 		/** Retrieves an implementation of a material usable only from the core thread. */
 		/** Retrieves an implementation of a material usable only from the core thread. */
@@ -580,6 +596,7 @@ namespace bs
 		void initialize() override;
 		void initialize() override;
 
 
 		/** Creates a deep copy of the material and returns the new object. */
 		/** Creates a deep copy of the material and returns the new object. */
+		BS_SCRIPT_EXPORT(n:Clone)
 		HMaterial clone();
 		HMaterial clone();
 
 
 		/**
 		/**
@@ -587,9 +604,11 @@ namespace bs
 		 * 			
 		 * 			
 		 * @note	Make sure you call Material::setShader before using it.
 		 * @note	Make sure you call Material::setShader before using it.
 		 */
 		 */
+		BS_SCRIPT_EXPORT(ec:Material)
 		static HMaterial create();
 		static HMaterial create();
 
 
 		/** Creates a new material with the specified shader. */
 		/** Creates a new material with the specified shader. */
+		BS_SCRIPT_EXPORT(ec:Material)
 		static HMaterial create(const HShader& shader);
 		static HMaterial create(const HShader& shader);
 
 
 		/** @name Internal
 		/** @name Internal

+ 9 - 2
Source/BansheeCore/Material/BsShader.h

@@ -369,14 +369,21 @@ namespace bs
 	typedef TSHADER_DESC<false> SHADER_DESC;
 	typedef TSHADER_DESC<false> SHADER_DESC;
 
 
 	/** 
 	/** 
+	 * @native
 	 * Shader represents a collection of techniques that control object rendering. They are used in Material%s, which can be
 	 * Shader represents a collection of techniques that control object rendering. They are used in Material%s, which can be
 	 * considered as instances of a Shader. Multiple materials may share the same shader but provide different parameters to
 	 * considered as instances of a Shader. Multiple materials may share the same shader but provide different parameters to
 	 * it.
 	 * it.
 	 *
 	 *
 	 * Shader will always choose the first supported technique based on the current render system, render manager and other
 	 * Shader will always choose the first supported technique based on the current render system, render manager and other
-	 * properties. So make sure to add most important techniques first so you make sure they are used if they are supported. 
+	 * properties. So make sure to add most important techniques first so you make sure they are used if they are supported.
+	 * @endnative
+	 * 
+	 * @script
+	 * Contains definitions of GPU programs used for rendering, as well as a set of global parameters to control those 
+	 * programs.
+	 * @endscript
 	 */
 	 */
-	class BS_CORE_EXPORT Shader : public Resource, public TShader<false>
+	class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Rendering) Shader : public Resource, public TShader<false>
 	{
 	{
 	public:
 	public:
 		/** Retrieves an implementation of a shader usable only from the core thread. */
 		/** Retrieves an implementation of a shader usable only from the core thread. */

+ 8 - 14
Source/BansheeCore/Renderer/BsRenderable.h

@@ -50,8 +50,8 @@ namespace bs
 		virtual ~TRenderable();
 		virtual ~TRenderable();
 
 
 		/**
 		/**
-		 * Sets the mesh to render. All sub-meshes of the mesh will be rendered, and you may set individual materials for
-		 * each sub-mesh.
+		 * Determines the mesh to render. All sub-meshes of the mesh will be rendered, and you may set individual materials
+		 * for each sub-mesh.
 		 */
 		 */
 		void setMesh(const MeshType& mesh);
 		void setMesh(const MeshType& mesh);
 
 
@@ -69,22 +69,19 @@ namespace bs
 		 */
 		 */
 		void setMaterial(const MaterialType& material);
 		void setMaterial(const MaterialType& material);
 
 
-		/**
-		 * Returns all materials used for rendering this renderable. Each of the materials is used for rendering a single
-		 * sub-mesh.
-		 */
+		/** @copydoc setMaterials() */
 		const Vector<MaterialType>& getMaterials() { return mMaterials; }
 		const Vector<MaterialType>& getMaterials() { return mMaterials; }
 
 
 		/**
 		/**
-		 * Sets all materials used for rendering this renderable. Each of the materials is used for rendering a single
+		 * Determines all materials used for rendering this renderable. Each of the materials is used for rendering a single
 		 * sub-mesh. If number of materials is larger than number of sub-meshes, they will be ignored. If lower, the
 		 * sub-mesh. If number of materials is larger than number of sub-meshes, they will be ignored. If lower, the
 		 * remaining materials will be removed.
 		 * remaining materials will be removed.
 		 */
 		 */
 		void setMaterials(const Vector<MaterialType>& materials);
 		void setMaterials(const Vector<MaterialType>& materials);
 
 
 		/**
 		/**
-		 * Sets the layer bitfield that controls whether a renderable is considered visible in a specific camera. Renderable
-		 * layer must match camera layer in order for the camera to render the component.
+		 * Determines the layer bitfield that controls whether a renderable is considered visible in a specific camera. 
+		 * Renderable layer must match camera layer in order for the camera to render the component.
 		 */
 		 */
 		void setLayer(UINT64 layer);
 		void setLayer(UINT64 layer);
 
 
@@ -121,13 +118,10 @@ namespace bs
 		 */
 		 */
 		void setUseOverrideBounds(bool enable);
 		void setUseOverrideBounds(bool enable);
 
 
-		/**
-		 * Gets the layer bitfield that controls whether a renderable is considered visible in a specific camera. 
-		 * Renderable layer must match camera layer in order for the camera to render the component.
-		 */
+		/** @copydoc setLayer() */
 		UINT64 getLayer() const { return mLayer; }
 		UINT64 getLayer() const { return mLayer; }
 
 
-		/**	Returns the mesh used for rendering. */
+		/**	@copydoc setMesh() */
 		MeshType getMesh() const { return mMesh; }
 		MeshType getMesh() const { return mMesh; }
 
 
 		/**	Returns the material used for rendering a sub-mesh with the specified index. */
 		/**	Returns the material used for rendering a sub-mesh with the specified index. */

+ 6 - 1
Source/BansheeCore/Scene/BsComponent.h

@@ -15,7 +15,12 @@ namespace bs
 	/** Flags that control behavior of a Component. */
 	/** Flags that control behavior of a Component. */
 	enum class ComponentFlag
 	enum class ComponentFlag
 	{
 	{
-		AlwaysRun = 1 /**< Ensures that scene manager cannot pause or stop component callbacks from executing. Off by default. */
+		/** 
+		 * Ensures that scene manager cannot pause or stop component callbacks from executing. Off by default. 
+		 * Note that this flag must be specified on component creation, in its constructor and any later changes
+		 * to the flag will be ignored.
+		 */
+		AlwaysRun = 1 
 	};
 	};
 
 
 	typedef Flags<ComponentFlag> ComponentFlags;
 	typedef Flags<ComponentFlag> ComponentFlags;

+ 36 - 0
Source/BansheeCore/Scene/BsSceneObject.cpp

@@ -631,6 +631,42 @@ namespace bs
 		}
 		}
 	}
 	}
 
 
+	HSceneObject SceneObject::findPath(const String& path) const
+	{
+		if (path.empty())
+			return HSceneObject();
+		
+		String trimmedPath = path;
+		StringUtil::trim(trimmedPath, "/");
+
+		Vector<String> entries = StringUtil::split(trimmedPath, "/");
+
+		// Find scene object referenced by the path
+		HSceneObject so = getHandle();
+		UINT32 pathIdx = 0;
+		for (; pathIdx < (UINT32)entries.size(); pathIdx++)
+		{
+			String entry = entries[pathIdx];
+
+			if (entry.empty())
+				continue;
+
+			// This character signifies not-a-scene-object. This is allowed to support
+			// paths used by the scripting system (which can point to properties of
+			// components on scene objects).
+			if (entry[0] != '!')
+				break;
+
+			String childName = entry.substr(1, entry.size() - 1);
+			so = so->findChild(childName);
+
+			if (so == nullptr)
+				break;
+		}
+
+		return so;
+	}
+
 	HSceneObject SceneObject::findChild(const String& name, bool recursive)
 	HSceneObject SceneObject::findChild(const String& name, bool recursive)
 	{
 	{
 		for (auto& child : mChildren)
 		for (auto& child : mChildren)

+ 13 - 5
Source/BansheeCore/Scene/BsSceneObject.h

@@ -25,7 +25,7 @@ namespace bs
 		SOF_Persistent = 0x04,		/**< Object will remain in the scene even after scene clear, unless destroyed directly. 
 		SOF_Persistent = 0x04,		/**< Object will remain in the scene even after scene clear, unless destroyed directly. 
 										 This only works with top-level objects. */
 										 This only works with top-level objects. */
 		SOF_Internal = 0x08			/**< Provides a hint to external systems that his object is used by engine internals.
 		SOF_Internal = 0x08			/**< Provides a hint to external systems that his object is used by engine internals.
-									     For example, those systems might not want to display those objects together with the
+										 For example, those systems might not want to display those objects together with the
 										 user created ones. */
 										 user created ones. */
 	};
 	};
 
 
@@ -266,10 +266,10 @@ namespace bs
 		const Matrix4& getLocalTfrm() const;
 		const Matrix4& getLocalTfrm() const;
 
 
 		/**	Moves the object's position by the vector offset provided along world axes. */
 		/**	Moves the object's position by the vector offset provided along world axes. */
-        void move(const Vector3& vec);
+		void move(const Vector3& vec);
 
 
 		/**	Moves the object's position by the vector offset provided along it's own axes (relative to orientation). */
 		/**	Moves the object's position by the vector offset provided along it's own axes (relative to orientation). */
-        void moveRelative(const Vector3& vec);
+		void moveRelative(const Vector3& vec);
 
 
 		/**
 		/**
 		 * Gets the Z (forward) axis of the object, in world space.
 		 * Gets the Z (forward) axis of the object, in world space.
@@ -302,10 +302,10 @@ namespace bs
 		void setForward(const Vector3& forwardDir);
 		void setForward(const Vector3& forwardDir);
 
 
 		/**	Rotate the object around an arbitrary axis. */
 		/**	Rotate the object around an arbitrary axis. */
-        void rotate(const Vector3& axis, const Radian& angle);
+		void rotate(const Vector3& axis, const Radian& angle);
 
 
 		/**	Rotate the object around an arbitrary axis using a Quaternion. */
 		/**	Rotate the object around an arbitrary axis using a Quaternion. */
-        void rotate(const Quaternion& q);
+		void rotate(const Quaternion& q);
 
 
 		/**
 		/**
 		 * Rotates around local Z axis.
 		 * Rotates around local Z axis.
@@ -421,6 +421,14 @@ namespace bs
 		/**	Gets the number of all child GameObjects. */
 		/**	Gets the number of all child GameObjects. */
 		UINT32 getNumChildren() const { return (UINT32)mChildren.size(); }
 		UINT32 getNumChildren() const { return (UINT32)mChildren.size(); }
 
 
+		/** 
+		 * Searches the scene object hierarchy to find a child scene object using the provided path.
+		 *
+		 * @param[in]	path	Path to the property, where each element of the path is separated with "/" Path elements signify
+		 *						names of child scene objects (first one relative to this object). 
+		 */
+		HSceneObject findPath(const String& path) const;
+
 		/**
 		/**
 		 * Searches the child objects for an object matching the specified name.
 		 * Searches the child objects for an object matching the specified name.
 		 *
 		 *

+ 17 - 8
Source/BansheeCore/Utility/BsCommonTypes.h

@@ -584,20 +584,29 @@ namespace bs
 
 
 		TextureAddressingMode u, v, w;
 		TextureAddressingMode u, v, w;
 	};
 	};
-    
+
 	/**	References a subset of surfaces within a texture. */
 	/**	References a subset of surfaces within a texture. */
-	struct TextureSurface
+	struct BS_SCRIPT_EXPORT(m:Rendering,pl:true) TextureSurface
 	{
 	{
-		TextureSurface(UINT32 mipLevel = 0, UINT32 numMipLevels = 1, 
-			UINT32 arraySlice = 0, UINT32 numArraySlices = 1)
-			:mipLevel(mipLevel), numMipLevels(numMipLevels), 
-			arraySlice(arraySlice), numArraySlices(numArraySlices)
+		TextureSurface(UINT32 mipLevel = 0, UINT32 numMipLevels = 1, UINT32 face = 0, UINT32 numFaces = 1)
+			:mipLevel(mipLevel), numMipLevels(numMipLevels), face(face), numFaces(numFaces)
 		{ }
 		{ }
 
 
+		/** First mip level to reference. */
 		UINT32 mipLevel;
 		UINT32 mipLevel;
+
+		/** Number of mip levels to reference. Must be greater than zero. */
 		UINT32 numMipLevels;
 		UINT32 numMipLevels;
-		UINT32 arraySlice;
-		UINT32 numArraySlices;
+
+		/** 
+		 * First face to reference. Face can represent a single cubemap face, or a single array entry in a 
+		 * texture array. If cubemaps are laid out in a texture array then every six sequential faces represent a single
+		 * array entry.
+		 */
+		UINT32 face;
+
+		/** Number of faces to reference, if the texture has more than one. */
+		UINT32 numFaces;
 
 
 		/** Surface that covers all texture sub-resources. */
 		/** Surface that covers all texture sub-resources. */
 		static BS_CORE_EXPORT const TextureSurface COMPLETE;
 		static BS_CORE_EXPORT const TextureSurface COMPLETE;

+ 2 - 2
Source/BansheeD3D11RenderAPI/BsD3D11RenderAPI.cpp

@@ -402,7 +402,7 @@ namespace bs { namespace ct
 						if (texture != nullptr)
 						if (texture != nullptr)
 						{
 						{
 							SPtr<TextureView> texView = texture->requestView(surface.mipLevel, surface.numMipLevels, 
 							SPtr<TextureView> texView = texture->requestView(surface.mipLevel, surface.numMipLevels, 
-															surface.arraySlice, surface.numArraySlices, GVU_DEFAULT);
+															surface.face, surface.numFaces, GVU_DEFAULT);
 
 
 							D3D11TextureView* d3d11texView = static_cast<D3D11TextureView*>(texView.get());
 							D3D11TextureView* d3d11texView = static_cast<D3D11TextureView*>(texView.get());
 							srvs[slot] = d3d11texView->getSRV();
 							srvs[slot] = d3d11texView->getSRV();
@@ -454,7 +454,7 @@ namespace bs { namespace ct
 						if (texture != nullptr)
 						if (texture != nullptr)
 						{
 						{
 							SPtr<TextureView> texView = texture->requestView(surface.mipLevel, 1,
 							SPtr<TextureView> texView = texture->requestView(surface.mipLevel, 1,
-								surface.arraySlice, surface.numArraySlices, GVU_RANDOMWRITE);
+								surface.face, surface.numFaces, GVU_RANDOMWRITE);
 
 
 							D3D11TextureView* d3d11texView = static_cast<D3D11TextureView*>(texView.get());
 							D3D11TextureView* d3d11texView = static_cast<D3D11TextureView*>(texView.get());
 							uavs[slot] = d3d11texView->getUAV();
 							uavs[slot] = d3d11texView->getUAV();

+ 174 - 174
Source/BansheeUtility/Math/BsQuaternion.cpp

@@ -8,89 +8,89 @@
 
 
 namespace bs 
 namespace bs 
 {
 {
-    const float Quaternion::EPSILON = 1e-03f;
-    const Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
-    const Quaternion Quaternion::IDENTITY(1.0f, 0.0f, 0.0f, 0.0f);
+	const float Quaternion::EPSILON = 1e-03f;
+	const Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
+	const Quaternion Quaternion::IDENTITY(1.0f, 0.0f, 0.0f, 0.0f);
 	const Quaternion::EulerAngleOrderData Quaternion::EA_LOOKUP[6] = 
 	const Quaternion::EulerAngleOrderData Quaternion::EA_LOOKUP[6] = 
 		{ { 0, 1, 2}, { 0, 2, 1}, { 1, 0, 2},
 		{ { 0, 1, 2}, { 0, 2, 1}, { 1, 0, 2},
 		{ 1, 2, 0}, { 2, 0, 1}, { 2, 1, 0} };;
 		{ 1, 2, 0}, { 2, 0, 1}, { 2, 1, 0} };;
 
 
-    void Quaternion::fromRotationMatrix(const Matrix3& mat)
-    {
-        // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
-        // article "Quaternion Calculus and Fast Animation".
-
-        float trace = mat[0][0]+mat[1][1]+mat[2][2];
-        float root;
-
-        if (trace > 0.0f)
-        {
-            // |w| > 1/2, may as well choose w > 1/2
-            root = Math::sqrt(trace + 1.0f);  // 2w
-            w = 0.5f*root;
-            root = 0.5f/root;  // 1/(4w)
-            x = (mat[2][1]-mat[1][2])*root;
-            y = (mat[0][2]-mat[2][0])*root;
-            z = (mat[1][0]-mat[0][1])*root;
-        }
-        else
-        {
-            // |w| <= 1/2
-            static UINT32 nextLookup[3] = { 1, 2, 0 };
-            UINT32 i = 0;
-
-            if (mat[1][1] > mat[0][0])
-                i = 1;
-
-            if (mat[2][2] > mat[i][i])
-                i = 2;
-
-            UINT32 j = nextLookup[i];
-            UINT32 k = nextLookup[j];
-
-            root = Math::sqrt(mat[i][i]-mat[j][j]-mat[k][k] + 1.0f);
-
-            float* cmpntLookup[3] = { &x, &y, &z };
-            *cmpntLookup[i] = 0.5f*root;
-            root = 0.5f/root;
-
-            w = (mat[k][j]-mat[j][k])*root;
-            *cmpntLookup[j] = (mat[j][i]+mat[i][j])*root;
-            *cmpntLookup[k] = (mat[k][i]+mat[i][k])*root;
-        }
+	void Quaternion::fromRotationMatrix(const Matrix3& mat)
+	{
+		// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
+		// article "Quaternion Calculus and Fast Animation".
+
+		float trace = mat[0][0]+mat[1][1]+mat[2][2];
+		float root;
+
+		if (trace > 0.0f)
+		{
+			// |w| > 1/2, may as well choose w > 1/2
+			root = Math::sqrt(trace + 1.0f);  // 2w
+			w = 0.5f*root;
+			root = 0.5f/root;  // 1/(4w)
+			x = (mat[2][1]-mat[1][2])*root;
+			y = (mat[0][2]-mat[2][0])*root;
+			z = (mat[1][0]-mat[0][1])*root;
+		}
+		else
+		{
+			// |w| <= 1/2
+			static UINT32 nextLookup[3] = { 1, 2, 0 };
+			UINT32 i = 0;
+
+			if (mat[1][1] > mat[0][0])
+				i = 1;
+
+			if (mat[2][2] > mat[i][i])
+				i = 2;
+
+			UINT32 j = nextLookup[i];
+			UINT32 k = nextLookup[j];
+
+			root = Math::sqrt(mat[i][i]-mat[j][j]-mat[k][k] + 1.0f);
+
+			float* cmpntLookup[3] = { &x, &y, &z };
+			*cmpntLookup[i] = 0.5f*root;
+			root = 0.5f/root;
+
+			w = (mat[k][j]-mat[j][k])*root;
+			*cmpntLookup[j] = (mat[j][i]+mat[i][j])*root;
+			*cmpntLookup[k] = (mat[k][i]+mat[i][k])*root;
+		}
 
 
 		normalize();
 		normalize();
-    }
+	}
 
 
-    void Quaternion::fromAxisAngle(const Vector3& axis, const Radian& angle)
-    {
-        Radian halfAngle (0.5f*angle);
-        float sin = Math::sin(halfAngle);
+	void Quaternion::fromAxisAngle(const Vector3& axis, const Radian& angle)
+	{
+		Radian halfAngle (0.5f*angle);
+		float sin = Math::sin(halfAngle);
 
 
-        w = Math::cos(halfAngle);
-        x = sin*axis.x;
-        y = sin*axis.y;
-        z = sin*axis.z;
-    }
+		w = Math::cos(halfAngle);
+		x = sin*axis.x;
+		y = sin*axis.y;
+		z = sin*axis.z;
+	}
 
 
-    void Quaternion::fromAxes(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis)
-    {
-        Matrix3 kRot;
+	void Quaternion::fromAxes(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis)
+	{
+		Matrix3 kRot;
 
 
-        kRot[0][0] = xaxis.x;
-        kRot[1][0] = xaxis.y;
-        kRot[2][0] = xaxis.z;
+		kRot[0][0] = xaxis.x;
+		kRot[1][0] = xaxis.y;
+		kRot[2][0] = xaxis.z;
 
 
-        kRot[0][1] = yaxis.x;
-        kRot[1][1] = yaxis.y;
-        kRot[2][1] = yaxis.z;
+		kRot[0][1] = yaxis.x;
+		kRot[1][1] = yaxis.y;
+		kRot[2][1] = yaxis.z;
 
 
-        kRot[0][2] = zaxis.x;
-        kRot[1][2] = zaxis.y;
-        kRot[2][2] = zaxis.z;
+		kRot[0][2] = zaxis.x;
+		kRot[1][2] = zaxis.y;
+		kRot[2][2] = zaxis.z;
 
 
-        fromRotationMatrix(kRot);
-    }
+		fromRotationMatrix(kRot);
+	}
 
 
 	void Quaternion::fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle)
 	void Quaternion::fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle)
 	{
 	{
@@ -211,76 +211,76 @@ namespace bs
 		return matRot.toEulerAngles(xAngle, yAngle, zAngle);
 		return matRot.toEulerAngles(xAngle, yAngle, zAngle);
 	}
 	}
 
 
-    Vector3 Quaternion::xAxis() const
-    {
-        float fTy  = 2.0f*y;
-        float fTz  = 2.0f*z;
-        float fTwy = fTy*w;
-        float fTwz = fTz*w;
-        float fTxy = fTy*x;
-        float fTxz = fTz*x;
-        float fTyy = fTy*y;
-        float fTzz = fTz*z;
-
-        return Vector3(1.0f-(fTyy+fTzz), fTxy+fTwz, fTxz-fTwy);
-    }
-
-    Vector3 Quaternion::yAxis() const
-    {
-        float fTx  = 2.0f*x;
-        float fTy  = 2.0f*y;
-        float fTz  = 2.0f*z;
-        float fTwx = fTx*w;
-        float fTwz = fTz*w;
-        float fTxx = fTx*x;
-        float fTxy = fTy*x;
-        float fTyz = fTz*y;
-        float fTzz = fTz*z;
-
-        return Vector3(fTxy-fTwz, 1.0f-(fTxx+fTzz), fTyz+fTwx);
-    }
-
-    Vector3 Quaternion::zAxis() const
-    {
-        float fTx  = 2.0f*x;
-        float fTy  = 2.0f*y;
-        float fTz  = 2.0f*z;
-        float fTwx = fTx*w;
-        float fTwy = fTy*w;
-        float fTxx = fTx*x;
-        float fTxz = fTz*x;
-        float fTyy = fTy*y;
-        float fTyz = fTz*y;
-
-        return Vector3(fTxz+fTwy, fTyz-fTwx, 1.0f-(fTxx+fTyy));
-    }
-
-    Quaternion Quaternion::inverse() const
-    {
-        float fNorm = w*w+x*x+y*y+z*z;
-        if (fNorm > 0.0f)
-        {
-            float fInvNorm = 1.0f/fNorm;
-            return Quaternion(w*fInvNorm,-x*fInvNorm,-y*fInvNorm,-z*fInvNorm);
-        }
-        else
-        {
-            // Return an invalid result to flag the error
-            return ZERO;
-        }
-    }
-
-    Vector3 Quaternion::rotate(const Vector3& v) const
-    {
+	Vector3 Quaternion::xAxis() const
+	{
+		float fTy  = 2.0f*y;
+		float fTz  = 2.0f*z;
+		float fTwy = fTy*w;
+		float fTwz = fTz*w;
+		float fTxy = fTy*x;
+		float fTxz = fTz*x;
+		float fTyy = fTy*y;
+		float fTzz = fTz*z;
+
+		return Vector3(1.0f-(fTyy+fTzz), fTxy+fTwz, fTxz-fTwy);
+	}
+
+	Vector3 Quaternion::yAxis() const
+	{
+		float fTx  = 2.0f*x;
+		float fTy  = 2.0f*y;
+		float fTz  = 2.0f*z;
+		float fTwx = fTx*w;
+		float fTwz = fTz*w;
+		float fTxx = fTx*x;
+		float fTxy = fTy*x;
+		float fTyz = fTz*y;
+		float fTzz = fTz*z;
+
+		return Vector3(fTxy-fTwz, 1.0f-(fTxx+fTzz), fTyz+fTwx);
+	}
+
+	Vector3 Quaternion::zAxis() const
+	{
+		float fTx  = 2.0f*x;
+		float fTy  = 2.0f*y;
+		float fTz  = 2.0f*z;
+		float fTwx = fTx*w;
+		float fTwy = fTy*w;
+		float fTxx = fTx*x;
+		float fTxz = fTz*x;
+		float fTyy = fTy*y;
+		float fTyz = fTz*y;
+
+		return Vector3(fTxz+fTwy, fTyz-fTwx, 1.0f-(fTxx+fTyy));
+	}
+
+	Quaternion Quaternion::inverse() const
+	{
+		float fNorm = w*w+x*x+y*y+z*z;
+		if (fNorm > 0.0f)
+		{
+			float fInvNorm = 1.0f/fNorm;
+			return Quaternion(w*fInvNorm,-x*fInvNorm,-y*fInvNorm,-z*fInvNorm);
+		}
+		else
+		{
+			// Return an invalid result to flag the error
+			return ZERO;
+		}
+	}
+
+	Vector3 Quaternion::rotate(const Vector3& v) const
+	{
 		// Note: Does compiler generate fast code here? Perhaps its better to pull all code locally without constructing
 		// Note: Does compiler generate fast code here? Perhaps its better to pull all code locally without constructing
 		//       an intermediate matrix.
 		//       an intermediate matrix.
 		Matrix3 rot;
 		Matrix3 rot;
 		toRotationMatrix(rot);
 		toRotationMatrix(rot);
 		return rot.transform(v);
 		return rot.transform(v);
-    }
+	}
 
 
 	void Quaternion::lookRotation(const Vector3& forwardDir)
 	void Quaternion::lookRotation(const Vector3& forwardDir)
-    {
+	{
 		if (forwardDir == Vector3::ZERO)
 		if (forwardDir == Vector3::ZERO)
 			return;
 			return;
 
 
@@ -299,7 +299,7 @@ namespace bs
 			Quaternion rotQuat = getRotationFromTo(currentForwardDir, nrmForwardDir);
 			Quaternion rotQuat = getRotationFromTo(currentForwardDir, nrmForwardDir);
 			*this = rotQuat * *this;
 			*this = rotQuat * *this;
 		}
 		}
-    }
+	}
 
 
 	void Quaternion::lookRotation(const Vector3& forwardDir, const Vector3& upDir)
 	void Quaternion::lookRotation(const Vector3& forwardDir, const Vector3& upDir)
 	{
 	{
@@ -321,46 +321,46 @@ namespace bs
 		*this = Quaternion(x, y, -forward);
 		*this = Quaternion(x, y, -forward);
 	}
 	}
 
 
-    Quaternion Quaternion::slerp(float t, const Quaternion& p, const Quaternion& q, bool shortestPath)
-    {
-        float cos = p.dot(q);
-        Quaternion quat;
-
-        if (cos < 0.0f && shortestPath)
-        {
-            cos = -cos;
-            quat = -q;
-        }
-        else
-        {
-            quat = q;
-        }
-
-        if (Math::abs(cos) < 1 - EPSILON)
-        {
-            // Standard case (slerp)
-            float sin = Math::sqrt(1 - Math::sqr(cos));
-            Radian angle = Math::atan2(sin, cos);
-            float invSin = 1.0f / sin;
-            float coeff0 = Math::sin((1.0f - t) * angle) * invSin;
-            float coeff1 = Math::sin(t * angle) * invSin;
-            return coeff0 * p + coeff1 * quat;
-        }
-        else
-        {
-            // There are two situations:
-            // 1. "p" and "q" are very close (fCos ~= +1), so we can do a linear
-            //    interpolation safely.
-            // 2. "p" and "q" are almost inverse of each other (fCos ~= -1), there
-            //    are an infinite number of possibilities interpolation. but we haven't
-            //    have method to fix this case, so just use linear interpolation here.
-            Quaternion ret = (1.0f - t) * p + t * quat;
-
-            // Taking the complement requires renormalization
-            ret.normalize();
-            return ret;
-        }
-    }
+	Quaternion Quaternion::slerp(float t, const Quaternion& p, const Quaternion& q, bool shortestPath)
+	{
+		float cos = p.dot(q);
+		Quaternion quat;
+
+		if (cos < 0.0f && shortestPath)
+		{
+			cos = -cos;
+			quat = -q;
+		}
+		else
+		{
+			quat = q;
+		}
+
+		if (Math::abs(cos) < 1 - EPSILON)
+		{
+			// Standard case (slerp)
+			float sin = Math::sqrt(1 - Math::sqr(cos));
+			Radian angle = Math::atan2(sin, cos);
+			float invSin = 1.0f / sin;
+			float coeff0 = Math::sin((1.0f - t) * angle) * invSin;
+			float coeff1 = Math::sin(t * angle) * invSin;
+			return coeff0 * p + coeff1 * quat;
+		}
+		else
+		{
+			// There are two situations:
+			// 1. "p" and "q" are very close (fCos ~= +1), so we can do a linear
+			//    interpolation safely.
+			// 2. "p" and "q" are almost inverse of each other (fCos ~= -1), there
+			//    are an infinite number of possibilities interpolation. but we haven't
+			//    have method to fix this case, so just use linear interpolation here.
+			Quaternion ret = (1.0f - t) * p + t * quat;
+
+			// Taking the complement requires renormalization
+			ret.normalize();
+			return ret;
+		}
+	}
 
 
 	Quaternion Quaternion::getRotationFromTo(const Vector3& from, const Vector3& dest, const Vector3& fallbackAxis)
 	Quaternion Quaternion::getRotationFromTo(const Vector3& from, const Vector3& dest, const Vector3& fallbackAxis)
 	{
 	{

+ 104 - 104
Source/BansheeUtility/Math/BsQuaternion.h

@@ -12,16 +12,16 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-    /** Represents a quaternion used for 3D rotations. */
-    class BS_UTILITY_EXPORT Quaternion
-    {
+	/** Represents a quaternion used for 3D rotations. */
+	class BS_UTILITY_EXPORT Quaternion
+	{
 	private:
 	private:
 		struct EulerAngleOrderData
 		struct EulerAngleOrderData
 		{
 		{
 			int a, b, c;
 			int a, b, c;
 		};
 		};
 
 
-    public:
+	public:
 		Quaternion()
 		Quaternion()
 		{ }
 		{ }
 
 
@@ -33,43 +33,43 @@ namespace bs
 			:x(0.0f), y(0.0f), z(0.0f), w(1.0f)
 			:x(0.0f), y(0.0f), z(0.0f), w(1.0f)
 		{ }
 		{ }
 
 
-        Quaternion(float w, float x, float y, float z)
+		Quaternion(float w, float x, float y, float z)
 			:x(x), y(y), z(z), w(w)
 			:x(x), y(y), z(z), w(w)
 		{ }
 		{ }
 
 
-        /** Construct a quaternion from a rotation matrix. */
-        explicit Quaternion(const Matrix3& rot)
-        {
-            fromRotationMatrix(rot);
-        }
-
-        /** Construct a quaternion from an angle/axis. */
-        explicit Quaternion(const Vector3& axis, const Radian& angle)
-        {
-            fromAxisAngle(axis, angle);
-        }
-
-        /** Construct a quaternion from 3 orthonormal local axes. */
-        explicit Quaternion(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis)
-        {
-            fromAxes(xaxis, yaxis, zaxis);
-        }
-
-        /**
-         * Construct a quaternion from euler angles, YXZ ordering.
-         * 			
+		/** Construct a quaternion from a rotation matrix. */
+		explicit Quaternion(const Matrix3& rot)
+		{
+			fromRotationMatrix(rot);
+		}
+
+		/** Construct a quaternion from an angle/axis. */
+		explicit Quaternion(const Vector3& axis, const Radian& angle)
+		{
+			fromAxisAngle(axis, angle);
+		}
+
+		/** Construct a quaternion from 3 orthonormal local axes. */
+		explicit Quaternion(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis)
+		{
+			fromAxes(xaxis, yaxis, zaxis);
+		}
+
+		/**
+		 * Construct a quaternion from euler angles, YXZ ordering.
+		 * 			
 		 * @see		Quaternion::fromEulerAngles
 		 * @see		Quaternion::fromEulerAngles
-         */
+		 */
 		explicit Quaternion(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle)
 		explicit Quaternion(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle)
 		{
 		{
 			fromEulerAngles(xAngle, yAngle, zAngle);
 			fromEulerAngles(xAngle, yAngle, zAngle);
 		}
 		}
 
 
-        /**
-         * Construct a quaternion from euler angles, custom ordering.
-         * 			
+		/**
+		 * Construct a quaternion from euler angles, custom ordering.
+		 * 			
 		 * @see		Quaternion::fromEulerAngles
 		 * @see		Quaternion::fromEulerAngles
-         */
+		 */
 		explicit Quaternion(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle, EulerAngleOrder order)
 		explicit Quaternion(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle, EulerAngleOrder order)
 		{
 		{
 			fromEulerAngles(xAngle, yAngle, zAngle, order);
 			fromEulerAngles(xAngle, yAngle, zAngle, order);
@@ -109,39 +109,39 @@ namespace bs
 		 * Initializes the quaternion from an angle axis pair. Quaternion will represent a rotation of "angle" radians 
 		 * Initializes the quaternion from an angle axis pair. Quaternion will represent a rotation of "angle" radians 
 		 * around "axis".
 		 * around "axis".
 		 */
 		 */
-        void fromAxisAngle(const Vector3& axis, const Radian& angle);
+		void fromAxisAngle(const Vector3& axis, const Radian& angle);
 
 
-        /**
-         * Initializes the quaternion from orthonormal set of axes. Quaternion will represent a rotation from base axes 
+		/**
+		 * Initializes the quaternion from orthonormal set of axes. Quaternion will represent a rotation from base axes 
 		 * to the specified set of axes.
 		 * to the specified set of axes.
-         * 			
+		 * 			
 		 * @note	It's up to the caller to ensure the axes are orthonormal.
 		 * @note	It's up to the caller to ensure the axes are orthonormal.
-         */
-        void fromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
-        
-        /**
-         * Creates a quaternion from the provided Pitch/Yaw/Roll angles.
-         *
+		 */
+		void fromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
+		
+		/**
+		 * Creates a quaternion from the provided Pitch/Yaw/Roll angles.
+		 *
 		 * @param[in]	xAngle	Rotation about x axis. (AKA Pitch)
 		 * @param[in]	xAngle	Rotation about x axis. (AKA Pitch)
 		 * @param[in]	yAngle	Rotation about y axis. (AKA Yaw)
 		 * @param[in]	yAngle	Rotation about y axis. (AKA Yaw)
 		 * @param[in]	zAngle	Rotation about z axis. (AKA Roll)
 		 * @param[in]	zAngle	Rotation about z axis. (AKA Roll)
-         *
-         * @note	
+		 *
+		 * @note	
 		 * Since different values will be produced depending in which order are the rotations applied, this method assumes
 		 * Since different values will be produced depending in which order are the rotations applied, this method assumes
 		 * they are applied in YXZ order. If you need a specific order, use the overloaded fromEulerAngles() method instead.
 		 * they are applied in YXZ order. If you need a specific order, use the overloaded fromEulerAngles() method instead.
-         */
-        void fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle);
+		 */
+		void fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle);
 
 
-        /**
-         * Creates a quaternion from the provided Pitch/Yaw/Roll angles.
-         *
+		/**
+		 * Creates a quaternion from the provided Pitch/Yaw/Roll angles.
+		 *
 		 * @param[in]	xAngle	Rotation about x axis. (AKA Pitch)
 		 * @param[in]	xAngle	Rotation about x axis. (AKA Pitch)
 		 * @param[in]	yAngle	Rotation about y axis. (AKA Yaw)
 		 * @param[in]	yAngle	Rotation about y axis. (AKA Yaw)
 		 * @param[in]	zAngle	Rotation about z axis. (AKA Roll)
 		 * @param[in]	zAngle	Rotation about z axis. (AKA Roll)
 		 * @param[in]	order 	The order in which rotations will be extracted. Different values can be retrieved depending 
 		 * @param[in]	order 	The order in which rotations will be extracted. Different values can be retrieved depending 
 		 *						on the order.
 		 *						on the order.
-         */
-        void fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle, EulerAngleOrder order);
+		 */
+		void fromEulerAngles(const Radian& xAngle, const Radian& yAngle, const Radian& zAngle, EulerAngleOrder order);
 
 
 		/**
 		/**
 		 * Converts a quaternion to a rotation matrix.
 		 * Converts a quaternion to a rotation matrix.
@@ -166,26 +166,26 @@ namespace bs
 		void toAxes(Vector3& xAxis, Vector3& yAxis, Vector3& zAxis) const;
 		void toAxes(Vector3& xAxis, Vector3& yAxis, Vector3& zAxis) const;
 
 
 		/**
 		/**
-         * Extracts Pitch/Yaw/Roll rotations from this quaternion.
-         *
-         * @param[out]	xAngle	Rotation about x axis. (AKA Pitch)
-         * @param[out]	yAngle  Rotation about y axis. (AKA Yaw)
-         * @param[out]	zAngle 	Rotation about z axis. (AKA Roll)
-         *
-         * @return	True if unique solution was found, false otherwise.
-         */
-        bool toEulerAngles(Radian& xAngle, Radian& yAngle, Radian& zAngle) const;
-
-        /** Gets the positive x-axis of the coordinate system transformed by this quaternion. */
-        Vector3 xAxis() const;
-
-        /** Gets the positive y-axis of the coordinate system transformed by this quaternion. */
-        Vector3 yAxis() const;
+		 * Extracts Pitch/Yaw/Roll rotations from this quaternion.
+		 *
+		 * @param[out]	xAngle	Rotation about x axis. (AKA Pitch)
+		 * @param[out]	yAngle  Rotation about y axis. (AKA Yaw)
+		 * @param[out]	zAngle 	Rotation about z axis. (AKA Roll)
+		 *
+		 * @return	True if unique solution was found, false otherwise.
+		 */
+		bool toEulerAngles(Radian& xAngle, Radian& yAngle, Radian& zAngle) const;
+
+		/** Gets the positive x-axis of the coordinate system transformed by this quaternion. */
+		Vector3 xAxis() const;
+
+		/** Gets the positive y-axis of the coordinate system transformed by this quaternion. */
+		Vector3 yAxis() const;
 
 
 		/** Gets the positive z-axis of the coordinate system transformed by this quaternion. */
 		/** Gets the positive z-axis of the coordinate system transformed by this quaternion. */
-        Vector3 zAxis() const;
+		Vector3 zAxis() const;
 
 
-        Quaternion& operator= (const Quaternion& rhs)
+		Quaternion& operator= (const Quaternion& rhs)
 		{
 		{
 			w = rhs.w;
 			w = rhs.w;
 			x = rhs.x;
 			x = rhs.x;
@@ -195,12 +195,12 @@ namespace bs
 			return *this;
 			return *this;
 		}
 		}
 
 
-        Quaternion operator+ (const Quaternion& rhs) const 
+		Quaternion operator+ (const Quaternion& rhs) const 
 		{
 		{
 			return Quaternion(w + rhs.w, x + rhs.x, y + rhs.y, z + rhs.z);
 			return Quaternion(w + rhs.w, x + rhs.x, y + rhs.y, z + rhs.z);
 		}
 		}
 
 
-        Quaternion operator- (const Quaternion& rhs) const
+		Quaternion operator- (const Quaternion& rhs) const
 		{
 		{
 			return Quaternion(w - rhs.w, x - rhs.x, y - rhs.y, z - rhs.z);
 			return Quaternion(w - rhs.w, x - rhs.x, y - rhs.y, z - rhs.z);
 		}
 		}
@@ -221,17 +221,17 @@ namespace bs
 			return Quaternion(rhs * w, rhs * x, rhs * y, rhs * z);
 			return Quaternion(rhs * w, rhs * x, rhs * y, rhs * z);
 		}
 		}
 
 
-        Quaternion operator- () const
+		Quaternion operator- () const
 		{
 		{
 			return Quaternion(-w, -x, -y, -z);
 			return Quaternion(-w, -x, -y, -z);
 		}
 		}
 
 
-        bool operator== (const Quaternion& rhs) const
+		bool operator== (const Quaternion& rhs) const
 		{
 		{
 			return (rhs.x == x) && (rhs.y == y) && (rhs.z == z) && (rhs.w == w);
 			return (rhs.x == x) && (rhs.y == y) && (rhs.z == z) && (rhs.w == w);
 		}
 		}
 
 
-        bool operator!= (const Quaternion& rhs) const
+		bool operator!= (const Quaternion& rhs) const
 		{
 		{
 			return !operator==(rhs);
 			return !operator==(rhs);
 		}
 		}
@@ -276,45 +276,45 @@ namespace bs
 			return Quaternion(lhs * rhs.w, lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
 			return Quaternion(lhs * rhs.w, lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
 		}
 		}
 
 
-        /** Calculates the dot product of this quaternion and another. */
-        float dot(const Quaternion& other) const
-        {
+		/** Calculates the dot product of this quaternion and another. */
+		float dot(const Quaternion& other) const
+		{
 			return w * other.w + x * other.x + y * other.y + z * other.z;
 			return w * other.w + x * other.x + y * other.y + z * other.z;
-        }
+		}
 
 
-        /** Normalizes this quaternion, and returns the previous length. */
-        float normalize()
-        {
+		/** Normalizes this quaternion, and returns the previous length. */
+		float normalize()
+		{
 			float len = w*w + x*x + y*y + z*z;
 			float len = w*w + x*x + y*y + z*z;
 			float factor = 1.0f / Math::sqrt(len);
 			float factor = 1.0f / Math::sqrt(len);
 			*this = *this * factor;
 			*this = *this * factor;
 			return len;
 			return len;
-        }
+		}
 
 
-        /**
-         * Gets the inverse.
-         *
-         * @note	Quaternion must be non-zero.
-         */
-        Quaternion inverse() const; 
+		/**
+		 * Gets the inverse.
+		 *
+		 * @note	Quaternion must be non-zero.
+		 */
+		Quaternion inverse() const; 
 
 
-        /** Rotates the provided vector. */
-        Vector3 rotate(const Vector3& vec) const;
+		/** Rotates the provided vector. */
+		Vector3 rotate(const Vector3& vec) const;
 
 
-        /**
-         * Orients the quaternion so its negative z axis points to the provided direction.
+		/**
+		 * Orients the quaternion so its negative z axis points to the provided direction.
 		 *
 		 *
 		 * @param[in]	forwardDir	Direction to orient towards.
 		 * @param[in]	forwardDir	Direction to orient towards.
-         */
+		 */
 		void lookRotation(const Vector3& forwardDir);
 		void lookRotation(const Vector3& forwardDir);
 
 
-        /**
-         * Orients the quaternion so its negative z axis points to the provided direction.
+		/**
+		 * Orients the quaternion so its negative z axis points to the provided direction.
 		 *
 		 *
 		 * @param[in]	forwardDir	Direction to orient towards.
 		 * @param[in]	forwardDir	Direction to orient towards.
 		 * @param[in]	upDir		Constrains y axis orientation to a plane this vector lies on. This rule might be broken
 		 * @param[in]	upDir		Constrains y axis orientation to a plane this vector lies on. This rule might be broken
 		 *							if forward and up direction are nearly parallel.
 		 *							if forward and up direction are nearly parallel.
-         */
+		 */
 		void lookRotation(const Vector3& forwardDir, const Vector3& upDir);
 		void lookRotation(const Vector3& forwardDir, const Vector3& upDir);
 
 
 		/** Query if any of the components of the quaternion are not a number. */
 		/** Query if any of the components of the quaternion are not a number. */
@@ -338,11 +338,11 @@ namespace bs
 			return q * factor;
 			return q * factor;
 		}
 		}
 
 
-        /**
-         * Performs spherical interpolation between two quaternions. Spherical interpolation neatly interpolates between 
+		/**
+		 * Performs spherical interpolation between two quaternions. Spherical interpolation neatly interpolates between 
 		 * two rotations without modifying the size of the vector it is applied to (unlike linear interpolation).
 		 * two rotations without modifying the size of the vector it is applied to (unlike linear interpolation).
-         */
-        static Quaternion slerp(float t, const Quaternion& p, const Quaternion& q, bool shortestPath = true);
+		 */
+		static Quaternion slerp(float t, const Quaternion& p, const Quaternion& q, bool shortestPath = true);
 
 
 		/** 
 		/** 
 		 * Linearly interpolates between the two quaternions using @p t. t should be in [0, 1] range, where t = 0 
 		 * Linearly interpolates between the two quaternions using @p t. t should be in [0, 1] range, where t = 0 
@@ -357,19 +357,19 @@ namespace bs
 			return normalize(output);
 			return normalize(output);
 		}
 		}
 
 
-        /** Gets the shortest arc quaternion to rotate this vector to the destination vector. */
-        static Quaternion getRotationFromTo(const Vector3& from, const Vector3& dest, const Vector3& fallbackAxis = Vector3::ZERO);
+		/** Gets the shortest arc quaternion to rotate this vector to the destination vector. */
+		static Quaternion getRotationFromTo(const Vector3& from, const Vector3& dest, const Vector3& fallbackAxis = Vector3::ZERO);
 
 
-        static const float EPSILON;
+		static const float EPSILON;
 
 
-        static const Quaternion ZERO;
-        static const Quaternion IDENTITY;
+		static const Quaternion ZERO;
+		static const Quaternion IDENTITY;
 
 
 		float x, y, z, w; // Note: Order is relevant, don't break it
 		float x, y, z, w; // Note: Order is relevant, don't break it
 
 
 		private:
 		private:
 			static const EulerAngleOrderData EA_LOOKUP[6];
 			static const EulerAngleOrderData EA_LOOKUP[6];
-    };
+	};
 
 
 	/** @} */
 	/** @} */
 
 

+ 1 - 1
Source/CMakeLists.txt

@@ -5,7 +5,7 @@ project (Banshee)
 set (BS_VERSION_MAJOR 0)
 set (BS_VERSION_MAJOR 0)
 set (BS_VERSION_MINOR 4)
 set (BS_VERSION_MINOR 4)
 
 
-set (BS_PREBUILT_DEPENDENCIES_VERSION 10)
+set (BS_PREBUILT_DEPENDENCIES_VERSION 11)
 set (BS_SRC_DEPENDENCIES_VERSION 15)
 set (BS_SRC_DEPENDENCIES_VERSION 15)
 set (BS_BUILTIN_ASSETS_VERSION 1)
 set (BS_BUILTIN_ASSETS_VERSION 1)
 
 

+ 30 - 30
Source/MBansheeEditor/Inspectors/MaterialInspector.cs

@@ -138,10 +138,10 @@ namespace BansheeEditor
 
 
             foreach (var param in shaderParams)
             foreach (var param in shaderParams)
             {
             {
-                if (param.Internal)
+                if (param.isInternal)
                     continue;
                     continue;
 
 
-                switch (param.Type)
+                switch (param.type)
                 {
                 {
                     case ShaderParameterType.Float:
                     case ShaderParameterType.Float:
                         layout.AddSpace(5);
                         layout.AddSpace(5);
@@ -228,11 +228,11 @@ namespace BansheeEditor
         internal MaterialParamFloatGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamFloatGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUIFloatField(title);
             guiElem = new GUIFloatField(title);
             guiElem.OnChanged += (x) =>
             guiElem.OnChanged += (x) =>
             {
             {
-                material.SetFloat(shaderParam.Name, x);
+                material.SetFloat(shaderParam.name, x);
                 EditorApplication.SetDirty(material);
                 EditorApplication.SetDirty(material);
             };
             };
 
 
@@ -242,7 +242,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            guiElem.Value = material.GetFloat(shaderParam.Name);
+            guiElem.Value = material.GetFloat(shaderParam.name);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -268,11 +268,11 @@ namespace BansheeEditor
         internal MaterialParamVec2GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamVec2GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUIVector2Field(title);
             guiElem = new GUIVector2Field(title);
             guiElem.OnChanged += (x) =>
             guiElem.OnChanged += (x) =>
             {
             {
-                material.SetVector2(shaderParam.Name, x);
+                material.SetVector2(shaderParam.name, x);
                 EditorApplication.SetDirty(material);
                 EditorApplication.SetDirty(material);
             };
             };
 
 
@@ -282,7 +282,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            guiElem.Value = material.GetVector2(shaderParam.Name);
+            guiElem.Value = material.GetVector2(shaderParam.name);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -308,11 +308,11 @@ namespace BansheeEditor
         internal MaterialParamVec3GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamVec3GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUIVector3Field(title);
             guiElem = new GUIVector3Field(title);
             guiElem.OnChanged += (x) =>
             guiElem.OnChanged += (x) =>
             {
             {
-                material.SetVector3(shaderParam.Name, x);
+                material.SetVector3(shaderParam.name, x);
                 EditorApplication.SetDirty(material);
                 EditorApplication.SetDirty(material);
             };
             };
 
 
@@ -322,7 +322,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            guiElem.Value = material.GetVector3(shaderParam.Name);
+            guiElem.Value = material.GetVector3(shaderParam.name);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -348,11 +348,11 @@ namespace BansheeEditor
         internal MaterialParamVec4GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamVec4GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUIVector4Field(title);
             guiElem = new GUIVector4Field(title);
             guiElem.OnChanged += (x) =>
             guiElem.OnChanged += (x) =>
             {
             {
-                material.SetVector4(shaderParam.Name, x);
+                material.SetVector4(shaderParam.name, x);
                 EditorApplication.SetDirty(material);
                 EditorApplication.SetDirty(material);
             };
             };
 
 
@@ -362,7 +362,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            guiElem.Value = material.GetVector4(shaderParam.Name);
+            guiElem.Value = material.GetVector4(shaderParam.name);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -391,7 +391,7 @@ namespace BansheeEditor
         internal MaterialParamMat3GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamMat3GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             GUILabel guiTitle = new GUILabel(title, GUIOption.FixedWidth(100));
             GUILabel guiTitle = new GUILabel(title, GUIOption.FixedWidth(100));
 
 
             mainLayout = layout.AddLayoutY();
             mainLayout = layout.AddLayoutY();
@@ -420,9 +420,9 @@ namespace BansheeEditor
                     int hoistedCol = col;
                     int hoistedCol = col;
                     field.OnChanged += (x) =>
                     field.OnChanged += (x) =>
                     {
                     {
-                        Matrix3 value = material.GetMatrix3(shaderParam.Name);
+                        Matrix3 value = material.GetMatrix3(shaderParam.name);
                         value[hoistedRow, hoistedCol] = x;
                         value[hoistedRow, hoistedCol] = x;
-                        material.SetMatrix3(shaderParam.Name, value);
+                        material.SetMatrix3(shaderParam.name, value);
                         EditorApplication.SetDirty(material);
                         EditorApplication.SetDirty(material);
                     };
                     };
                 }
                 }
@@ -432,7 +432,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            Matrix3 value = material.GetMatrix3(shaderParam.Name);
+            Matrix3 value = material.GetMatrix3(shaderParam.name);
 
 
             for (int row = 0; row < MAT_SIZE; row++)
             for (int row = 0; row < MAT_SIZE; row++)
             {
             {
@@ -470,7 +470,7 @@ namespace BansheeEditor
         internal MaterialParamMat4GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamMat4GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             GUILabel guiTitle = new GUILabel(title, GUIOption.FixedWidth(100));
             GUILabel guiTitle = new GUILabel(title, GUIOption.FixedWidth(100));
 
 
             mainLayout = layout.AddLayoutY();
             mainLayout = layout.AddLayoutY();
@@ -499,9 +499,9 @@ namespace BansheeEditor
                     int hoistedCol = col;
                     int hoistedCol = col;
                     field.OnChanged += (x) =>
                     field.OnChanged += (x) =>
                     {
                     {
-                        Matrix4 value = material.GetMatrix4(shaderParam.Name);
+                        Matrix4 value = material.GetMatrix4(shaderParam.name);
                         value[hoistedRow, hoistedCol] = x;
                         value[hoistedRow, hoistedCol] = x;
-                        material.SetMatrix4(shaderParam.Name, value);
+                        material.SetMatrix4(shaderParam.name, value);
                         EditorApplication.SetDirty(material);
                         EditorApplication.SetDirty(material);
                     };
                     };
                 }
                 }
@@ -511,7 +511,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            Matrix4 value = material.GetMatrix4(shaderParam.Name);
+            Matrix4 value = material.GetMatrix4(shaderParam.name);
 
 
             for (int row = 0; row < MAT_SIZE; row++)
             for (int row = 0; row < MAT_SIZE; row++)
             {
             {
@@ -546,11 +546,11 @@ namespace BansheeEditor
         internal MaterialParamColorGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamColorGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUIColorField(title);
             guiElem = new GUIColorField(title);
             guiElem.OnChanged += (x) =>
             guiElem.OnChanged += (x) =>
             {
             {
-                material.SetColor(shaderParam.Name, x);
+                material.SetColor(shaderParam.name, x);
                 EditorApplication.SetDirty(material);
                 EditorApplication.SetDirty(material);
             };
             };
 
 
@@ -560,7 +560,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            guiElem.Value = material.GetColor(shaderParam.Name);
+            guiElem.Value = material.GetColor(shaderParam.name);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -586,10 +586,10 @@ namespace BansheeEditor
         internal MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
         internal MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
             : base(shaderParam)
             : base(shaderParam)
         {
         {
-            LocString title = new LocEdString(shaderParam.Name);
+            LocString title = new LocEdString(shaderParam.name);
             guiElem = new GUITextureField(title);
             guiElem = new GUITextureField(title);
 
 
-            switch (shaderParam.Type)
+            switch (shaderParam.type)
             {
             {
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture3D:
                 case ShaderParameterType.Texture3D:
@@ -598,7 +598,7 @@ namespace BansheeEditor
                     {
                     {
                         Texture texture = Resources.Load<Texture>(x);
                         Texture texture = Resources.Load<Texture>(x);
 
 
-                        material.SetTexture(shaderParam.Name, texture);
+                        material.SetTexture(shaderParam.name, texture);
                         EditorApplication.SetDirty(material);
                         EditorApplication.SetDirty(material);
                     };
                     };
                     break;
                     break;
@@ -611,12 +611,12 @@ namespace BansheeEditor
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
             Texture value = null;
             Texture value = null;
-            switch (shaderParam.Type)
+            switch (shaderParam.type)
             {
             {
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture3D:
                 case ShaderParameterType.Texture3D:
                 case ShaderParameterType.TextureCube:
                 case ShaderParameterType.TextureCube:
-                    value = material.GetTexture(shaderParam.Name);
+                    value = material.GetTexture(shaderParam.name);
                     break;
                     break;
             }
             }
 
 

+ 33 - 1010
Source/MBansheeEngine/Animation/Animation.cs

@@ -11,23 +11,9 @@ namespace BansheeEngine
      *  @{
      *  @{
      */
      */
 
 
-    /// <summary>
-    /// Handles animation playback. Takes one or multiple animation clips as input and evaluates them every animation update
-    /// tick depending on set properties.The evaluated data is used by the core thread for skeletal animation, by the sim
-    /// thread for updating attached scene objects and bones (if skeleton is attached), or the data is made available for
-    /// manual queries in the case of generic animation.
-    /// </summary>
-    public class Animation : ManagedComponent
+    public partial class Animation
     {
     {
-        private NativeAnimation _native;
-
-        [SerializeField] private SerializableData serializableData = new SerializableData();
-
         private FloatCurvePropertyInfo[] floatProperties;
         private FloatCurvePropertyInfo[] floatProperties;
-        private List<SceneObjectMappingInfo> mappingInfo = new List<SceneObjectMappingInfo>();
-        private AnimationClip primaryClip;
-        private Renderable animatedRenderable;
-        private State state = State.Inactive;
 
 
         /// <summary>
         /// <summary>
         /// Contains mapping for a suffix used by property paths used for curve identifiers, to their index and type.
         /// Contains mapping for a suffix used by property paths used for curve identifiers, to their index and type.
@@ -45,373 +31,6 @@ namespace BansheeEngine
             {".a", new PropertySuffixInfo(3, false)}
             {".a", new PropertySuffixInfo(3, false)}
         };
         };
 
 
-        /// <summary>
-        /// Returns the non-component version of Animation that is wrapped by this component. 
-        /// </summary>
-        internal NativeAnimation Native
-        {
-            get { return _native; }
-        }
-
-        /// <summary>
-        /// Determines the default clip to play as soon as the component is enabled. If more control over playing clips is
-        /// needed use the <see cref="Play"/>, <see cref="Blend1D"/>, <see cref="Blend2D"/> and <see cref="CrossFade"/> 
-        /// methods to queue clips for playback manually, and <see cref="SetState"/> method for modify their states 
-        /// individually.
-        /// </summary>
-        public AnimationClip DefaultClip
-        {
-            get { return serializableData.defaultClip; }
-            set
-            {
-                serializableData.defaultClip = value;
-
-                if (value != null)
-                {
-                    switch (state)
-                    {
-                        case State.Active:
-                            _native.Play(value);
-                            break;
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Determines the wrap mode for all active animations. Wrap mode determines what happens when animation reaches the 
-        /// first or last frame.
-        /// <see cref="AnimWrapMode"/>
-        /// </summary>
-        public AnimWrapMode WrapMode
-        {
-            get { return serializableData.wrapMode; }
-            set
-            {
-                serializableData.wrapMode = value;
-
-                switch (state)
-                {
-                    case State.Active:
-                        _native.WrapMode = value;
-                        break;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Determines the speed for all animations. The default value is 1.0f. Use negative values to play-back in reverse.
-        /// </summary>
-        public float Speed
-        {
-            get { return serializableData.speed; }
-            set
-            {
-                serializableData.speed = value;
-
-                switch (state)
-                {
-                    case State.Active:
-                        _native.Speed = value;
-                        break;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Checks if any animation clips are currently playing.
-        /// </summary>
-        public bool IsPlaying
-        {
-            get
-            {
-                switch (state)
-                {
-                    case State.Active:
-                        return _native.IsPlaying();
-                    default:
-                        return false;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Sets bounds that will be used for animation and mesh culling. Only relevant if <see cref="UseBounds"/> is set
-        /// to true.
-        /// </summary>
-        public AABox Bounds
-        {
-            get { return serializableData.bounds; }
-            set
-            {
-                serializableData.bounds = value;
-
-                if (serializableData.useBounds)
-                {
-                    if (animatedRenderable != null && animatedRenderable.Native != null)
-                        animatedRenderable.Native.OverrideBounds = value;
-
-                    AABox bounds = serializableData.bounds;
-
-                    Matrix4 parentTfrm;
-                    if (SceneObject.Parent != null)
-                        parentTfrm = SceneObject.Parent.WorldTransform;
-                    else
-                        parentTfrm = Matrix4.Identity;
-
-                    bounds.TransformAffine(parentTfrm);
-
-                    switch (state)
-                    {
-                        case State.Active:
-                            _native.Bounds = bounds;
-                            break;
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Determines should animation bounds be used for visibility determination (culling). If false the bounds of the
-        /// mesh attached to the relevant <see cref="Renderable"/> component will be used instead.
-        /// </summary>
-        public bool UseBounds
-        {
-            get { return serializableData.useBounds; }
-            set
-            {
-                serializableData.useBounds = value;
-
-                UpdateBounds();
-            }
-        }
-
-        /// <summary>
-        /// If true, the animation will not be evaluated when it is out of view.
-        /// </summary>
-        public bool Cull
-        {
-            get { return serializableData.cull; }
-            set
-            {
-                serializableData.cull = value;
-
-                switch (state)
-                {
-                    case State.Active:
-                        _native.Cull = value;
-                        break;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Plays the specified animation clip. 
-        /// </summary>
-        /// <param name="clip">Clip to play.</param>
-        public void Play(AnimationClip clip)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.Play(clip);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Plays the specified animation clip on top of the animation currently playing in the main layer. Multiple such
-        /// clips can be playing at once, as long as you ensure each is given its own layer. Each animation can also have a
-        /// weight that determines how much it influences the main animation.        
-        /// </summary>
-        /// <param name="clip">Clip to additively blend. Must contain additive animation curves.</param>
-        /// <param name="weight">Determines how much of an effect will the blended animation have on the final output.
-        ///                      In range [0, 1].</param>
-        /// <param name="fadeLength">Applies the blend over a specified time period, increasing the weight as the time
-        ///                          passes. Set to zero to blend immediately. In seconds.</param>
-        /// <param name="layer">Layer to play the clip in. Multiple additive clips can be playing at once in separate layers
-        ///                     and each layer has its own weight.</param>
-        public void BlendAdditive(AnimationClip clip, float weight, float fadeLength, int layer)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.BlendAdditive(clip, weight, fadeLength, layer);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Blends multiple animation clips between each other using linear interpolation. Unlike normal animations these
-        /// animations are not advanced with the progress of time, and is instead expected the user manually changes the
-        /// <see cref="t"/> parameter.
-        /// </summary>
-        /// <param name="info">Information about the clips to blend. Clip positions must be sorted from lowest to highest.
-        ///                    </param>
-        /// <param name="t">Parameter that controls the blending, in range [0, 1]. t = 0 means left animation has full
-        ///                 influence, t = 1 means right animation has full influence.</param>
-        public void Blend1D(Blend1DInfo info, float t)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.Blend1D(info, t);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Blend four animation clips between each other using bilinear interpolation. Unlike normal animations these
-        /// animations are not advanced with the progress of time, and is instead expected the user manually changes the
-        /// <see cref="t"/> parameter.
-        /// </summary>
-        /// <param name="info">Information about the clips to blend.</param>
-        /// <param name="t">Parameter that controls the blending, in range [(0, 0), (1, 1)]. t = (0, 0) means top left
-        ///                 animation has full influence, t = (0, 1) means top right animation has full influence, 
-        ///                 t = (1, 0) means bottom left animation has full influence, t = (1, 1) means bottom right
-        ///                 animation has full influence.
-        ///                 </param>
-        public void Blend2D(Blend2DInfo info, Vector2 t)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.Blend2D(info, t);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Fades the specified animation clip in, while fading other playing animation out, over the specified time period.
-        /// </summary>
-        /// <param name="clip">Clip to fade in.</param>
-        /// <param name="fadeLength">Determines the time period over which the fade occurs. In seconds.</param>
-        public void CrossFade(AnimationClip clip, float fadeLength)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.CrossFade(clip, fadeLength);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Samples an animation clip at the specified time, displaying only that particular frame without further playback.
-        /// </summary>
-        /// <param name="clip">Animation clip to sample.</param>
-        /// <param name="time">Time to sample the clip at.</param>
-        public void Sample(AnimationClip clip, float time)
-        {
-            switch (state)
-            {
-                case State.Active:
-                case State.EditorActive:
-                    _native.Sample(clip, time);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Stops playing all animations on the provided layer.
-        /// </summary>
-        /// <param name="layer">Layer on which to stop animations on.</param>
-        public void Stop(int layer)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.Stop(layer);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Stops playing all animations.
-        /// </summary>
-        public void StopAll()
-        {
-            switch (state)
-            {
-                case State.Active:
-                    _native.StopAll();
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Retrieves detailed information about a currently playing animation clip.
-        /// </summary>
-        /// <param name="clip">Clip to retrieve the information for.</param>
-        /// <param name="state">Animation clip state containing the requested information. Only valid if the method returns
-        ///                     true.</param>
-        /// <returns>True if the state was found (animation clip is playing), false otherwise.</returns>
-        public bool GetState(AnimationClip clip, out AnimationClipState state)
-        {
-            switch (this.state)
-            {
-                case State.Active:
-                case State.EditorActive:
-                    return _native.GetState(clip, out state);
-                default:
-                    state = new AnimationClipState();
-                    return false;
-            }
-        }
-
-        /// <summary>
-        /// Changes the state of a playing animation clip. If animation clip is not currently playing the state change is
-        /// ignored.
-        /// </summary>
-        /// <param name="clip">Clip to change the state for.</param>
-        /// <param name="state">New state of the animation (e.g. changing the time for seeking).</param>
-        public void SetState(AnimationClip clip, AnimationClipState state)
-        {
-            switch (this.state)
-            {
-                case State.Active:
-                case State.EditorActive:
-                    _native.SetState(clip, state);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Changes a weight of a single morph channel, determining how much of it to apply on top of the base mesh.
-        /// </summary>
-        /// <param name="name">Name of the morph channel to modify the weight for. This depends on the mesh the animation
-        ///                    is currently animating.</param>
-        /// <param name="weight">Weight that determines how much of the channel to apply to the mesh, in range [0, 1].
-        ///                     </param>
-        public void SetMorphChannelWeight(string name, float weight)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    if (animatedRenderable == null)
-                        return;
-
-                    Mesh mesh = animatedRenderable.Mesh;
-                    if (mesh == null)
-                        return;
-
-                    MorphShapes morphShapes = mesh.MorphShapes;
-                    if (morphShapes == null)
-                        return;
-
-                    MorphChannel[] channels = morphShapes.Channels;
-                    for (int i = 0; i < channels.Length; i++)
-                    {
-                        if (channels[i].Name == name)
-                        {
-                            _native.SetMorphChannelWeight(i, weight);
-                            break;
-                        }
-                    }
-                    break;
-            }
-        }
-
         /// <summary>
         /// <summary>
         /// Allows the caller to play an animation clip during edit mode. This form of animation playback is limited as
         /// Allows the caller to play an animation clip during edit mode. This form of animation playback is limited as
         /// you have no control over clip properties, and features like blending, cross fade or animation events are not
         /// you have no control over clip properties, and features like blending, cross fade or animation events are not
@@ -429,30 +48,22 @@ namespace BansheeEngine
         ///                      animation.</param>
         ///                      animation.</param>
         internal void EditorPlay(AnimationClip clip, float startTime, bool freeze = false)
         internal void EditorPlay(AnimationClip clip, float startTime, bool freeze = false)
         {
         {
-            switch (state)
-            {
-                case State.Inactive:
-                    SwitchState(State.EditorActive);
-                    break;
-            }
-
-            switch (state)
-            {
-                case State.EditorActive:
-                    if (freeze)
-                        Sample(clip, startTime);
-                    else
-                    {
-                        AnimationClipState clipState = AnimationClipState.Create();
-                        clipState.time = startTime;
+            bool inPreviewMode = Internal__togglePreviewMode(mCachedPtr, true);
 
 
-                        SetState(clip, clipState);
-                    }
+            if (!inPreviewMode)
+                return;
 
 
-                    RefreshClipMappings();
+            if (freeze)
+                Sample(clip, startTime);
+            else
+            {
+                AnimationClipState clipState = AnimationClipState.Default();
+                clipState.time = startTime;
 
 
-                    break;
+                SetState(clip, clipState);
             }
             }
+
+            Internal__refreshClipMappings(mCachedPtr);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -460,12 +71,7 @@ namespace BansheeEngine
         /// </summary>
         /// </summary>
         internal void EditorStop()
         internal void EditorStop()
         {
         {
-            switch (state)
-            {
-                case State.EditorActive:
-                    SwitchState(State.Inactive);
-                    break;
-            }
+            Internal__togglePreviewMode(mCachedPtr, false);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -474,50 +80,22 @@ namespace BansheeEngine
         /// <returns>Time in seconds.</returns>
         /// <returns>Time in seconds.</returns>
         internal float EditorGetTime()
         internal float EditorGetTime()
         {
         {
-            switch (state)
-            {
-                case State.EditorActive:
-                    AnimationClip clip = _native.GetClip(0);
+            AnimationClip clip = Internal_getClip(mCachedPtr, 0);
 
 
-                    AnimationClipState clipState;
-                    if (clip != null && GetState(clip, out clipState))
-                        return clipState.time;
-
-                    return 0.0f;
-            }
+            AnimationClipState clipState;
+            if (clip != null && GetState(clip, out clipState))
+                return clipState.time;
 
 
             return 0.0f;
             return 0.0f;
         }
         }
 
 
-        /// <summary>
-        /// Rebuilds internal curve -> property mapping about the currently playing animation clip. This mapping allows the
-        /// animation component to know which property to assign which values from an animation curve. This Should be called
-        /// whenever playback for a new clip starts, or when clip curves change.
-        /// </summary>
-        internal void RefreshClipMappings()
-        {
-            primaryClip = _native.GetClip(0);
-
-            RebuildFloatProperties(primaryClip);
-            UpdateSceneObjectMapping();
-        }
-
         /// <summary>
         /// <summary>
         /// Updates generic float properties on relevant objects, based on the most recently evaluated animation curve 
         /// Updates generic float properties on relevant objects, based on the most recently evaluated animation curve 
         /// values.
         /// values.
         /// </summary>
         /// </summary>
         internal void UpdateFloatProperties()
         internal void UpdateFloatProperties()
         {
         {
-            // Apply values from generic float curves
-            if (floatProperties != null)
-            {
-                foreach (var entry in floatProperties)
-                {
-                    float curveValue;
-                    if (_native.GetGenericCurveValue(entry.curveIdx, out curveValue))
-                        entry.setter(curveValue);
-                }
-            }
+            _UpdateFloatProperties();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -678,442 +256,11 @@ namespace BansheeEngine
             }
             }
         }
         }
 
 
-        /// <summary>
-        /// Searches the scene object hierarchy to find a child scene object using the provided path.
-        /// </summary>
-        /// <param name="root">Root scene object to which the path is relative to.</param>
-        /// <param name="path">Path to the property, where each element of the path is separated with "/". 
-        /// 
-        ///                    Path elements signify names of child scene objects (first one relative to 
-        ///                    <paramref name="root"/>. Name of the root element should not be included in the path.
-        ///                    Elements must be prefixed with "!" in order to match the path format of 
-        ///                    <see cref="FindProperty"/>.</param>
-        /// <returns>Child scene object if found, or null otherwise.</returns>
-        internal static SceneObject FindSceneObject(SceneObject root, string path)
-        {
-            if (string.IsNullOrEmpty(path) || root == null)
-                return null;
-
-            string trimmedPath = path.Trim('/');
-            string[] entries = trimmedPath.Split('/');
-
-            // Find scene object referenced by the path
-            SceneObject so = root;
-            int pathIdx = 0;
-            for (; pathIdx < entries.Length; pathIdx++)
-            {
-                string entry = entries[pathIdx];
-
-                if (string.IsNullOrEmpty(entry))
-                    continue;
-
-                // Not a scene object, break
-                if (entry[0] != '!')
-                    break;
-
-                string childName = entry.Substring(1, entry.Length - 1);
-                so = so.FindChild(childName);
-
-                if (so == null)
-                    break;
-            }
-
-            return so;
-        }
-
-        private void OnInitialize()
-        {
-            NotifyFlags = TransformChangedFlags.Transform;
-        }
-
-        private void OnEnable()
-        {
-            switch (state)
-            {
-                case State.Inactive:
-                    SwitchState(State.Active);
-                    break;
-                case State.EditorActive:
-                    SwitchState(State.Inactive);
-                    SwitchState(State.Active);
-                    break;
-            }
-        }
-
-        private void OnDisable()
-        {
-            switch (state)
-            {
-                case State.Active:
-                case State.EditorActive:
-                    SwitchState(State.Inactive);
-                    break;
-            }
-        }
-
-        private void OnDestroy()
-        {
-            switch (state)
-            {
-                case State.Active:
-                case State.EditorActive:
-                    SwitchState(State.Inactive);
-                    break;
-            }
-        }
-
-        private void OnUpdate()
-        {
-            switch (state)
-            {
-                case State.Active:
-                    AnimationClip newPrimaryClip = _native.GetClip(0);
-                    if (newPrimaryClip != primaryClip)
-                        RefreshClipMappings();
-
-                    UpdateFloatProperties();
-                    break;
-            }
-        }
-
-        private void OnTransformChanged(TransformChangedFlags flags)
-        {
-            if (!SceneObject.Active)
-                return;
-
-            if ((flags & (TransformChangedFlags.Transform)) != 0)
-                UpdateBounds(false);
-        }
-
-        /// <summary>
-        /// Changes the state of the animation state machine. Doesn't check for valid transitions.
-        /// </summary>
-        /// <param name="state">New state of the animation.</param>
-        private void SwitchState(State state)
-        {
-            this.state = state;
-
-            switch (state)
-            {
-                case State.Active:
-                    if (_native != null)
-                        _native.Destroy();
-
-                    _native = new NativeAnimation();
-                    _native.OnEventTriggered += EventTriggered;
-
-                    animatedRenderable = SceneObject.GetComponent<Renderable>();
-
-                    // Restore saved values after reset
-                    _native.WrapMode = serializableData.wrapMode;
-                    _native.Speed = serializableData.speed;
-                    _native.Cull = serializableData.cull;
-
-                    UpdateBounds();
-
-                    if (serializableData.defaultClip != null)
-                        _native.Play(serializableData.defaultClip);
-
-                    primaryClip = _native.GetClip(0);
-                    if (primaryClip != null)
-                        RebuildFloatProperties(primaryClip);
-
-                    SetBoneMappings();
-                    UpdateSceneObjectMapping();
-
-                    if (animatedRenderable != null)
-                        animatedRenderable.RegisterAnimation(this);
-                    break;
-                case State.EditorActive:
-                    if (_native != null)
-                        _native.Destroy();
-
-                    _native = new NativeAnimation();
-
-                    animatedRenderable = SceneObject.GetComponent<Renderable>();
-
-                    UpdateBounds();
-                    SetBoneMappings();
-
-                    if (animatedRenderable != null)
-                        animatedRenderable.RegisterAnimation(this);
-                    break;
-                case State.Inactive:
-                    if (animatedRenderable != null)
-                        animatedRenderable.UnregisterAnimation();
-
-                    if (_native != null)
-                    {
-                        _native.Destroy();
-                        _native = null;
-                    }
-
-                    primaryClip = null;
-                    mappingInfo.Clear();
-                    floatProperties = null;
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Finds any curves that affect a transform of a specific scene object, and ensures that animation properly updates
-        /// those transforms. This does not include curves referencing bones.
-        /// </summary>
-        private void UpdateSceneObjectMapping()
-        {
-            List<SceneObjectMappingInfo> newMappingInfos = new List<SceneObjectMappingInfo>();
-            foreach(var entry in mappingInfo)
-            {
-                if (entry.isMappedToBone)
-                    newMappingInfos.Add(entry);
-                else
-                    _native.UnmapSceneObject(entry.sceneObject);
-            }
-
-            if (primaryClip != null)
-            {
-                SceneObject root = SceneObject;
-
-                Action<string,AnimationCurveFlags> findMappings = (name, flags) =>
-                {
-                    if (flags.HasFlag(AnimationCurveFlags.ImportedCurve))
-                        return;
-
-                    SceneObject currentSO = FindSceneObject(root, name);
-
-                    bool found = false;
-                    for (int i = 0; i < newMappingInfos.Count; i++)
-                    {
-                        if (newMappingInfos[i].sceneObject == currentSO)
-                        {
-                            found = true;
-                            break;
-                        }
-                    }
-
-                    if (!found)
-                    {
-                        SceneObjectMappingInfo newMappingInfo = new SceneObjectMappingInfo();
-                        newMappingInfo.isMappedToBone = false;
-                        newMappingInfo.sceneObject = currentSO;
-
-                        newMappingInfos.Add(newMappingInfo);
-
-                        _native.MapCurveToSceneObject(name, currentSO);
-                    }
-                };
-
-                AnimationCurves curves = primaryClip.Curves;
-                NamedVector3Curve[] posCurves = curves.Position;
-                foreach (var curve in posCurves)
-                    findMappings(curve.name, curve.flags);
-
-                NamedQuaternionCurve[] rotCurves = curves.Rotation;
-                foreach (var curve in rotCurves)
-                    findMappings(curve.name, curve.flags);
-
-                NamedVector3Curve[] scaleCurves = curves.Scale;
-                foreach (var curve in scaleCurves)
-                    findMappings(curve.name, curve.flags);
-            }
-
-            mappingInfo = newMappingInfos;
-        }
-
-        /// <summary>
-        /// Registers a new bone component, creating a new transform mapping from the bone name to the scene object
-        /// the component is attached to.
-        /// </summary>
-        /// <param name="bone">Bone component to register.</param>
-        internal void AddBone(Bone bone)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    SceneObject currentSO = bone.SceneObject;
-
-                    SceneObjectMappingInfo newMapping = new SceneObjectMappingInfo();
-                    newMapping.sceneObject = currentSO;
-                    newMapping.isMappedToBone = true;
-                    newMapping.bone = bone;
-
-                    mappingInfo.Add(newMapping);
-                    _native.MapCurveToSceneObject(bone.Name, newMapping.sceneObject);
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Unregisters a bone component, removing the bone -> scene object mapping.
-        /// </summary>
-        /// <param name="bone">Bone to unregister.</param>
-        internal void RemoveBone(Bone bone)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    for (int i = 0; i < mappingInfo.Count; i++)
-                    {
-                        if (mappingInfo[i].bone == bone)
-                        {
-                            _native.UnmapSceneObject(mappingInfo[i].sceneObject);
-                            mappingInfo.RemoveAt(i);
-                            i--;
-                        }
-                    }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Called whenever the bone the <see cref="Bone"/> component points to changed.
-        /// </summary>
-        /// <param name="bone">Bone component to modify.</param>
-        internal void NotifyBoneChanged(Bone bone)
-        {
-            switch (state)
-            {
-                case State.Active:
-                    for (int i = 0; i < mappingInfo.Count; i++)
-                    {
-                        if (mappingInfo[i].bone == bone)
-                        {
-                            _native.UnmapSceneObject(mappingInfo[i].sceneObject);
-                            _native.MapCurveToSceneObject(bone.Name, mappingInfo[i].sceneObject);
-                            break;
-                        }
-                    }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Finds any scene objects that are mapped to bone transforms. Such object's transforms will be affected by
-        /// skeleton bone animation.
-        /// </summary>
-        private void SetBoneMappings()
-        {
-            mappingInfo.Clear();
-
-            SceneObjectMappingInfo rootMapping = new SceneObjectMappingInfo();
-            rootMapping.sceneObject = SceneObject;
-            rootMapping.isMappedToBone = true;
-
-            mappingInfo.Add(rootMapping);
-            _native.MapCurveToSceneObject("", rootMapping.sceneObject);
-
-            Bone[] childBones = FindChildBones();
-            foreach (var entry in childBones)
-                AddBone(entry);
-        }
-
-        /// <summary>
-        /// Searches child scene objects for <see cref="Bone"/> components and returns any found ones.
-        /// </summary>
-        private Bone[] FindChildBones()
-        {
-            Stack<SceneObject> todo = new Stack<SceneObject>();
-            todo.Push(SceneObject);
-
-            List<Bone> bones = new List<Bone>();
-            while (todo.Count > 0)
-            {
-                SceneObject currentSO = todo.Pop();
-
-                Bone bone = currentSO.GetComponent<Bone>();
-                if (bone != null)
-                {
-                    bone.SetParent(this, true);
-                    bones.Add(bone);
-                }
-
-                int childCount = currentSO.GetNumChildren();
-                for (int i = 0; i < childCount; i++)
-                {
-                    SceneObject child = currentSO.GetChild(i);
-                    if (child.GetComponent<Animation>() != null)
-                        continue;
-
-                    todo.Push(child);
-                }
-            }
-
-            return bones.ToArray();
-        }
-
-        /// <summary>
-        /// Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists.
-        /// </summary>
-        internal void UpdateBounds(bool updateRenderable = true)
-        {
-            NativeRenderable renderable = null;
-            if (updateRenderable && animatedRenderable != null)
-                renderable = animatedRenderable.Native;
-
-            if (serializableData.useBounds)
-            {
-                if (renderable != null)
-                {
-                    renderable.UseOverrideBounds = true;
-                    renderable.OverrideBounds = serializableData.bounds;
-                }
-
-                if (_native != null)
-                {
-                    AABox bounds = serializableData.bounds;
-
-                    Matrix4 parentTfrm;
-                    if (SceneObject.Parent != null)
-                        parentTfrm = SceneObject.Parent.WorldTransform;
-                    else
-                        parentTfrm = Matrix4.Identity;
-
-                    bounds.TransformAffine(parentTfrm);
-
-                    _native.Bounds = bounds;
-                }
-            }
-            else
-            {
-                if (renderable != null)
-                    renderable.UseOverrideBounds = false;
-
-                if (_native != null)
-                {
-                    AABox bounds = new AABox();
-                    if (animatedRenderable != null)
-                        bounds = animatedRenderable.Bounds.Box;
-
-                    _native.Bounds = bounds;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Registers an <see cref="Renderable"/> component with the animation. When registered the animation will use the
-        /// renderable's bounds for culling, and the animation override bounds will be applied to the renderable.
-        /// </summary>
-        /// <param name="renderable">Component that was added</param>
-        internal void RegisterRenderable(Renderable renderable)
-        {
-            animatedRenderable = renderable;
-
-            UpdateBounds();
-        }
-
-        /// <summary>
-        /// Removes renderable from the animation component. <see cref="RegisterRenderable"/>.
-        /// </summary>
-        internal void UnregisterRenderable()
-        {
-            animatedRenderable = null;
-        }
-
         /// <summary>
         /// <summary>
         /// Builds a list of properties that will be animated using float animation curves.
         /// Builds a list of properties that will be animated using float animation curves.
         /// </summary>
         /// </summary>
         /// <param name="clip">Clip to retrieve the float animation curves from.</param>
         /// <param name="clip">Clip to retrieve the float animation curves from.</param>
-        private void RebuildFloatProperties(AnimationClip clip)
+        partial void RebuildFloatProperties(AnimationClip clip)
         {
         {
             if (clip == null)
             if (clip == null)
             {
             {
@@ -1244,7 +391,7 @@ namespace BansheeEngine
         /// </summary>
         /// </summary>
         /// <param name="clip">Clip that the event originated from.</param>
         /// <param name="clip">Clip that the event originated from.</param>
         /// <param name="name">Name of the event.</param>
         /// <param name="name">Name of the event.</param>
-        private void EventTriggered(AnimationClip clip, string name)
+        partial void EventTriggered(AnimationClip clip, string name)
         {
         {
             // Event should be in format "ComponentType/MethodName"
             // Event should be in format "ComponentType/MethodName"
             if (string.IsNullOrEmpty(name))
             if (string.IsNullOrEmpty(name))
@@ -1269,17 +416,20 @@ namespace BansheeEngine
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Holds all data the animation component needs to persist through serialization.
+        /// Partial method implementation for <see cref="UpdateFloatProperties"/>
         /// </summary>
         /// </summary>
-        [SerializeObject]
-        private class SerializableData
+        partial void _UpdateFloatProperties()
         {
         {
-            public AnimationClip defaultClip;
-            public AnimWrapMode wrapMode = AnimWrapMode.Loop;
-            public float speed = 1.0f;
-            public AABox bounds;
-            public bool useBounds;
-            public bool cull = true;
+            // Apply values from generic float curves
+            if (floatProperties != null)
+            {
+                foreach (var entry in floatProperties)
+                {
+                    float curveValue;
+                    if (Internal__getGenericCurveValue(mCachedPtr, (uint)entry.curveIdx, out curveValue))
+                        entry.setter(curveValue);
+                }
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -1305,133 +455,6 @@ namespace BansheeEngine
             public int elementIdx;
             public int elementIdx;
             public bool isVector;
             public bool isVector;
         }
         }
-
-        /// <summary>
-        /// Information about scene objects bound to a specific animation curve.
-        /// </summary>
-        internal struct SceneObjectMappingInfo
-        {
-            public SceneObject sceneObject;
-            public bool isMappedToBone;
-            public Bone bone;
-        }
-
-        /// <summary>
-        /// Possible states the animation component can be in.
-        /// </summary>
-        private enum State
-        {
-            /// <summary>
-            /// Animation object isn't constructed.
-            /// </summary>
-            Inactive,
-            /// <summary>
-            /// Animation object is constructed and fully functional.
-            /// </summary>
-            Active,
-            /// <summary>
-            /// Animation object is constructed and functional with limited funcionality for editor purposes.
-            /// </summary>
-            EditorActive
-        }
-    }
-
-
-    /// <summary>
-    /// Determines how an animation clip behaves when it reaches the end.
-    /// </summary>
-    public enum AnimWrapMode // Note: Must match C++ enum AnimWrapMode
-    {
-        /// <summary>
-        /// Loop around to the beginning/end when the last/first frame is reached.
-        /// </summary>
-        Loop,
-        /// <summary>
-        /// Clamp to end/beginning, keeping the last/first frame active.
-        /// </summary>
-	    Clamp
-    }
-
-    /// <summary>
-    /// Represents an animation clip used in 1D blending. Each clip has a position on the number line.
-    /// </summary>
-    public class BlendClipInfo
-    {
-        public AnimationClip clip;
-        public float position;
-    }
-
-    /// <summary>
-    /// Defines a 1D blend where two animation clips are blended between each other using linear interpolation.
-    /// </summary>
-    public class Blend1DInfo
-    {
-        public Blend1DInfo()
-        { }
-
-        public Blend1DInfo(int numClips)
-        {
-            clips = new BlendClipInfo[numClips];
-        }
-
-        public BlendClipInfo[] clips;
-    }
-
-    /// <summary>
-    /// Defines a 2D blend where two animation clips are blended between each other using bilinear interpolation.
-    /// </summary>
-    public class Blend2DInfo
-    {
-        public AnimationClip topLeftClip;
-        public AnimationClip topRightClip;
-        public AnimationClip botLeftClip;
-        public AnimationClip botRightClip;
-    }
-
-    /// <summary>
-    /// Contains information about a currently playing animation clip.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct AnimationClipState // Note: Must match C++ struct AnimationClipState
-    {
-        /// <summary>
-        /// Layer the clip is playing on. Multiple clips can be played simulatenously on different layers.
-        /// </summary>
-        public int layer;
-
-        /// <summary>
-        /// Current time the animation is playing from.
-        /// </summary>
-        public float time;
-
-        /// <summary>
-        /// Speed at which the animation is playing.
-        /// </summary>
-        public float speed;
-
-        /// <summary>
-        /// Determines how much of an influence does the clip have on the final pose.
-        /// </summary>
-        public float weight;
-
-        /// <summary>
-        /// Determines what happens to other animation clips when a new clip starts playing.
-        /// </summary>
-        public AnimWrapMode wrapMode;
-
-        /// <summary>
-        /// Creates a new clip state, with default values initialized.
-        /// </summary>
-        /// <returns>New animation clip state.</returns>
-        public static AnimationClipState Create()
-        {
-            AnimationClipState state = new AnimationClipState();
-            state.speed = 1.0f;
-            state.weight = 1.0f;
-            state.wrapMode = AnimWrapMode.Loop;
-
-            return state;
-        }
     }
     }
 
 
     /** @} */
     /** @} */

+ 0 - 125
Source/MBansheeEngine/Animation/Bone.cs

@@ -1,125 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Animation
-     *  @{
-     */
-
-    /// <summary>
-    /// Component that maps animation for specific bone also be applied to the <see cref="SceneObject"/> this component
-    /// is attached to. The component will attach to the first found parent <see cref="Animation"/> component.
-    /// </summary>
-    public class Bone : ManagedComponent
-    {
-        [SerializeField]
-        private string name;
-
-        private Animation parent;
-
-        /// <summary>
-        /// Name of the bone to attach to.
-        /// </summary>
-        public string Name
-        {
-            get { return name; }
-            set
-            {
-                if (name != value)
-                {
-                    name = value;
-
-                    if (parent != null)
-                        parent.NotifyBoneChanged(this);
-                }
-            }
-        }
-
-        private void OnInitialize()
-        {
-            NotifyFlags = TransformChangedFlags.Parent;
-        }
-
-        private void OnEnable()
-        {
-            UpdateParentAnimation();
-        }
-
-        private void OnDisable()
-        {
-            if (parent != null)
-                parent.RemoveBone(this);
-
-            parent = null;
-        }
-
-        private void OnDestroy()
-        {
-            if (parent != null)
-                parent.RemoveBone(this);
-
-            parent = null;
-        }
-
-        private void OnTransformChanged(TransformChangedFlags flags)
-        {
-            if (!SceneObject.Active)
-                return;
-
-            if ((flags & TransformChangedFlags.Parent) != 0)
-                UpdateParentAnimation();
-        }
-
-        /// <summary>
-        /// Attempts to find the parent <see cref="Animation"/> component and registers itself with it.
-        /// </summary>
-        private void UpdateParentAnimation()
-        {
-            SceneObject currentSO = SceneObject;
-            while (currentSO != null)
-            {
-                Animation parent = currentSO.GetComponent<Animation>();
-                if (parent != null)
-                {
-                    if (currentSO.Active)
-                        SetParent(parent);
-                    else
-                        SetParent(null);
-
-                    return;
-                }
-
-                currentSO = currentSO.Parent;
-            }
-
-            SetParent(null);
-        }
-
-        /// <summary>
-        /// Changes the parent animation of this component.
-        /// </summary>
-        /// <param name="animation">New animation parent, can be null.</param>
-        /// <param name="isInternal">If true the bone will just be changed internally, but parent animation will not be
-        ///                          notified.</param>
-        internal void SetParent(Animation animation, bool isInternal = false)
-        {
-            if (animation == parent)
-                return;
-
-            if (!isInternal)
-            {
-                if (parent != null)
-                    parent.RemoveBone(this);
-
-                if (animation != null)
-                    animation.AddBone(this);
-            }
-
-            parent = animation;
-        }
-    }
-
-    /** @} */
-}

+ 0 - 246
Source/MBansheeEngine/Animation/Interop/NativeAnimation.cs

@@ -1,246 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @cond INTEROP */
-
-    /// <summary>
-    /// Wrapper around the native Animation class.
-    /// <see cref="Animation"/>
-    /// </summary>
-    internal class NativeAnimation : ScriptObject
-    {
-        public AnimWrapMode WrapMode
-        {
-            set { Internal_SetWrapMode(mCachedPtr, value); }
-        }
-
-        public float Speed
-        {
-            set { Internal_SetSpeed(mCachedPtr, value); }
-        }
-
-        public int NumClips
-        {
-            get { return Internal_GetNumClips(mCachedPtr); }
-        }
-
-        public AABox Bounds
-        {
-            set { Internal_SetBounds(mCachedPtr, ref value); }
-        }
-
-        public bool Cull
-        {
-            set { Internal_SetCull(mCachedPtr, value); }
-        }
-
-        public Action<AnimationClip, string> OnEventTriggered;
-
-        public void Play(AnimationClip clip)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            Internal_Play(mCachedPtr, clipPtr);
-        }
-
-        public void BlendAdditive(AnimationClip clip, float weight, float fadeLength, int layer)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            Internal_BlendAdditive(mCachedPtr, clipPtr, weight, fadeLength, layer);
-        }
-
-        public void Blend1D(Blend1DInfo info, float t)
-        {
-            if (info == null)
-                return;
-
-            Internal_Blend1D(mCachedPtr, info, t);
-        }
-
-        public void Blend2D(Blend2DInfo info, Vector2 t)
-        {
-            if (info == null)
-                return;
-
-            Internal_Blend2D(mCachedPtr, info, ref t);
-        }
-
-        public void CrossFade(AnimationClip clip, float fadeLength)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            Internal_CrossFade(mCachedPtr, clipPtr, fadeLength);
-        }
-
-        public void Sample(AnimationClip clip, float time)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            Internal_Sample(mCachedPtr, clipPtr, time);
-        }
-
-        public void Stop(int layer)
-        {
-            Internal_Stop(mCachedPtr, layer);
-        }
-
-        public void StopAll()
-        {
-            Internal_StopAll(mCachedPtr);
-        }
-
-        public bool IsPlaying()
-        {
-            return Internal_IsPlaying(mCachedPtr);
-        }
-
-        public AnimationClip GetClip(int index)
-        {
-            return Internal_GetClip(mCachedPtr, index);
-        }
-
-        public bool GetState(AnimationClip clip, out AnimationClipState state)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            return Internal_GetState(mCachedPtr, clipPtr, out state);
-        }
-
-        public void SetState(AnimationClip clip, AnimationClipState state)
-        {
-            IntPtr clipPtr = IntPtr.Zero;
-            if (clip != null)
-                clipPtr = clip.GetCachedPtr();
-
-            Internal_SetState(mCachedPtr, clipPtr, ref state);
-        }
-
-        public void SetMorphChannelWeight(int idx, float weight)
-        {
-            Internal_SetMorphChannelWeight(mCachedPtr, idx, weight);
-        }
-
-        public bool GetGenericCurveValue(int curveIdx, out float value)
-        {
-            return Internal_GetGenericCurveValue(mCachedPtr, curveIdx, out value);
-        }
-
-        public void MapCurveToSceneObject(string curve, SceneObject sceneObject)
-        {
-            if (curve == null || sceneObject == null)
-                return;
-
-            Internal_MapCurveToSceneObject(mCachedPtr, curve, sceneObject.GetCachedPtr());
-        }
-
-        public void UnmapSceneObject(SceneObject sceneObject)
-        {
-            if (sceneObject == null)
-                return;
-
-            Internal_UnmapSceneObject(mCachedPtr, sceneObject.GetCachedPtr());
-        }
-
-        internal NativeAnimation()
-        {
-            Internal_Create(this);
-        }
-        
-        internal void Destroy()
-        {
-            Internal_Destroy(mCachedPtr);
-        }
-
-        private void Internal_OnEventTriggered(AnimationClip clip, string name)
-        {
-            OnEventTriggered?.Invoke(clip, name);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Create(NativeAnimation instance);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Destroy(IntPtr thisPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetWrapMode(IntPtr thisPtr, AnimWrapMode wrapMode);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetSpeed(IntPtr thisPtr, float speed);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Play(IntPtr thisPtr, IntPtr clipPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_BlendAdditive(IntPtr thisPtr, IntPtr clipPtr, float weight, float fadeLength,
-            int layer);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Blend1D(IntPtr thisPtr, Blend1DInfo info, float t);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Blend2D(IntPtr thisPtr, Blend2DInfo info, ref Vector2 t);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CrossFade(IntPtr thisPtr, IntPtr clipPtr, float fadeLength);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Sample(IntPtr thisPtr, IntPtr clipPtr, float time);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Stop(IntPtr thisPtr, int layer);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_StopAll(IntPtr thisPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern bool Internal_IsPlaying(IntPtr thisPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern bool Internal_GetState(IntPtr thisPtr, IntPtr clipPtr, out AnimationClipState state);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetState(IntPtr thisPtr, IntPtr clipPtr, ref AnimationClipState state);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMorphChannelWeight(IntPtr thisPtr, int idx, float weight);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern int Internal_GetNumClips(IntPtr thisPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern AnimationClip Internal_GetClip(IntPtr thisPtr, int idx);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern bool Internal_GetGenericCurveValue(IntPtr thisPtr, int curveIdx, out float value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_MapCurveToSceneObject(IntPtr thisPtr, string curve, IntPtr sceneObjectPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_UnmapSceneObject(IntPtr thisPtr, IntPtr sceneObjectPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetBounds(IntPtr thisPtr, ref AABox bounds);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetCull(IntPtr thisPtr, bool cull);
-    }
-
-    /** @endcond */
-}

+ 0 - 170
Source/MBansheeEngine/Interop/NativeRenderable.cs

@@ -1,170 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @cond INTEROP */
-
-    /// <summary>
-    /// Wrapper around the native Renderable class.
-    /// <see cref="Renderable"/>
-    /// </summary>
-    internal class NativeRenderable : ScriptObject
-    {
-        internal Mesh Mesh
-        {
-            get
-            {
-                return mesh; 
-            }
-            set
-            {
-                mesh = value;
-
-                IntPtr meshPtr = IntPtr.Zero;
-                if (mesh != null)
-                    meshPtr = mesh.GetCachedPtr();
-
-                Internal_SetMesh(mCachedPtr, meshPtr); 
-                
-            }
-        }
-
-        internal Bounds GetBounds(SceneObject parent)
-        {
-            AABox box;
-            Sphere sphere;
-
-            Internal_GetBounds(mCachedPtr, parent.mCachedPtr, out box, out sphere);
-
-            return new Bounds(box, sphere);
-        }
-
-        internal AABox OverrideBounds
-        {
-            set { Internal_SetOverrideBounds(mCachedPtr, ref value); }
-        }
-
-        internal bool UseOverrideBounds
-        {
-            set { Internal_SetUseOverrideBounds(mCachedPtr, value); }
-        }
-
-        internal UInt64 Layers
-        {
-            get { return Internal_GetLayers(mCachedPtr); }
-            set { Internal_SetLayers(mCachedPtr, value); }
-        }
-
-        internal NativeAnimation Animation
-        {
-            set
-            {
-                IntPtr animationPtr = IntPtr.Zero;
-                if (value != null)
-                    animationPtr = value.GetCachedPtr();
-
-                Internal_SetAnimation(mCachedPtr, animationPtr);
-            }
-        }
-
-        private Material[] materials = new Material[1];
-        private Mesh mesh;
-        
-        public NativeRenderable(SceneObject sceneObject)
-        {
-            IntPtr sceneObjPtr = IntPtr.Zero;
-            if (sceneObject != null)
-                sceneObjPtr = sceneObject.GetCachedPtr();
-
-            Internal_Create(this, sceneObjPtr);
-        }
-
-        internal Material[] Materials
-        {
-            get
-            {
-                if (materials == null)
-                    return null;
-
-                Material[] copy = new Material[materials.Length];
-                Array.Copy(materials, copy, materials.Length);
-
-                return copy;
-            }
-            set
-            {
-                materials = new Material[value.Length];
-                Array.Copy(value, materials, value.Length);
-
-                Internal_SetMaterials(mCachedPtr, value);
-            }
-        }
-
-        internal Material GetMaterial(int index = 0)
-        {
-            return materials[index];
-        }
-
-        internal void SetMaterial(Material material, int index = 0)
-        {
-            materials[index] = material;
-
-            IntPtr materialPtr = IntPtr.Zero;
-            if (material != null)
-                materialPtr = material.GetCachedPtr();
-
-            Internal_SetMaterial(mCachedPtr, materialPtr, index);
-        }
-
-        internal void UpdateTransform(SceneObject sceneObject, bool force)
-        {
-            Internal_UpdateTransform(mCachedPtr, sceneObject.mCachedPtr, force);
-        }
-        
-        internal void OnDestroy()
-        {
-            Internal_OnDestroy(mCachedPtr);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Create(NativeRenderable instance, IntPtr parentSO);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetAnimation(IntPtr thisPtr, IntPtr animation);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_UpdateTransform(IntPtr thisPtr, IntPtr parentSO, bool force);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMesh(IntPtr thisPtr, IntPtr mesh);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern UInt64 Internal_GetLayers(IntPtr thisPtr);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetLayers(IntPtr thisPtr, UInt64 layers);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMaterial(IntPtr thisPtr, IntPtr material, int index);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMaterials(IntPtr thisPtr, Material[] materials);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetOverrideBounds(IntPtr thisPtr, ref AABox box);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetUseOverrideBounds(IntPtr thisPtr, bool enable);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_OnDestroy(IntPtr thisPtr);
-    }
-
-    /** @endcond */
-}

+ 1 - 6
Source/MBansheeEngine/MBansheeEngine.csproj

@@ -45,10 +45,9 @@
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <Compile Include="Animation\Animation.cs" />
     <Compile Include="Animation\Animation.cs" />
-    <Compile Include="Animation\Bone.cs" />
-    <Compile Include="Animation\Interop\NativeAnimation.cs" />
     <Compile Include="GUI\GUICanvas.cs" />
     <Compile Include="GUI\GUICanvas.cs" />
     <Compile Include="GUI\GUIScrollBar.cs" />
     <Compile Include="GUI\GUIScrollBar.cs" />
+    <Compile Include="Rendering\Material.cs" />
     <Compile Include="Rendering\RenderSettings.cs" />
     <Compile Include="Rendering\RenderSettings.cs" />
     <Compile Include="Serialization\ShowInInspector.cs" />
     <Compile Include="Serialization\ShowInInspector.cs" />
     <Compile Include="Serialization\Step.cs" />
     <Compile Include="Serialization\Step.cs" />
@@ -104,7 +103,6 @@
     <Compile Include="Interop\NativeLight.cs" />
     <Compile Include="Interop\NativeLight.cs" />
     <Compile Include="GUI\LocString.cs" />
     <Compile Include="GUI\LocString.cs" />
     <Compile Include="Resources\ManagedResource.cs" />
     <Compile Include="Resources\ManagedResource.cs" />
-    <Compile Include="Rendering\Material.cs" />
     <Compile Include="Math\AABox.cs" />
     <Compile Include="Math\AABox.cs" />
     <Compile Include="Math\BsRect3.cs" />
     <Compile Include="Math\BsRect3.cs" />
     <Compile Include="Math\Degree.cs" />
     <Compile Include="Math\Degree.cs" />
@@ -128,8 +126,6 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Math\Quaternion.cs" />
     <Compile Include="Math\Quaternion.cs" />
     <Compile Include="Serialization\Range.cs" />
     <Compile Include="Serialization\Range.cs" />
-    <Compile Include="Rendering\Renderable.cs" />
-    <Compile Include="Interop\NativeRenderable.cs" />
     <Compile Include="Rendering\RenderTarget.cs" />
     <Compile Include="Rendering\RenderTarget.cs" />
     <Compile Include="Rendering\RenderTexture.cs" />
     <Compile Include="Rendering\RenderTexture.cs" />
     <Compile Include="Rendering\RenderTexture2D.cs" />
     <Compile Include="Rendering\RenderTexture2D.cs" />
@@ -150,7 +146,6 @@
     <Compile Include="Serialization\SerializableUtility.cs" />
     <Compile Include="Serialization\SerializableUtility.cs" />
     <Compile Include="Serialization\SerializeObject.cs" />
     <Compile Include="Serialization\SerializeObject.cs" />
     <Compile Include="Serialization\SerializeField.cs" />
     <Compile Include="Serialization\SerializeField.cs" />
-    <Compile Include="Rendering\Shader.cs" />
     <Compile Include="Rendering\ShaderInclude.cs" />
     <Compile Include="Rendering\ShaderInclude.cs" />
     <Compile Include="GUI\ShortcutKey.cs" />
     <Compile Include="GUI\ShortcutKey.cs" />
     <Compile Include="Math\Sphere.cs" />
     <Compile Include="Math\Sphere.cs" />

+ 3 - 0
Source/MBansheeEngine/Math/Bounds.cs

@@ -1,5 +1,7 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+using System.Runtime.InteropServices;
+
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
     /** @addtogroup Math
     /** @addtogroup Math
@@ -9,6 +11,7 @@ namespace BansheeEngine
     /// <summary>
     /// <summary>
     /// Bounds represented by an axis aligned box and a sphere.
     /// Bounds represented by an axis aligned box and a sphere.
     /// </summary>
     /// </summary>
+    [StructLayout(LayoutKind.Sequential), SerializeObject]
     public struct Bounds
     public struct Bounds
     {
     {
         /// <summary>
         /// <summary>

+ 19 - 283
Source/MBansheeEngine/Rendering/Material.cs

@@ -1,309 +1,45 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
     /** @addtogroup Rendering
     /** @addtogroup Rendering
      *  @{
      *  @{
      */
      */
 
 
-    /// <summary>
-    /// Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that 
-    /// shader. It provides a simple interface for manipulating the parameters.
-    /// </summary>
-    public class Material : Resource
+    public partial class Material
     {
     {
         /// <summary>
         /// <summary>
-        /// Creates a new empty material that references no shader.
-        /// </summary>
-        public Material()
-        {
-            Internal_CreateInstance(this, IntPtr.Zero);
-        }
-
-        /// <summary>
-        /// Constructor for internal runtime use only.
-        /// </summary>
-        /// <param name="dummy">Dummy parameter to differentiate it from other constructors.</param>
-        private Material(bool dummy)
-        { }
-
-        /// <summary>
-        /// Creates a new material with the specified shader.
-        /// </summary>
-        /// <param name="shader">Shader to initialize the material with.</param>
-        public Material(Shader shader)
-        {
-            IntPtr nativeShader = IntPtr.Zero;
-            if (shader != null)
-                nativeShader = shader.GetCachedPtr();
-
-            Internal_CreateInstance(this, nativeShader);
-        }
-
-        /// <summary>
-        /// Shader used by the material. Best technique from the shader will be used for rendering, depending on currently
-        /// active renderer and render API.
-        /// </summary>
-        public Shader Shader
-        {
-            get { return Internal_GetShader(mCachedPtr); }
-            set
-            {
-                IntPtr nativeShader = IntPtr.Zero;
-                if (value != null)
-                    nativeShader = value.GetCachedPtr();
-
-                Internal_SetShader(mCachedPtr, nativeShader); 
-            }
-        }
-
-        /// <summary>
-        /// Assigns a float value to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetFloat(string name, float value)
-        {
-            Internal_SetFloat(mCachedPtr, name, value);
-        }
-
-        /// <summary>
-        /// Assigns a 2D vector to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetVector2(string name, Vector2 value)
-        {
-            Internal_SetVector2(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a 3D vector to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetVector3(string name, Vector3 value)
-        {
-            Internal_SetVector3(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a 4D vector to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetVector4(string name, Vector4 value)
-        {
-            Internal_SetVector4(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a 3x3 matrix to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetMatrix3(string name, Matrix3 value)
-        {
-            Internal_SetMatrix3(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a 4x4 matrix to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetMatrix4(string name, Matrix4 value)
-        {
-            Internal_SetMatrix4(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a color to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetColor(string name, Color value)
-        {
-            Internal_SetColor(mCachedPtr, name, ref value);
-        }
-
-        /// <summary>
-        /// Assigns a texture to the shader parameter with the specified name.
+        /// Returns a texture assigned to the material.
         /// </summary>
         /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetTexture(string name, Texture value)
-        {
-            IntPtr texturePtr = IntPtr.Zero;
-            if (value != null)
-                texturePtr = value.GetCachedPtr();
-
-            Internal_SetTexture(mCachedPtr, name, texturePtr);
-        }
-        
-        /// <summary>
-        /// Returns a float value assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public float GetFloat(string name)
-        {
-            return Internal_GetFloat(mCachedPtr, name);
-        }
-
-        /// <summary>
-        /// Returns a 2D vector assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Vector2 GetVector2(string name)
-        {
-            Vector2 value;
-            Internal_GetVector2(mCachedPtr, name, out value);
-            return value;
-        }
-
-        /// <summary>
-        /// Returns a 3D vector assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Vector3 GetVector3(string name)
-        {
-            Vector3 value;
-            Internal_GetVector3(mCachedPtr, name, out value);
-            return value;
-        }
-
-        /// <summary>
-        /// Returns a 4D vector assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Vector4 GetVector4(string name)
-        {
-            Vector4 value;
-            Internal_GetVector4(mCachedPtr, name, out value);
-            return value;
-        }
-
-        /// <summary>
-        /// Returns a 3x3 matrix assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Matrix3 GetMatrix3(string name)
-        {
-            Matrix3 value;
-            Internal_GetMatrix3(mCachedPtr, name, out value);
-            return value;
-        }
-
-        /// <summary>
-        /// Returns a 4x4 matrix assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Matrix4 GetMatrix4(string name)
+        /// <param name="name">Name of the texture parameter.</param>
+        /// <returns>Texture assigned to the specified material</returns>
+        public Texture GetTexture(string name)
         {
         {
-            Matrix4 value;
-            Internal_GetMatrix4(mCachedPtr, name, out value);
-            return value;
+            return Internal_getTexture(mCachedPtr, name);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Returns a color assigned with the parameter with the specified name.
+        /// Assigns a texture to the specified material parameter. Allows you to specify a surface parameter that allows you
+        /// to bind only a sub-set of the texture.
         /// </summary>
         /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Color GetColor(string name)
+        /// <param name="name">Name of the texture parameter.</param>
+        /// <param name="texture">Texture resource to assign.</param>
+        /// <param name="surface">Subset of the texture to assign.</param>
+        public void SetTexture(string name, Texture texture, TextureSurface surface)
         {
         {
-            Color value;
-            Internal_GetColor(mCachedPtr, name, out value);
-            return value;
+            Internal_setTexture(mCachedPtr, name, texture, surface.mipLevel, surface.numMipLevels, surface.face, 
+                surface.numFaces);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Returns a texture assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Texture GetTexture(string name)
-        {
-            return Internal_GetTexture(mCachedPtr, name);
-        }
-        
-        /// <summary>
-        /// Creates a deep copy of the material.
+        /// Assigns a texture to the specified material parameter.
         /// </summary>
         /// </summary>
-        /// <returns>A new object with exact data as this object.</returns>
-        public Material Clone()
+        /// <param name="name">Name of the texture parameter.</param>
+        /// <param name="texture">Texture resource to assign.</param>
+        public void SetTexture(string name, Texture texture)
         {
         {
-            return Internal_Clone(mCachedPtr);
+            Internal_setTexture(mCachedPtr, name, texture, 0, 0, 0, 0);
         }
         }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(Material instance, IntPtr shader);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Shader Internal_GetShader(IntPtr nativeInstance);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetShader(IntPtr nativeInstance, IntPtr shader);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetFloat(IntPtr nativeInstance, string name, float value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetVector2(IntPtr nativeInstance, string name, ref Vector2 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetVector3(IntPtr nativeInstance, string name, ref Vector3 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetVector4(IntPtr nativeInstance, string name, ref Vector4 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMatrix3(IntPtr nativeInstance, string name, ref Matrix3 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetMatrix4(IntPtr nativeInstance, string name, ref Matrix4 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetColor(IntPtr nativeInstance, string name, ref Color value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTexture(IntPtr nativeInstance, string name, IntPtr value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern float Internal_GetFloat(IntPtr nativeInstance, string name);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetVector2(IntPtr nativeInstance, string name, out Vector2 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetVector3(IntPtr nativeInstance, string name, out Vector3 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetVector4(IntPtr nativeInstance, string name, out Vector4 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetMatrix3(IntPtr nativeInstance, string name, out Matrix3 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetMatrix4(IntPtr nativeInstance, string name, out Matrix4 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetColor(IntPtr nativeInstance, string name, out Color value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture Internal_GetTexture(IntPtr nativeInstance, string name);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Material Internal_Clone(IntPtr nativeInstance);
     }
     }
 
 
     /** @} */
     /** @} */

+ 0 - 219
Source/MBansheeEngine/Rendering/Renderable.cs

@@ -1,219 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Rendering
-     *  @{
-     */
-
-    /// <summary>
-    /// Renderable represents any visible object in the scene. It has a mesh, bounds and a set of materials. Renderer will 
-    /// render any Renderable objects visible by a camera.
-    /// </summary>
-    [RunInEditor]
-    public sealed class Renderable : ManagedComponent
-    {
-        private NativeRenderable _native;
-        private Animation animation;
-
-        [SerializeField]
-        private SerializableData serializableData = new SerializableData();
-
-        /// <summary>
-        /// Returns the non-component version of Renderable that is wrapped by this component. 
-        /// </summary>
-        internal NativeRenderable Native
-        {
-            get { return _native; }
-        }
-
-        /// <summary>
-        /// Mesh to render. 
-        /// </summary>
-        public Mesh Mesh
-        {
-            get { return _native.Mesh; }
-            set 
-            { 
-                _native.Mesh = value; 
-                serializableData.mesh = value;
-
-                int subMeshCount = 0;
-                if (value != null)
-                    subMeshCount = (int)value.SubMeshCount;
-
-                Material[] newMaterials = new Material[subMeshCount];
-                int numToCopy = MathEx.Min(newMaterials.Length, serializableData.materials.Length);
-                Array.Copy(serializableData.materials, newMaterials, numToCopy);
-                serializableData.materials = newMaterials;
-
-                if (animation != null)
-                    animation.UpdateBounds(false);
-            }
-        }
-
-        /// <summary>
-        /// Material to use when rendering the mesh. If the mesh contains multiple sub-meshes then you may set individual
-        /// materials for each sub-mesh.
-        /// </summary>
-        public Material Material
-        {
-            get { return _native.GetMaterial(0); }
-            set 
-            { _native.SetMaterial(value); serializableData.materials[0] = value; }
-        }
-
-        /// <summary>
-        /// Materials to use when rendering the mesh. 
-        /// </summary>
-        public Material[] Materials
-        {
-            get { return _native.Materials; }
-            set
-            {
-                _native.Materials = value;
-
-                serializableData.materials = new Material[value.Length];
-                Array.Copy(value, serializableData.materials, value.Length);
-            }
-        }
-
-        /// <summary>
-        /// Returns a material for a specific sub-mesh.
-        /// </summary>
-        /// <param name="index">Index of the sub-mesh.</param>
-        /// <returns>Material used for rendering the sub-mesh at the specified index.</returns>
-        public Material GetMaterial(int index = 0)
-        {
-            return _native.GetMaterial(index);
-        }
-
-        /// <summary>
-        /// Sets a material for a specific sub-mesh.
-        /// </summary>
-        /// <param name="material">Material to use for rendering the sub-mesh at the specified index.</param>
-        /// <param name="index">Index of the sub-mesh.</param>
-        public void SetMaterial(Material material, int index = 0)
-        {
-            _native.SetMaterial(material, index);
-            serializableData.materials[index] = material;
-        }
-
-        /// <summary>
-        /// Layer bitfield that controls whether a renderable is considered visible in a specific camera. Renderable layer 
-        /// must match camera layer in order for the camera to render the component.
-        /// </summary>
-        public UInt64 Layers
-        {
-            get { return _native.Layers; }
-            set { _native.Layers = value; serializableData.layers = value; }
-        }
-
-        /// <summary>
-        /// Gets world bounds of the mesh rendered by this object.
-        /// </summary>
-        public Bounds Bounds
-        {
-            get { return _native.GetBounds(SceneObject); }
-        }
-
-        private void OnInitialize()
-        {
-            animation = SceneObject.GetComponent<Animation>();
-            if (animation != null)
-            {
-                RegisterAnimation(animation);
-                animation.RegisterRenderable(this);
-            }
-        }
-
-        private void OnReset()
-        {
-            if (_native != null)
-                _native.OnDestroy();
-
-            _native = new NativeRenderable(SceneObject);
-
-            // Restore saved values after reset
-            _native.Mesh = serializableData.mesh;
-
-            if (serializableData.materials != null)
-                _native.Materials = serializableData.materials;
-
-            _native.Layers = serializableData.layers;
-        }
-
-        private void OnUpdate()
-        {
-            _native.UpdateTransform(SceneObject, false);
-        }
-
-        private void OnDestroy()
-        {
-            if (animation != null)
-                animation.UnregisterRenderable();
-
-            _native.OnDestroy();
-        }
-
-        /// <summary>
-        /// Registers an <see cref="Animation"/> component with the renderable. Rendering will be affected by the animation.
-        /// </summary>
-        /// <param name="animation">Component that was added</param>
-        internal void RegisterAnimation(Animation animation)
-        {
-            this.animation = animation;
-            if (_native != null)
-            {
-                _native.Animation = animation.Native;
-
-                // Need to update transform because animated renderables handle local transforms through bones, so it
-                // shouldn't be included in the renderable's transform.
-                _native.UpdateTransform(SceneObject, true);
-            }
-        }
-
-        /// <summary>
-        /// Removes animation from the renderable. Rendering will no longer be affected by animation.
-        /// </summary>
-        internal void UnregisterAnimation()
-        {
-            animation = null;
-
-            if (_native != null)
-            {
-                _native.Animation = null;
-
-                // Need to update transform because animated renderables handle local transforms through bones, so it
-                // shouldn't be included in the renderable's transform.
-                _native.UpdateTransform(SceneObject, true);
-            }
-        }
-
-        /// <inheritdoc/>
-        protected internal override bool CalculateBounds(out AABox box, out Sphere sphere)
-        {
-            Bounds bounds = Bounds;
-
-            box = bounds.Box;
-            sphere = bounds.Sphere;
-
-            return true;
-        }
-
-        /// <summary>
-        /// Holds all data the renderable component needs to persist through serialization.
-        /// </summary>
-        [SerializeObject]
-        private class SerializableData
-        {
-            public Mesh mesh;
-            public Material[] materials = new Material[1];
-            public UInt64 layers = 1;
-        }
-    }
-
-    /** @} */
-}

+ 0 - 102
Source/MBansheeEngine/Rendering/Shader.cs

@@ -1,102 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Rendering
-     *  @{
-     */
-
-    /// <summary>
-    /// Type of parameters that can be defined in a shader.
-    /// </summary>
-    public enum ShaderParameterType // Note: Must match C++ ShaderParameterType enum
-    {
-        Float, Vector2, Vector3, Vector4, Color,
-        Matrix3, Matrix4, Texture2D, 
-        Texture3D, TextureCube, Sampler
-    }
-
-    /// <summary>
-    /// Contains information about a shader parameter.
-    /// </summary>
-    public struct ShaderParameter
-    {
-        /// <summary>
-        /// Returns the name of the parameter variable.
-        /// </summary>
-        public string Name { get { return name; } }
-
-        /// <summary>
-        /// Returns the data type of the parameter.
-        /// </summary>
-        public ShaderParameterType Type { get { return type; } }
-
-        /// <summary>
-        /// Determines is parameter managed internally be the renderer, or is it expected to be set by the user.
-        /// </summary>
-        public bool Internal { get { return isInternal; } }
-
-        private string name;
-        private ShaderParameterType type;
-        private bool isInternal;
-
-        /// <summary>
-        /// Creates a new shader parameter.
-        /// </summary>
-        /// <param name="name">Name of the parameter variable.</param>
-        /// <param name="type">Data type of the parameter.</param>
-        /// <param name="isInternal">Determines is parameter managed internally be the renderer, or is expected to be set 
-        ///                          by the user.</param>
-        internal ShaderParameter(string name, ShaderParameterType type, bool isInternal)
-        {
-            this.name = name;
-            this.type = type;
-            this.isInternal = isInternal;
-        }
-    }
-
-    /// <summary>
-    /// Contains definitions of GPU programs used for rendering, as well as a set of global parameters to control those
-    /// programs.
-    /// </summary>
-    public class Shader : Resource
-    {
-        /// <summary>
-        /// Constuctor for internal runtime use only.
-        /// </summary>
-        private Shader()
-        { }
-
-        /// <summary>
-        /// Returns data about all parameters available in the shader.
-        /// </summary>
-        public ShaderParameter[] Parameters
-        {
-            get
-            {
-                string[] names;
-                ShaderParameterType[] types;
-                bool[] visibility;
-
-                Internal_GetShaderParameters(mCachedPtr, out names, out types, out visibility);
-
-                ShaderParameter[] parameters = new ShaderParameter[names.Length];
-                for (int i = 0; i < names.Length; i++)
-                {
-                    parameters[i] = new ShaderParameter(names[i], types[i], visibility[i]);
-                }
-
-                return parameters;
-            }
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetShaderParameters(IntPtr nativeInstance, out string[] names,
-            out ShaderParameterType[] types, out bool[] visibility);
-    }
-
-    /** @} */
-}

+ 1 - 1
Source/RenderBeast/BsShadowRendering.cpp

@@ -230,7 +230,7 @@ namespace bs { namespace ct
 		gShadowProjectVertParamsDef.gPositionAndScale.set(mVertParams, lightPosAndScale);
 		gShadowProjectVertParamsDef.gPositionAndScale.set(mVertParams, lightPosAndScale);
 
 
 		TextureSurface surface;
 		TextureSurface surface;
-		surface.arraySlice = params.shadowMapFace;
+		surface.face = params.shadowMapFace;
 
 
 		mGBufferParams.bind(params.gbuffer);
 		mGBufferParams.bind(params.gbuffer);
 
 

+ 4 - 8
Source/SBansheeEngine/CMakeSources.cmake

@@ -71,12 +71,10 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 	"Wrappers/BsScriptLight.h"
 	"Wrappers/BsScriptLight.h"
 	"Wrappers/BsScriptLogEntry.h"
 	"Wrappers/BsScriptLogEntry.h"
 	"Wrappers/BsScriptManagedResource.h"
 	"Wrappers/BsScriptManagedResource.h"
-	"Wrappers/BsScriptMaterial.h"
 	"Wrappers/BsScriptPixelUtility.h"
 	"Wrappers/BsScriptPixelUtility.h"
 	"Wrappers/BsScriptPlainText.h"
 	"Wrappers/BsScriptPlainText.h"
 	"Wrappers/BsScriptPrefab.h"
 	"Wrappers/BsScriptPrefab.h"
 	"Wrappers/BsScriptProfilerOverlayInternal.h"
 	"Wrappers/BsScriptProfilerOverlayInternal.h"
-	"Wrappers/BsScriptRenderable.h"
 	"Wrappers/BsScriptRenderTarget.h"
 	"Wrappers/BsScriptRenderTarget.h"
 	"Wrappers/BsScriptRenderTexture.h"
 	"Wrappers/BsScriptRenderTexture.h"
 	"Wrappers/BsScriptRenderTexture2D.h"
 	"Wrappers/BsScriptRenderTexture2D.h"
@@ -89,7 +87,6 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 	"Wrappers/BsScriptStringTable.h"
 	"Wrappers/BsScriptStringTable.h"
 	"Wrappers/BsScriptSpriteTexture.h"
 	"Wrappers/BsScriptSpriteTexture.h"
 	"Wrappers/BsScriptShaderInclude.h"
 	"Wrappers/BsScriptShaderInclude.h"
-	"Wrappers/BsScriptShader.h"
 	"Wrappers/BsScriptSerializableUtility.h"
 	"Wrappers/BsScriptSerializableUtility.h"
 	"Wrappers/BsScriptSerializableProperty.h"
 	"Wrappers/BsScriptSerializableProperty.h"
 	"Wrappers/BsScriptSerializableObject.h"
 	"Wrappers/BsScriptSerializableObject.h"
@@ -103,7 +100,6 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 	"Wrappers/BsScriptResources.h"
 	"Wrappers/BsScriptResources.h"
 	"Wrappers/BsScriptResourceRef.h"
 	"Wrappers/BsScriptResourceRef.h"
 	"Wrappers/BsScriptRenderSettings.h"
 	"Wrappers/BsScriptRenderSettings.h"
-	"Wrappers/BsScriptAnimation.h"
 	"Wrappers/BsScriptManagedComponent.h"
 	"Wrappers/BsScriptManagedComponent.h"
 	"Wrappers/BsScriptQuaternion.h"
 	"Wrappers/BsScriptQuaternion.h"
 )
 )
@@ -167,7 +163,6 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS
 	"Wrappers/BsScriptLight.cpp"
 	"Wrappers/BsScriptLight.cpp"
 	"Wrappers/BsScriptLogEntry.cpp"
 	"Wrappers/BsScriptLogEntry.cpp"
 	"Wrappers/BsScriptManagedResource.cpp"
 	"Wrappers/BsScriptManagedResource.cpp"
-	"Wrappers/BsScriptMaterial.cpp"
 	"Wrappers/BsScriptPixelUtility.cpp"
 	"Wrappers/BsScriptPixelUtility.cpp"
 	"Wrappers/BsScriptPlainText.cpp"
 	"Wrappers/BsScriptPlainText.cpp"
 	"Wrappers/BsScriptPrefab.cpp"
 	"Wrappers/BsScriptPrefab.cpp"
@@ -180,7 +175,6 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS
 	"Wrappers/BsScriptStringTable.cpp"
 	"Wrappers/BsScriptStringTable.cpp"
 	"Wrappers/BsScriptSpriteTexture.cpp"
 	"Wrappers/BsScriptSpriteTexture.cpp"
 	"Wrappers/BsScriptShaderInclude.cpp"
 	"Wrappers/BsScriptShaderInclude.cpp"
-	"Wrappers/BsScriptShader.cpp"
 	"Wrappers/BsScriptSerializableUtility.cpp"
 	"Wrappers/BsScriptSerializableUtility.cpp"
 	"Wrappers/BsScriptSerializableProperty.cpp"
 	"Wrappers/BsScriptSerializableProperty.cpp"
 	"Wrappers/BsScriptSerializableObject.cpp"
 	"Wrappers/BsScriptSerializableObject.cpp"
@@ -197,9 +191,7 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS
 	"Wrappers/BsScriptRenderTexture2D.cpp"
 	"Wrappers/BsScriptRenderTexture2D.cpp"
 	"Wrappers/BsScriptRenderTexture.cpp"
 	"Wrappers/BsScriptRenderTexture.cpp"
 	"Wrappers/BsScriptRenderTarget.cpp"
 	"Wrappers/BsScriptRenderTarget.cpp"
-	"Wrappers/BsScriptRenderable.cpp"
 	"Wrappers/BsScriptRenderSettings.cpp"
 	"Wrappers/BsScriptRenderSettings.cpp"
-	"Wrappers/BsScriptAnimation.cpp"
 	"Wrappers/BsScriptManagedComponent.cpp"
 	"Wrappers/BsScriptManagedComponent.cpp"
 	"Wrappers/BsScriptQuaternion.cpp"
 	"Wrappers/BsScriptQuaternion.cpp"
 )
 )
@@ -249,6 +241,8 @@ set(BS_SBANSHEEENGINE_INC_EXTENSIONS
 	"Extensions/BsSkeletonEx.h"
 	"Extensions/BsSkeletonEx.h"
 	"Extensions/BsPhysicsMeshEx.h"
 	"Extensions/BsPhysicsMeshEx.h"
 	"Extensions/BsAnimationEx.h"
 	"Extensions/BsAnimationEx.h"
+	"Extensions/BsShaderEx.h"
+	"Extensions/BsMaterialEx.h"
 )
 )
 
 
 set(BS_SBANSHEEENGINE_SRC_EXTENSIONS
 set(BS_SBANSHEEENGINE_SRC_EXTENSIONS
@@ -260,6 +254,8 @@ set(BS_SBANSHEEENGINE_SRC_EXTENSIONS
 	"Extensions/BsSkeletonEx.cpp"
 	"Extensions/BsSkeletonEx.cpp"
 	"Extensions/BsPhysicsMeshEx.cpp"
 	"Extensions/BsPhysicsMeshEx.cpp"
 	"Extensions/BsAnimationEx.cpp"
 	"Extensions/BsAnimationEx.cpp"
+	"Extensions/BsShaderEx.cpp"
+	"Extensions/BsMaterialEx.cpp"
 )
 )
 
 
 source_group("Header Files" FILES ${BS_SBANSHEEENGINE_INC_NOFILTER})
 source_group("Header Files" FILES ${BS_SBANSHEEENGINE_INC_NOFILTER})

+ 18 - 0
Source/SBansheeEngine/Extensions/BsMaterialEx.cpp

@@ -0,0 +1,18 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "Extensions/BsMaterialEx.h"
+#include "CoreThread/BsCoreThread.h"
+
+namespace bs
+{
+	void MaterialEx::setTexture(const HMaterial& thisPtr, const String& name, const ResourceHandle<Texture>& value, 
+		UINT32 mipLevel, UINT32 numMipLevels, UINT32 arraySlice, UINT32 numArraySlices)
+	{
+		thisPtr->setTexture(name, value, TextureSurface(mipLevel, numMipLevels, arraySlice, numArraySlices));
+	}
+
+	HTexture MaterialEx::getTexture(const HMaterial& thisPtr, const String& name)
+	{
+		return thisPtr->getTexture(name);
+	}
+}

+ 30 - 0
Source/SBansheeEngine/Extensions/BsMaterialEx.h

@@ -0,0 +1,30 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "Wrappers/BsScriptResource.h"
+#include "Material/BsMaterial.h"
+
+namespace bs
+{
+	/** @addtogroup ScriptInteropEngine
+	 *  @{
+	 */
+	/** @cond SCRIPT_EXTENSIONS */
+
+	/** Extension class for Material, for adding additional functionality for the script version of the class. */
+	class BS_SCRIPT_EXPORT(e:Material) MaterialEx
+	{
+	public:
+		BS_SCRIPT_EXPORT(e:Material,in:true)
+		static void setTexture(const HMaterial& thisPtr, const String& name, const HTexture& value, 
+			UINT32 mipLevel, UINT32 numMipLevels, UINT32 arraySlice, UINT32 numArraySlices);
+
+		BS_SCRIPT_EXPORT(e:Material,in:true)
+		static HTexture getTexture(const HMaterial& thisPtr, const String& name);
+	};
+
+	/** @endcond */
+	/** @} */
+}

+ 101 - 0
Source/SBansheeEngine/Extensions/BsShaderEx.cpp

@@ -0,0 +1,101 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "Extensions/BsShaderEx.h"
+#include "CoreThread/BsCoreThread.h"
+
+namespace bs
+{
+	Vector<ShaderParameter> ShaderEx::getParameters(const HShader& thisPtr)
+	{
+		if (!thisPtr.isLoaded())
+			return Vector<ShaderParameter>();
+
+		const Map<String, SHADER_DATA_PARAM_DESC>& dataParams = thisPtr->getDataParams();
+		const Map<String, SHADER_OBJECT_PARAM_DESC>& textureParams = thisPtr->getTextureParams();
+		const Map<String, SHADER_OBJECT_PARAM_DESC>& samplerParams = thisPtr->getSamplerParams();
+
+		Vector<ShaderParameter> paramInfos;
+
+		// TODO - Ignoring int, bool, struct and non-square matrices
+		// TODO - Ignoring buffers and load/store textures
+		for (auto& param : dataParams)
+		{
+			ShaderParameterType type;
+			bool isValidType = false;
+			bool isInternal = !param.second.rendererSemantic.empty();
+			switch (param.second.type) 
+			{
+			case GPDT_FLOAT1:
+				type = ShaderParameterType::Float;
+				isValidType = true;
+				break;
+			case GPDT_FLOAT2:
+				type = ShaderParameterType::Vector2;
+				isValidType = true;
+				break;
+			case GPDT_FLOAT3:
+				type = ShaderParameterType::Vector3;
+				isValidType = true;
+				break;
+			case GPDT_FLOAT4:
+				type = ShaderParameterType::Vector4;
+				isValidType = true;
+				break;
+			case GPDT_MATRIX_3X3:
+				type = ShaderParameterType::Matrix3;
+				isValidType = true;
+				break;
+			case GPDT_MATRIX_4X4:
+				type = ShaderParameterType::Matrix4;
+				isValidType = true;
+				break;
+			case GPDT_COLOR:
+				type = ShaderParameterType::Color;
+				isValidType = true;
+				break;
+			default:
+				break;
+			}
+
+			if (isValidType)
+				paramInfos.push_back({ param.first, type, isInternal });
+		}
+
+		for (auto& param : textureParams)
+		{
+			ShaderParameterType type;
+			bool isValidType = false;
+			bool isInternal = !param.second.rendererSemantic.empty();
+			switch (param.second.type)
+			{
+			case GPOT_TEXTURE2D:
+			case GPOT_TEXTURE2DMS:
+				type = ShaderParameterType::Texture2D;
+				isValidType = true;
+				break;
+			case GPOT_TEXTURE3D:
+				type = ShaderParameterType::Texture3D;
+				isValidType = true;
+				break;
+			case GPOT_TEXTURECUBE:
+				type = ShaderParameterType::TextureCube;
+				isValidType = true;
+				break;
+			default:
+				break;
+			}
+
+			if (isValidType)
+				paramInfos.push_back({ param.first, type, isInternal });
+		}
+
+		for (auto& param : samplerParams)
+		{
+			ShaderParameterType type = ShaderParameterType::Sampler;
+			bool isInternal = !param.second.rendererSemantic.empty();
+			paramInfos.push_back({ param.first, type, isInternal });
+		}
+
+		return paramInfos;
+	}
+}

+ 48 - 0
Source/SBansheeEngine/Extensions/BsShaderEx.h

@@ -0,0 +1,48 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "Wrappers/BsScriptResource.h"
+#include "Material/BsShader.h"
+
+namespace bs
+{
+	/** @addtogroup ScriptInteropEngine
+	 *  @{
+	 */
+	/** @cond SCRIPT_EXTENSIONS */
+
+	/** Type of parameters that can be defined by a shader. */
+	enum class BS_SCRIPT_EXPORT(m:Rendering) ShaderParameterType
+	{
+		Float, Vector2, Vector3, Vector4, Color,
+		Matrix3, Matrix4, Texture2D,
+		Texture3D, TextureCube, Sampler
+	};
+
+	/** Contains information about a single shader parameter. */
+	struct BS_SCRIPT_EXPORT(m:Rendering,pl:true) ShaderParameter
+	{
+		/** Name of the parameter variable. */
+		String name;
+
+		/** Data type of the parameter. */
+		ShaderParameterType type;
+
+		/** Determines is parameter managed internally be the renderer, or is it expected to be set by the user. */
+		bool isInternal;
+	};
+
+	/** Extension class for Shader, for adding additional functionality for the script version of the class. */
+	class BS_SCRIPT_EXPORT(e:Shader) ShaderEx
+	{
+	public:
+		/** Returns information about all parameters available in the shader. */
+		BS_SCRIPT_EXPORT(e:Shader,pr:getter,n:Parameters)
+		static Vector<ShaderParameter> getParameters(const HShader& thisPtr);
+	};
+
+	/** @endcond */
+	/** @} */
+}

+ 2 - 3
Source/SBansheeEngine/Serialization/BsScriptAssemblyManager.cpp

@@ -11,7 +11,6 @@
 #include "Wrappers/BsScriptManagedResource.h"
 #include "Wrappers/BsScriptManagedResource.h"
 #include "Wrappers/BsScriptComponent.h"
 #include "Wrappers/BsScriptComponent.h"
 #include "Wrappers/BsScriptSpriteTexture.h"
 #include "Wrappers/BsScriptSpriteTexture.h"
-#include "Wrappers/BsScriptMaterial.h"
 
 
 #include "BsBuiltinComponentLookup.generated.h"
 #include "BsBuiltinComponentLookup.generated.h"
 
 
@@ -36,9 +35,7 @@
 #include "Wrappers/BsScriptSpriteTexture.h"
 #include "Wrappers/BsScriptSpriteTexture.h"
 #include "Wrappers/BsScriptPlainText.h"
 #include "Wrappers/BsScriptPlainText.h"
 #include "Wrappers/BsScriptScriptCode.h"
 #include "Wrappers/BsScriptScriptCode.h"
-#include "Wrappers/BsScriptShader.h"
 #include "Wrappers/BsScriptShaderInclude.h"
 #include "Wrappers/BsScriptShaderInclude.h"
-#include "Wrappers/BsScriptMaterial.h"
 #include "Wrappers/BsScriptFont.h"
 #include "Wrappers/BsScriptFont.h"
 #include "Wrappers/BsScriptPrefab.h"
 #include "Wrappers/BsScriptPrefab.h"
 #include "Wrappers/BsScriptStringTable.h"
 #include "Wrappers/BsScriptStringTable.h"
@@ -50,6 +47,8 @@
 #include "BsScriptPhysicsMaterial.generated.h"
 #include "BsScriptPhysicsMaterial.generated.h"
 #include "BsScriptAnimationClip.generated.h"
 #include "BsScriptAnimationClip.generated.h"
 #include "BsScriptAudioClip.generated.h"
 #include "BsScriptAudioClip.generated.h"
+#include "BsScriptShader.generated.h"
+#include "BsScriptMaterial.generated.h"
 
 
 namespace bs
 namespace bs
 {
 {

+ 0 - 336
Source/SBansheeEngine/Wrappers/BsScriptAnimation.cpp

@@ -1,336 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "Wrappers/BsScriptAnimation.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoMethod.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsMonoUtil.h"
-#include "Wrappers/BsScriptSceneObject.h"
-#include "BsScriptResourceManager.h"
-
-#include "BsScriptAnimationClip.generated.h"
-
-using namespace std::placeholders;
-
-namespace bs
-{
-	ScriptAnimation::OnEventTriggeredThunkDef ScriptAnimation::sOnEventTriggeredThunk = nullptr;
-
-	ScriptAnimation::ScriptAnimation(MonoObject* managedInstance)
-		:ScriptObject(managedInstance), mAnimation(nullptr)
-	{
-		mAnimation = Animation::create();
-		mAnimation->onEventTriggered.connect(std::bind(&ScriptAnimation::eventTriggered, this, _1, _2));
-	}
-
-	ScriptAnimation::~ScriptAnimation()
-	{ }
-
-	void ScriptAnimation::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_Create", (void*)&ScriptAnimation::internal_Create);
-		metaData.scriptClass->addInternalCall("Internal_Destroy", (void*)&ScriptAnimation::internal_Destroy);
-
-		metaData.scriptClass->addInternalCall("Internal_SetWrapMode", (void*)&ScriptAnimation::internal_SetWrapMode);
-		metaData.scriptClass->addInternalCall("Internal_SetSpeed", (void*)&ScriptAnimation::internal_SetSpeed);
-
-		metaData.scriptClass->addInternalCall("Internal_Play", (void*)&ScriptAnimation::internal_Play);
-		metaData.scriptClass->addInternalCall("Internal_BlendAdditive", (void*)&ScriptAnimation::internal_BlendAdditive);
-		metaData.scriptClass->addInternalCall("Internal_Blend1D", (void*)&ScriptAnimation::internal_Blend1D);
-		metaData.scriptClass->addInternalCall("Internal_Blend2D", (void*)&ScriptAnimation::internal_Blend2D);
-		metaData.scriptClass->addInternalCall("Internal_CrossFade", (void*)&ScriptAnimation::internal_CrossFade);
-		metaData.scriptClass->addInternalCall("Internal_Sample", (void*)&ScriptAnimation::internal_Sample);
-
-		metaData.scriptClass->addInternalCall("Internal_Stop", (void*)&ScriptAnimation::internal_Stop);
-		metaData.scriptClass->addInternalCall("Internal_StopAll", (void*)&ScriptAnimation::internal_StopAll);
-		metaData.scriptClass->addInternalCall("Internal_IsPlaying", (void*)&ScriptAnimation::internal_IsPlaying);
-
-		metaData.scriptClass->addInternalCall("Internal_GetState", (void*)&ScriptAnimation::internal_GetState);
-		metaData.scriptClass->addInternalCall("Internal_SetState", (void*)&ScriptAnimation::internal_SetState);
-
-		metaData.scriptClass->addInternalCall("Internal_SetMorphChannelWeight", (void*)&ScriptAnimation::internal_SetMorphChannelWeight);
-
-		metaData.scriptClass->addInternalCall("Internal_GetNumClips", (void*)&ScriptAnimation::internal_GetNumClips);
-		metaData.scriptClass->addInternalCall("Internal_GetClip", (void*)&ScriptAnimation::internal_GetClip);
-
-		metaData.scriptClass->addInternalCall("Internal_MapCurveToSceneObject", (void*)&ScriptAnimation::internal_MapCurveToSceneObject);
-		metaData.scriptClass->addInternalCall("Internal_UnmapSceneObject", (void*)&ScriptAnimation::internal_UnmapSceneObject);
-
-		metaData.scriptClass->addInternalCall("Internal_SetBounds", (void*)&ScriptAnimation::internal_SetBounds);
-		metaData.scriptClass->addInternalCall("Internal_SetCull", (void*)&ScriptAnimation::internal_SetCull);
-
-		metaData.scriptClass->addInternalCall("Internal_GetGenericCurveValue", (void*)&ScriptAnimation::internal_GetGenericCurveValue);
-
-		sOnEventTriggeredThunk = (OnEventTriggeredThunkDef)metaData.scriptClass->getMethod("Internal_OnEventTriggered", 2)->getThunk();
-	}
-
-	void ScriptAnimation::eventTriggered(const HAnimationClip& clip, const String& name)
-	{
-		ScriptResourceBase* scriptClip = ScriptResourceManager::instance().getScriptResource(clip, true);
-		MonoString* monoName = MonoUtil::stringToMono(name);
-
-		MonoUtil::invokeThunk(sOnEventTriggeredThunk, mManagedInstance, scriptClip->getManagedInstance(), monoName);
-	}
-
-	void ScriptAnimation::internal_Create(MonoObject* instance)
-	{
-		new (bs_alloc<ScriptAnimation>()) ScriptAnimation(instance);
-	}
-
-	void ScriptAnimation::internal_Destroy(ScriptAnimation* thisPtr)
-	{
-		thisPtr->mAnimation = nullptr;
-	}
-
-	void ScriptAnimation::internal_SetWrapMode(ScriptAnimation* thisPtr, AnimWrapMode wrapMode)
-	{
-		thisPtr->getInternal()->setWrapMode(wrapMode);
-	}
-
-	void ScriptAnimation::internal_SetSpeed(ScriptAnimation* thisPtr, float speed)
-	{
-		thisPtr->getInternal()->setSpeed(speed);
-	}
-
-	void ScriptAnimation::internal_Play(ScriptAnimation* thisPtr, ScriptAnimationClip* clip)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		thisPtr->getInternal()->play(nativeClip);
-	}
-
-	void ScriptAnimation::internal_BlendAdditive(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float weight, 
-		float fadeLength, UINT32 layer)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		thisPtr->getInternal()->blendAdditive(nativeClip, weight, fadeLength, layer);
-	}
-
-	void ScriptAnimation::internal_Blend1D(ScriptAnimation* thisPtr, MonoObject* info, float t)
-	{
-		Blend1DInfo nativeInfo = ScriptBlend1DInfo::fromManaged(info);
-		thisPtr->getInternal()->blend1D(nativeInfo, t);
-	}
-
-	void ScriptAnimation::internal_Blend2D(ScriptAnimation* thisPtr, MonoObject* info, Vector2* t)
-	{
-		Blend2DInfo nativeInfo = ScriptBlend2DInfo::fromManaged(info);
-		thisPtr->getInternal()->blend2D(nativeInfo, *t);
-	}
-
-	void ScriptAnimation::internal_CrossFade(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float fadeLength)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		thisPtr->getInternal()->crossFade(nativeClip, fadeLength);
-	}
-
-	void ScriptAnimation::internal_Sample(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float time)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		thisPtr->getInternal()->sample(nativeClip, time);
-	}
-
-	void ScriptAnimation::internal_Stop(ScriptAnimation* thisPtr, UINT32 layer)
-	{
-		thisPtr->getInternal()->stop(layer);
-	}
-
-	void ScriptAnimation::internal_StopAll(ScriptAnimation* thisPtr)
-	{
-		thisPtr->getInternal()->stopAll();
-	}
-
-	bool ScriptAnimation::internal_IsPlaying(ScriptAnimation* thisPtr)
-	{
-		return thisPtr->getInternal()->isPlaying();
-	}
-
-	UINT32 ScriptAnimation::internal_GetNumClips(ScriptAnimation* thisPtr)
-	{
-		return thisPtr->getInternal()->getNumClips();
-	}
-
-	MonoObject* ScriptAnimation::internal_GetClip(ScriptAnimation* thisPtr, UINT32 idx)
-	{
-		HAnimationClip clip = thisPtr->getInternal()->getClip(idx);
-		if (!clip.isLoaded())
-			return nullptr;
-
-		ScriptResourceBase* scriptClip = ScriptResourceManager::instance().getScriptResource(clip, true);
-		return scriptClip->getManagedInstance();
-	}
-
-	bool ScriptAnimation::internal_GetState(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, AnimationClipState* state)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		return thisPtr->getInternal()->getState(nativeClip, *state);
-	}
-
-	void ScriptAnimation::internal_SetState(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, AnimationClipState* state)
-	{
-		HAnimationClip nativeClip;
-		if (clip != nullptr)
-			nativeClip = clip->getHandle();
-
-		thisPtr->getInternal()->setState(nativeClip, *state);
-	}
-
-	void ScriptAnimation::internal_SetMorphChannelWeight(ScriptAnimation* thisPtr, UINT32 idx, float weight)
-	{
-		thisPtr->getInternal()->setMorphChannelWeight(idx, weight);
-	}
-
-	bool ScriptAnimation::internal_GetGenericCurveValue(ScriptAnimation* thisPtr, UINT32 curveIdx, float* value)
-	{
-		return thisPtr->getInternal()->getGenericCurveValue(curveIdx, *value);
-	}
-
-	void ScriptAnimation::internal_MapCurveToSceneObject(ScriptAnimation* thisPtr, MonoString* curve, ScriptSceneObject* so)
-	{
-		String curveName = MonoUtil::monoToString(curve);
-		HSceneObject soHandle = so->getNativeHandle();
-
-		thisPtr->getInternal()->mapCurveToSceneObject(curveName, soHandle);
-	}
-
-	void ScriptAnimation::internal_UnmapSceneObject(ScriptAnimation* thisPtr, ScriptSceneObject* so)
-	{
-		HSceneObject soHandle = so->getNativeHandle();
-		thisPtr->getInternal()->unmapSceneObject(soHandle);
-	}
-
-	void ScriptAnimation::internal_SetBounds(ScriptAnimation* thisPtr, AABox* bounds)
-	{
-		thisPtr->getInternal()->setBounds(*bounds);
-	}
-
-	void ScriptAnimation::internal_SetCull(ScriptAnimation* thisPtr, bool cull)
-	{
-		thisPtr->getInternal()->setCulling(cull);
-	}
-
-	MonoField* ScriptBlendClipInfo::clipField = nullptr;
-	MonoField* ScriptBlendClipInfo::positionField = nullptr;
-
-	ScriptBlendClipInfo::ScriptBlendClipInfo(MonoObject* instance)
-		:ScriptObject(instance)
-	{ }
-
-	void ScriptBlendClipInfo::initRuntimeData()
-	{
-		clipField = metaData.scriptClass->getField("clip");
-		positionField = metaData.scriptClass->getField("position");
-	}
-
-	BlendClipInfo ScriptBlendClipInfo::fromManaged(MonoObject* instance)
-	{
-		BlendClipInfo output;
-
-		MonoObject* managedAnimClip = clipField->getBoxed(instance);
-		if(managedAnimClip)
-		{
-			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedAnimClip);
-			output.clip = clip->getHandle();
-		}
-		
-		positionField->get(instance, &output.position);
-
-		return output;
-	}
-
-	MonoField* ScriptBlend1DInfo::clipsField = nullptr;
-
-	ScriptBlend1DInfo::ScriptBlend1DInfo(MonoObject* instance)
-		:ScriptObject(instance)
-	{ }
-
-	void ScriptBlend1DInfo::initRuntimeData()
-	{
-		clipsField = metaData.scriptClass->getField("clips");
-	}
-
-	Blend1DInfo ScriptBlend1DInfo::fromManaged(MonoObject* instance)
-	{
-		MonoArray* managedClipsArray = (MonoArray*)clipsField->getBoxed(instance);
-		if (managedClipsArray == nullptr)
-			return Blend1DInfo(0);
-
-		ScriptArray clipsArray(managedClipsArray);
-
-		UINT32 numClips = clipsArray.size();
-		Blend1DInfo output(numClips);
-
-		for (UINT32 i = 0; i < numClips; i++)
-			output.clips[i] = ScriptBlendClipInfo::fromManaged(clipsArray.get<MonoObject*>(i));
-
-		return output;
-	}
-
-	MonoField* ScriptBlend2DInfo::topLeftClipField = nullptr;
-	MonoField* ScriptBlend2DInfo::topRightClipField = nullptr;
-	MonoField* ScriptBlend2DInfo::botLeftClipField = nullptr;
-	MonoField* ScriptBlend2DInfo::botRightClipField = nullptr;
-
-	ScriptBlend2DInfo::ScriptBlend2DInfo(MonoObject* instance)
-		:ScriptObject(instance)
-	{ }
-
-	void ScriptBlend2DInfo::initRuntimeData()
-	{
-		topLeftClipField = metaData.scriptClass->getField("topLeftClip");
-		topRightClipField = metaData.scriptClass->getField("topRightClip");
-		botLeftClipField = metaData.scriptClass->getField("botLeftClip");
-		botRightClipField = metaData.scriptClass->getField("botRightClip");
-	}
-
-	Blend2DInfo ScriptBlend2DInfo::fromManaged(MonoObject* instance)
-	{
-		Blend2DInfo output;
-
-		MonoObject* managedTopLeftClip = topLeftClipField->getBoxed(instance);
-		if (managedTopLeftClip != nullptr)
-		{
-			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedTopLeftClip);
-			output.topLeftClip = clip->getHandle();
-		}
-
-		MonoObject* managedTopRightClip = topRightClipField->getBoxed(instance);
-		if (managedTopRightClip != nullptr)
-		{
-			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedTopRightClip);
-			output.topRightClip = clip->getHandle();
-		}
-
-		MonoObject* managedBotLeftClip = botLeftClipField->getBoxed(instance);
-		if (managedBotLeftClip != nullptr)
-		{
-			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedBotLeftClip);
-			output.botLeftClip = clip->getHandle();
-		}
-
-		MonoObject* managedBotRightClip = botRightClipField->getBoxed(instance);
-		if (managedBotRightClip != nullptr)
-		{
-			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedBotRightClip);
-			output.botRightClip = clip->getHandle();
-		}
-
-		return output;
-	}
-}

+ 0 - 134
Source/SBansheeEngine/Wrappers/BsScriptAnimation.h

@@ -1,134 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "Animation/BsAnimation.h"
-
-namespace bs
-{
-	class ScriptAnimationClip;
-
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for Animation. */
-	class BS_SCR_BE_EXPORT ScriptAnimation : public ScriptObject <ScriptAnimation>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "NativeAnimation")
-
-		/**	Returns the native wrapped animation. */
-		SPtr<Animation> getInternal() const { return mAnimation; }
-
-	private:
-		ScriptAnimation(MonoObject* managedInstance);
-		~ScriptAnimation();
-
-		/** Callback triggered when animation event triggers. */
-		void eventTriggered(const HAnimationClip& clip, const String& name);
-
-		SPtr<Animation> mAnimation;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_Create(MonoObject* instance);
-		static void internal_Destroy(ScriptAnimation* thisPtr);
-
-		static void internal_SetWrapMode(ScriptAnimation* thisPtr, AnimWrapMode wrapMode);
-		static void internal_SetSpeed(ScriptAnimation* thisPtr, float speed);
-
-		static void internal_Play(ScriptAnimation* thisPtr, ScriptAnimationClip* clip);
-		static void internal_BlendAdditive(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float weight, float fadeLength, UINT32 layer);
-		static void internal_Blend1D(ScriptAnimation* thisPtr, MonoObject* info, float t);
-		static void internal_Blend2D(ScriptAnimation* thisPtr, MonoObject* info, Vector2* t);
-		static void internal_CrossFade(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float fadeLength);
-		static void internal_Sample(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, float time);
-
-		static void internal_Stop(ScriptAnimation* thisPtr, UINT32 layer);
-		static void internal_StopAll(ScriptAnimation* thisPtr);
-		static bool internal_IsPlaying(ScriptAnimation* thisPtr);
-
-		static bool internal_GetState(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, AnimationClipState* state);
-		static void internal_SetState(ScriptAnimation* thisPtr, ScriptAnimationClip* clip, AnimationClipState* state);
-
-		static void internal_SetMorphChannelWeight(ScriptAnimation* thisPtr, UINT32 idx, float weight);
-
-		static UINT32 internal_GetNumClips(ScriptAnimation* thisPtr);
-		static MonoObject* internal_GetClip(ScriptAnimation* thisPtr, UINT32 idx);
-
-		static void internal_MapCurveToSceneObject(ScriptAnimation* thisPtr, MonoString* curve, ScriptSceneObject* so);
-		static void internal_UnmapSceneObject(ScriptAnimation* thisPtr, ScriptSceneObject* so);
-
-		static void internal_SetBounds(ScriptAnimation* thisPtr, AABox* bounds);
-		static void internal_SetCull(ScriptAnimation* thisPtr, bool cull);
-
-		static bool internal_GetGenericCurveValue(ScriptAnimation* thisPtr, UINT32 curveIdx, float* value);
-
-		typedef void(BS_THUNKCALL *OnEventTriggeredThunkDef) (MonoObject*, MonoObject*, MonoString*, MonoException**);
-		static OnEventTriggeredThunkDef sOnEventTriggeredThunk;
-	};
-
-	/** Helper class for dealing with BlendSequentialClipInfo structure. */
-	class BS_SCR_BE_EXPORT ScriptBlendClipInfo : public ScriptObject<ScriptBlendClipInfo>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "BlendClipInfo")
-
-		/** Converts managed object to its native counterpart. */
-		static BlendClipInfo fromManaged(MonoObject* object);
-
-	private:
-		ScriptBlendClipInfo(MonoObject* instance);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static MonoField* clipField;
-		static MonoField* positionField;
-	};
-
-	/** Helper class for dealing with Blend1DInfo structure. */
-	class BS_SCR_BE_EXPORT ScriptBlend1DInfo : public ScriptObject<ScriptBlend1DInfo>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Blend1DInfo")
-
-		/** Converts managed object to its native counterpart. */
-		static Blend1DInfo fromManaged(MonoObject* object);
-
-	private:
-		ScriptBlend1DInfo(MonoObject* instance);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static MonoField* clipsField;
-	};
-
-	/** Helper class for dealing with Blend2DInfo structure. */
-	class BS_SCR_BE_EXPORT ScriptBlend2DInfo : public ScriptObject<ScriptBlend2DInfo>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Blend2DInfo")
-
-		/** Converts managed object to its native counterpart. */
-		static Blend2DInfo fromManaged(MonoObject* object);
-
-	private:
-		ScriptBlend2DInfo(MonoObject* instance);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static MonoField* topLeftClipField;
-		static MonoField* topRightClipField;
-		static MonoField* botLeftClipField;
-		static MonoField* botRightClipField;
-	};
-
-	/** @} */
-}

+ 0 - 1
Source/SBansheeEngine/Wrappers/BsScriptBuiltin.cpp

@@ -7,7 +7,6 @@
 #include "BsMonoUtil.h"
 #include "BsMonoUtil.h"
 #include "Resources/BsBuiltinResources.h"
 #include "Resources/BsBuiltinResources.h"
 #include "Wrappers/BsScriptSpriteTexture.h"
 #include "Wrappers/BsScriptSpriteTexture.h"
-#include "Wrappers/BsScriptShader.h"
 #include "Wrappers/BsScriptFont.h"
 #include "Wrappers/BsScriptFont.h"
 #include "BsScriptResourceManager.h"
 #include "BsScriptResourceManager.h"
 
 

+ 0 - 233
Source/SBansheeEngine/Wrappers/BsScriptMaterial.cpp

@@ -1,233 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "Wrappers/BsScriptMaterial.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsMonoUtil.h"
-#include "Wrappers/BsScriptShader.h"
-#include "Resources/BsBuiltinResources.h"
-
-#include "BsScriptTexture.generated.h"
-
-namespace bs
-{
-	ScriptMaterial::ScriptMaterial(MonoObject* instance, const HMaterial& material)
-		:TScriptResource(instance, material)
-	{
-
-	}
-
-	void ScriptMaterial::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", (void*)&ScriptMaterial::internal_CreateInstance);
-		metaData.scriptClass->addInternalCall("Internal_Clone", (void*)&ScriptMaterial::internal_Clone);
-
-		metaData.scriptClass->addInternalCall("Internal_GetShader", (void*)&ScriptMaterial::internal_GetShader);
-		metaData.scriptClass->addInternalCall("Internal_SetShader", (void*)&ScriptMaterial::internal_SetShader);
-
-		metaData.scriptClass->addInternalCall("Internal_SetFloat", (void*)&ScriptMaterial::internal_SetFloat);
-		metaData.scriptClass->addInternalCall("Internal_SetVector2", (void*)&ScriptMaterial::internal_SetVector2);
-		metaData.scriptClass->addInternalCall("Internal_SetVector3", (void*)&ScriptMaterial::internal_SetVector3);
-		metaData.scriptClass->addInternalCall("Internal_SetVector4", (void*)&ScriptMaterial::internal_SetVector4);
-		metaData.scriptClass->addInternalCall("Internal_SetMatrix3", (void*)&ScriptMaterial::internal_SetMatrix3);
-		metaData.scriptClass->addInternalCall("Internal_SetMatrix4", (void*)&ScriptMaterial::internal_SetMatrix4);
-		metaData.scriptClass->addInternalCall("Internal_SetColor", (void*)&ScriptMaterial::internal_SetColor);
-		metaData.scriptClass->addInternalCall("Internal_SetTexture", (void*)&ScriptMaterial::internal_SetTexture);
-
-		metaData.scriptClass->addInternalCall("Internal_GetFloat", (void*)&ScriptMaterial::internal_GetFloat);
-		metaData.scriptClass->addInternalCall("Internal_GetVector2", (void*)&ScriptMaterial::internal_GetVector2);
-		metaData.scriptClass->addInternalCall("Internal_GetVector3", (void*)&ScriptMaterial::internal_GetVector3);
-		metaData.scriptClass->addInternalCall("Internal_GetVector4", (void*)&ScriptMaterial::internal_GetVector4);
-		metaData.scriptClass->addInternalCall("Internal_GetMatrix3", (void*)&ScriptMaterial::internal_GetMatrix3);
-		metaData.scriptClass->addInternalCall("Internal_GetMatrix4", (void*)&ScriptMaterial::internal_GetMatrix4);
-		metaData.scriptClass->addInternalCall("Internal_GetColor", (void*)&ScriptMaterial::internal_GetColor);
-		metaData.scriptClass->addInternalCall("Internal_GetTexture", (void*)&ScriptMaterial::internal_GetTexture);
-	}
-
-	void ScriptMaterial::internal_CreateInstance(MonoObject* instance, ScriptShader* shader)
-	{
-		HShader nativeShader;
-		if (shader != nullptr)
-			nativeShader = shader->getHandle();
-
-		if (nativeShader == nullptr)
-			nativeShader = BuiltinResources::instance().getBuiltinShader(BuiltinShader::Standard);
-
-		HMaterial material = Material::create(nativeShader);
-		ScriptResourceManager::instance().createBuiltinScriptResource(material, instance);
-	}
-
-	MonoObject* ScriptMaterial::internal_Clone(ScriptMaterial* nativeInstance)
-	{
-		HMaterial clone = nativeInstance->getHandle()->clone();
-
-		ScriptResourceBase* scriptClone = ScriptResourceManager::instance().createBuiltinScriptResource(clone);
-		return scriptClone->getManagedInstance();
-	}
-
-	MonoObject* ScriptMaterial::internal_GetShader(ScriptMaterial* nativeInstance)
-	{
-		HShader shader = nativeInstance->getHandle()->getShader();
-
-		if (!shader.isLoaded())
-			return nullptr;
-
-		ScriptResourceBase* scriptShader = ScriptResourceManager::instance().getScriptResource(shader, true);
-		return scriptShader->getManagedInstance();
-	}
-
-	void ScriptMaterial::internal_SetShader(ScriptMaterial* nativeInstance, ScriptShader* shader)
-	{
-		HShader nativeShader;
-		if (shader != nullptr)
-			nativeShader = shader->getHandle();
-
-		if (nativeShader == nullptr)
-			nativeShader = BuiltinResources::instance().getBuiltinShader(BuiltinShader::Standard);
-
-		nativeInstance->getHandle()->setShader(nativeShader);
-	}
-
-	void ScriptMaterial::internal_SetFloat(ScriptMaterial* nativeInstance, MonoString* name, float value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setFloat(paramName, value);
-	}
-
-	void ScriptMaterial::internal_SetVector2(ScriptMaterial* nativeInstance, MonoString* name, Vector2* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setVec2(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetVector3(ScriptMaterial* nativeInstance, MonoString* name, Vector3* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setVec3(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetVector4(ScriptMaterial* nativeInstance, MonoString* name, Vector4* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setVec4(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setMat3(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setMat4(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		nativeInstance->getHandle()->setColor(paramName, *value);
-	}
-
-	void ScriptMaterial::internal_SetTexture(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture;
-
-		if (value != nullptr)
-			texture = value->getHandle();
-
-		nativeInstance->getHandle()->setTexture(paramName, texture);
-	}
-
-	float ScriptMaterial::internal_GetFloat(ScriptMaterial* nativeInstance, MonoString* name)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		return nativeInstance->getHandle()->getFloat(paramName);
-	}
-
-	void ScriptMaterial::internal_GetVector2(ScriptMaterial* nativeInstance, MonoString* name, Vector2* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getVec2(paramName);
-	}
-
-	void ScriptMaterial::internal_GetVector3(ScriptMaterial* nativeInstance, MonoString* name, Vector3* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getVec3(paramName);
-	}
-
-	void ScriptMaterial::internal_GetVector4(ScriptMaterial* nativeInstance, MonoString* name, Vector4* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getVec4(paramName);
-	}
-
-	void ScriptMaterial::internal_GetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getMat3(paramName);
-	}
-
-	void ScriptMaterial::internal_GetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getMat4(paramName);
-	}
-
-	void ScriptMaterial::internal_GetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		*value = nativeInstance->getHandle()->getColor(paramName);
-	}
-
-	MonoObject* ScriptMaterial::internal_GetTexture(ScriptMaterial* nativeInstance, MonoString* name)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture = nativeInstance->getHandle()->getTexture(paramName);
-		if (texture == nullptr)
-			return nullptr;
-
-		ScriptResourceBase* scriptTexture = ScriptResourceManager::instance().getScriptResource(texture, true);
-		return scriptTexture->getManagedInstance();
-	}
-
-	MonoObject* ScriptMaterial::createInstance()
-	{
-		bool dummy = false;
-
-		void* params[1];
-		params[0] = &dummy;
-
-		return metaData.scriptClass->createInstance("bool", params);
-	}
-
-	MonoObject* ScriptMaterial::_createManagedInstance(bool construct)
-	{
-		if (construct)
-			return createInstance();
-
-		return metaData.scriptClass->createInstance(false);
-	}
-}

+ 0 - 68
Source/SBansheeEngine/Wrappers/BsScriptMaterial.h

@@ -1,68 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "Wrappers/BsScriptResource.h"
-#include "Material/BsMaterial.h"
-#include "Math/BsVector2.h"
-#include "Math/BsVector3.h"
-#include "Math/BsVector4.h"
-#include "Math/BsMatrix3.h"
-#include "Math/BsMatrix4.h"
-#include "Image/BsColor.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for Material. */
-	class BS_SCR_BE_EXPORT ScriptMaterial : public TScriptResource <ScriptMaterial, Material>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Material")
-
-		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
-		static MonoObject* createInstance();
-
-	private:
-		friend class ScriptResourceManager;
-		friend class BuiltinResourceTypes;
-
-		ScriptMaterial(MonoObject* instance, const HMaterial& material);
-
-		/** @copydoc ScriptObjectBase::_createManagedInstance */
-		MonoObject* _createManagedInstance(bool construct) override;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_CreateInstance(MonoObject* instance, ScriptShader* shader);
-		static MonoObject* internal_Clone(ScriptMaterial* nativeInstance);
-
-		static MonoObject* internal_GetShader(ScriptMaterial* nativeInstance);
-		static void internal_SetShader(ScriptMaterial* nativeInstance, ScriptShader* shader);
-
-		static void internal_SetFloat(ScriptMaterial* nativeInstance, MonoString* name, float value);
-		static void internal_SetVector2(ScriptMaterial* nativeInstance, MonoString* name, Vector2* value);
-		static void internal_SetVector3(ScriptMaterial* nativeInstance, MonoString* name, Vector3* value);
-		static void internal_SetVector4(ScriptMaterial* nativeInstance, MonoString* name, Vector4* value);
-		static void internal_SetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value);
-		static void internal_SetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value);
-		static void internal_SetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value);
-		static void internal_SetTexture(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture* value);
-
-		static float internal_GetFloat(ScriptMaterial* nativeInstance, MonoString* name);
-		static void internal_GetVector2(ScriptMaterial* nativeInstance, MonoString* name, Vector2* value);
-		static void internal_GetVector3(ScriptMaterial* nativeInstance, MonoString* name, Vector3* value);
-		static void internal_GetVector4(ScriptMaterial* nativeInstance, MonoString* name, Vector4* value);
-		static void internal_GetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value);
-		static void internal_GetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value);
-		static void internal_GetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value);
-		static MonoObject* internal_GetTexture(ScriptMaterial* nativeInstance, MonoString* name);
-	};
-
-	/** @} */
-}

+ 0 - 174
Source/SBansheeEngine/Wrappers/BsScriptRenderable.cpp

@@ -1,174 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "Wrappers/BsScriptRenderable.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsMonoUtil.h"
-#include "BsApplication.h"
-#include "Components/BsCRenderable.h"
-#include "Wrappers/BsScriptSceneObject.h"
-#include "Scene/BsSceneObject.h"
-#include "Scene/BsSceneManager.h"
-#include "Wrappers/BsScriptAnimation.h"
-#include "Wrappers/BsScriptMaterial.h"
-#include "BsScriptResourceManager.h"
-
-#include "BsScriptMesh.generated.h"
-
-namespace bs
-{
-	ScriptRenderable::ScriptRenderable(MonoObject* managedInstance, const HSceneObject& parentSO)
-		:ScriptObject(managedInstance), mRenderable(nullptr)
-	{
-		mRenderable = Renderable::create();
-		gSceneManager()._registerRenderable(mRenderable, parentSO);
-	}
-
-	ScriptRenderable::~ScriptRenderable()
-	{ }
-
-	void ScriptRenderable::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_Create", (void*)&ScriptRenderable::internal_Create);
-		metaData.scriptClass->addInternalCall("Internal_SetAnimation", (void*)&ScriptRenderable::internal_SetAnimation);
-		metaData.scriptClass->addInternalCall("Internal_UpdateTransform", (void*)&ScriptRenderable::internal_UpdateTransform);
-		metaData.scriptClass->addInternalCall("Internal_SetMesh", (void*)&ScriptRenderable::internal_SetMesh);
-		metaData.scriptClass->addInternalCall("Internal_GetBounds", (void*)&ScriptRenderable::internal_GetBounds);
-		metaData.scriptClass->addInternalCall("Internal_GetLayers", (void*)&ScriptRenderable::internal_GetLayers);
-		metaData.scriptClass->addInternalCall("Internal_SetLayers", (void*)&ScriptRenderable::internal_SetLayers);
-		metaData.scriptClass->addInternalCall("Internal_SetMaterial", (void*)&ScriptRenderable::internal_SetMaterial);
-		metaData.scriptClass->addInternalCall("Internal_SetMaterials", (void*)&ScriptRenderable::internal_SetMaterials);
-		metaData.scriptClass->addInternalCall("Internal_SetOverrideBounds", (void*)&ScriptRenderable::internal_SetOverrideBounds);
-		metaData.scriptClass->addInternalCall("Internal_SetUseOverrideBounds", (void*)&ScriptRenderable::internal_SetUseOverrideBounds);
-		metaData.scriptClass->addInternalCall("Internal_OnDestroy", (void*)&ScriptRenderable::internal_OnDestroy);
-	}
-
-	void ScriptRenderable::updateTransform(const HSceneObject& parent, bool force)
-	{
-		mRenderable->_updateTransform(parent, force);
-
-		if (parent->getActive() != mRenderable->getIsActive())
-			mRenderable->setIsActive(parent->getActive());
-	}
-
-	void ScriptRenderable::internal_Create(MonoObject* instance, ScriptSceneObject* parentSO)
-	{
-		HSceneObject so;
-		if (parentSO != nullptr)
-			so = parentSO->getNativeHandle();
-
-		new (bs_alloc<ScriptRenderable>()) ScriptRenderable(instance, so);
-	}
-
-	void ScriptRenderable::internal_SetAnimation(ScriptRenderable* thisPtr, ScriptAnimation* animation)
-	{
-		SPtr<Animation> anim;
-		if (animation != nullptr)
-			anim = animation->getInternal();
-
-		thisPtr->getInternal()->setAnimation(anim);
-	}
-
-	void ScriptRenderable::internal_UpdateTransform(ScriptRenderable* thisPtr, ScriptSceneObject* parent, bool force)
-	{
-		HSceneObject parentSO = parent->getNativeSceneObject();
-
-		thisPtr->updateTransform(parentSO, force);
-	}
-
-	void ScriptRenderable::internal_SetMesh(ScriptRenderable* thisPtr, ScriptMesh* mesh)
-	{
-		HMesh nativeMesh;
-		if (mesh != nullptr)
-			nativeMesh = mesh->getHandle();
-
-		thisPtr->getInternal()->setMesh(nativeMesh);
-	}
-
-	void ScriptRenderable::internal_GetBounds(ScriptRenderable* thisPtr, ScriptSceneObject* parent, AABox* box, Sphere* sphere)
-	{
-		HSceneObject parentSO = parent->getNativeSceneObject();
-		thisPtr->updateTransform(parentSO, false);
-
-		Bounds bounds = thisPtr->getInternal()->getBounds();
-
-		*box = bounds.getBox();
-		*sphere = bounds.getSphere();
-	}
-
-	UINT64 ScriptRenderable::internal_GetLayers(ScriptRenderable* thisPtr)
-	{
-		return thisPtr->getInternal()->getLayer();
-	}
-
-	void ScriptRenderable::internal_SetLayers(ScriptRenderable* thisPtr, UINT64 layers)
-	{
-		thisPtr->getInternal()->setLayer(layers);
-	}
-
-	void ScriptRenderable::internal_SetMaterials(ScriptRenderable* thisPtr, MonoArray* materials)
-	{
-		if (materials != nullptr)
-		{
-			ScriptArray scriptMaterials(materials);
-
-			Vector<HMaterial> nativeMaterials(scriptMaterials.size());
-			for (UINT32 i = 0; i < scriptMaterials.size(); i++)
-			{
-				MonoObject* monoMaterial = scriptMaterials.get<MonoObject*>(i);
-				ScriptMaterial* scriptMaterial = ScriptMaterial::toNative(monoMaterial);
-
-				if (scriptMaterial != nullptr)
-					nativeMaterials[i] = scriptMaterial->getHandle();
-			}
-
-			thisPtr->getInternal()->setMaterials(nativeMaterials);
-		}
-		else
-		{
-			thisPtr->getInternal()->setMaterials({});
-		}
-	}
-
-	void ScriptRenderable::internal_SetMaterial(ScriptRenderable* thisPtr, ScriptMaterial* material, int index)
-	{
-		HMaterial nativeMaterial;
-		if (material != nullptr)
-			nativeMaterial = material->getHandle();
-
-		thisPtr->getInternal()->setMaterial(index, nativeMaterial);
-	}
-
-	void ScriptRenderable::internal_SetOverrideBounds(ScriptRenderable* thisPtr, AABox* box)
-	{
-		thisPtr->getInternal()->setOverrideBounds(*box);
-	}
-
-	void ScriptRenderable::internal_SetUseOverrideBounds(ScriptRenderable* thisPtr, bool enable)
-	{
-		thisPtr->getInternal()->setUseOverrideBounds(enable);
-	}
-
-	void ScriptRenderable::internal_OnDestroy(ScriptRenderable* thisPtr)
-	{
-		thisPtr->destroy();
-	}
-
-	void ScriptRenderable::destroy()
-	{
-		if (mRenderable->isDestroyed())
-			return;
-
-		gSceneManager()._unregisterRenderable(mRenderable);
-		mRenderable->destroy();
-	}
-
-	void ScriptRenderable::_onManagedInstanceDeleted()
-	{
-		destroy();
-
-		ScriptObject::_onManagedInstanceDeleted();
-	}
-}

+ 0 - 58
Source/SBansheeEngine/Wrappers/BsScriptRenderable.h

@@ -1,58 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "Wrappers/BsScriptComponent.h"
-
-namespace bs
-{
-	class ScriptAnimation;
-
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for Renderable. */
-	class BS_SCR_BE_EXPORT ScriptRenderable : public ScriptObject < ScriptRenderable >
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "NativeRenderable")
-
-		/**	Returns the native wrapped renderable. */
-		SPtr<Renderable> getInternal() const { return mRenderable; }
-
-	private:
-		ScriptRenderable(MonoObject* managedInstance, const HSceneObject& parentSO);
-		~ScriptRenderable();
-
-		/** Updates the internal transform of the renderable handled according to the scene object it is attached to. */
-		void updateTransform(const HSceneObject& parent, bool force);
-
-		/**	Destroys the internal renderable object. */
-		void destroy();
-
-		/** @copydoc ScriptObject::_onManagedInstanceDeleted */
-		void _onManagedInstanceDeleted() override;
-
-		SPtr<Renderable> mRenderable;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_Create(MonoObject* instance, ScriptSceneObject* parentSO);
-		static void internal_SetAnimation(ScriptRenderable* thisPtr, ScriptAnimation* animation);
-		static void internal_UpdateTransform(ScriptRenderable* thisPtr, ScriptSceneObject* parentSO, bool force);
-		static void internal_SetMesh(ScriptRenderable* thisPtr, ScriptMesh* mesh);
-		static void internal_GetBounds(ScriptRenderable* thisPtr, ScriptSceneObject* parentSO, AABox* box, Sphere* sphere);
-		static UINT64 internal_GetLayers(ScriptRenderable* thisPtr);
-		static void internal_SetLayers(ScriptRenderable* thisPtr, UINT64 layers);
-		static void internal_SetMaterial(ScriptRenderable* thisPtr, ScriptMaterial* material, int index);
-		static void internal_SetMaterials(ScriptRenderable* thisPtr, MonoArray* materials);
-		static void internal_SetOverrideBounds(ScriptRenderable* thisPtr, AABox* box);
-		static void internal_SetUseOverrideBounds(ScriptRenderable* thisPtr, bool enable);
-		static void internal_OnDestroy(ScriptRenderable* thisPtr);
-	};
-
-	/** @} */
-}

+ 0 - 167
Source/SBansheeEngine/Wrappers/BsScriptShader.cpp

@@ -1,167 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "Wrappers/BsScriptShader.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoArray.h"
-#include "BsMonoManager.h"
-
-namespace bs
-{
-	/**	Shader parameter types that can be handled using managed code. */
-	enum class ShaderParameterType // Note: This must match C# ShaderParameterType enum
-	{
-		Float, Vector2, Vector3, Vector4, Color,
-		Matrix3, Matrix4, Texture2D,
-		Texture3D, TextureCube, Sampler
-	};
-
-	ScriptShader::ScriptShader(MonoObject* instance, const HShader& shader)
-		:TScriptResource(instance, shader)
-	{
-
-	}
-
-	void ScriptShader::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_GetShaderParameters", (void*)&ScriptShader::internal_GetShaderParameters);
-	}
-
-	void ScriptShader::internal_GetShaderParameters(ScriptShader* nativeInstance, MonoArray** outNames, 
-		MonoArray** outTypes, MonoArray** outVisibility)
-	{
-		HShader shader = nativeInstance->getHandle();
-		if (!shader.isLoaded())
-		{
-			ScriptArray names = ScriptArray::create<String>(0);
-			ScriptArray types = ScriptArray::create<UINT32>(0);
-			ScriptArray visibility = ScriptArray::create<bool>(0);
-
-			*outNames = names.getInternal();
-			*outTypes = types.getInternal();
-			*outVisibility = visibility.getInternal();
-			return;
-		}
-
-		const Map<String, SHADER_DATA_PARAM_DESC>& dataParams = shader->getDataParams();
-		const Map<String, SHADER_OBJECT_PARAM_DESC>& textureParams = shader->getTextureParams();
-		const Map<String, SHADER_OBJECT_PARAM_DESC>& samplerParams = shader->getSamplerParams();
-
-		struct ParamInfo
-		{
-			String name;
-			ShaderParameterType type;
-			bool internal;
-		};
-
-		Vector<ParamInfo> paramInfos;
-
-		// TODO - Ignoring int, bool, struct and non-square matrices
-		// TODO - Ignoring buffers and load/store textures
-		for (auto& param : dataParams)
-		{
-			ShaderParameterType type;
-			bool isValidType = false;
-			bool isInternal = !param.second.rendererSemantic.empty();
-			switch (param.second.type) 
-			{
-			case GPDT_FLOAT1:
-				type = ShaderParameterType::Float;
-				isValidType = true;
-				break;
-			case GPDT_FLOAT2:
-				type = ShaderParameterType::Vector2;
-				isValidType = true;
-				break;
-			case GPDT_FLOAT3:
-				type = ShaderParameterType::Vector3;
-				isValidType = true;
-				break;
-			case GPDT_FLOAT4:
-				type = ShaderParameterType::Vector4;
-				isValidType = true;
-				break;
-			case GPDT_MATRIX_3X3:
-				type = ShaderParameterType::Matrix3;
-				isValidType = true;
-				break;
-			case GPDT_MATRIX_4X4:
-				type = ShaderParameterType::Matrix4;
-				isValidType = true;
-				break;
-			case GPDT_COLOR:
-				type = ShaderParameterType::Color;
-				isValidType = true;
-				break;
-			default:
-				break;
-			}
-
-			if (isValidType)
-				paramInfos.push_back({ param.first, type, isInternal });
-		}
-
-		for (auto& param : textureParams)
-		{
-			ShaderParameterType type;
-			bool isValidType = false;
-			bool isInternal = !param.second.rendererSemantic.empty();
-			switch (param.second.type)
-			{
-			case GPOT_TEXTURE2D:
-			case GPOT_TEXTURE2DMS:
-				type = ShaderParameterType::Texture2D;
-				isValidType = true;
-				break;
-			case GPOT_TEXTURE3D:
-				type = ShaderParameterType::Texture3D;
-				isValidType = true;
-				break;
-			case GPOT_TEXTURECUBE:
-				type = ShaderParameterType::TextureCube;
-				isValidType = true;
-				break;
-			default:
-				break;
-			}
-
-			if (isValidType)
-				paramInfos.push_back({ param.first, type, isInternal });
-		}
-
-		for (auto& param : samplerParams)
-		{
-			ShaderParameterType type = ShaderParameterType::Sampler;
-			bool isInternal = !param.second.rendererSemantic.empty();
-			paramInfos.push_back({ param.first, type, isInternal });
-		}
-
-
-		UINT32 totalNumParams = (UINT32)paramInfos.size();
-
-		ScriptArray names = ScriptArray::create<String>(totalNumParams);
-		ScriptArray types = ScriptArray::create<UINT32>(totalNumParams);
-		ScriptArray visibility = ScriptArray::create<bool>(totalNumParams);
-
-		UINT32 idx = 0;
-		for (auto& param : paramInfos)
-		{
-			names.set(idx, param.name);
-			types.set(idx, param.type);
-			visibility.set(idx, param.internal);
-
-			idx++;
-		}
-
-		*outNames = names.getInternal();
-		*outTypes = types.getInternal();
-		*outVisibility = visibility.getInternal();
-	}
-
-	MonoObject* ScriptShader::createInstance()
-	{
-		return metaData.scriptClass->createInstance();
-	}
-}

+ 0 - 38
Source/SBansheeEngine/Wrappers/BsScriptShader.h

@@ -1,38 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "Wrappers/BsScriptResource.h"
-#include "Material/BsShader.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for Shader. */
-	class BS_SCR_BE_EXPORT ScriptShader : public TScriptResource <ScriptShader, Shader>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Shader")
-
-		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
-		static MonoObject* createInstance();
-
-	private:
-		friend class ScriptResourceManager;
-		friend class BuiltinResourceTypes;
-
-		ScriptShader(MonoObject* instance, const HShader& shader);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_GetShaderParameters(ScriptShader* nativeInstance, MonoArray** outNames, MonoArray** outTypes, 
-			MonoArray** outVisibility);
-	};
-
-	/** @} */
-}