|
@@ -0,0 +1,76 @@
|
|
|
|
|
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
|
|
|
|
|
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
|
|
|
|
|
+#include "BsScriptAnimationCurve.h"
|
|
|
|
|
+#include "BsMonoUtil.h"
|
|
|
|
|
+#include "BsMonoClass.h"
|
|
|
|
|
+#include "BsMonoMethod.h"
|
|
|
|
|
+#include "BsAnimationCurve.h"
|
|
|
|
|
+
|
|
|
|
|
+using namespace std::placeholders;
|
|
|
|
|
+
|
|
|
|
|
+namespace BansheeEngine
|
|
|
|
|
+{
|
|
|
|
|
+ ScriptKeyFrame::ScriptKeyFrame(MonoObject* instance)
|
|
|
|
|
+ :ScriptObject(instance)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
|
|
+ void ScriptKeyFrame::initRuntimeData()
|
|
|
|
|
+ {
|
|
|
|
|
+ // Do nothing
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ScriptAnimationCurve::ScriptAnimationCurve(MonoObject* instance, const SPtr<TAnimationCurve<float>>& curve)
|
|
|
|
|
+ :ScriptObject(instance), mCurve(curve)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
|
|
+ void ScriptAnimationCurve::initRuntimeData()
|
|
|
|
|
+ {
|
|
|
|
|
+ metaData.scriptClass->addInternalCall("Internal_Create", &ScriptAnimationCurve::internal_Create);
|
|
|
|
|
+ metaData.scriptClass->addInternalCall("Internal_GetKeyFrames", &ScriptAnimationCurve::internal_GetKeyFrames);
|
|
|
|
|
+ metaData.scriptClass->addInternalCall("Internal_SetKeyFrames", &ScriptAnimationCurve::internal_SetKeyFrames);
|
|
|
|
|
+ metaData.scriptClass->addInternalCall("Internal_Evaluate", &ScriptAnimationCurve::internal_Evaluate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void ScriptAnimationCurve::internal_Create(MonoObject* instance, MonoArray* keyFrames)
|
|
|
|
|
+ {
|
|
|
|
|
+ ScriptArray inArray(keyFrames);
|
|
|
|
|
+
|
|
|
|
|
+ UINT32 numKeyframes = inArray.size();
|
|
|
|
|
+ Vector<TKeyframe<float>> nativeKeyframes(numKeyframes);
|
|
|
|
|
+
|
|
|
|
|
+ memcpy(nativeKeyframes.data(), (UINT8*)inArray.getRawPtr<TKeyframe<float>>(),
|
|
|
|
|
+ numKeyframes * sizeof(TKeyframe<float>));
|
|
|
|
|
+
|
|
|
|
|
+ SPtr<TAnimationCurve<float>> curve = bs_shared_ptr_new<TAnimationCurve<float>>(nativeKeyframes);
|
|
|
|
|
+ new (bs_alloc<ScriptAnimationCurve>()) ScriptAnimationCurve(instance, curve);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MonoArray* ScriptAnimationCurve::internal_GetKeyFrames(ScriptAnimationCurve* thisPtr)
|
|
|
|
|
+ {
|
|
|
|
|
+ UINT32 numKeyframes = thisPtr->mCurve->getNumKeyFrames();
|
|
|
|
|
+
|
|
|
|
|
+ ScriptArray output = ScriptArray::create<ScriptKeyFrame>(numKeyframes);
|
|
|
|
|
+ for (UINT32 i = 0; i < numKeyframes; i++)
|
|
|
|
|
+ output.set(i, thisPtr->mCurve->getKeyFrame(i));
|
|
|
|
|
+
|
|
|
|
|
+ return output.getInternal();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void ScriptAnimationCurve::internal_SetKeyFrames(ScriptAnimationCurve* thisPtr, MonoArray* keyFrames)
|
|
|
|
|
+ {
|
|
|
|
|
+ ScriptArray inArray(keyFrames);
|
|
|
|
|
+
|
|
|
|
|
+ UINT32 numKeyframes = inArray.size();
|
|
|
|
|
+ Vector<TKeyframe<float>> nativeKeyframes(numKeyframes);
|
|
|
|
|
+
|
|
|
|
|
+ memcpy(nativeKeyframes.data(), (UINT8*)inArray.getRawPtr<TKeyframe<float>>(),
|
|
|
|
|
+ numKeyframes * sizeof(TKeyframe<float>));
|
|
|
|
|
+
|
|
|
|
|
+ thisPtr->mCurve = bs_shared_ptr_new<TAnimationCurve<float>>(nativeKeyframes);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ float ScriptAnimationCurve::internal_Evaluate(ScriptAnimationCurve* thisPtr, float time, bool loop)
|
|
|
|
|
+ {
|
|
|
|
|
+ return thisPtr->mCurve->evaluate(time, loop);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|