ModelImporter & MeshController: bugfixes & refactoring; Scene: SaveScene default...
authorm.kucher <m.kucher@samsung.com>
Fri, 7 Feb 2014 12:34:30 +0000 (14:34 +0200)
committerm.kucher <m.kucher@samsung.com>
Fri, 7 Feb 2014 12:34:30 +0000 (14:34 +0200)
Change-Id: I358eef0eb7334e7830f17d416c44990f02239a98
Signed-off-by: m.kucher <m.kucher@samsung.com>
12 files changed:
inc/FUiAnimMeshController.h
inc/FUiAnimModelImporter.h
inc/FUiAnimScene.h
src/ui/animations/FUiAnimMeshController.cpp
src/ui/animations/FUiAnimModelImporter.cpp
src/ui/animations/FUiAnimScene.cpp
src/ui/animations/FUiAnim_JointImpl.cpp
src/ui/animations/FUiAnim_JointImpl.h
src/ui/animations/FUiAnim_MeshControllerImpl.cpp
src/ui/animations/FUiAnim_MeshControllerImpl.h
src/ui/animations/FUiAnim_ModelImporterImpl.cpp
src/ui/animations/FUiAnim_SceneImpl.cpp

index 126286d..056266e 100644 (file)
@@ -41,29 +41,36 @@ public:
         *
         * @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);
 
 
        /**
@@ -71,8 +78,11 @@ public:
         *
         * @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
@@ -81,6 +91,7 @@ public:
         *
         * @return              animation status
         *
+        * @exception   E_INVALID_OPERATION             MeshController is not constructed
         */
        bool IsAnimating(void) const;
 
@@ -89,10 +100,10 @@ public:
         *
         * @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
@@ -107,7 +118,6 @@ public:
 
        bool GetPhysicsControll(void) const;
 
-
        /**
         * Sets a VisualElement to be controlled by a specified joint
         *
@@ -117,7 +127,7 @@ public:
         * @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
@@ -162,7 +172,7 @@ public:
         *
         * @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
         *
         */
@@ -289,7 +299,6 @@ public:
         */
        float GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName);
 
-
        /**
         *  Sets duration of animation
         *
@@ -324,7 +333,7 @@ public:
         *
         * @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
@@ -374,6 +383,7 @@ public:
         */
        result Construct(void);
 
+       result ResetMesh(void);
 private:
        /**
         * Default constructor of the class
index 1b7bee7..503f561 100644 (file)
@@ -34,6 +34,8 @@
 
 namespace Tizen { namespace Ui { namespace Animations {
 
+class DisplayContext;
+
 class _OSP_EXPORT_ ModelImporter
        : public Tizen::Base::Object
 {
@@ -44,8 +46,12 @@ public:
         * @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);
 
@@ -58,6 +64,10 @@ public:
         * @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);
 
@@ -69,6 +79,10 @@ public:
         * @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 = "");
 
@@ -80,6 +94,11 @@ public:
         * @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 = "");
 
@@ -92,8 +111,21 @@ public:
         * @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.
@@ -102,6 +134,11 @@ public:
         *
         * @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);
 
@@ -112,6 +149,11 @@ public:
         *
         * @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);
 
@@ -122,6 +164,11 @@ public:
         *
         * @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);
 
@@ -132,6 +179,11 @@ public:
         *
         * @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);
 
@@ -142,6 +194,11 @@ public:
         *
         * @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);
 
@@ -152,6 +209,11 @@ public:
         *
         * @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:
index c54c2aa..b71575b 100644 (file)
@@ -805,10 +805,11 @@ public:
         *
         * @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:
index 7352823..b8d23a6 100644 (file)
@@ -53,40 +53,36 @@ MeshController::~MeshController(void)
        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
@@ -97,13 +93,12 @@ MeshController::IsAnimating(void) const
        return __pMeshControllerImpl->IsAnimating();
 }
 
-void
+result
 MeshController::SetGpuSkinning(bool value)
 {
        ClearLastResult();
        CHECK_IMPL;
-       __pMeshControllerImpl->SetGPUSkinning(value);
-       return;
+       return __pMeshControllerImpl->SetGPUSkinning(value);
 }
 
 bool
@@ -122,13 +117,13 @@ MeshController::GetPhysicsControll(void) const
        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*
@@ -222,7 +217,6 @@ MeshController::GetJointLocalMatrix(const Tizen::Base::String& jointName, Tizen:
     if (res == E_SUCCESS)
        {
        memcpy(localMatrix.matrix, local.m, sizeof(float) * 16);
-       localMatrix.Transpose();
        }
 
     return res;
@@ -239,7 +233,6 @@ MeshController::GetJointInvBindMatrix(const Tizen::Base::String& jointName, Tize
     if (res == E_SUCCESS)
        {
        memcpy(localMatrix.matrix, local.m, sizeof(float) * 16);
-       localMatrix.Transpose();
        }
 
     return res;
@@ -256,7 +249,6 @@ MeshController::GetJointGlobalMatrix(const Tizen::Base::String& jointName, Tizen
     if (res == E_SUCCESS)
        {
        memcpy(globalMatrix.matrix, global.m, sizeof(float) * 16);
-       globalMatrix.Transpose();
        }
 
     return res;
@@ -329,7 +321,6 @@ MeshController::GetJointKeyFrame(const Tizen::Base::String& jointName, unsigned
     if (res == E_SUCCESS)
        {
        memcpy(value.matrix, matrix.m, sizeof(float) * 16);
-       value.Transpose();
        }
 
     return res;
@@ -344,4 +335,13 @@ MeshController::Construct(void)
        return __pMeshControllerImpl->Construct();
 }
 
+result
+MeshController::ResetMesh(void)
+{
+       ClearLastResult();
+       CHECK_IMPL;
+
+       return __pMeshControllerImpl->ResetMesh();
+}
+
 }}} //Tizen::Ui::Animations
index 4140180..e93363d 100644 (file)
@@ -25,6 +25,9 @@
 #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 {
 
@@ -85,7 +88,7 @@ ModelImporter::LoadMeshN(const Tizen::Base::String& fileName, const Tizen::Base:
                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;
 }
@@ -118,7 +121,7 @@ ModelImporter::LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::B
                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;
 }
@@ -140,7 +143,7 @@ ModelImporter::LoadLightN(const Tizen::Base::String& fileName, const Tizen::Base
                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;
 }
@@ -161,13 +164,13 @@ ModelImporter::LoadCameraN(const Tizen::Base::String& fileName, const Tizen::Bas
                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);
 
@@ -179,9 +182,40 @@ ModelImporter::LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base
 
        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;
 }
 
@@ -192,7 +226,6 @@ ModelImporter::GetMeshNamesN(const Tizen::Base::String& fileName)
        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*
index 09e1b9a..20ef76c 100644 (file)
 #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;
@@ -515,11 +521,49 @@ Scene::GetSurfaceAtN(int index) const
 }
 
 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);
 }
 
index 2fc919d..6e6df56 100644 (file)
@@ -199,10 +199,10 @@ _JointImpl::GetGlobal(void) const
        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;
@@ -212,17 +212,17 @@ _JointImpl::AddKeyFrame(float time, const _Math::Matrix4& value)
        {
                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
index 3166d5f..bfbc2a5 100644 (file)
@@ -69,7 +69,7 @@ public:
        _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;
 
index 93f8d1a..cb604ba 100644 (file)
@@ -87,13 +87,12 @@ _MeshControllerImpl::_MeshControllerImpl(void)
 
 _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 )
@@ -262,7 +261,7 @@ _MeshControllerImpl::GetJointChildrenNames(const Tizen::Base::String& jointName)
 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();
 }
 
@@ -276,11 +275,9 @@ _MeshControllerImpl::GetJointCount()
 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();
 }
 
 
@@ -289,7 +286,7 @@ _MeshControllerImpl::GetJointLocalMatrix(const Tizen::Base::String& jointName, _
 {
        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;
@@ -300,7 +297,7 @@ _MeshControllerImpl::GetJointInvBindMatrix(const Tizen::Base::String& jointName,
 {
        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;
@@ -312,7 +309,7 @@ _MeshControllerImpl::GetJointGlobalMatrix(const Tizen::Base::String& jointName,
 {
        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)
        {
@@ -536,13 +533,18 @@ _MeshControllerImpl::SetJointWeight(unsigned int vertexIndex, const Tizen::Base:
 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;
@@ -681,22 +683,20 @@ _MeshControllerImpl::AddKeyFrame(const Tizen::Base::String& jointName, float tim
 {
        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();
 }
@@ -706,7 +706,7 @@ _MeshControllerImpl::GetJointKeyFrame(const Tizen::Base::String& jointName, unsi
 {
        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);
 }
@@ -714,6 +714,8 @@ _MeshControllerImpl::GetJointKeyFrame(const Tizen::Base::String& jointName, unsi
 result
 _MeshControllerImpl::StartAnimation(void)
 {
+       SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
        __animationTime = 0;
        __endAnimationTime = __animationDuration;
        __animationStarted = true;
@@ -723,6 +725,8 @@ _MeshControllerImpl::StartAnimation(void)
 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;
@@ -742,6 +746,8 @@ _MeshControllerImpl::StartAnimation(float startAnimationTime)
 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;
@@ -771,6 +777,8 @@ _MeshControllerImpl::StartAnimation(float startAnimationTime, float endAnimation
 result
 _MeshControllerImpl::StopAnimation(void)
 {
+       SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
        __animationTime = 0.0f;
        __endAnimationTime = __animationDuration;
        if (! __gpuSkinning)
@@ -813,13 +821,15 @@ _MeshControllerImpl::GetPhysicsControll(void) const
        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
index 3feff75..22c6485 100644 (file)
@@ -90,7 +90,7 @@ public:
        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;
index f883e41..e1a2af5 100644 (file)
@@ -893,227 +893,230 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
                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;
index 7c82581..5daed51 100644 (file)
@@ -2010,6 +2010,7 @@ ConvertWStringToString(std::wstring& wString)
 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></>
@@ -3874,6 +3875,7 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        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)
                        {
@@ -4086,7 +4088,12 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
 
                        if (!pUserDataT->surfaceDescriptor.sourceFileName.IsEmpty())
                        {
-                               VisualElementSurface* pSurface = new VisualElementSurface();
+                               VisualElementSurface* pSurface;
+
+//Surface loading
+#ifndef BUILD_UI_CORE
+
+                               pSurface = new VisualElementSurface();
 
                                if (!pSurface)
                                {
@@ -4095,8 +4102,6 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                                        return;
                                }
 
-//Surface loading
-#ifndef BUILD_UI_CORE
                                Tizen::Media::Image image;
                                image.Construct();
 
@@ -4124,6 +4129,11 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                                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;