*
* @since 3.0
*
+ * @return An error code
+ *
+ * @exception E_INVALID_OPERATION MeshController is not constructed
*/
- void StartAnimation(void);
+ result StartAnimation(void);
/**
* Starts animation from specified time till animationDuration
*
* @since 3.0
*
+ * @return An error code
* @param[in] startAnimationTime
*
+ * @exception E_INVALID_OPERATION MeshController is not constructed
*/
- void StartAnimation(float startAnimationTime);
+ result StartAnimation(float startAnimationTime);
/**
* Starts animation from first keyframe
*
* @since 3.0
*
+ * @return An error code
* @param[in] startAnimationTime
* @param[in] endAnimationTime
*
+ * @exception E_INVALID_OPERATION MeshController is not constructed
*/
- void StartAnimation(float startAnimationTime, float endAnimationTime);
+ result StartAnimation(float startAnimationTime, float endAnimationTime);
/**
*
* @since 3.0
*
+ * @return An error code
+ *
+ * @exception E_INVALID_OPERATION MeshController is not constructed
*/
- void StopAnimation(void);
+ result StopAnimation(void);
/**
* Returns true if mesh animation is started
*
* @return animation status
*
+ * @exception E_INVALID_OPERATION MeshController is not constructed
*/
bool IsAnimating(void) const;
*
* @since 3.0
*
+ * @return An error code
* @param[in] value
- *
*/
- void SetGpuSkinning(bool value);
+ result SetGpuSkinning(bool value);
/**
* Returns true if skinning is performed on shader
bool GetPhysicsControll(void) const;
-
/**
* Sets a VisualElement to be controlled by a specified joint
*
* @param[in] pVisualElement Pointer to visual element
* @exception E_INVALID_ARG Specified joint not found
*/
- void SetJointVisualElement(const Tizen::Base::String& jointName, VisualElement* pVisualElement);
+ result SetJointVisualElement(const Tizen::Base::String& jointName, VisualElement* pVisualElement);
/**
* Returns VisualElement controlled by a specified joint
*
* @exception E_INVALID_OPERATION Mesh controller is constructed
* @exception E_INVALID_ARG Specified joint is not found @n
- * - Joint with specified already exist @n
+ * - Joint with specified name already exist @n
* @exception E_OUT_OF_MEMORY Memory allocation failed
*
*/
*/
float GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName);
-
/**
* Sets duration of animation
*
*
* @exception E_INVALID_OPERATION Mesh controller is constructed
* @exception E_DATA_NOT_FOUND There is no skeleton
- * @exception E_INVALID_DATA Duration of animation is less or equal then 0
+ * @exception E_INVALID_DATA Duration of animation is less then 0
* @exception E_INVALID_ARG Specified joint is not found @n
* - Time is less then 0 @n
* - Keyframe with this time stamp is already exist
*/
result Construct(void);
+ result ResetMesh(void);
private:
/**
* Default constructor of the class
namespace Tizen { namespace Ui { namespace Animations {
+class DisplayContext;
+
class _OSP_EXPORT_ ModelImporter
: public Tizen::Base::Object
{
* @since 3.0
*
* @return New mesh object
- * @param[in] fileName Name of file
- * @param[in] modelName Id of geometry in COLLADA file
+ * @param[in] fileName Name of file
+ * @param[in] modelName Id of geometry in COLLADA file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
*/
static Mesh* LoadMeshN(const Tizen::Base::String& fileName, const Tizen::Base::String modelName = "", bool loadWithoutController = false);
* @param[in] fileName Name of file
* @param[in] modelName Id of material in COLLADA file
* @param[out] textureName Name of the image file that is used as a texture(if it exist)
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
*/
static Material* LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String materialName = "", Tizen::Base::String* textureName = null);
* @return New light object
* @param[in] fileName Name of file
* @param[in] modelName Id of light in COLLADA file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
*/
static Light* LoadLightN(const Tizen::Base::String& fileName, const Tizen::Base::String lightName = "");
* @return New camera object
* @param[in] fileName Name of file
* @param[in] modelName Id of camera in COLLADA file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Camera* LoadCameraN(const Tizen::Base::String& fileName, const Tizen::Base::String cameraName = "");
* @param[in] fileName Name of file
* @param[in] sceneName Id of scene in COLLADA file
* @param[in] pSceneRootVisualElement VisualElement which will be used as root for scene
+ * @param[in] pDisplayContext DisplayContext pointer (can be null in case of COLLADA loading, used to load textures in .scn format)
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ * @exception E_FILE_NOT_FOUND File not found
+ *
+ * @remark
+ * First file extension will be tested.
+ * If equals .dae - COLLADA loading will be called
+ * If equals .scn - internal format parser will be called, and fileName will be split to path, file name and file extension.
+ * Scene structure will be loaded as /path/filename.scn, scene resources (like mesh) will be loaded from /path/filename_res/*
+ * Scene name will be ignored, and pDisplayContext is required.
*/
- static Scene* LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, VisualElement& pSceneRootVisualElement);
+ static Scene* LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, VisualElement& pSceneRootVisualElement, const DisplayContext* pDisplayContext);
/**
* Load list of mesh names.
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetMeshNamesN(const Tizen::Base::String& fileName);
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetMaterialNamesN(const Tizen::Base::String& fileName);
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetSceneNamesN(const Tizen::Base::String& fileName);
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetLightNamesN(const Tizen::Base::String& fileName);
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetCameraNamesN(const Tizen::Base::String& fileName);
*
* @return List object
* @param[in] fileName Name of file
+ *
+ * @exception E_SUCCESS The method is successful
+ * @exception E_UNSUPPORTED_FORMAT Wrong file format
+ * @exception E_INVALID_DATA XML or COLLADA error
+ *
*/
static Tizen::Base::Collection::IList* GetMeshWithControllerNamesN(const Tizen::Base::String& fileName);
private:
*
* @return An error code
* @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Empty scene name
* @exception E_OUT_OF_MEMORY The memory is insufficient.
* @exception E_SYSTEM XML subsystem error.
*/
- result SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix) const;
+ result SaveScene(const Tizen::Base::String filePath) const;
protected:
private:
return;
}
-void
+result
MeshController::StartAnimation(void)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->StartAnimation();
- return;
+ return __pMeshControllerImpl->StartAnimation();
}
-void
+result
MeshController::StartAnimation(float startAnimationTime)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->StartAnimation(startAnimationTime);
- return;
+ return __pMeshControllerImpl->StartAnimation(startAnimationTime);
}
-void
+result
MeshController::StartAnimation(float startAnimationTime, float endAnimationTime)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->StartAnimation(startAnimationTime, endAnimationTime);
- return;
+ return __pMeshControllerImpl->StartAnimation(startAnimationTime, endAnimationTime);
}
-void
+result
MeshController::StopAnimation(void)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->StopAnimation();
- return;
+ return __pMeshControllerImpl->StopAnimation();
}
bool
return __pMeshControllerImpl->IsAnimating();
}
-void
+result
MeshController::SetGpuSkinning(bool value)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->SetGPUSkinning(value);
- return;
+ return __pMeshControllerImpl->SetGPUSkinning(value);
}
bool
return __pMeshControllerImpl->GetPhysicsControll();
}
-void
+result
MeshController::SetJointVisualElement(const Tizen::Base::String& jointName, VisualElement* pVisualElement)
{
ClearLastResult();
CHECK_IMPL;
- __pMeshControllerImpl->SetJointVisualElement(jointName, pVisualElement);
+ return __pMeshControllerImpl->SetJointVisualElement(jointName, pVisualElement);
}
VisualElement*
if (res == E_SUCCESS)
{
memcpy(localMatrix.matrix, local.m, sizeof(float) * 16);
- localMatrix.Transpose();
}
return res;
if (res == E_SUCCESS)
{
memcpy(localMatrix.matrix, local.m, sizeof(float) * 16);
- localMatrix.Transpose();
}
return res;
if (res == E_SUCCESS)
{
memcpy(globalMatrix.matrix, global.m, sizeof(float) * 16);
- globalMatrix.Transpose();
}
return res;
if (res == E_SUCCESS)
{
memcpy(value.matrix, matrix.m, sizeof(float) * 16);
- value.Transpose();
}
return res;
return __pMeshControllerImpl->Construct();
}
+result
+MeshController::ResetMesh(void)
+{
+ ClearLastResult();
+ CHECK_IMPL;
+
+ return __pMeshControllerImpl->ResetMesh();
+}
+
}}} //Tizen::Ui::Animations
#include "FUiAnimModelImporter.h"
#include "FUiAnim_ModelImporterImpl.h"
#include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
+#include "FUiAnimDisplayContext.h"
+#include "FUiAnim_SceneImpl.h"
+
namespace Tizen { namespace Ui { namespace Animations {
return pMesh;
}
- SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+ SysTryReturn(NID_UI, false, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
return null;
}
return _ModelImporterImpl::LoadMaterialN(fileName);
}
- SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+ SysTryReturn(NID_UI, false, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
return null;
}
return _ModelImporterImpl::LoadLightN(fileName);
}
- SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+ SysTryReturn(NID_UI, false, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
return null;
}
return null;
}
- SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+ SysTryReturn(NID_UI, false, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
return null;
}
Scene*
-ModelImporter::LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, VisualElement& pSceneRootVisualElement)
+ModelImporter::LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, VisualElement& pSceneRootVisualElement, const DisplayContext* pDisplayContext)
{
SetLastResult(E_SUCCESS);
if (CheckFileExt(fileName, L".scn"))
{
- return null;
+ Tizen::Base::String filesPath, resourceFilesPath, scenePrefix;
+ Tizen::Base::String filePath = fileName;
+
+ int lastDelimeter = 0;
+ Tizen::Base::String tmp;
+
+ //split path
+ filePath.LastIndexOf(L'/', filePath.GetLength() - 1, lastDelimeter); //linux delimiter
+ if (lastDelimeter == -1)
+ {
+ filePath.LastIndexOf(L'\\', filePath.GetLength() - 1, lastDelimeter); //windows delimiter
+ if (lastDelimeter == -1)
+ lastDelimeter = 0;
+ }
+ filePath.SubString(0, (lastDelimeter == 0)?0:(lastDelimeter+1), filesPath);
+
+ filePath.SubString((lastDelimeter == 0)?0:(lastDelimeter+1), tmp);
+ tmp.LastIndexOf(L'.', tmp.GetLength() - 1, lastDelimeter);
+ if (lastDelimeter == -1)
+ {
+ lastDelimeter = tmp.GetLength();
+ }
+ tmp.SubString(0, lastDelimeter , scenePrefix);
+
+ resourceFilesPath = filesPath + scenePrefix + L"_res/";
+
+ AppLog("Loading Scene Public, file=\"%ls\" -> path=\"%ls\" respath=\"%ls\" prefix=\"%ls\";",
+ filePath.GetPointer(), filesPath.GetPointer(), resourceFilesPath.GetPointer(), scenePrefix.GetPointer());
+
+ return _SceneImpl::LoadSceneN(filesPath, resourceFilesPath, scenePrefix, pSceneRootVisualElement, pDisplayContext);
}
+ SysTryReturn(NID_UI, false, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+
return null;
}
std::string strFileName = WToStd(fileName);
_ModelImporterImpl modelImporter(strFileName, false, true, false, false, false, false, false, false, false); //true: Geometries
return modelImporter.GetMeshNamesN();
-
}
Tizen::Base::Collection::IList*
#include "FUiAnimScene.h"
#include "FUiAnim_SceneImpl.h"
+#if defined(_WIN32)
+ #include <windows.h>
+#else
+ #include <FIo.h>
+#endif
+
namespace Tizen { namespace Ui { namespace Animations {
using namespace Tizen::Base;
}
result
-Scene::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix) const
+Scene::SaveScene(const Tizen::Base::String filePath) const
{
ClearLastResult();
SysAssertf(__pSceneImpl != null,
"Not yet constructed. Construct() should be called before use.");
+
+ String filesPath, resourceFilesPath, scenePrefix;
+
+ int lastDelimeter = 0;
+ String tmp;
+
+ //split path
+ filePath.LastIndexOf(L'/', filePath.GetLength() - 1, lastDelimeter); //linux delimiter
+ if (lastDelimeter == -1)
+ {
+ filePath.LastIndexOf(L'\\', filePath.GetLength() - 1, lastDelimeter); //windows delimiter
+ if (lastDelimeter == -1)
+ lastDelimeter = 0;
+ }
+ filePath.SubString(0, (lastDelimeter == 0)?0:(lastDelimeter+1), filesPath);
+
+ filePath.SubString((lastDelimeter == 0)?0:(lastDelimeter+1), tmp);
+ tmp.LastIndexOf(L'.', tmp.GetLength() - 1, lastDelimeter);
+ if (lastDelimeter == -1)
+ {
+ lastDelimeter = tmp.GetLength();
+ }
+ tmp.SubString(0, lastDelimeter , scenePrefix);
+
+ resourceFilesPath = filesPath + scenePrefix + L"_res/";
+
+ std::wstring ws = resourceFilesPath.GetPointer();
+ std::string s(ws.begin(), ws.end());
+
+#if defined(_WIN32)
+ CreateDirectory((LPTSTR)s.c_str(), (LPSECURITY_ATTRIBUTES)NULL);
+#else
+ Tizen::Io::Directory::Create(resourceFilesPath, true);
+#endif
+
+
+// AppLog("Saving Scene Public, file=\"%ls\" -> path=\"%ls\" respath=\"%ls\" prefix=\"%ls\";",
+// filePath.GetPointer(), filesPath.GetPointer(), resourceFilesPath.GetPointer(), scenePrefix.GetPointer());
return __pSceneImpl->SaveScene(filesPath, resourceFilesPath, scenePrefix);
}
return __global;
}
-void
+result
_JointImpl::AddKeyFrame(float time, const _Math::Matrix4& value)
{
- SysTryReturnVoidResult(NID_UI, time >= 0, E_INVALID_ARG, "Time value should be greater or equal than 0(value = %f)", time); //TODO check eng
+ SysTryReturnResult(NID_UI, time >= 0, E_INVALID_ARG, "Time value should be greater or equal than 0(value = %f)", time); //TODO check eng
KeyFrame keyFrame;
keyFrame.time = time;
{
for (KeyFrames::iterator i = __keyFrames.begin(); i != __keyFrames.end(); i++)
{
- SysTryReturnVoidResult(NID_UI, (fabs(time - i->time) > _Math::fEPS), E_INVALID_ARG, "KeyFrame for this animation time already exist"); //TODO check eng
+ SysTryReturnResult(NID_UI, (fabs(time - i->time) > _Math::fEPS), E_INVALID_ARG, "KeyFrame for this animation time already exist"); //TODO check eng
if (time < i->time)
{
__keyFrames.insert(i, keyFrame);
- return;
+ return E_SUCCESS;
}
}
}
__keyFrames.push_back(keyFrame);
- return;
+ return E_SUCCESS;
}
unsigned int
_Math::Matrix4 GetLocal(void) const;
_Math::Matrix4 GetGlobal(void) const;
- void AddKeyFrame(float time, const _Math::Matrix4& value);
+ result AddKeyFrame(float time, const _Math::Matrix4& value);
unsigned int GetKeyFrameCount(void) const;
result GetKeyFrame(unsigned int index, float& time, _Math::Matrix4& value) const;
_MeshControllerImpl::~_MeshControllerImpl(void)
{
- if (__joints.size() > 0)
+ if (__pRoot != null)
{
- _JointImpl* rootJoint = *__joints.begin();
- delete rootJoint;
+ delete __pRoot; //root will destroy children
+ __pRoot = null;
__joints.clear();
- __pRoot = null;
}
if (__pInitialPositions != null )
Tizen::Base::String
_MeshControllerImpl::GetRootJointName(void) const
{
- SysTryReturn(NID_UI, __pRoot != null, "", E_DATA_NOT_FOUND, "Skeleton is not set.");
+ SysTryReturn(NID_UI, __pRoot != null, L"", E_DATA_NOT_FOUND, "Skeleton is not set.");
return __pRoot->GetName();
}
Tizen::Base::String
_MeshControllerImpl::GetJointName(unsigned int index)
{
- if (index < __joints.size())
- {
- return __joints[index]->GetName();
- }
- return "";
+ SysTryReturn(NID_UI, index < __joints.size(), L"", E_DATA_NOT_FOUND, "Joint index is greater than count.");
+
+ return __joints[index]->GetName();
}
{
SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
_JointImpl* pJoint = __pRoot->Find(jointName);
- SysTryReturn(NID_UI, pJoint != null, null, E_INVALID_ARG, "Joint %S is not found", jointName.GetPointer());
+ SysTryReturnResult(NID_UI, pJoint != null, E_INVALID_ARG, "Joint %S is not found", jointName.GetPointer());
localMatrix.Set(pJoint->GetLocal());
return E_SUCCESS;
{
SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
_JointImpl* pJoint = __pRoot->Find(jointName);
- SysTryReturn(NID_UI, pJoint != null, null, E_INVALID_ARG, "Joint %S is not found", jointName.GetPointer());
+ SysTryReturnResult(NID_UI, pJoint != null, E_INVALID_ARG, "Joint %S is not found", jointName.GetPointer());
localMatrix.Set(pJoint->GetInvertBindMatrix());
return E_SUCCESS;
{
SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
_JointImpl* pJoint = __pRoot->Find(jointName);
- SysTryReturn(NID_UI, pJoint != null, null, E_DATA_NOT_FOUND, "Joint %S is not found", jointName.GetPointer());
+ SysTryReturnResult(NID_UI, pJoint != null, E_INVALID_ARG, "Joint %S is not found", jointName.GetPointer());
if (!__physicsControll)
{
float
_MeshControllerImpl::GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName)
{
+ SysTryReturn(NID_UI_ANIM, vertexIndex < __vertexCount, 0.0f, E_INVALID_ARG, "Vertex not found.");
+
for (unsigned int i = 0; i < 4; i++)
{
- unsigned int jointIndex = __pIDs[vertexIndex * 4 + i];
- _JointImpl* joint = __joints[jointIndex];
- if (joint->GetName().CompareTo(jointName))
+ int jointIndex = __pIDs[vertexIndex * 4 + i];
+ if (jointIndex >= 0)
{
- return __pWeights[vertexIndex * 4 + i];
+ _JointImpl* joint = __joints[jointIndex];
+ if (joint->GetName().Equals(jointName, false))
+ {
+ return __pWeights[vertexIndex * 4 + i];
+ }
}
}
return 0.0f;
{
SysTryReturnResult(NID_UI, !__isConstructed, E_INVALID_OPERATION, "Already constructed!"); //TODO: Check error type
SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
- SysTryReturnResult(NID_UI, __animationDuration > 0, E_INVALID_DATA, "Duration of animation is = 0");
+ SysTryReturnResult(NID_UI, time <= __animationDuration, E_INVALID_DATA, "Keyframe time value should be less than duration of animation");
_JointImpl* joint = __pRoot->Find(jointName);
SysTryReturnResult(NID_UI, joint != null, E_INVALID_ARG, "Joint %S is not found.", jointName.GetPointer());
- joint->AddKeyFrame(time, value); //result?
-
- return E_SUCCESS;
+ return joint->AddKeyFrame(time, value);
}
unsigned int
_MeshControllerImpl::GetJointKeyFrameCount(const Tizen::Base::String& jointName) const
{
- SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
+ SysTryReturn(NID_UI, __pRoot != null, 0, E_DATA_NOT_FOUND, "Skeleton is not set.");
_JointImpl* joint = __pRoot->Find(jointName);
- SysTryReturn(NID_UI, joint != null, null, E_DATA_NOT_FOUND, "Joint %S is not found.", jointName.GetPointer());
+ SysTryReturn(NID_UI, joint != null, 0, E_INVALID_ARG, "Joint %S is not found.", jointName.GetPointer());
return joint->GetKeyFrameCount();
}
{
SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
_JointImpl* joint = __pRoot->Find(jointName);
- SysTryReturn(NID_UI, joint != null, null, E_DATA_NOT_FOUND, "Joint %S is not found.", jointName.GetPointer());
+ SysTryReturnResult(NID_UI, joint != null, E_INVALID_ARG, "Joint %S is not found.", jointName.GetPointer());
return joint->GetKeyFrame(index, time, value);
}
result
_MeshControllerImpl::StartAnimation(void)
{
+ SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
__animationTime = 0;
__endAnimationTime = __animationDuration;
__animationStarted = true;
result
_MeshControllerImpl::StartAnimation(float startAnimationTime)
{
+ SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
if (startAnimationTime < 0.0f)
{
startAnimationTime = 0.0f;
result
_MeshControllerImpl::StartAnimation(float startAnimationTime, float endAnimationTime)
{
+ SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
if (startAnimationTime < 0.0f)
{
startAnimationTime = 0.0f;
result
_MeshControllerImpl::StopAnimation(void)
{
+ SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
__animationTime = 0.0f;
__endAnimationTime = __animationDuration;
if (! __gpuSkinning)
return __physicsControll;
}
-void
+result
_MeshControllerImpl::SetGPUSkinning(bool value)
{
- SysTryReturnVoidResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!");
+ SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!");
- SysTryReturnVoidResult(NID_UI, (__joints.size() <= 64) || (!value), E_INVALID_ARG, "GPU skinning available only for skeleton with number of joints less or equal 64.");
+ SysTryReturnResult(NID_UI, (__joints.size() <= 64) || (!value), E_INVALID_ARG, "GPU skinning available only for skeleton with number of joints less or equal 64.");
__gpuSkinning = value;
+
+ return E_SUCCESS;
}
void
bool IsAnimating(void) const;
//for renderer
- void SetGPUSkinning(bool value);
+ result SetGPUSkinning(bool value);
void SetPhysicsControll(bool value);
bool IsGpuSkinning(void) const;
bool GetPhysicsControll(void) const;
return;
}
+ bool NodeIsSkeletonJoint = false;
std::list<std::string>::iterator it = skeletionRootJoints.begin();
std::list<std::string>::iterator itEnd = skeletionRootJoints.end();
while (it != itEnd)
{
if (pNode->GetID().compare(*it) == 0) //Do not create VE if node is a skeleton joint
{
- return;
+ NodeIsSkeletonJoint = true;
}
it++;
}
- VisualElement* pVisElem = new (std::nothrow) VisualElement();
- pVisElem->Construct();
- pVisElem->SetName(pNode->GetID().c_str());
- pVisElem->SetShowState(true);
- pVisElem->SetImplicitAnimationEnabled(false);
- pParentVisElem->AttachChild(pVisElem);
-
- unsigned int instancesCount = pNode->GetInstancesCount();
-
- if (instancesCount > 0)
+ if (!NodeIsSkeletonJoint)
{
- _Math::Matrix4 globalMatrix;
- globalMatrix.Set(pNode->GetGlobalMatrix());
+ VisualElement* pVisElem = new (std::nothrow) VisualElement();
+ pVisElem->Construct();
+ pVisElem->SetName(pNode->GetID().c_str());
+ pVisElem->SetShowState(true);
+ pVisElem->SetImplicitAnimationEnabled(false);
+ pParentVisElem->AttachChild(pVisElem);
- for (unsigned int i = 0; i < instancesCount; i++)
+ unsigned int instancesCount = pNode->GetInstancesCount();
+
+ if (instancesCount > 0)
{
- LibraryVisualScenes::Instance* pInstance = pNode->GetInstanceByIndex(i);
- if (pInstance->GetType() == LibraryVisualScenes::Instance::GEOMETRY)
+ _Math::Matrix4 globalMatrix;
+ globalMatrix.Set(pNode->GetGlobalMatrix());
+
+ for (unsigned int i = 0; i < instancesCount; i++)
{
- LibraryVisualScenes::InstanceGeometry* pInstanceGeometry = dynamic_cast<LibraryVisualScenes::InstanceGeometry*>(pInstance);
+ LibraryVisualScenes::Instance* pInstance = pNode->GetInstanceByIndex(i);
+ if (pInstance->GetType() == LibraryVisualScenes::Instance::GEOMETRY)
+ {
+ LibraryVisualScenes::InstanceGeometry* pInstanceGeometry = dynamic_cast<LibraryVisualScenes::InstanceGeometry*>(pInstance);
- VisualElement* pVisEleMesh = new (std::nothrow) VisualElement();
- pVisEleMesh->Construct();
- pVisEleMesh->SetShowState(true);
- pVisEleMesh->SetImplicitAnimationEnabled(false);
- pVisElem->AttachChild(pVisEleMesh);
+ VisualElement* pVisEleMesh = new (std::nothrow) VisualElement();
+ pVisEleMesh->Construct();
+ pVisEleMesh->SetShowState(true);
+ pVisEleMesh->SetImplicitAnimationEnabled(false);
+ pVisElem->AttachChild(pVisEleMesh);
- //===================================================================================Set global matrix
- FloatMatrix4 floatMatrix4;
- memcpy(floatMatrix4.matrix, UseUpAxis(globalMatrix).GetTransposed().m, sizeof(float) * 16);
- pVisEleMesh->SetProperty(L"transform", floatMatrix4);
+ //===================================================================================Set global matrix
+ FloatMatrix4 floatMatrix4;
+ memcpy(floatMatrix4.matrix, UseUpAxis(globalMatrix).GetTransposed().m, sizeof(float) * 16);
+ pVisEleMesh->SetProperty(L"transform", floatMatrix4);
- //===================================================================================Set mesh
- std::string geomId(pInstanceGeometry->GetUrl().c_str() + 1);
- std::string matId;
- Mesh* pMesh = LoadMeshCollada(geomId, matId);
- pVisEleMesh->SetMesh(pMesh);
+ //===================================================================================Set mesh
+ std::string geomId(pInstanceGeometry->GetUrl().c_str() + 1);
+ std::string matId;
+ Mesh* pMesh = LoadMeshCollada(geomId, matId);
+ pVisEleMesh->SetMesh(pMesh);
- pScene->AddMesh(pMesh);
+ pScene->AddMesh(pMesh);
- std::string visualElementName = pNode->GetID() + "_"+ geomId;
- pVisEleMesh->SetName(visualElementName.c_str());
+ std::string visualElementName = pNode->GetID() + "_"+ geomId;
+ pVisEleMesh->SetName(visualElementName.c_str());
- //===================================================================================SetMaterial
- matId = pInstanceGeometry->pBindMaterial->GetTargetBySymbol(matId);
- int materialIndex = pScene->ContainsMaterial(matId.c_str() + 1);
+ //===================================================================================SetMaterial
+ matId = pInstanceGeometry->pBindMaterial->GetTargetBySymbol(matId);
+ int materialIndex = pScene->ContainsMaterial(matId.c_str() + 1);
- Material* pMaterial = pScene->GetMaterialN(matId.c_str() + 1);
- std::string textureId = "";
+ Material* pMaterial = pScene->GetMaterialN(matId.c_str() + 1);
+ std::string textureId = "";
- if (pMaterial == null)
- {
- LibraryEffects::Effect::ShaderType shaderType;
- pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
- }
+ if (pMaterial == null)
+ {
+ LibraryEffects::Effect::ShaderType shaderType;
+ pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
+ }
- if (pMaterial != null)
- {
- pScene->AddMaterial(pMaterial);
- pVisEleMesh->SetMaterial(pMaterial);
- }
+ if (pMaterial != null)
+ {
+ pScene->AddMaterial(pMaterial);
+ pVisEleMesh->SetMaterial(pMaterial);
+ }
- if (pMesh != null)
- {
- delete pMesh;
- pMesh = null;
+ if (pMesh != null)
+ {
+ delete pMesh;
+ pMesh = null;
+ }
+
+ if (pMaterial != null)
+ {
+ delete pMaterial;
+ pMaterial = null;
+ }
}
- if (pMaterial != null)
+ if (pInstance->GetType() == LibraryVisualScenes::Instance::CONTROLLER)
{
- delete pMaterial;
- pMaterial = null;
- }
- }
+ VisualElement* pVisElemController = new (std::nothrow) VisualElement();
+ pVisElemController->Construct();
+ pVisElemController->SetShowState(true);
+ pVisElemController->SetImplicitAnimationEnabled(false);
+ pVisElem->AttachChild(pVisElemController);
- if (pInstance->GetType() == LibraryVisualScenes::Instance::CONTROLLER)
- {
- VisualElement* pVisElemController = new (std::nothrow) VisualElement();
- pVisElemController->Construct();
- pVisElemController->SetShowState(true);
- pVisElemController->SetImplicitAnimationEnabled(false);
- pVisElem->AttachChild(pVisElemController);
+ //----------------------------------------------------------------------RootBone
+ LibraryVisualScenes::InstanceController* pInstanceController = dynamic_cast<LibraryVisualScenes::InstanceController*>(pInstance);
+ std::string boneName(pInstanceController->GetRootBoneID(0).c_str() + 1);
+ LibraryVisualScenes::Node* pSceletonRootNode = pRootNode->FindNode(boneName);
- //----------------------------------------------------------------------RootBone
- LibraryVisualScenes::InstanceController* pInstanceController = dynamic_cast<LibraryVisualScenes::InstanceController*>(pInstance);
- std::string boneName(pInstanceController->GetRootBoneID(0).c_str() + 1);
- LibraryVisualScenes::Node* pSceletonRootNode = pRootNode->FindNode(boneName);
+ //===================================================================================Set global matrix
- //===================================================================================Set global matrix
+ _Math::Matrix4 matrix;
+ if (pSceletonRootNode->Parent() != null)
+ {
+ matrix.Set(pSceletonRootNode->Parent()->GetGlobalMatrix());
+ }
- _Math::Matrix4 matrix;
- if (pSceletonRootNode->Parent() != null)
- {
- matrix.Set(pSceletonRootNode->Parent()->GetGlobalMatrix());
- }
+ FloatMatrix4 floatMatrix4;
+ memcpy(floatMatrix4.matrix, UseUpAxis(matrix).GetTransposed().m, sizeof(float) * 16);
+ pVisElemController->SetProperty(L"transform", floatMatrix4);
- FloatMatrix4 floatMatrix4;
- memcpy(floatMatrix4.matrix, UseUpAxis(matrix).GetTransposed().m, sizeof(float) * 16);
- pVisElemController->SetProperty(L"transform", floatMatrix4);
+ //----------------------------------------------------------------------Controller
+ std::string matId;
+ Mesh* pMesh;
- //----------------------------------------------------------------------Controller
- std::string matId;
- Mesh* pMesh;
+ std::string controllerId(pInstanceController->GetUrl().c_str() + 1);
+ CreateController(controllerId, pSceletonRootNode, &pMesh, matId, false);
- std::string controllerId(pInstanceController->GetUrl().c_str() + 1);
- CreateController(controllerId, pSceletonRootNode, &pMesh, matId, false);
+ pVisElemController->SetMesh(pMesh);
+ pScene->AddMesh(pMesh);
- pVisElemController->SetMesh(pMesh);
- pScene->AddMesh(pMesh);
+ std::string visualElementName = pNode->GetID() + "_"+ controllerId;
+ pVisElemController->SetName(visualElementName.c_str());
- std::string visualElementName = pNode->GetID() + "_"+ controllerId;
- pVisElemController->SetName(visualElementName.c_str());
+ //===================================================================================SetMaterial
+ matId = pInstanceController->pBindMaterial->GetTargetBySymbol(matId);
+ int materialIndex = pScene->ContainsMaterial(matId.c_str() + 1);
- //===================================================================================SetMaterial
- matId = pInstanceController->pBindMaterial->GetTargetBySymbol(matId);
- int materialIndex = pScene->ContainsMaterial(matId.c_str() + 1);
+ Material* pMaterial = pScene->GetMaterialN(matId.c_str() + 1);
+ std::string textureId = "";
- Material* pMaterial = pScene->GetMaterialN(matId.c_str() + 1);
- std::string textureId = "";
+ if (pMaterial == null)
+ {
+ LibraryEffects::Effect::ShaderType shaderType;
+ pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
+ }
- if (pMaterial == null)
- {
- LibraryEffects::Effect::ShaderType shaderType;
- pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
- }
+ if (pMaterial != null)
+ {
+ pScene->AddMaterial(pMaterial);
+ pVisElemController->SetMaterial(pMaterial);
+ }
- if (pMaterial != null)
- {
- pScene->AddMaterial(pMaterial);
- pVisElemController->SetMaterial(pMaterial);
- }
+ delete pMesh;
- delete pMesh;
+ }
- }
+ if (pInstance->GetType() == LibraryVisualScenes::Instance::LIGHT)
+ {
+ VisualElement* pVisElemLight = new (std::nothrow) VisualElement();
+ pVisElemLight->Construct();
+ pVisElemLight->SetShowState(true);
+ pVisElemLight->SetImplicitAnimationEnabled(false);
+ pVisElem->AttachChild(pVisElemLight);
- if (pInstance->GetType() == LibraryVisualScenes::Instance::LIGHT)
- {
- VisualElement* pVisElemLight = new (std::nothrow) VisualElement();
- pVisElemLight->Construct();
- pVisElemLight->SetShowState(true);
- pVisElemLight->SetImplicitAnimationEnabled(false);
- pVisElem->AttachChild(pVisElemLight);
+ std::string lightId(pInstance->GetUrl().c_str() + 1);
+ Light* pLight = LoadLightCollada(lightId);
- std::string lightId(pInstance->GetUrl().c_str() + 1);
- Light* pLight = LoadLightCollada(lightId);
+ _Math::Vector4 lightPosition(0.0f, 0.0f, 0.0f, 1.0f);
+ lightPosition = UseUpAxis(globalMatrix) * lightPosition;
- _Math::Vector4 lightPosition(0.0f, 0.0f, 0.0f, 1.0f);
- lightPosition = UseUpAxis(globalMatrix) * lightPosition;
+ _Math::Vector4 lightDirection(0.0f, 0.0f, -1.0f, 0.0f);
+ lightDirection = UseUpAxis(globalMatrix) * lightDirection;
- _Math::Vector4 lightDirection(0.0f, 0.0f, -1.0f, 0.0f);
- lightDirection = UseUpAxis(globalMatrix) * lightDirection;
+ pLight->SetPosition(FloatVector4(lightPosition.x, lightPosition.y, lightPosition.z, lightPosition.w));
+ pLight->SetDirection(FloatPoint3(lightDirection.x, lightDirection.y, lightDirection.z));
- pLight->SetPosition(FloatVector4(lightPosition.x, lightPosition.y, lightPosition.z, lightPosition.w));
- pLight->SetDirection(FloatPoint3(lightDirection.x, lightDirection.y, lightDirection.z));
+ //pVisElemLight->SetLight(pLight);
- //pVisElemLight->SetLight(pLight);
+ //pScene->AddLight(pLight);
- //pScene->AddLight(pLight);
+ std::string visualElementName = pNode->GetID() + "_"+ lightId;
+ pVisElemLight->SetName(visualElementName.c_str());
- std::string visualElementName = pNode->GetID() + "_"+ lightId;
- pVisElemLight->SetName(visualElementName.c_str());
+ //printf("------->>>> Light pos(%f, %f, %f, %f) dir(%f, %f, %f)\n", lightPosition.x, lightPosition.y, lightPosition.z, lightPosition.w, lightDirection.x, lightDirection.y, lightDirection.z);
- printf("------->>>> Light pos(%f, %f, %f, %f) dir(%f, %f, %f)\n", lightPosition.x, lightPosition.y, lightPosition.z, lightPosition.w, lightDirection.x, lightDirection.y, lightDirection.z);
+ delete pLight;
+ }
- delete pLight;
- }
+ if (pInstance->GetType() == LibraryVisualScenes::Instance::CAMERA)
+ {
+ VisualElement* pVisElemCamera = new (std::nothrow) VisualElement();
+ pVisElemCamera->Construct();
+ pVisElemCamera->SetShowState(true);
+ pVisElemCamera->SetImplicitAnimationEnabled(false);
+ pVisElem->AttachChild(pVisElemCamera);
- if (pInstance->GetType() == LibraryVisualScenes::Instance::CAMERA)
- {
- VisualElement* pVisElemCamera = new (std::nothrow) VisualElement();
- pVisElemCamera->Construct();
- pVisElemCamera->SetShowState(true);
- pVisElemCamera->SetImplicitAnimationEnabled(false);
- pVisElem->AttachChild(pVisElemCamera);
+ std::string cameraId = pInstance->GetUrl().c_str() + 1;
+ Camera* pCamera = LoadCameraCollada(cameraId);
- std::string cameraId = pInstance->GetUrl().c_str() + 1;
- Camera* pCamera = LoadCameraCollada(cameraId);
+ _Math::Vector4 cameraPosition(0.0f, 0.0f, 0.0f, 1.0f);
+ cameraPosition = UseUpAxis(globalMatrix) * cameraPosition;
- _Math::Vector4 cameraPosition(0.0f, 0.0f, 0.0f, 1.0f);
- cameraPosition = UseUpAxis(globalMatrix) * cameraPosition;
+ _Math::Vector4 cameraDirection(0.0f, 0.0f, -1.0f, 0.0f);
+ cameraDirection = UseUpAxis(globalMatrix) * cameraDirection;
- _Math::Vector4 cameraDirection(0.0f, 0.0f, -1.0f, 0.0f);
- cameraDirection = UseUpAxis(globalMatrix) * cameraDirection;
+ _Math::Vector4 cameraUp(0.0f, 1.0f, 0.0f, 0.0f);
+ cameraUp = UseUpAxis(globalMatrix) * cameraUp;
- _Math::Vector4 cameraUp(0.0f, 1.0f, 0.0f, 0.0f);
- cameraUp = UseUpAxis(globalMatrix) * cameraUp;
+ cameraDirection += cameraPosition;
- cameraDirection += cameraPosition;
+ //pCamera->LookAt(FloatPoint3(cameraPosition.GetPointer()), FloatPoint3(cameraDirection.GetPointer()), FloatPoint3(cameraUp.GetPointer()));
- //pCamera->LookAt(FloatPoint3(cameraPosition.GetPointer()), FloatPoint3(cameraDirection.GetPointer()), FloatPoint3(cameraUp.GetPointer()));
+ std::string visualElementName = pNode->GetID() + "_"+ cameraId;
+ pVisElemCamera->SetName(visualElementName.c_str());
- std::string visualElementName = pNode->GetID() + "_"+ cameraId;
- pVisElemCamera->SetName(visualElementName.c_str());
+ //printf("------->>>> Camera pos(%f, %f, %f) at(%f, %f, %f) up(%f, %f, %f)\n",
+ // cameraPosition.x, cameraPosition.y, cameraPosition.z,
+ // cameraDirection.x, cameraDirection.y, cameraDirection.z,
+ // cameraUp.x, cameraUp.y, cameraUp.z);
- printf("------->>>> Camera pos(%f, %f, %f) at(%f, %f, %f) up(%f, %f, %f)\n",
- cameraPosition.x, cameraPosition.y, cameraPosition.z,
- cameraDirection.x, cameraDirection.y, cameraDirection.z,
- cameraUp.x, cameraUp.y, cameraUp.z);
+ //pVisElemCamera->SetCamera(pCamera);
- //pVisElemCamera->SetCamera(pCamera);
+ //pScene->AddCamera(pCamera);
+ delete pCamera;
+ }
- //pScene->AddCamera(pCamera);
- delete pCamera;
}
-
}
+ WalkingTheTree(pRootNode, pNode->Children(), pScene, pVisElem, skeletionRootJoints);
}
-
- WalkingTheTree(pRootNode, pNode->Children(), pScene, pVisElem, skeletionRootJoints);
WalkingTheTree(pRootNode, pNode->Next(), pScene, pParentVisElem, skeletionRootJoints);
return;
result
_SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix) const //in format: home/abc/scenespath/ or c:\\abc\\scenepath\\ ..
{
+ SysTryReturnResult(NID_UI_ANIM, !scenePrefix.IsEmpty(), E_INVALID_ARG, "Get empty scene name, save scene failed");
/*xml structure:
<sceneName str></>
meshFileName.Format(pUserDataT->resourceFilesPath.GetLength() + pUserDataT->scenePrefix.GetLength() + meshResFileName.GetLength() + meshResFileExtension.GetLength() + 8 + 2, \
L"%ls%ls%ls%04d%ls", pUserDataT->resourceFilesPath.GetPointer(), pUserDataT->scenePrefix.GetPointer(), meshResFileName.GetPointer(), pUserDataT->currentMeshId, meshResFileExtension.GetPointer());
pUserDataT->meshDescriptor.pMesh = ModelImporter::LoadMeshN(meshFileName, "");
+ pUserDataT->meshDescriptor.pMesh->AdjustBoundingVolume();
if (pUserDataT->meshDescriptor.pMesh != null)
{
if (!pUserDataT->surfaceDescriptor.sourceFileName.IsEmpty())
{
- VisualElementSurface* pSurface = new VisualElementSurface();
+ VisualElementSurface* pSurface;
+
+//Surface loading
+#ifndef BUILD_UI_CORE
+
+ pSurface = new VisualElementSurface();
if (!pSurface)
{
return;
}
-//Surface loading
-#ifndef BUILD_UI_CORE
Tizen::Media::Image image;
image.Construct();
tempWString = surfaceFileAbsolutePath.GetPointer();
tempString = ConvertWStringToString(tempWString);
pSurface = UiCore::LoadTextureN(pUserDataT->pDisplayContext, tempString.c_str());
+
+ if (!pSurface)
+ {
+ SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load Surface Image #%d from %ls", pUserDataT->currentSurfaceId, surfaceFileAbsolutePath.GetPointer() );
+ }
#endif
pUserDataT->surfaceDescriptor.pSurface = pSurface;