Complex changes, try2: try1 remarks included, small comment and other fixes, save...
authorYouri Sdobnikov <i.sdobnikov@samsung.com>
Tue, 21 Jan 2014 09:02:07 +0000 (11:02 +0200)
committerYouri Sdobnikov <i.sdobnikov@samsung.com>
Tue, 21 Jan 2014 09:02:07 +0000 (11:02 +0200)
Change-Id: I2094729a1f7b095cdd7718140a3b53c08d4c20cd
Signed-off-by: Youri Sdobnikov <i.sdobnikov@samsung.com>
63 files changed:
inc/FUiAnimMeshController.h
inc/FUiAnimModelImporter.h
inc/FUiAnimScene.h
inc/FUiAnimVisualElement.h
src/ui/CMakeLists.txt
src/ui/animations/FUiAnimLight.cpp
src/ui/animations/FUiAnimMaterial.cpp
src/ui/animations/FUiAnimMesh.cpp
src/ui/animations/FUiAnimMeshController.cpp
src/ui/animations/FUiAnimModelImporter.cpp
src/ui/animations/FUiAnimScene.cpp
src/ui/animations/FUiAnimVisualElement.cpp
src/ui/animations/FUiAnim_GeometryInfo.cpp
src/ui/animations/FUiAnim_GlContext.h
src/ui/animations/FUiAnim_GlNode.cpp
src/ui/animations/FUiAnim_GlRenderManager.cpp
src/ui/animations/FUiAnim_GlRenderManager.h
src/ui/animations/FUiAnim_JointImpl.cpp
src/ui/animations/FUiAnim_JointImpl.h
src/ui/animations/FUiAnim_LightImpl.cpp
src/ui/animations/FUiAnim_LightImpl.h
src/ui/animations/FUiAnim_LightParser.cpp
src/ui/animations/FUiAnim_MaterialImpl.cpp
src/ui/animations/FUiAnim_MaterialImpl.h
src/ui/animations/FUiAnim_MaterialParser.cpp
src/ui/animations/FUiAnim_MaterialParser.h
src/ui/animations/FUiAnim_MeshControllerImpl.cpp
src/ui/animations/FUiAnim_MeshControllerImpl.h
src/ui/animations/FUiAnim_MeshGeneratorImpl.h
src/ui/animations/FUiAnim_MeshImpl.cpp
src/ui/animations/FUiAnim_ModelImporterImpl.cpp
src/ui/animations/FUiAnim_Ray.cpp
src/ui/animations/FUiAnim_Ray.h
src/ui/animations/FUiAnim_SceneImpl.cpp
src/ui/animations/FUiAnim_ShaderProgramImpl.cpp
src/ui/animations/FUiAnim_ShaderProgramImpl.h
src/ui/animations/FUiAnim_SkeletonModelProcessing.cpp [new file with mode: 0644]
src/ui/animations/FUiAnim_SkeletonModelProcessing.h [new file with mode: 0644]
src/ui/animations/FUiAnim_TransactionNode.h
src/ui/animations/FUiAnim_VisualElementImpl.cpp
src/ui/animations/import-collada/FUiAnim_ImportColladaColladaAssets.cpp
src/ui/animations/import-collada/library-cameras/FUiAnim_ImportColladaLibCamLibraryCameras.cpp
src/ui/animations/import-collada/library-cameras/FUiAnim_ImportColladaLibCamLibraryCameras.h
src/ui/animations/import-collada/library-effects/FUiAnim_ImportColladaLibEffEffect.cpp
src/ui/animations/import-collada/library-effects/FUiAnim_ImportColladaLibEffEffect.h
src/ui/animations/import-collada/library-lights/FUiAnim_ImportColladaLibLigLightWithAttenuation.cpp
src/ui/animations/import-collada/library-lights/FUiAnim_ImportColladaLibLigLightWithAttenuation.h
src/ui/animations/import-collada/library-lights/FUiAnim_ImportColladaLibLigSpot.cpp
src/ui/animations/import-collada/library-lights/FUiAnim_ImportColladaLibLigSpot.h
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenLibraryVisualScenes.cpp
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenLibraryVisualScenes.h
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenNode.cpp
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenNode.h
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenVisualScene.cpp
src/ui/animations/import-collada/library-visual-scenes/FUiAnim_ImportColladaLibVisScenVisualScene.h
src/ui/animations/platform/FUiAnim_GlContext.cpp
src/ui/animations/platform/FUiAnim_X11Window.cpp
src/ui/animations/platform/FUiAnim_X11Window.h
src/ui/inc/FUiAnim_MeshImpl.h
src/ui/inc/FUiAnim_ModelImporterImpl.h
src/ui/inc/FUiAnim_SceneImpl.h
src/ui/inc/FUiAnim_ShaderProgramGenerator.h
src/ui/inc/FUiAnim_VisualElementImpl.h

index 229b236..126286d 100644 (file)
@@ -45,6 +45,28 @@ public:
        void StartAnimation(void);
 
        /**
+        * Starts animation from specified time till animationDuration
+        *
+        * @since               3.0
+        *
+        * @param[in]   startAnimationTime
+        *
+        */
+       void StartAnimation(float startAnimationTime);
+
+       /**
+        * Starts animation from first keyframe
+        *
+        * @since               3.0
+        *
+        * @param[in]   startAnimationTime
+        * @param[in]   endAnimationTime
+        *
+        */
+       void StartAnimation(float startAnimationTime, float endAnimationTime);
+
+
+       /**
         * Stops animation and reset mesh to default position
         *
         * @since               3.0
@@ -83,6 +105,9 @@ public:
         */
        bool IsGpuSkinning(void) const;
 
+       bool GetPhysicsControll(void) const;
+
+
        /**
         * Sets a VisualElement to be controlled by a specified joint
         *
@@ -167,6 +192,26 @@ public:
        Tizen::Base::Collection::IList* GetJointChildrenNames(const Tizen::Base::String& jointName) const;
 
        /**
+        *  Returns joint count
+        *
+        * @since               3.0
+        *
+        * @return              Joints count
+        */
+       unsigned int GetJointCount();
+
+       /**
+        *  Returns a specified joint name
+        *
+        * @since               3.0
+        *
+        * @param[in]   index           Index of joint
+        * @return              Joint name
+        * @exception   E_INVALID_ARG                   Specified joint is not found
+        */
+       Tizen::Base::String GetJointName(unsigned int index);
+
+       /**
         *  Returns local matrix of specified joint
         *
         * @since               3.0
@@ -181,6 +226,20 @@ public:
        result GetJointLocalMatrix(const Tizen::Base::String& jointName, Tizen::Graphics::FloatMatrix4& localMatrix) const;
 
        /**
+        *  Returns local matrix of specified joint
+        *
+        * @since               3.0
+        *
+        * @return              An error code
+        * @param[in]   jointName                       Name of joint
+        * @param[out]  localMatrix                     Local inverted binding matrix of joint
+        *
+        * @exception   E_DATA_NOT_FOUND                There is no skeleton
+        * @exception   E_INVALID_ARG                   Specified joint is not found
+        */     
+       result GetJointInvBindMatrix(const Tizen::Base::String& jointName, Tizen::Graphics::FloatMatrix4& localMatrix) const;
+
+       /**
         *  Returns global matrix of specified joint
         *
         * @since               3.0
@@ -212,6 +271,24 @@ public:
         *
         */
        result SetJointWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName, float weightValue);
+       
+       /**
+        *  Gets value of specified joint weight affecting to specified vertex 
+        *
+        * @since               3.0
+        *
+        * @return              Specified joint weight
+        * @param[in]   vertexIndex                     Index of vertex
+        * @param[in]   jointName                       Name of joint
+        *
+        * @exception   E_INVALID_ARG                   Specified joint is not found @n
+        *                                                                              - Specified vertex is not found @n
+        *                                                                              - Weight value is greater then 1 or less 0
+        * @exception   E_INVALID_OPERATION             Mesh controller is constructed
+        *
+        */
+       float GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName);
+
 
        /**
         *  Sets duration of animation
index 75f1dc2..28d7f18 100644 (file)
@@ -30,6 +30,7 @@
 #include "FUiAnimMesh.h"
 #include "FUiAnimMaterial.h"
 #include "FUiAnimScene.h"
+#include "FUiAnimCamera.h"
 
 namespace Tizen { namespace Ui { namespace Animations {
 
@@ -37,44 +38,50 @@ class _OSP_EXPORT_ ModelImporter
        : public Tizen::Base::Object
 {
 public:
-       enum MODEL_FORMAT {
-               COLLADA,
-               BIN
-       };
-
        /**
         * Load mesh from file.
         *
         * @since               3.0
         *
         * @return              New mesh object
-        * @param[in]   modelFormat                     Format of file(COLLADA or Binary)
         * @param[in]   fileName                        Name of file
         * @param[in]   modelName                       Id of geometry in COLLADA file
         */
-       static Mesh* LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName = L"");
+       static Mesh* LoadMeshN(const Tizen::Base::String& fileName, const Tizen::Base::String modelName = "", bool loadWithoutController = false);
 
        /**
-        * Load mesh from file.
+        * Load material from file.
         *
         * @since               3.0
         *
-        * @return              New mesh object
+        * @return              New material object
         * @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)
         */
-       static Mesh* LoadMeshN(const Tizen::Base::String& fileName);
+       static Material* LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String materialName = "", Tizen::Base::String* textureName = null);
 
        /**
-        * Load material from file.
+        * Load light from file.
         *
         * @since               3.0
         *
-        * @return              New Material object
+        * @return              New light object
         * @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)
+        * @param[in]   modelName                       Id of light in COLLADA file
+        */
+       static Light* LoadLightN(const Tizen::Base::String& fileName, const Tizen::Base::String lightName = "");
+
+       /**
+        * Load camera from file.
+        *
+        * @since               3.0
+        *
+        * @return              New camera object
+        * @param[in]   fileName                        Name of file
+        * @param[in]   modelName                       Id of camera in COLLADA file
         */
-       static Material* LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String& materialName, Tizen::Base::String* textureName);
+       static Camera* LoadCameraN(const Tizen::Base::String& fileName, const Tizen::Base::String cameraName = "");
 
        /**
         * Load scene from file.
@@ -82,13 +89,25 @@ public:
         * @since               3.0
         *
         * @return              Scene object
-        * @param[in]   fileName                        Name of file
-        * @param[in]   sceneName                       Id of scene in COLLADA file
+        * @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
         */
        static Scene* LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, VisualElement& pSceneRootVisualElement);
 
 
+       //------------------------------------------- NAMES
+
+       static Tizen::Base::Collection::IList* GetMeshNamesN(const Tizen::Base::String& fileName);
+       static Tizen::Base::Collection::IList* GetMaterialNamesN(const Tizen::Base::String& fileName);
+       static Tizen::Base::Collection::IList* GetSceneNamesN(const Tizen::Base::String& fileName);
+       static Tizen::Base::Collection::IList* GetLightNamesN(const Tizen::Base::String& fileName);
+       static Tizen::Base::Collection::IList* GetCameraNamesN(const Tizen::Base::String& fileName);
+       static Tizen::Base::Collection::IList* GetMeshWithControllerNamesN(const Tizen::Base::String& fileName);
 private:
+
+       static bool CheckFileExt(const Tizen::Base::String& fileName, const Tizen::Base::String& extension);
+
        ModelImporter(void);
        virtual ~ModelImporter(void);
 };
index 357bad1..c54c2aa 100644 (file)
@@ -41,6 +41,7 @@ class Material;
 class Light;
 class ShaderProgram;
 class VisualElement;
+class VisualElementSurface;
 
 class _OSP_EXPORT_ Scene
        : public Tizen::Base::Object
@@ -182,7 +183,7 @@ public:
         * @remark      Creates a new public object instance, memory free left by user
         * @see AddMesh()
         */
-       Mesh* GetMeshN(const Tizen::Base::String meshName) const;
+       Mesh* GetMeshN(const Tizen::Base::String& meshName) const;
 
        /**
         * Checks if Mesh exists in scene by name
@@ -200,11 +201,11 @@ public:
        //int ContainsMesh(const Tizen::Base::String meshName) const;
 
        /**
-        * Checks if Mesh exists in scene by name
+        * Checks if Mesh exists in scene by pointer
         *
         * @since               3.0
         *
-        * @param[in]   meshName                Name of  object
+        * @param[in]   pMesh           Pointer to object
         *
         * @return              object index in scene container, or -1 if not found
         * @exception   E_SUCCESS                       The method is successful.
@@ -330,7 +331,7 @@ public:
         * @remark      Creates a new public object instance, memory free left by user
         * @see AddMaterial()
         */
-       Material* GetMaterialN(const Tizen::Base::String materialName) const;
+       Material* GetMaterialN(const Tizen::Base::String& materialName) const;
 
        /**
         * Checks if Material exists in scene by name
@@ -345,7 +346,7 @@ public:
         * @remark              Return value is in range [0,n-1] n - object count
         * @see AddMaterial(), GetMaterialCount(), GetMaterialAtN()
         */
-       //int ContainsMaterial(const Tizen::Base::String materialName) const;
+       int ContainsMaterial(const Tizen::Base::String& materialName) const;
 
        /**
         * Checks if Material exists in scene by name
@@ -479,7 +480,7 @@ public:
         * @remark      Creates a new public object instance, memory free left by user
         * @see AddLight()
         */
-       Light* GetLightN(const Tizen::Base::String lightName) const;
+       Light* GetLightN(const Tizen::Base::String& lightName) const;
 
        /**
         * Checks if Light exists in scene by name
@@ -573,7 +574,7 @@ public:
         * @remark      Creates a new public object instance, given one memory free left by user
         * @see GetShaderProgramN(), RemoveShaderProgram()
         */
-       ShaderProgram* AddShaderProgramN(const Tizen::Base::String shaderProgramName, const char* vertexShader, const char* fragmentShader);
+       ShaderProgram* AddShaderProgramN(const Tizen::Base::String& shaderProgramName, const char* vertexShader, const char* fragmentShader);
 
        /**
         * Removes a ShaderProgram object from the scene container by name
@@ -629,7 +630,7 @@ public:
         * @remark      Creates a new public object instance, memory free left by user
         * @see AddShaderProgram()
         */
-       ShaderProgram* GetShaderProgramN(const Tizen::Base::String shaderProgramName) const;
+       ShaderProgram* GetShaderProgramN(const Tizen::Base::String& shaderProgramName) const;
 
        /**
         * Checks if ShaderProgram exists in scene by name
@@ -707,69 +708,91 @@ public:
        Tizen::Base::String GetShaderProgramNameAt(int index) const;
 
        /**
-        * Adds a texture file name to scene container
+        * Adds a new Surface object to the scene container
         *
         * @since               3.0
         *
-        * @param[in]   textureFileName                 Name of texture file
+        * @param[in]   pSurface                        Pointer to object
+        * @param[in]   sourceFileName          Surface image file name (in scene resource path) (for load scene)
         *
         * @return              An error code
-        * @exception   E_SUCCESS               The method is successful.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           Input object pointer is null
+        * @exception   E_OUT_OF_MEMORY         Failed to create new object instance
+        *
+        * @remark      Creates a new public object instance, given one memory free left by user
+        * @see GetSurfaceN(), RemoveSurface()
         */
-       result AddTextureFileName(const Tizen::Base::String textureFileName);
+       result AddSurface(const VisualElementSurface* pSurface, const Tizen::Base::String& sourceFileName);
 
        /**
-        * Takes TextureFileName count in scene container
+        * Removes a Surface object from the scene container by pointer
         *
         * @since               3.0
         *
-        * @return              object count in scene
+        * @param[in]   pSurface                Pointer to object
         *
-        * @see AddTextureFileName(), GetTextureFileNameAt()
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         No such object in scene
+        * @exception   E_INVALID_ARG           Pointer to object is null
         */
-       int GetTextureFileNameCount(void) const;
+       result RemoveSurface(const VisualElementSurface* pSurface);
 
        /**
-        * Gets a TextureFileName string in scene container by index
+        * Removes all Surfaces in scene
         *
         * @since               3.0
         *
-        * @param[in]   index           object index in scene
-        *
-        * @return              String containing file name or path and name
+        * @return              An error code
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_OBJ_NOT_FOUND         No such index in scene
-        * @exception   E_OUT_OF_MEMORY         Failed to create new object instance
-        *
-        * @see AddTextureFileName(), GetTextureFileNameCount()
         */
-       Tizen::Base::String GetTextureFileNameAt(int index) const;
+       result RemoveAllSurface(void);
 
        /**
-        * Gets a TextureFileName string in scene container by index
+        * Checks if Surface exists in scene and return index
         *
         * @since               3.0
         *
-        * @param[in]   index           object index in scene
+        * @param[in]   pSurface                Pointer to object
         *
-        * @return              an error code
+        * @return              object index in scene container, or -1 if not found
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_OBJ_NOT_FOUND         No such index in scene
+        * @exception   E_INVALID_ARG           invalid object pointer
         *
-        * @see AddTextureFileName(), GetTextureFileNameCount(), GetTextureFileNameAt()
+        * @remark              Return value is in range [0,n-1] n - object count
+        * @see AddSurface(), GetSurfaceCount(), GetSurfaceAtN()
         */
-       result RemoveTextureFileNameAt(int index);
+       int ContainsSurface(const VisualElementSurface* pSurface) const;
 
        /**
-        * Removes all Texture file names in scene
+        * Takes Surface count in scene container
         *
         * @since               3.0
         *
-        * @return              An error code
+        * @return              object count in scene
+        *
+        * @see AddSurface(), GetSurfaceAtN()
+        */
+       int GetSurfaceCount(void) const;
+
+       /**
+        * Gets a pointer to the Surface in scene container by index
+        *
+        * @since               3.0
+        *
+        * @param[in]   index           object index in scene
+        *
+        * @return              Pointer to the object
         * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         No such index in scene
+        * @exception   E_OUT_OF_MEMORY         Failed to create new object instance
+        *
+        * @remark      Creates a new public object instance, memory free left by user
+        * @see AddSurface(), GetSurfaceCount()
         */
-       result RemoveAllTextureFileName(void);
+       VisualElementSurface* GetSurfaceAtN(int index) const;
+
 
        /**
         * Saves scene content into set of files at path, and scene structure to .xml
index 45bc7d5..34e7d05 100644 (file)
@@ -300,9 +300,9 @@ public:
 
        /**
         * Before the system calls OnDraw() method to fill the contents, the %OnPrepareDraw() method is called to give an opportunity to hook or prepare drawing. @n
-        * If the [IVisualElementContentProvider](@ref Tizen::Ui::Animations::IVisualElementContentProvider) interface is set to this instance
+        * If the [IVisualElementContentProvider](@ref Tizen::Ui::Animations::IVisualElementContentProvider) interface is set to this instance,
         * the [PrepareDraw()](@ref Tizen::Ui::Animations::IVisualElementContentProvider::PrepareDraw) callback will be called instead.
-
+        *
         * @since               2.0
         *
         * @return              @c true if OnDraw() can be called, @n
@@ -1253,6 +1253,20 @@ public:
        result SetExtraSurfaceOpacity(ExtraSurfaceIndex extraSurfaceIndex, float opacity);
 
        /**
+        * Gets the opacity for ExtraSurface by extraSurfaceIndex. @n
+        *
+        * @since               3.0
+        *
+        * @return              opacity                         The value of opacity in [0.0 .. 1.0] @n
+        * @param[in]   extraSurfaceIndex       The identifier to extraSurfaceIndex @n
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           If extraSurfaceIndex < EXTRA_SURFACE_1 or >=  EXTRA_SURFACE_MAX
+        * @exception   E_OBJ_NOT_FOUND         If ExtraSurface by extraSurfaceIndex is not exist
+        * @see                 ExtraSurfaceIndex
+        */
+       float GetExtraSurfaceOpacity(const ExtraSurfaceIndex extraSurfaceIndex) const;
+
+       /**
         * Gets the AlphaMask which is used in VisualElement. @n
         *
         * @since               3.0
index 4430090..51f9225 100644 (file)
@@ -53,6 +53,7 @@ SET (${this_target}_SOURCE_FILES
 # GL
     animations/platform/FUiAnim_GlContext.cpp
     animations/platform/FUiAnim_Egl.cpp
+ #   animations/platform/FUiAnim_Wgl.cpp
     animations/FUiAnim_GlNode.cpp
        animations/FUiAnim_GlLayer.cpp
        animations/FUiAnim_GlLoader.cpp
@@ -164,6 +165,7 @@ SET (${this_target}_SOURCE_FILES
        animations/FUiAnim_ShaderProgramImpl.cpp
        animations/FUiAnimShader.cpp
        animations/FUiAnimShaderProgram.cpp
+       animations/FUiAnim_SkeletonModelProcessing.cpp
 #####################################################################################
 
 #=====================================================
@@ -224,6 +226,7 @@ SET (${this_target}_SOURCE_FILES
 #=====================================================
        animations/math/FUiAnim_MathAdapterFunctions.cpp
        animations/math/FUiAnim_MathCommon.cpp
+       animations/math/FUiAnim_MathTools.cpp
        animations/math/FUiAnim_MathMatrix2.cpp
        animations/math/FUiAnim_MathMatrix3.cpp
        animations/math/FUiAnim_MathMatrix4.cpp
index fa24c40..f5331c2 100644 (file)
@@ -118,6 +118,14 @@ Light::SetAmbient(const Tizen::Graphics::FloatVector4& ambient)
        color[2] = ambient.z;
        color[3] = ambient.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Ambient color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pLightImpl->SetAmbient(color);
 }
 
@@ -143,6 +151,14 @@ Light::SetDiffuse(const Tizen::Graphics::FloatVector4& diffuse)
        color[2] = diffuse.z;
        color[3] = diffuse.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Diffuse color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pLightImpl->SetDiffuse(color);
 }
 
@@ -168,6 +184,14 @@ Light::SetSpecular(const Tizen::Graphics::FloatVector4& specular)
        color[2] = specular.z;
        color[3] = specular.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Specular color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pLightImpl->SetSpecular(color);
 }
 
@@ -249,6 +273,11 @@ Light::SetCutOff(float cutOff)
 {
        SysAssertf(__pLightImpl != null, "Not yet constructed.");
 
+       if (cutOff > 180.f)
+       {
+               SysLogException(NID_UI_ANIM, E_INVALID_DATA, "%s CutOff value have to be lower then 180 degree: ", GetErrorMessage(E_INVALID_DATA));
+       }
+
        __pLightImpl->SetCutOff(cutOff);
 }
 
index b3e088d..a404062 100644 (file)
@@ -115,6 +115,13 @@ Material::SetAmbient(const Tizen::Graphics::FloatVector4& ambient)
        color[2] = ambient.z;
        color[3] = ambient.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Ambient color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
        __pMaterialImpl->SetAmbient(color);
 }
 
@@ -140,6 +147,14 @@ Material::SetDiffuse(const Tizen::Graphics::FloatVector4& diffuse)
        color[2] = diffuse.z;
        color[3] = diffuse.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Diffuse color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pMaterialImpl->SetDiffuse(color);
 }
 
@@ -165,6 +180,14 @@ Material::SetSpecular(const Tizen::Graphics::FloatVector4& specular)
        color[2] = specular.z;
        color[3] = specular.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Specular color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pMaterialImpl->SetSpecular(color);
 }
 
@@ -190,6 +213,14 @@ Material::SetEmissive(const Tizen::Graphics::FloatVector4& emissive)
        color[2] = emissive.z;
        color[3] = emissive.w;
 
+       for (int i = 0; i < 4; ++i)
+       {
+               if ((color[i] < 0.0f) || (color[i] > 1.0f))
+               {
+                       SysLogException(NID_UI_ANIM, E_OUT_OF_RANGE, "%s Emissive color value isn't correct: ", GetErrorMessage(E_OUT_OF_RANGE));
+               }
+       }
+
        __pMaterialImpl->SetEmissive(color);
 }
 
index 6614b3b..1eff41d 100644 (file)
@@ -31,8 +31,6 @@
 #include "FGrpFloatPoint3.h"
 #include "FGrpColor.h"
 
-//#include "stdint.h"
-
 #include "FUiAnimMeshController.h"
 
 using namespace Tizen::Graphics;
index 87f4ef8..7352823 100644 (file)
@@ -63,6 +63,24 @@ MeshController::StartAnimation(void)
 }
 
 void
+MeshController::StartAnimation(float startAnimationTime)
+{
+       ClearLastResult();
+       CHECK_IMPL;
+       __pMeshControllerImpl->StartAnimation(startAnimationTime);
+       return;
+}
+
+void
+MeshController::StartAnimation(float startAnimationTime, float endAnimationTime)
+{
+       ClearLastResult();
+       CHECK_IMPL;
+       __pMeshControllerImpl->StartAnimation(startAnimationTime, endAnimationTime);
+       return;
+}
+
+void
 MeshController::StopAnimation(void)
 {
        ClearLastResult();
@@ -96,6 +114,14 @@ MeshController::IsGpuSkinning(void) const
        return __pMeshControllerImpl->IsGpuSkinning();
 }
 
+bool
+MeshController::GetPhysicsControll(void) const
+{
+       ClearLastResult();
+       CHECK_IMPL;
+       return __pMeshControllerImpl->GetPhysicsControll();
+}
+
 void
 MeshController::SetJointVisualElement(const Tizen::Base::String& jointName, VisualElement* pVisualElement)
 {
@@ -167,6 +193,24 @@ MeshController::GetJointChildrenNames(const Tizen::Base::String& jointName) cons
        return __pMeshControllerImpl->GetJointChildrenNames(jointName);
 }
 
+unsigned int
+MeshController::GetJointCount()
+{
+       ClearLastResult();
+       CHECK_IMPL;
+
+       return __pMeshControllerImpl->GetJointCount();
+}
+
+Tizen::Base::String
+MeshController::GetJointName(unsigned int index)
+{
+       ClearLastResult();
+       CHECK_IMPL;
+
+       return __pMeshControllerImpl->GetJointName(index);
+}
+
 result
 MeshController::GetJointLocalMatrix(const Tizen::Base::String& jointName, Tizen::Graphics::FloatMatrix4& localMatrix) const
 {
@@ -185,6 +229,23 @@ MeshController::GetJointLocalMatrix(const Tizen::Base::String& jointName, Tizen:
 }
 
 result
+MeshController::GetJointInvBindMatrix(const Tizen::Base::String& jointName, Tizen::Graphics::FloatMatrix4& localMatrix) const
+{
+       ClearLastResult();
+       CHECK_IMPL;
+
+       _Math::Matrix4 local;
+    result res = __pMeshControllerImpl->GetJointInvBindMatrix(jointName, local);
+    if (res == E_SUCCESS)
+       {
+       memcpy(localMatrix.matrix, local.m, sizeof(float) * 16);
+       localMatrix.Transpose();
+       }
+
+    return res;
+}
+
+result
 MeshController::GetJointGlobalMatrix(const Tizen::Base::String& jointName, Tizen::Graphics::FloatMatrix4& globalMatrix) const
 {
        ClearLastResult();
@@ -210,6 +271,15 @@ MeshController::SetJointWeight(unsigned int vertexIndex, const Tizen::Base::Stri
        return __pMeshControllerImpl->SetJointWeight(vertexIndex, jointName, weightValue);
 }
 
+float
+MeshController::GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName)
+{
+       ClearLastResult();
+       CHECK_IMPL;
+
+       return __pMeshControllerImpl->GetWeight(vertexIndex, jointName);
+}
+
 result
 MeshController::SetAnimationDuration(float seconds)
 {
index 9be1cae..42d91e1 100644 (file)
@@ -46,72 +46,209 @@ ModelImporter::~ModelImporter(void)
 }
 
 Mesh*
-ModelImporter::LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName)
+ModelImporter::LoadMeshN(const Tizen::Base::String& fileName, const Tizen::Base::String modelName, bool loadWithoutController)
 {
-       Mesh* pMesh = null;
-       std::string strFileName = WToStd(fileName);
-       std::string strModelName = WToStd(modelName);
+       SetLastResult(E_SUCCESS);
 
-       switch(modelFormat)
+       if (CheckFileExt(fileName, L".dae"))
        {
-               case COLLADA:
+               Mesh* pMesh = null;
+
+               if ( ! loadWithoutController )
                {
-                       _ModelImporterImpl modelImporter(strFileName, false, true, false, false, false, false, false, false, false); //true: Geometries
-                       std::string materialId;
-                       pMesh = modelImporter.LoadMeshCollada(strModelName, materialId);
+                       _ModelImporterImpl modelImporter(WToStd(fileName), true, true, true, true, true, true, true, false, false); //true: VisualScenes, Geometries, Controllers, Animations, Materials, Effects
+                       pMesh = modelImporter.LoadMeshWithControllerCollada(WToStd(modelName));
+
                }
-               break;
-               case BIN:
+
+               if (pMesh == null)
                {
-                       // WARNING : modelName is not used...
-                       pMesh = _ModelImporterImpl::LoadMeshN(fileName);
+                       _ModelImporterImpl modelImporter(WToStd(fileName), false, true, false, false, false, false, false, false, false); //true: Geometries
+                       std::string materialId;
+                       pMesh = modelImporter.LoadMeshCollada(WToStd(modelName), materialId);
+                       modelImporter.ApplyUpAxis(*pMesh);
                }
-               break;
+
+               return pMesh;
        }
-       return pMesh;
+
+       if (CheckFileExt(fileName, L".msh"))
+       {
+               Mesh* pMesh = null;
+
+               AppLog("ModelImporter::LoadMesh::BIN");
+               pMesh = _ModelImporterImpl::LoadMeshN(fileName, loadWithoutController);
+
+               return pMesh;
+       }
+
+       SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+
+       return null;
 }
 
-Mesh*
-ModelImporter::LoadMeshN(const Tizen::Base::String& fileName)
+Material*
+ModelImporter::LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String materialName, Tizen::Base::String* pTextureName)
 {
        SetLastResult(E_SUCCESS);
-       AppLog("ModelImporter::LoadMesh::BIN");
-       Mesh* pMesh = _ModelImporterImpl::LoadMeshN(fileName);
-       return pMesh;
+
+       if (CheckFileExt(fileName, L".dae"))
+       {
+               Material* pMaterial = null;
+               std::string textureId;
+               _ImportCollada::LibraryEffects::Effect::ShaderType shaderType;
+
+               _ModelImporterImpl modelImporter(WToStd(fileName), false, false, false, false, true, true, true, false, false); //true:Materials, Effects, Images
+               pMaterial = modelImporter.LoadMaterial(WToStd(materialName), textureId, shaderType);
+
+               if (pTextureName != null)
+               {
+                       *pTextureName = Tizen::Base::String(textureId.c_str());
+               }
+
+               return pMaterial;
+       }
+
+       if (CheckFileExt(fileName, L".mtr"))
+       {
+               AppLog("ModelImporter::LoadMaterial::Xml");
+               return _ModelImporterImpl::LoadMaterialN(fileName);
+       }
+
+       SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
+
+       return null;
 }
 
-Material*
-ModelImporter::LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String& materialName, Tizen::Base::String* pTextureName)
+Light*
+ModelImporter::LoadLightN(const Tizen::Base::String& fileName, const Tizen::Base::String lightName)
 {
-       Material* pMaterial = null;
+       SetLastResult(E_SUCCESS);
+
+       if (CheckFileExt(fileName, L".dae"))
+       {
+               _ModelImporterImpl modelImporter(WToStd(fileName), false, false, false, false, false, false, false, true, false);
+               return modelImporter.LoadLightCollada(WToStd(lightName));
+       }
+
+       if (CheckFileExt(fileName, L".lgh"))
+       {
+               AppLog("ModelImporter::LoadLight::Xml");
+               return _ModelImporterImpl::LoadLightN(fileName);
+       }
+
+       SysTryReturn(NID_UI, true, null, E_UNSUPPORTED_FORMAT, "Format of file is not supported.");
 
-       std::string textureId;
-       _ImportCollada::LibraryEffects::Effect::ShaderType shaderType;
+       return null;
+}
 
-       _ModelImporterImpl modelImporter(WToStd(fileName), false, false, false, false, true, true, true, false, false); //true:Materials, Effects, Images
-       pMaterial = modelImporter.LoadMaterial(WToStd(materialName), textureId, shaderType);
+Camera*
+ModelImporter::LoadCameraN(const Tizen::Base::String& fileName, const Tizen::Base::String cameraName)
+{
+       SetLastResult(E_SUCCESS);
+
+       if (CheckFileExt(fileName, L".dae"))
+       {
+               _ModelImporterImpl modelImporter(WToStd(fileName), false, false, false, false, false, false, false, false, true);
+               return modelImporter.LoadCameraCollada(WToStd(cameraName));
+       }
 
-       if (pTextureName != null)
+       if (CheckFileExt(fileName, L".cmr"))
        {
-               *pTextureName = Tizen::Base::String(textureId.c_str());
+               return null;
        }
 
-       return pMaterial;
+       SysTryReturn(NID_UI, true, 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)
 {
+       SetLastResult(E_SUCCESS);
+
+       if (CheckFileExt(fileName, L".dae"))
+       {
+               _ModelImporterImpl modelImporter(WToStd(fileName), true, true, true, true, true, true, true, false, false);
+               return modelImporter.LoadScene(WToStd(sceneName), pSceneRootVisualElement);
+       }
+
+       if (CheckFileExt(fileName, L".scn"))
+       {
+               return null;
+       }
+
+       return null;
+}
+
+Tizen::Base::Collection::IList*
+ModelImporter::GetMeshNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       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*
+ModelImporter::GetMaterialNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       std::string strFileName = WToStd(fileName);
+       _ModelImporterImpl modelImporter(strFileName, false, false, false, false, true, false, false, false, false); //true: Materials
+       return modelImporter.GetMaterialNamesN();
+
+}
+
+Tizen::Base::Collection::IList*
+ModelImporter::GetSceneNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       std::string strFileName = WToStd(fileName);
+       _ModelImporterImpl modelImporter(strFileName, true, false, false, false, false, false, false, false, false); //true: VisualScenes
+       return modelImporter.GetSceneNamesN();
+}
+
+Tizen::Base::Collection::IList*
+ModelImporter::GetLightNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       std::string strFileName = WToStd(fileName);
+       _ModelImporterImpl modelImporter(strFileName, false, false, false, false, false, false, false, true, false); //true: Lights
+       return modelImporter.GetLightNamesN();
+}
+
+Tizen::Base::Collection::IList*
+ModelImporter::GetCameraNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       std::string strFileName = WToStd(fileName);
+       _ModelImporterImpl modelImporter(strFileName, false, false, false, false, false, false, false, false, true); //true: Cameras
+       return modelImporter.GetCameraNamesN();
+}
 
-       _ModelImporterImpl modelImporter(WToStd(fileName), true, true, true, true, true, true, true, false, false);
+Tizen::Base::Collection::IList*
+ModelImporter::GetMeshWithControllerNamesN(const Tizen::Base::String& fileName)
+{
+       SetLastResult(E_SUCCESS);
+       std::string strFileName = WToStd(fileName);
+       _ModelImporterImpl modelImporter(strFileName, false, false, true, false, false, false, false, false, false); //true: Controllers
+       return modelImporter.GetMeshWithControllerNamesN();
+}
 
-//#ifndef BUILD_UI_CORE
-//     _ModelImporterImpl modelImporter(WToStd(fileName), true, true, true, true, true, false, false, false, false); //true: VisualScene, Geometries, Controllers, Animations, Materials, Effects, Images
-//#else
-//     _ModelImporterImpl modelImporter(WToStd(fileName), true, true, false, false, true, true, false, false, false); //true: VisualScene, Geometries, Controllers, Animations, Materials, Effects, Images
-//#endif
+bool
+ModelImporter::CheckFileExt(const Tizen::Base::String& fileName, const Tizen::Base::String& extension)
+{
+       Tizen::Base::String upperCaseFileName;
+       Tizen::Base::String upperCaseExtention;
 
-       return modelImporter.LoadScene(WToStd(sceneName), pSceneRootVisualElement);
+       fileName.ToUpperCase(upperCaseFileName);
+       extension.ToUpperCase(upperCaseExtention);
+
+       return upperCaseFileName.EndsWith(upperCaseExtention);
 }
 
+
 }}}
index a981f47..09e1b9a 100644 (file)
@@ -136,7 +136,7 @@ Scene::RemoveAllMesh(void)
 }
 
 Mesh*
-Scene::GetMeshN(const Tizen::Base::String meshName) const
+Scene::GetMeshN(const Tizen::Base::String& meshName) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
@@ -227,7 +227,7 @@ Scene::RemoveAllMaterial(void)
 }
 
 Material*
-Scene::GetMaterialN(const Tizen::Base::String materialName) const
+Scene::GetMaterialN(const Tizen::Base::String& materialName) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
@@ -235,14 +235,14 @@ Scene::GetMaterialN(const Tizen::Base::String materialName) const
        return __pSceneImpl->GetMaterialN(materialName);
 }
 
-//int
-//Scene::ContainsMaterial(const Tizen::Base::String materialName) const //index = [0,n-1], or -1 if not exist
-//{
-//     ClearLastResult();
-//     SysAssertf(__pSceneImpl != null,
-//             "Not yet constructed. Construct() should be called before use.");
-//     return __pSceneImpl->ContainsMaterial(materialName);
-//}
+int
+Scene::ContainsMaterial(const Tizen::Base::String& materialName) const //index = [0,n-1], or -1 if not exist
+{
+       ClearLastResult();
+       SysAssertf(__pSceneImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+       return __pSceneImpl->ContainsMaterial(materialName);
+}
 
 int
 Scene::ContainsMaterial(const Material* pMaterial) const //index = [0,n-1], or -1 if not exist
@@ -317,7 +317,7 @@ Scene::RemoveAllLight(void)
 }
 
 Light*
-Scene::GetLightN(const Tizen::Base::String lightName) const
+Scene::GetLightN(const Tizen::Base::String& lightName) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
@@ -371,7 +371,7 @@ Scene::GetLightNameAt(int index) const
 }
 //----------ShaderProgram
 ShaderProgram*
-Scene::AddShaderProgramN(const String shaderProgramName, const char* vertexShader, const char* fragmentShader)
+Scene::AddShaderProgramN(const String& shaderProgramName, const char* vertexShader, const char* fragmentShader)
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
@@ -407,7 +407,7 @@ Scene::RemoveAllShaderProgram(void)
 }
 
 ShaderProgram*
-Scene::GetShaderProgramN(const Tizen::Base::String shaderProgramName) const
+Scene::GetShaderProgramN(const Tizen::Base::String& shaderProgramName) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
@@ -460,51 +460,58 @@ Scene::GetShaderProgramNameAt(int index) const
        return __pSceneImpl->GetShaderProgramNameAt(index);
 }
 
-//------------Texture
+result
+Scene::AddSurface(const VisualElementSurface* pSurface, const Tizen::Base::String& sourceFileName)
+{
+       ClearLastResult();
+       SysAssertf(__pSceneImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+       return __pSceneImpl->AddSurface(pSurface, sourceFileName);
+}
 
 result
-Scene::AddTextureFileName(const Tizen::Base::String textureFileName)
+Scene::RemoveSurface(const VisualElementSurface* pSurface)
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
                "Not yet constructed. Construct() should be called before use.");
-       return __pSceneImpl->AddTextureFileName(textureFileName);
+       return __pSceneImpl->RemoveSurface(pSurface);
 }
 
-int
-Scene::GetTextureFileNameCount(void) const
+result
+Scene::RemoveAllSurface(void)
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
                "Not yet constructed. Construct() should be called before use.");
-       return __pSceneImpl->GetTextureFileNameCount();
+       return __pSceneImpl->RemoveAllSurface();
 }
 
-Tizen::Base::String
-Scene::GetTextureFileNameAt(int index) const
+int
+Scene::ContainsSurface(const VisualElementSurface* pSurface) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
                "Not yet constructed. Construct() should be called before use.");
-       return __pSceneImpl->GetTextureFileNameAt(index);
+       return __pSceneImpl->ContainsSurface(pSurface);
 }
 
-result
-Scene::RemoveTextureFileNameAt(int index)
+int
+Scene::GetSurfaceCount(void) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
                "Not yet constructed. Construct() should be called before use.");
-       return __pSceneImpl->RemoveTextureFileNameAt(index);
+       return __pSceneImpl->GetSurfaceCount();
 }
 
-result
-Scene::RemoveAllTextureFileName(void)
+VisualElementSurface*
+Scene::GetSurfaceAtN(int index) const
 {
        ClearLastResult();
        SysAssertf(__pSceneImpl != null,
                "Not yet constructed. Construct() should be called before use.");
-       return __pSceneImpl->RemoveAllTextureFileName();
+       return __pSceneImpl->GetSurfaceAtN(index);
 }
 
 result
index 588ae47..a838a73 100644 (file)
@@ -625,6 +625,7 @@ VisualElement::SetSurface(VisualElementSurface* pSurface)
 result
 VisualElement::SetAlphaMask(VisualElementSurface* pAlphaMaskSurface)
 {
+       ClearLastResult();
        CHECK_CONSTRUCTED;
 
        return _pVisualElementImpl->SetAlphaMask(pAlphaMaskSurface);
@@ -633,6 +634,7 @@ VisualElement::SetAlphaMask(VisualElementSurface* pAlphaMaskSurface)
 result
 VisualElement::SetExtraSurface(ExtraSurfaceIndex extraSurfaceIndex, VisualElementSurface* pExtraSurface)
 {
+       ClearLastResult();
        CHECK_CONSTRUCTED;
 
        return _pVisualElementImpl->SetExtraSurface(extraSurfaceIndex, pExtraSurface);
@@ -641,11 +643,21 @@ VisualElement::SetExtraSurface(ExtraSurfaceIndex extraSurfaceIndex, VisualElemen
 result
 VisualElement::SetExtraSurfaceOpacity(ExtraSurfaceIndex extraSurfaceIndex, float opacity)
 {
+       ClearLastResult();
        CHECK_CONSTRUCTED;
 
        return _pVisualElementImpl->SetExtraSurfaceOpacity(extraSurfaceIndex, opacity);
 }
 
+float
+VisualElement::GetExtraSurfaceOpacity(const ExtraSurfaceIndex extraSurfaceIndex) const
+{
+       ClearLastResult();
+       CHECK_CONSTRUCTED;
+
+       return _pVisualElementImpl->GetExtraSurfaceOpacity(extraSurfaceIndex);
+}
+
 VisualElementSurface*
 VisualElement::GetAlphaMaskN(void) const
 {
@@ -988,6 +1000,7 @@ VisualElement::GetLightIndex(const Light& light) const
 {
        CHECK_CONSTRUCTED;
        ClearLastResult();
+
        int index  = _pVisualElementImpl->GetLightIndex(light);
        if(index == -1)
        {
@@ -1008,12 +1021,14 @@ VisualElement::GetLightN(int index) const
 {
        ClearLastResult();
        CHECK_CONSTRUCTED;
+
        Light* pLight = _pVisualElementImpl->GetLight(index);
 
        if (pLight != null)
        {
                return new (std::nothrow) Light(*pLight);
        }
+
        SetLastResult(E_OBJ_NOT_FOUND);
        return null;
 }
index a24b992..2e0a42e 100644 (file)
@@ -173,14 +173,17 @@ result
 _GeometryInfo::RemoveLight(int index)
 {
        Light* pLight = null;
-       if ( __lightArray.GetAt(index, pLight) == E_SUCCESS)
+       if (index >= 0 && index < __lightArray.GetCount())
        {
-               if ( pLight )
+               if ( __lightArray.GetAt(index, pLight) == E_SUCCESS)
                {
-                       delete pLight;
+                       if ( pLight )
+                       {
+                               delete pLight;
+                       }
+                       __lightArray.RemoveAt(index);
+                       return E_SUCCESS;
                }
-               __lightArray.RemoveAt(index);
-               return E_SUCCESS;
        }
        return E_OBJ_NOT_FOUND;
 }
@@ -189,7 +192,7 @@ int
 _GeometryInfo::GetLightIndex(const Light& light) const
 {
        int count = __lightArray.GetCount();
-       for(int i = 0; i< count; i++)
+       for(int i = 0; i < count; i++)
        {
                Light* pTemp = null;
                if ( __lightArray.GetAt(i, pTemp) == E_SUCCESS)
@@ -214,11 +217,14 @@ Light*
 _GeometryInfo::GetLight(int index) const
 {
        Light* pLight = null;
-       if ( __lightArray.GetAt(index, pLight) == E_SUCCESS)
+       if (index >= 0 && index < __lightArray.GetCount())
        {
-               if(pLight)
+               if ( __lightArray.GetAt(index, pLight) == E_SUCCESS)
                {
-                       return pLight;
+                       if(pLight)
+                       {
+                               return pLight;
+                       }
                }
        }
        return null;
index 5569c28..767308d 100644 (file)
@@ -25,8 +25,6 @@
 #ifndef _FUI_ANIM_INTERNAL_GL_CONTEXT_H_
 #define _FUI_ANIM_INTERNAL_GL_CONTEXT_H_
 
-//TODO: remove dep.
-#include <EGL/egl.h>
 #include <FBaseDataType.h>
 
 #include "FGrp_Canvas.h"
index 3d1b796..e1072c7 100644 (file)
@@ -486,6 +486,7 @@ _GlNode::SyncStatus(VisualElementSurface* pSurface, _VisualElementImpl& element)
                                __pLight = new (std::nothrow) Light(*pLight);
                        }
                }
+
        }
        else
        {
index 35d1614..69f3e00 100644 (file)
 
 #include "FUiAnim_Debug.h"
 
-#ifdef BUILD_UI_CORE
- #include <GL/glew.h>
+#ifdef _WIN32
+       #include <GL/glew.h> 
 #else
- #include <GLES2/gl2.h>
      #include <GLES2/gl2.h>
 #endif
 
 
@@ -77,6 +77,8 @@ using namespace Tizen::Ui::Animations;
 #define PRINT(...)
 
 
+//#define ELAPSE(_STR) unique_ptr<_ElapsedTime> ptr(new _ElapsedTime(_STR));
+
 #ifdef VE_USE_GL_MULTI_CONTEXT
 #define        CHECK_GL_CONTEXT(pGlContext)    SysAssertf(pGlContext, "Invalid render manager status(no context)");
 #else
@@ -132,6 +134,10 @@ _GlRenderManager::_RenderObject::_RenderObject(void)
        , __GPUSkinning(false)
        , __aWeights(-1)
        , __aJointIds(-1)
+       , __aJointIndex0(-1)
+       , __aJointIndex1(-1)
+       , __aJointIndex2(-1)
+       , __aJointIndex3(-1)
        , __pWeights(null)
        , __pJointIds(null)
        , __jointsCount(0)
@@ -238,6 +244,7 @@ _GlRenderManager::_RenderObject::GetShaderProgram(int type)
        {
                alphaMask = true;
                texture = true;
+
        }
 
        if (type & SHADER_TYPE_EXTRA_SURFACE_1)
@@ -485,7 +492,10 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
                {
                        __GPUSkinning = meshController->IsGpuSkinning();
 
-                       if (__GPUSkinning) shaderType |= SHADER_TYPE_SKINING;
+                       if (__GPUSkinning)
+                       {
+                               shaderType |= SHADER_TYPE_SKINING;
+                       }
 
                        __pWeights = meshController->GetWeightsPointer();
                        __pJointIds = meshController->GetIdsPointer();
@@ -666,6 +676,11 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
        __aWeights  = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC4_WEIGHTS];
        __aJointIds = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC4_JOINTS];
 
+       __aJointIndex0 = pProgramImpl->__attributeLocation[ATTRIBUTE_INT_INDEX0];
+       __aJointIndex1 = pProgramImpl->__attributeLocation[ATTRIBUTE_INT_INDEX1];
+       __aJointIndex2 = pProgramImpl->__attributeLocation[ATTRIBUTE_INT_INDEX2];
+       __aJointIndex3 = pProgramImpl->__attributeLocation[ATTRIBUTE_INT_INDEX3];
+
        return;
 }
 
@@ -1069,16 +1084,28 @@ _GlRenderManager::FlushRenderQueue(void)
                        glVertexAttribPointer(__pRenderQueue[i].__aWeights,  4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), __pRenderQueue[i].__pWeights);
                        glVertexAttribPointer(__pRenderQueue[i].__aJointIds, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), __pRenderQueue[i].__pJointIds); //TODO: for GL_INT need glVertexAttribI(!)Pointer
 
+                       int index0 = (int)(__pRenderQueue[i].__pJointIds)[0];
+                       int index1 = (int)(__pRenderQueue[i].__pJointIds)[1];
+                       int index2 = (int)(__pRenderQueue[i].__pJointIds)[2];
+                       int index3 = (int)(__pRenderQueue[i].__pJointIds)[3];
+                       glVertexAttribPointer(__pRenderQueue[i].__aJointIndex0, 1, GL_INT, GL_FALSE, sizeof(int), &index0);
+                       glVertexAttribPointer(__pRenderQueue[i].__aJointIndex1, 1, GL_INT, GL_FALSE, sizeof(int), &index1);
+                       glVertexAttribPointer(__pRenderQueue[i].__aJointIndex2, 1, GL_INT, GL_FALSE, sizeof(int), &index2);
+                       glVertexAttribPointer(__pRenderQueue[i].__aJointIndex3, 1, GL_INT, GL_FALSE, sizeof(int), &index3);
+
                        glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_ARRAY_JOINTSMATRICES], __pRenderQueue[i].__jointsCount, GL_FALSE, __pRenderQueue[i].__pJointsMatrices);
                }
 
                // Set uniform
+
+               const float* f = __pRenderQueue[i].__mvp.GetItems();
                glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_MVP], 1, GL_FALSE, __pRenderQueue[i].__mvp.GetItems());
                glUniform1f(pProgramImpl->__uniformLocation[UNIFORM_FLOAT_OPACITY], __pRenderQueue[i].__opacity);
                glUniform4f(pProgramImpl->__uniformLocation[UNIFORM_VEC4_COLOR], __pRenderQueue[i].__objectColor.Red(), __pRenderQueue[i].__objectColor.Green(),
                                __pRenderQueue[i].__objectColor.Blue(), __pRenderQueue[i].__objectColor.Alpha());
 
                glUniform3fv(pProgramImpl->__uniformLocation[UNIFORM_VEC3_EYE_POSITION], 1, __pRenderQueue[i].__eyePosition);
+               //glUniform3f(pProgramImpl->__uniformLocation[UNIFORM_VEC3_EYE_POSITION], 360, 640, 350);
                glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_MODEL_VIEW], 1, GL_FALSE, __pRenderQueue[i].__modelview.GetItems());
                glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_INV_MODEL_VIEW], 1, GL_FALSE, __pRenderQueue[i].__invModelview.GetItems());
 
@@ -1106,6 +1133,10 @@ _GlRenderManager::FlushRenderQueue(void)
 
                        glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_INT_ACTIVE_LIGHT_COUNT], __pRenderQueue[i].__activeLightCount);
                }
+               else
+               {
+                       glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_INT_ACTIVE_LIGHT_COUNT], 0);
+               }
 
                if (__pRenderQueue[i].__pMaterial)
                {
index f6e0c20..fd0ec81 100644 (file)
@@ -229,6 +229,10 @@ private:
                bool __GPUSkinning;
                int __aWeights;
                int __aJointIds;
+               int __aJointIndex0;
+               int __aJointIndex1;
+               int __aJointIndex2;
+               int __aJointIndex3;
 
                const float* __pWeights;
                const float* __pJointIds;
index 0c76d10..2fc919d 100644 (file)
@@ -149,8 +149,8 @@ _JointImpl::CalculateGlobal(bool updateChildrenGlobals)
        {
                Graphics::FloatMatrix4 matrix;
                memcpy(matrix.matrix, __global.m, sizeof(float) * 16);
-               matrix.Transpose();
-               __pVisualElement->SetTransformMatrix(matrix);
+               matrix.Transpose();             
+               __pVisualElement->SetProperty(L"transform", matrix);
        }
 
        if (updateChildrenGlobals)
@@ -164,6 +164,15 @@ _JointImpl::CalculateGlobal(bool updateChildrenGlobals)
 }
 
 void
+_JointImpl::SetLocal(const _Math::Matrix4& local)
+{
+       __local.Set(local);
+       CalculateGlobal(true);
+       return;
+}
+
+
+void
 _JointImpl::SetGlobal(const _Math::Matrix4& global)
 {
        __global.Set(global);
@@ -173,7 +182,7 @@ _JointImpl::SetGlobal(const _Math::Matrix4& global)
                Graphics::FloatMatrix4 matrix;
                memcpy(matrix.matrix, __global.m, sizeof(float) * 16);
                matrix.Transpose();
-               __pVisualElement->SetTransformMatrix(matrix);
+               __pVisualElement->SetProperty(L"transform", matrix);
        }
        return;
 }
@@ -193,7 +202,7 @@ _JointImpl::GetGlobal(void) const
 void
 _JointImpl::AddKeyFrame(float time, const _Math::Matrix4& value)
 {
-       SysTryReturnVoidResult(NID_UI, time > 0, E_INVALID_ARG, "Time value should be greater than 0"); //TODO check eng
+       SysTryReturnVoidResult(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;
index 40e6e0a..3166d5f 100644 (file)
@@ -64,6 +64,7 @@ public:
        _Math::Matrix4 GetInvertBindMatrix() const;
 
        void CalculateGlobal(bool updateChildrenGlobals = true);
+       void SetLocal(const _Math::Matrix4& local);
        void SetGlobal(const _Math::Matrix4& global);
        _Math::Matrix4 GetLocal(void) const;
        _Math::Matrix4 GetGlobal(void) const;
index e7d03a4..48a0f9a 100644 (file)
@@ -172,9 +172,21 @@ _LightImpl::GetPositionInEyeCoords(void) const
 void
 _LightImpl::SetDirection(const float direction[3])
 {
-       __direction[0] = direction[0];
-       __direction[1] = direction[1];
-       __direction[2] = direction[2];
+
+       float lenght = sqrtf( direction[0]*direction[0] + direction[1]*direction[1] + direction[2]*direction[2]);
+
+        if (lenght > 0.0f)
+        {
+               __direction[0] = direction[0] / lenght;
+               __direction[1] = direction[1] / lenght;
+               __direction[2] = direction[2] / lenght;
+        }
+        else
+        {
+               __direction[0] = direction[0];
+               __direction[1] = direction[1];
+               __direction[2] = direction[2];
+        }
 }
 
 float*
@@ -224,7 +236,7 @@ _LightImpl::GetCutOff(void) const
 float
 _LightImpl::GetCutOffCos(void) const
 {
-       return cosf(__cutOff * M_PI / 180.0f);
+       return cosf(__cutOff * M_PI / 180.0f) ;
 }
 
 void
index 10f88fd..9a600ea 100644 (file)
@@ -176,7 +176,24 @@ public:
         */
        float* GetPosition(void) const;
 
+       /**
+        * Sets light position in world coordiantes.
+        *
+        * @since 3.0
+        *
+        * @param[in]   position                New light position.
+        * @see                 GetPosition().
+        */
        void SetPositionInEyeCoords(const float position[4]);
+
+       /**
+        * Gets light position in world coordiantes.
+        *
+        * @since 3.0
+        *
+        * @return              Light position.
+        * @see                 SetPosition().
+        */
        float* GetPositionInEyeCoords(void) const;
 
        /**
@@ -198,8 +215,25 @@ public:
         * @see                 SetDirection().
         */
        float* GetDirection(void) const;
-
+       
+       /**
+        * Sets light direction in world coordiantes.
+        *
+        * @since 3.0
+        *
+        * @param[in]   direction       New light direction.
+        * @see                 GetDirection().
+        */
        void SetDirectionInEyeCoords(const float direction[3]);
+
+       /**
+        * Gets light direction in world coordiantes.
+        *
+        * @since 3.0
+        *
+        * @return              light direction.
+        * @see                 SetDirection().
+        */
        float* GetDirectionInEyeCoords(void) const;
 
        /**
index e1d16d6..a7c4e1f 100644 (file)
@@ -22,7 +22,8 @@
  * This file contains implementation of the _LightParser class.
  */
 
-#include <FBaseString.h>
+#include <FApp.h>
+#include <FBase.h>
 #include <FBaseSysLog.h>
 #include <FGrpFloatVector4.h>
 #include <FGrpFloatPoint3.h>
@@ -35,8 +36,9 @@
 #include <libxml/xmlreader.h>
 #include <libxml/xpath.h>
 #include <stdlib.h>
-#include <FBaseColStlConverter.h>  //for std::wstringstream
+#include <FIo.h>
 #include <algorithm>
+#include <fstream>
 
 
 using namespace Tizen::Ui;
@@ -44,11 +46,15 @@ using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Graphics;
-//using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Utility;
 
 namespace Tizen { namespace Ui { namespace Animations
 {
 
+extern const int MAJOR_VERSION;
+extern const int MINOR_VERSION;
+extern const int RELEASE;
+
 #define FLOAT_VECTOR_FOUR_SIZE 4
 #define FLOAT_VECTOR_THREE_SIZE 3
 
@@ -120,12 +126,12 @@ StartElement(void *ctx,   const xmlChar *name, const xmlChar **atts)
                        }
        else if (TagName.compare("direction") == 0)
                        {
-                               SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == FLOAT_VECTOR_THREE_SIZE, E_OUT_OF_RANGE, " Direction attributes don't suitable, must be one instead there are (%d)", countArrayAttributes);
+                               SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == FLOAT_VECTOR_THREE_SIZE, E_OUT_OF_RANGE, " Direction attributes don't suitable, must be three instead there are (%d)", countArrayAttributes);
                                pParsingForLight->SetDirection(Tizen::Graphics::FloatPoint3(TizenStringToFloat(arrayAttributes[0]), TizenStringToFloat(arrayAttributes[1]), TizenStringToFloat(arrayAttributes[2])));
                        }
        else if (TagName.compare("attenuation") == 0)
                        {
-                               SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == FLOAT_VECTOR_THREE_SIZE, E_OUT_OF_RANGE, " Attenuation attributes don't suitable, must be one instead there are (%d)", countArrayAttributes);
+                               SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == FLOAT_VECTOR_THREE_SIZE, E_OUT_OF_RANGE, " Attenuation attributes don't suitable, must be three instead there are (%d)", countArrayAttributes);
                                pParsingForLight->SetConstantAttenuation(TizenStringToFloat(arrayAttributes[0]));
                                pParsingForLight->SetLinearAttenuation(TizenStringToFloat(arrayAttributes[1]));
                                pParsingForLight->SetQuadraticAttenuation(TizenStringToFloat(arrayAttributes[2]));
@@ -161,6 +167,19 @@ StartElement(void *ctx,    const xmlChar *name, const xmlChar **atts)
                                SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == 1, E_OUT_OF_RANGE, " Enabled attributes don't suitable, must be one instead there are (%d)",  countArrayAttributes);
                                pParsingForLight->SetEnabled((arrayAttributes[0].CompareTo("true") == 0)?1:0);
                        }
+       else if (TagName.compare("programversion") == 0)
+               {
+                       SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == FLOAT_VECTOR_THREE_SIZE, E_OUT_OF_RANGE, " ProgramVersion attributes don't suitable, must be three instead there are (%d)", countArrayAttributes);
+                       //Local Program Version Variables
+                       int32_t majorVersion;
+                       int32_t minorVersion;
+                       int32_t release;
+                       //------------------------
+                       majorVersion = TizenStringToFloat(arrayAttributes[0]);
+                       minorVersion = TizenStringToFloat(arrayAttributes[1]);
+                       release = TizenStringToFloat(arrayAttributes[2]);
+                       AppLog("%d, %d, %d,", majorVersion, minorVersion, release);
+               }
 }
 
 result
@@ -177,9 +196,22 @@ _LightParser::SaveLight (Light* pThis, const Tizen::Base::String& fileName)
                rc = xmlTextWriterStartDocument(writer, null, "UTF-8", null);
                err = xmlGetLastError();
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartDocument Failed! %s", err->message);
-                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Light");
+               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Light");
+               err = xmlGetLastError();
+               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementLight Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "ProgramVersion");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementProgramVersion Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "MajorVersion", "%d", MAJOR_VERSION);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "MinorVersion", "%d", MINOR_VERSION);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "Release", "%d", RELEASE);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of ProgramVersion
                        err = xmlGetLastError();
-                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementLight Failed! %s", err->message);
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementProgramVersion Failed! %s", err->message);
 
                        rc = xmlTextWriterStartElement(writer, (xmlChar*) "LightType");
                        err = xmlGetLastError();
@@ -192,135 +224,135 @@ _LightParser::SaveLight (Light* pThis, const Tizen::Base::String& fileName)
                        err = xmlGetLastError();
                        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementLightType Failed! %s", err->message);
 
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Ambient");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementAmbient Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetAmbient().x);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetAmbient().y);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetAmbient().z);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetAmbient().w);
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Ambient
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementAmbient Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Diffuse");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementDiffuse Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetDiffuse().x);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetDiffuse().y);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetDiffuse().z);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetDiffuse().w);
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Diffuse
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementDiffuse Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Specular");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementSpecular Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetSpecular().x);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetSpecular().y);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetSpecular().z);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetSpecular().w);
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Specular
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementSpecular Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Position");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementPosition Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetPosition().x);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetPosition().y);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetPosition().z);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetPosition().w);
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Position
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementPosition Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Direction");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementDirection Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetDirection().x);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetDirection().y);
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetDirection().z);
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Direction
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementDirection Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Attenuation");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementAttenuation Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "constAttenuation", "%f", pThis->GetConstantAttenuation());
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "linearAttenuation", "%f", pThis->GetLinearAttenuation());
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "quadraticAttenuation", "%f", pThis->GetQuadraticAttenuation());
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Attenuation
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementAttenuation Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Exponent");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementExponent Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "float", "%f", pThis->GetExponent());
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Exponent
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementExponent Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "CutOff");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementCutOff Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "float", "%f", pThis->GetCutOff());
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of CutOff
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementCutOff Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "Enabled");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementEnabled Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "bool", "%s", (pThis->IsEnabled())?"true":"false");
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
-
-                               rc = xmlTextWriterEndElement(writer);//end of Enabled
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementEnabled Failed! %s", err->message);
-
-                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "LightName");
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementLightName Failed! %s", err->message);
-
-                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "String", "%ls", pThis->GetName().GetPointer());
-                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Ambient");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementAmbient Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetAmbient().x);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetAmbient().y);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetAmbient().z);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetAmbient().w);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Ambient
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementAmbient Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Diffuse");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementDiffuse Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetDiffuse().x);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetDiffuse().y);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetDiffuse().z);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetDiffuse().w);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Diffuse
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementDiffuse Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Specular");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementSpecular Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetSpecular().x);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetSpecular().y);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetSpecular().z);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetSpecular().w);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Specular
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementSpecular Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Position");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementPosition Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetPosition().x);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetPosition().y);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetPosition().z);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "w", "%f", pThis->GetPosition().w);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Position
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementPosition Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Direction");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementDirection Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "x", "%f", pThis->GetDirection().x);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "y", "%f", pThis->GetDirection().y);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "z", "%f", pThis->GetDirection().z);
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Direction
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementDirection Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Attenuation");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementAttenuation Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "constAttenuation", "%f", pThis->GetConstantAttenuation());
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "linearAttenuation", "%f", pThis->GetLinearAttenuation());
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "quadraticAttenuation", "%f", pThis->GetQuadraticAttenuation());
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Attenuation
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementAttenuation Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Exponent");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementExponent Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "float", "%f", pThis->GetExponent());
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Exponent
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementExponent Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "CutOff");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementCutOff Failed! %s", err->message);
 
-                               rc = xmlTextWriterEndElement(writer);//end of LightName
-                               err = xmlGetLastError();
-                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementLightName Failed! %s", err->message);
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "float", "%f", pThis->GetCutOff());
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
 
-                       rc = xmlTextWriterEndElement(writer);//end of Light
+                       rc = xmlTextWriterEndElement(writer);//end of CutOff
                        err = xmlGetLastError();
-                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementLight Failed! %s", err->message);
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementCutOff Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "Enabled");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementEnabled Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "bool", "%s", (pThis->IsEnabled())?"true":"false");
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of Enabled
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementEnabled Failed! %s", err->message);
+
+                       rc = xmlTextWriterStartElement(writer, (xmlChar*) "LightName");
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementLightName Failed! %s", err->message);
+
+                               rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "String", "%ls", pThis->GetName().GetPointer());
+                               rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                       rc = xmlTextWriterEndElement(writer);//end of LightName
+                       err = xmlGetLastError();
+                       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementLightName Failed! %s", err->message);
+
+               rc = xmlTextWriterEndElement(writer);//end of Light
+               err = xmlGetLastError();
+               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementLight Failed! %s", err->message);
 
                rc = xmlTextWriterEndDocument(writer);
                err = xmlGetLastError();
@@ -348,6 +380,10 @@ _LightParser::LoadLightN(const Tizen::Base::String& fileName)
        std::wstring wStr(fileName.GetPointer());
        std::string strFileName(wStr.begin(), wStr.end());
 
+       std::ifstream f(strFileName.c_str());
+       SysTryReturn(NID_UI_ANIM, f.good(), null, E_FILE_NOT_FOUND, "Cannot open file %s while loading material.", strFileName.c_str());
+       f.close();
+
        pLight = new (std::nothrow) Light();
        SysTryReturn(NID_UI_ANIM, pLight != null, null, E_OUT_OF_MEMORY, "%s Memory allocation failed while creating Light.", GetErrorMessage(E_OUT_OF_MEMORY));
 
index 5eeb0f0..2e4e768 100644 (file)
  * This file contains implementation _MaterialImpl class.
  */
 #include <unique_ptr.h>
+#include <FApp.h>
+#include <FBase.h>
 #include <FGrpFloatVector4.h>
 #include "FUiAnim_DynamicProperty.h"
 #include "FUiAnim_VisualElementImpl.h"
 #include "FUiAnim_MaterialImpl.h"
-//#include <libxml/parser.h>
-//#include <libxml/tree.h>
-////#include <libxml/xmlstring.h>
-//#include <libxml/xmlwriter.h>
-//#include <libxml/xmlreader.h>
-////#include <libxml/xpath.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+//#include <libxml/xmlstring.h>
+#include <libxml/xmlwriter.h>
+#include <libxml/xmlreader.h>
+//#include <libxml/xpath.h>
 #include <stdlib.h>
-#include <FIoFile.h>
+#include <FIo.h>
 
 using namespace Tizen::Ui;
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Graphics;
-//using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Utility;
 
 //#define PRINT(...) fprintf(stderr, __VA_ARGS__)
 #define PRINT(...)
index 09f4ded..f9d0a7b 100644 (file)
@@ -28,6 +28,8 @@
 #include <FBaseString.h>
 #include <FUiAnimMaterial.h>
 #include "FUiAnim_RefObject.h"
+#include <libxml/xmlstring.h>
+#include <libxml/xpath.h>
 #include <vector>
 #include <string>
 
index 29f04b8..3fb165d 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <algorithm>
 #include <vector>
+#include <fstream>
 
 using namespace Tizen::Ui;
 using namespace Tizen::App;
@@ -53,6 +54,10 @@ using namespace Tizen::Graphics;
 namespace Tizen { namespace Ui { namespace Animations
 {
 
+extern const int MAJOR_VERSION;
+extern const int MINOR_VERSION;
+extern const int RELEASE;
+
 #define FLOAT_ARRAY_SIZE 4
 
 bool _MaterialParser::_materialIsEnabled = false;
@@ -148,6 +153,19 @@ SH_startElement(void *ctx, const xmlChar *name, const xmlChar **atts)
                {
                        _MaterialParser::_materialIsEnabled = true;
                }
+       else if (TagName.compare("programversion") == 0)
+               {
+                       SysTryReturnVoidResult(NID_UI_ANIM, countArrayAttributes == 3, E_OUT_OF_RANGE, " ProgramVersion attributes don't suitable, must be three instead there are (%d)", countArrayAttributes);
+                       //Local Program Version Variables
+                       int32_t majorVersion;
+                       int32_t minorVersion;
+                       int32_t release;
+                       //------------------------
+                       majorVersion = ConvertingTizenStringToFloat(arrayAttributes[0]);
+                       minorVersion = ConvertingTizenStringToFloat(arrayAttributes[1]);
+                       release = ConvertingTizenStringToFloat(arrayAttributes[2]);
+                       AppLog("%d, %d, %d,", majorVersion, minorVersion, release);
+               }
 }
 
 
@@ -163,6 +181,10 @@ _MaterialParser::LoadMaterialN(const Tizen::Base::String& fileName)
        std::wstring wStr(fileName.GetPointer());
        std::string strFileName(wStr.begin(), wStr.end());
 
+       std::ifstream f(strFileName.c_str());
+       SysTryReturn(NID_UI_ANIM, f.good(), null, E_FILE_NOT_FOUND, "Cannot open file %s while loading material.", strFileName.c_str());
+       f.close();
+
        pMaterial = new (std::nothrow) Material();
        SysTryReturn(NID_UI_ANIM, pMaterial != null, null, E_OUT_OF_MEMORY, "%s Memory allocation failed while creating Material.", GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -205,6 +227,19 @@ _MaterialParser::SaveMaterial (Material* pThis, const Tizen::Base::String& fileN
                        err = xmlGetLastError();
                        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementMaterial Failed! %s", err->message);
 
+                               rc = xmlTextWriterStartElement(writer, (xmlChar*) "ProgramVersion");
+                               err = xmlGetLastError();
+                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementProgramVersion Failed! %s", err->message);
+
+                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "MajorVersion", "%d", MAJOR_VERSION);
+                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "MinorVersion", "%d", MINOR_VERSION);
+                                       rc = xmlTextWriterWriteFormatAttribute(writer, (xmlChar*) "Release", "%d", RELEASE);
+                                       rc = xmlTextWriterWriteString(writer, (xmlChar*) "");
+
+                               rc = xmlTextWriterEndElement(writer);//end of ProgramVersion
+                               err = xmlGetLastError();
+                               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterEndElementProgramVersion Failed! %s", err->message);
+
                                rc = xmlTextWriterStartElement(writer, (xmlChar*) "Ambient");
                                err = xmlGetLastError();
                                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_OPERATION_FAILED, "xmlTextWriterStartElementAmbient Failed! %s", err->message);
index a6af1c6..6ff5013 100644 (file)
 
 #include <FUiAnimMaterial.h>
 
+namespace Tizen { namespace Base {
+class String;
+}}
+
 namespace Tizen { namespace Ui { namespace Animations {
 
 class _MaterialParser
index 61ef40e..dac10cc 100644 (file)
@@ -61,6 +61,7 @@ _MeshControllerImpl::_MeshControllerImpl(void)
        : __isConstructed(false)
        , __pRoot(null)
        , __pMesh(null)
+       , __pMeshImpl(null)
        , __bindShapeMatrix()
        , __joints()
        , __pInitialPositions(null)
@@ -74,6 +75,7 @@ _MeshControllerImpl::_MeshControllerImpl(void)
        , __animationStarted(false)
        , __animationDuration(0)
        , __animationTime(0)
+       , __endAnimationTime(0)
 {
 #ifdef _WIN32
        __prevTime = clock();
@@ -140,7 +142,7 @@ _MeshControllerImpl::SetMesh(Mesh* pMesh)
        __pWeights = new (std::nothrow) float[__vertexCount * 4];
        SysTryCatchLabel(NID_UI_ANIM, __pWeights != null, ,CATCH1, E_OUT_OF_MEMORY, "Memory allocation failed");
 
-       memset(__pIDs, 0.0f, __vertexCount * 4 * sizeof(float));
+       memset(__pIDs, -1.0f, __vertexCount * 4 * sizeof(float));
        memset(__pWeights, 0.0f, __vertexCount * 4 * sizeof(float));
 
        __pInitialPositions = new (std::nothrow) _Math::Vector4[__vertexCount];
@@ -164,6 +166,8 @@ _MeshControllerImpl::SetMesh(Mesh* pMesh)
                }               
        }
 
+       __pMeshImpl = _MeshImpl::GetInstance(*__pMesh);
+
        return E_SUCCESS;
 
 CATCH3:
@@ -180,12 +184,12 @@ CATCH:
 
 result _MeshControllerImpl::ResetMesh(void) const
 {
-       SysTryReturnResult(NID_UI, __pMesh != null, E_DATA_NOT_FOUND, "Mesh is not set.");
+       SysTryReturnResult(NID_UI, __pMeshImpl != null, E_DATA_NOT_FOUND, "Mesh is not set.");
 
        for (unsigned int index = 0; index < __vertexCount; index++)
        {
                _Math::Vector4& vertex =  __pInitialPositions[index];
-               __pMesh->SetVertex(index, FloatPoint3(vertex.x, vertex.y, vertex.z));
+               __pMeshImpl->SetVertex(index, FloatPoint3(vertex.x, vertex.y, vertex.z));
        }
 
        if (__pInitialNormals != null)
@@ -193,7 +197,7 @@ result _MeshControllerImpl::ResetMesh(void) const
                for (unsigned int index = 0; index < __vertexCount; index++)
                {
                        _Math::Vector4& normal =  __pInitialNormals[index];
-                       __pMesh->SetNormal(index, FloatPoint3(normal.x, normal.y, normal.z));
+                       __pMeshImpl->SetNormal(index, FloatPoint3(normal.x, normal.y, normal.z));
                }
        }
 
@@ -261,6 +265,24 @@ _MeshControllerImpl::GetRootJointName(void) const
        return __pRoot->GetName();
 }
 
+unsigned int
+_MeshControllerImpl::GetJointCount()
+{
+       return __joints.size();
+}
+
+
+Tizen::Base::String
+_MeshControllerImpl::GetJointName(unsigned int index)
+{
+       if (index < __joints.size())
+       {
+               return __joints[index]->GetName();
+       }
+       return "";
+}
+
+
 result
 _MeshControllerImpl::GetJointLocalMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& localMatrix) const
 {
@@ -273,6 +295,18 @@ _MeshControllerImpl::GetJointLocalMatrix(const Tizen::Base::String& jointName, _
 }
 
 result
+_MeshControllerImpl::GetJointInvBindMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& localMatrix) const
+{
+       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());
+
+       localMatrix.Set(pJoint->GetInvertBindMatrix());
+       return E_SUCCESS;
+}
+
+
+result
 _MeshControllerImpl::GetJointGlobalMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& globalMatrix) const
 {
        SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
@@ -306,7 +340,7 @@ _MeshControllerImpl::Construct(void)
 {
        SysTryReturnResult(NID_UI, !__isConstructed, E_INVALID_OPERATION, "Already constructed!"); //TODO: Check error type
 
-       SysTryReturnResult(NID_UI, __pMesh != null, E_DATA_NOT_FOUND, "Mesh is not set.");
+       SysTryReturnResult(NID_UI, __pMeshImpl != null, E_DATA_NOT_FOUND, "Mesh is not set.");
        SysTryReturnResult(NID_UI, __pRoot != null, E_DATA_NOT_FOUND, "Skeleton is not set.");
 
        __gpuSkinning =  (__joints.size() <= 64);
@@ -320,15 +354,18 @@ _MeshControllerImpl::Construct(void)
                unsigned int vertexJointsCount = 0;
                for (unsigned int i = 0; i < 4; i++)
                {
-                       unsigned int id = (int) __pIDs[vertexIndex * 4 + i];
-                       if (id != 0)
+                       int id = (int) __pIDs[vertexIndex * 4 + i];
+                       if (id != -1)
                        {
                                vertexJointsCount++;
                        }
+                       else
+                       {
+                               __pIDs[vertexIndex * 4 + i] = 0.0f;
+                       }
                }
 
                if (vertexJointsCount == 0){
-
                        AppLog("Vertex without Joint %i", vertexIndex);
 
                        __pIDs[vertexIndex * 4 + 0] = 0;
@@ -353,6 +390,103 @@ _MeshControllerImpl::Construct(void)
        }
 
        __isConstructed = true;
+
+       //--------------------------------------------------------------------------------------------
+
+       //turn off gpu skinning and perform joint matrices calculation
+       bool isGPUskinning = IsGpuSkinning();
+       SetGPUSkinning(false);
+       //Calculate();
+
+       //gets joint
+       std::vector<_JointImpl*>* joints = GetJoints();
+       _JointImpl* rootBone = GetRoot();
+       Tizen::Ui::Animations::_SkeletonModelProcessing skeletonBuilder;
+
+       //gets vertices
+       int vertexCount = __pMesh->GetVertexCount();
+       std::vector<_Math::Vector3> verticesForBuilding;
+       for (int i = 0; i < vertexCount; ++i)
+       {
+               const FloatPoint3& vertex = __pMesh->GetVertex(i);
+               verticesForBuilding.push_back(_Math::Vector3(vertex.x, vertex.y, vertex.z));
+       }
+
+       //gets indices
+       int indicesCount = __pMesh->GetIndexCount();
+       std::vector<int> vertexIndices;
+       for( int i = 0; i < indicesCount; ++i)
+       {
+               vertexIndices.push_back(__pMesh->GetIndex(i));
+       }
+
+       for (int index = 0; index < vertexCount; ++index)
+       {
+               const _Math::Vector3& initialVertexPosition = __bindShapeMatrix * verticesForBuilding[index];
+               verticesForBuilding[index] = initialVertexPosition;
+       }
+
+       //performs skeleton approximation
+       if(!skeletonBuilder.PrepareData(*rootBone, GetWeightsPointer(), GetIdsPointer(), verticesForBuilding, *joints, vertexIndices))
+       {
+               return null;
+       }
+
+       //turn gpuskining on
+       SetGPUSkinning(isGPUskinning);
+       ResetMesh();
+
+       __orientedBoxes = skeletonBuilder.GetOrientedBoxes();
+       __bones = skeletonBuilder.GetBones();
+
+       //todo:remove applogs
+
+       //cut oriented boxes
+       float a;
+       float b;
+       float c;
+       float maxABC;
+       float threshold = 1.f / 2.f; //same as for physics _PhysicalWorldBuilder::BuildSkeletalModelUsing3DModel()
+       int boxCount = __orientedBoxes.size();
+
+       for (int i = 0; i < boxCount; i++)
+       {
+               //todo:remove applogs
+//             AppLog("bone \"%ls\" abc(%f,%f,%f) pos(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                     __orientedBoxes[i].GetA(), __orientedBoxes[i].GetB(), __orientedBoxes[i].GetC(), \
+//                     __orientedBoxes[i].GetPosition().x,__orientedBoxes[i].GetPosition().y,__orientedBoxes[i].GetPosition().z);
+//             AppLog("bone \"%ls\" axis1(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[0],__orientedBoxes[i].GetOrientation().m[1], __orientedBoxes[i].GetOrientation().m[2]);
+//             AppLog("bone \"%ls\" axis2(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[3],__orientedBoxes[i].GetOrientation().m[4], __orientedBoxes[i].GetOrientation().m[5]);
+//             AppLog("bone \"%ls\" axis3(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[6],__orientedBoxes[i].GetOrientation().m[7], __orientedBoxes[i].GetOrientation().m[8]);
+//             AppLog("bone \"%ls\" a/b=%f a/c=%f", __bones[i]->GetName().GetPointer(), \
+//                                     __orientedBoxes[i].GetA()/__orientedBoxes[i].GetB(), __orientedBoxes[i].GetA()/__orientedBoxes[i].GetC());
+
+               a = __orientedBoxes[i].GetA();
+               b = __orientedBoxes[i].GetB();
+               c = __orientedBoxes[i].GetC();
+
+               maxABC = (a > b)?a:b;
+               maxABC = (maxABC > c)?maxABC:c; //_Math::Max(a, _Math::Max(b, c));
+
+               __orientedBoxes[i].SetA((a > threshold * maxABC ? a : threshold * maxABC));
+               __orientedBoxes[i].SetB((b > threshold * maxABC ? b : threshold * maxABC));
+               __orientedBoxes[i].SetC((c > threshold * maxABC ? c : threshold * maxABC));
+
+//             AppLog("bone \"%ls\" abc(%f,%f,%f) pos(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                     __orientedBoxes[i].GetA(), __orientedBoxes[i].GetB(), __orientedBoxes[i].GetC(), \
+//                     __orientedBoxes[i].GetPosition().x,__orientedBoxes[i].GetPosition().y,__orientedBoxes[i].GetPosition().z);
+//             AppLog("bone \"%ls\" axis1(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[0],__orientedBoxes[i].GetOrientation().m[1], __orientedBoxes[i].GetOrientation().m[2]);
+//             AppLog("bone \"%ls\" axis2(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[3],__orientedBoxes[i].GetOrientation().m[4], __orientedBoxes[i].GetOrientation().m[5]);
+//             AppLog("bone \"%ls\" axis3(%f,%f,%f)", __bones[i]->GetName().GetPointer(), \
+//                             __orientedBoxes[i].GetOrientation().m[6],__orientedBoxes[i].GetOrientation().m[7], __orientedBoxes[i].GetOrientation().m[8]);
+       }
+       Calculate();
+
        return E_SUCCESS;
 }
 
@@ -366,8 +500,6 @@ _MeshControllerImpl::SetJointWeight(unsigned int vertexIndex, const Tizen::Base:
        _JointImpl* pJoint = null;
        unsigned int jointIndex = 0;
        for (unsigned int i = 0; i < __joints.size(); i++){
-               //printf("===================>>>>> '%S'\n", __joints[i]->GetName().GetPointer());
-
                if (jointName.Equals(__joints[i]->GetName(), false)){
                        pJoint = __joints[i];
                        jointIndex = i;
@@ -400,15 +532,26 @@ _MeshControllerImpl::SetJointWeight(unsigned int vertexIndex, const Tizen::Base:
        return E_SUCCESS;
 }
 
+float
+_MeshControllerImpl::GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName)
+{
+       for (unsigned int i = 0; i < 4; i++)
+       {
+               unsigned int jointIndex = __pIDs[vertexIndex * 4 + i];
+               _JointImpl* joint = __joints[jointIndex];
+               if (joint->GetName().CompareTo(jointName))
+               {
+                       return __pWeights[vertexIndex * 4 + i];
+               }
+       }
+       return 0.0f;
+}
+
 result
 _MeshControllerImpl::Calculate(void)
 {
        SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
 
-       if (!__physicsControll){
-               __pRoot->CalculateGlobal();
-       }
-
 #ifdef _WIN32
        time_t curTime;
        curTime = clock();
@@ -421,23 +564,36 @@ _MeshControllerImpl::Calculate(void)
        __prevTime = curTime;
 #endif
 
-       
        if (__animationStarted & (dt > 0.0f))
        {
-               __animationTime += dt;
+               if (__animationTime < __endAnimationTime)
+               {
+                       __animationTime += dt;
+                       __animationStarted = (__animationTime < __endAnimationTime);
+               }
+               else
+               {
+                       __animationTime -= dt;
+                       __animationStarted = (__animationTime > __endAnimationTime);
+               }
+
                __pRoot->Animate(__animationTime, true);
 
-               if (__animationTime > __animationDuration)
+               if (__animationStarted)
                {
-                       __animationTime = 0;
-                       __animationStarted = false;
+                       //Post "update" message to renderer...
                }
                else
                {
-                       //Post "update" message to renderer...
+                       __animationTime = 0;
+                       __endAnimationTime = __animationDuration;
                }
        }
 
+       if (!__physicsControll){
+               __pRoot->CalculateGlobal();
+       }
+
        for (unsigned int jointIndex = 0; jointIndex < __joints.size(); jointIndex++)
        {
                __pGlobals[jointIndex].Set(__joints[jointIndex]->GetGlobal());
@@ -468,7 +624,7 @@ _MeshControllerImpl::Calculate(void)
                        newVertex += (__pGlobals[index2].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 2];
                        newVertex += (__pGlobals[index3].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 3];
 
-                       __pMesh->SetVertex(i, FloatPoint3(newVertex.x, newVertex.y, newVertex.z));
+                       __pMeshImpl->SetVertex(i, FloatPoint3(newVertex.x, newVertex.y, newVertex.z));
 
                        if (__pInitialNormals != null){
                                newNormal  = (__pGlobals[index0].GetTransposed() * __pInitialNormals[i]) * __pWeights[i * 4 + 0];
@@ -476,7 +632,7 @@ _MeshControllerImpl::Calculate(void)
                                newNormal += (__pGlobals[index2].GetTransposed() * __pInitialNormals[i]) * __pWeights[i * 4 + 2];
                                newNormal += (__pGlobals[index3].GetTransposed() * __pInitialNormals[i]) * __pWeights[i * 4 + 3];
 
-                               __pMesh->SetNormal(i, FloatPoint3(newNormal.x, newNormal.y, newNormal.z));
+                               __pMeshImpl->SetNormal(i, FloatPoint3(newNormal.x, newNormal.y, newNormal.z));
                        }
                }
        }
@@ -558,15 +714,64 @@ result
 _MeshControllerImpl::StartAnimation(void)
 {
        __animationTime = 0;
+       __endAnimationTime = __animationDuration;
+       __animationStarted = true;
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::StartAnimation(float startAnimationTime)
+{
+       if (startAnimationTime < 0.0f)
+       {
+               startAnimationTime = 0.0f;
+       }
+
+       if (startAnimationTime > __animationDuration)
+       {
+               startAnimationTime = __animationDuration;
+       }
+
+       __animationTime = startAnimationTime;
+       __endAnimationTime = __animationDuration;
        __animationStarted = true;
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::StartAnimation(float startAnimationTime, float endAnimationTime)
+{
+       if (startAnimationTime < 0.0f)
+       {
+               startAnimationTime = 0.0f;
+       }
+
+       if (startAnimationTime > __animationDuration)
+       {
+               startAnimationTime = __animationDuration;
+       }
+
+       if (endAnimationTime < 0.0f)
+       {
+               endAnimationTime = 0.0f;
+       }
+
+       if (endAnimationTime > __animationDuration)
+       {
+               endAnimationTime = __animationDuration;
+       }
 
+       __animationTime = startAnimationTime;
+       __endAnimationTime = endAnimationTime;
+       __animationStarted = true;
        return E_SUCCESS;
 }
 
 result
 _MeshControllerImpl::StopAnimation(void)
 {
-       __animationTime = 0;
+       __animationTime = 0.0f;
+       __endAnimationTime = __animationDuration;
        if (! __gpuSkinning)
        {
                ResetMesh(); //TODO needed?
@@ -581,6 +786,32 @@ _MeshControllerImpl::IsAnimating(void) const
        return __animationStarted;
 }
 
+result
+_MeshControllerImpl::SetIdsPointer(const float* value)
+{
+       for (int i = 0; i < __vertexCount * 4; ++i)
+       {
+               __pIDs[i] = value[i];
+       }
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::SetWeightsPointer(const float* value)
+{
+       for (int i = 0; i < __vertexCount * 4; ++i)
+       {
+               __pWeights[i] = value[i];
+       }
+       return E_SUCCESS;
+}
+
+bool
+_MeshControllerImpl::GetPhysicsControll(void) const
+{
+       return __physicsControll;
+}
+
 void
 _MeshControllerImpl::SetGPUSkinning(bool value)
 {
@@ -651,5 +882,10 @@ _MeshControllerImpl::GetJointVisualElement(const Tizen::Base::String& jointName)
        return pJoint->GetVisualElement();
 }
 
+Mesh*
+_MeshControllerImpl::GetMesh(void)
+{
+       return __pMesh;
+}
 
 }}}
index fa49a56..3feff75 100644 (file)
  */
 
 #include "FUiAnimMeshController.h"
+#include <FUiAnim_SkeletonModelProcessing.h>
 
 #include <vector>
 #include <FUiAnimMesh.h>
+#include <FUiAnim_MeshImpl.h>
 #include <FUiAnim_JointImpl.h>
 #include <FUiAnim_MathVector4.h>
 #include <FUiAnim_MathMatrix4.h>
@@ -48,18 +50,23 @@ public:
        static result DestroyPublicInstance(const MeshController& mesh);
 
        result SetMesh(Mesh* pMesh);
+       Mesh* GetMesh(void);
        result SetSkeleton(_JointImpl* pRootJoint);
        result AddJoint(const Tizen::Base::String& parentJointName, const Tizen::Base::String& jointName, const _Math::Matrix4& localMatrix, const _Math::Matrix4& invertBindMatrix);
        Tizen::Base::Collection::IList* GetJointChildrenNames(const Tizen::Base::String& jointName) const;
        Tizen::Base::String GetRootJointName(void) const;
+       unsigned int GetJointCount();
+       Tizen::Base::String GetJointName(unsigned int index);
 
        result GetJointLocalMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& localMatrix) const;
+       result GetJointInvBindMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& localMatrix) const;
        result GetJointGlobalMatrix(const Tizen::Base::String& jointName, _Math::Matrix4& globalMatrix) const;
 
        result SetBindShapeMatrix(const _Math::Matrix4& bindShapeMatrix);
        _Math::Matrix4 GetBindShapeMatrix(void) const;
 
        result SetJointWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName, float weightValue);
+       float GetWeight(unsigned int vertexIndex, const Tizen::Base::String& jointName);
 
        result Construct(void);
 
@@ -77,6 +84,8 @@ public:
        result GetJointKeyFrame(const Tizen::Base::String& jointName, unsigned int index, float& time, _Math::Matrix4& value) const;
 
        result StartAnimation(void);
+       result StartAnimation(float startAnimationTime);
+       result StartAnimation(float startAnimationTime, float endAnimationTime);
        result StopAnimation(void);
        bool IsAnimating(void) const;
 
@@ -84,9 +93,12 @@ public:
        void SetGPUSkinning(bool value);
        void SetPhysicsControll(bool value);
        bool IsGpuSkinning(void) const;
+       bool GetPhysicsControll(void) const;
        unsigned int GetJointsCount(void) const;
        const float* GetMatricesPointer(void) const;
        const float* GetIdsPointer(void) const;
+       result SetIdsPointer(const float* value);
+       result SetWeightsPointer(const float* value);
        const float* GetWeightsPointer(void) const;
        Joints* GetJoints(void);
 
@@ -104,7 +116,7 @@ private:
        _JointImpl* __pRoot;
 
        Mesh* __pMesh;
-       //_MeshImpl* __pMeshImpl;
+       _MeshImpl* __pMeshImpl;
 
        _Math::Matrix4 __bindShapeMatrix;
        Joints __joints;
@@ -126,10 +138,17 @@ private:
 #endif
 
        bool __animationStarted;
-       double __animationDuration;
-       double __animationTime;
+       float __animationDuration;
+       float __animationTime;
+
+       float __endAnimationTime;
+
+       Tizen::Ui::Animations::_SkeletonModelProcessing::OrientedBoxes __orientedBoxes;
+       //Tizen::Ui::Animations::Physics::_Internal::Utils::_SkeletonModelProcessing::Indices __indicesOfOrientedBoxes;
+       Tizen::Ui::Animations::_SkeletonModelProcessing::Bones __bones;
 
        friend class MeshController;
+       friend class _VisualElementImpl;
 };
 
 }}}
index 2153a37..72f8675 100755 (executable)
@@ -47,8 +47,8 @@ private:
                static void GenerateSquareTexCoords(float* pSquareTexCoords);
        public:
                float* pSquareVertex;
+               float* pSquareNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pSquareIndex;
-               float* pSquareNormal;           
                float* pSquareTexCoord;
                static const int SQUARE_VERTEX_COUNT;
                static const int SQUARE_INDEX_COUNT;
@@ -75,8 +75,8 @@ private:
                static void GenerateTriangleTexCoords(float* triangleTexCoords);
        public:
                float* pTriangleVertex;
+               float* pTriangleNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pTriangleIndex;
-               float* pTriangleNormal;         
                float* pTriangleTexCoord;
                static const int TRIANGLE_VERTEX_COUNT;
                static const int TRIANGLE_INDEX_COUNT;
@@ -102,8 +102,8 @@ private:
                static void GenerateSquareTextureCoord(float* pSquareTexCoords);
        public:
                float* pCubeVertex;
+               float* pCubeNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pCubeIndex;
-               float* pCubeNormal;             
                float* pCubeTexCoord;
                static const int CUBE_VERTEX_COUNT;
                static const int CUBE_INDEX_COUNT;
@@ -130,8 +130,8 @@ private:
                static void GeneratePyramidTextureCoord(float* pPyramidTexCoords);
        public:
                float* pPyramidVertex;
+               float* pPyramidNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pPyramidIndex;
-               float* pPyramidNormal;          
                float* pPyramidTexCoord;
                static const int PYRAMID_VERTEX_COUNT;
                static const int PYRAMID_INDEX_COUNT;
@@ -160,8 +160,8 @@ private:
                static void GenerateTruncPyramidTextureCoord(float* pSquareTexCoords);
        public:
                float* pTruncatedPyramidVertex;
+               float* pTruncatedPyramidNormals;
                Tizen::Ui::Animations::_MeshImpl::IndexType*    pTruncatedPyramidIndeces;
-               float* pTruncatedPyramidNormals;                
                float* pTruncatedPyramidTexCoords;
                static const int TRUNC_PYRAMID_VERTEX_COUNT;
                static const int TRUNC_PYRAMID_INDEX_COUNT;
@@ -188,8 +188,8 @@ private:
                static void GenerateCylinderTexCoords(float* pCylinderTexCoords);
        public:
                float* pCylinderVertex;
+               float* pCylinderNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pCylinderIndex;
-               float* pCylinderNormal;         
                float* pCylinderTexCoord;
                static const int CYLINDER_VERTEX_COUNT;
                static const int CYLINDER_INDEX_COUNT;
@@ -218,8 +218,8 @@ private:
                static void GenerateConiformTexCoords(float* pConiformTexCoords);
        public:
                float* pConiformVertex;
+               float* pConiformNormal;
                Tizen::Ui::Animations::_MeshImpl::IndexType* pConiformIndex;
-               float* pConiformNormal;         
                float* pConiformTexCoord;
                static const int CONIFORM_VERTEX_COUNT;
                static const int CONIFORM_INDEX_COUNT;
index 962b9f9..e553159 100644 (file)
@@ -22,6 +22,7 @@
  * This file contains implementation _MeshImpl class.
  */
 
+#include <stdio.h>
 #include <stdint.h>
 #include <string>
 #include <unique_ptr.h>
@@ -37,7 +38,7 @@
 #include "FUiAnim_VisualElementImpl.h"
 #include "FUiAnim_MeshImpl.h"
 #include <stdint.h>
-#include <string>
+//#include <string>
 
 #include "FUiAnim_MathMatrix4.h"
 
@@ -56,9 +57,9 @@ namespace Tizen { namespace Ui { namespace Animations {
 
 #define MESH_LOCK() _AutoMutex meshLock(*__pLock)
 
-//Header capacity =
-//{
-//};
+extern const int MAJOR_VERSION;
+extern const int MINOR_VERSION;
+extern const int RELEASE;
 
 void
 Header::SetMeshArrays(const _MeshImpl& rhs)
@@ -68,6 +69,7 @@ Header::SetMeshArrays(const _MeshImpl& rhs)
        isTextureCoordinateEnabled = rhs.IsTextureCoordinateEnabled();
        isColorEnabled = rhs.IsColorEnabled();
        isNormalEnabled = rhs.IsNormalEnabled();
+       isMeshController = (rhs.GetMeshControllerImpl() != null)?1:0;
 }
 
 _MeshImpl*
@@ -116,7 +118,7 @@ void
 _MeshImpl::Clear(void)
 {
        MESH_LOCK();
-#define FREE( __POINTER)if( __POINTER) delete __POINTER; __POINTER = null
+#define FREE( __POINTER)       if( __POINTER) delete __POINTER; __POINTER = null
        FREE(__pVertices);
        FREE(__pTexCoordinates);
        FREE(__pColors);
@@ -139,8 +141,6 @@ _MeshImpl::Clear(void)
        return ;
 }
 
-
-
 result
 _MeshImpl::AllocVertices(int count)
 {
@@ -162,7 +162,6 @@ _MeshImpl::AllocVertices(int count)
     return E_SUCCESS;
 }
 
-
 result
 _MeshImpl::AllocTextureCoordinates(void)
 {
@@ -259,7 +258,6 @@ _MeshImpl::AllocIndices(int count)
                return E_OUT_OF_MEMORY;
 }
 
-
 result
 _MeshImpl::SetVertex(int arrayIndex, const FloatPoint3& vertex)
 {
@@ -284,7 +282,6 @@ _MeshImpl::SetVertex(int arrayIndex, const FloatPoint3& vertex)
        return E_SUCCESS;
 }
 
-
 result
 _MeshImpl::SetTextureCoord(int arrayIndex, const FloatPoint& textureCoord)
 {
@@ -382,10 +379,10 @@ _MeshImpl::GetVertex(int arrayIndex) const
 {
     FloatPoint3 point(0.0f, 0.0f, 0.0f);
 
-    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
+    SysTryReturn(NID_UI_ANIM, __pVertices != null, point, E_INVALID_STATE, "%s Vertices haven't been allocated(%i, %i)",GetErrorMessage(E_INVALID_STATE), arrayIndex, __countOfAllocatedVertex );
 
+    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
     SysTryReturn(NID_UI_ANIM, arrayIndexState, point, E_INVALID_ARG, "%s Index is out of range(%d, %d)", GetErrorMessage(E_INVALID_ARG), arrayIndex, __countOfAllocatedVertex);
-    SysTryReturn(NID_UI_ANIM, __pVertices != null, point, E_INVALID_STATE, "%s Vertices haven't been allocated(%i, %i)",GetErrorMessage(E_INVALID_STATE), arrayIndex, __countOfAllocatedVertex );
 
        point.x = __pVertices[arrayIndex * APPROPRIATE_COUNT_VERTICES];
        point.y = __pVertices[arrayIndex * APPROPRIATE_COUNT_VERTICES + 1];
@@ -399,10 +396,10 @@ _MeshImpl::GetTextureCoord(int arrayIndex) const
 {
     FloatPoint point(0.0f, 0.0f);
 
-    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
+    SysTryReturn(NID_UI_ANIM, __pTexCoordinates != null, point, E_INVALID_STATE, "%s TexCoordinates haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
+    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
     SysTryReturn(NID_UI_ANIM, arrayIndexState, point, E_INVALID_ARG, "%s Index is out of range(%d, %d)", GetErrorMessage(E_INVALID_ARG), arrayIndex, __countOfAllocatedVertex);
-    SysTryReturn(NID_UI_ANIM, __pTexCoordinates != null, point, E_INVALID_STATE, "%s TexCoordinates haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
        point.x = __pTexCoordinates[arrayIndex * APPROPRIATE_COUNT_TEXTCOORDINATES];
        point.y = __pTexCoordinates[arrayIndex * APPROPRIATE_COUNT_TEXTCOORDINATES+1];
@@ -415,10 +412,10 @@ _MeshImpl::GetNormal(int arrayIndex) const
 {
     FloatPoint3 point(0.0f, 0.0f, 0.0f);
 
-       bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
+    SysTryReturn(NID_UI_ANIM, __pNormals != null, point, E_INVALID_STATE, "%s Normals haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
+       bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
     SysTryReturn(NID_UI_ANIM, arrayIndexState, point, E_INVALID_ARG, "%s Index is out of range(%d, %d)", GetErrorMessage(E_INVALID_ARG), arrayIndex, __countOfAllocatedVertex);
-    SysTryReturn(NID_UI_ANIM, __pNormals != null, point, E_INVALID_STATE, "%s Normals haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
        point.x = __pNormals[arrayIndex * APPROPRIATE_COUNT_NORMALS];
        point.y = __pNormals[arrayIndex * APPROPRIATE_COUNT_NORMALS + 1];
@@ -432,10 +429,10 @@ _MeshImpl::GetColor(int arrayIndex) const
 {
     Color color;
 
-    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
+    SysTryReturn(NID_UI_ANIM, __pColors != null, color, E_INVALID_STATE, "%s Colors haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
+    bool arrayIndexState = ((arrayIndex < __countOfAllocatedVertex) && (arrayIndex >= 0));
     SysTryReturn(NID_UI_ANIM, arrayIndexState, color, E_INVALID_ARG, "%s Index out of range(%d, %d)", GetErrorMessage(E_INVALID_ARG), arrayIndex, __countOfAllocatedVertex);
-    SysTryReturn(NID_UI_ANIM, __pColors != null, color, E_INVALID_STATE, "%s Colors haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
        color.SetRed    (__pColors[arrayIndex * APPROPRIATE_COUNT_COLORS]     * 255.0f);
        color.SetGreen  (__pColors[arrayIndex * APPROPRIATE_COUNT_COLORS + 1] * 255.0f);
@@ -446,11 +443,12 @@ _MeshImpl::GetColor(int arrayIndex) const
 
 int
 _MeshImpl::GetIndex(int arrayIndex) const
-{
-       bool arrayIndexState = ((arrayIndex < __countOfAllocatedIndex) && (arrayIndex >= 0));
+{      
+       
+       SysTryReturn(NID_UI_ANIM, __pIndices != null, 0, E_INVALID_STATE, "%s Indices haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
+       bool arrayIndexState = ((arrayIndex < __countOfAllocatedIndex) && (arrayIndex >= 0));
        SysTryReturn(NID_UI_ANIM, arrayIndexState, 0, E_INVALID_ARG, "%s Index out of range(%d, %d)", GetErrorMessage(E_INVALID_ARG), arrayIndex, __countOfAllocatedIndex);
-       SysTryReturn(NID_UI_ANIM, __pIndices != null, 0, E_INVALID_STATE, "%s Indices haven't been allocated", GetErrorMessage(E_INVALID_STATE));
 
     return __pIndices[arrayIndex];
 }
@@ -502,19 +500,144 @@ _MeshImpl::GetBoundingVolume(void) const
        return __boundingVolume;
 }
 
+std::string
+_MeshImpl::WideToStd(const Tizen::Base::String tizenString)
+{
+       std::wstring wStr(tizenString.GetPointer());
+       std::string str(wStr.begin(), wStr.end());
+       return str;
+}
+
+result
+_MeshImpl::LoadMeshController(FILE* pFile, _MeshControllerImpl* pMeshControllerImpl)
+{
+       uint32_t intsData;
+       uint32_t arraySizeJoint;
+       Tizen::Base::String tizenStringJointName;
+       Tizen::Base::String tizenStringParentName;
+       _Math::Matrix4 jointsLocalMatrix;
+       _Math::Matrix4 jointsInvertedMatrix;
+       float jointData[MATRIX4_SIZE];
+       float* jointIDsWeightArray;
+       char* charJointName;
+
+       SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Raed __local matrix
+       jointsLocalMatrix.Set(jointData);
+
+       SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Raed __invBindMatrix matrix
+
+       jointsInvertedMatrix.Set(jointData);
+
+       SysTryReturnResult(NID_UI_ANIM, fread (&intsData, sizeof(int32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read MeshController Joint's name size
+
+       charJointName = new (std::nothrow) char[intsData + 1];
+       SysTryReturnResult(NID_UI_ANIM,  charJointName != null, E_OUT_OF_MEMORY, "%s Memory allocation failed while reading  MeshController Root's name", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnResult(NID_UI_ANIM, fread (charJointName, 1, intsData, pFile) == intsData, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+
+       charJointName[intsData] = '\0';
+       tizenStringJointName = charJointName;
+       delete[] charJointName;
+       charJointName = null;
+       pMeshControllerImpl->AddJoint("", tizenStringJointName, jointsLocalMatrix, jointsInvertedMatrix); //Set joints
+
+       SysTryReturnResult(NID_UI_ANIM, fread(&jointData[0], sizeof(float), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Write __animationDuration to file
+       pMeshControllerImpl->SetAnimationDuration(jointData[0]);
+
+       SysTryReturnResult(NID_UI_ANIM, fread(&arraySizeJoint, sizeof(uint32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read KeyFrame size to file
+       for (int j = 0; j < arraySizeJoint; ++j)
+       {
+               SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Write KeyFrame matrixValue
+               jointsLocalMatrix.Set(jointData);
+
+               SysTryReturnResult(NID_UI_ANIM, fread(&jointData[0], sizeof(float), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Write KeyFrame _time
+               pMeshControllerImpl->AddKeyFrame(tizenStringJointName, jointData[0], jointsLocalMatrix);
+       }
+
+       SysTryReturnResult(NID_UI_ANIM, fread(&arraySizeJoint, sizeof(uint32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read Joints size
+       SysTryReturnResult(NID_UI_ANIM, arraySizeJoint > 0, E_OPERATION_FAILED, "%s. Propagating", GetErrorMessage(E_OPERATION_FAILED));
+
+       for (int count = 1; count < arraySizeJoint; ++count)
+       {
+               SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Raed __local matrix
+               jointsLocalMatrix.Set(jointData);
+
+               SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Raed __invBindMatrix matrix
+               jointsInvertedMatrix.Set(jointData);
+
+               SysTryReturnResult(NID_UI_ANIM, fread (&intsData, sizeof(int32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read MeshController Joint's name size
+               charJointName = new (std::nothrow) char[intsData + 1];
+               SysTryReturnResult(NID_UI_ANIM,  charJointName != null, E_OUT_OF_MEMORY, "%s Memory allocation failed while reading  MeshController Root's name", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturnResult(NID_UI_ANIM, fread (charJointName, 1, intsData, pFile) == intsData, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+               charJointName[intsData] = '\0';
+               tizenStringJointName = charJointName;
+               delete[] charJointName;
+               charJointName = null;
+
+               SysTryReturnResult(NID_UI_ANIM, fread (&intsData, sizeof(int32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read MeshController Parent's name size
+               charJointName = new (std::nothrow) char[intsData + 1];
+               SysTryReturnResult(NID_UI_ANIM,  charJointName != null, E_OUT_OF_MEMORY, "%s Memory allocation failed while reading  MeshController Child's name", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturnResult(NID_UI_ANIM, fread (charJointName, 1, intsData, pFile) == intsData, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+               charJointName[intsData] = '\0';
+               tizenStringParentName = charJointName;
+               delete[] charJointName;
+               charJointName = null;
+
+               pMeshControllerImpl->AddJoint(tizenStringParentName, tizenStringJointName, jointsLocalMatrix, jointsInvertedMatrix); //Set joints
+
+               SysTryReturnResult(NID_UI_ANIM, fread(&intsData, sizeof(uint32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read KeyFrame size to file
+               for (int j = 0; j < intsData; ++j)
+               {
+                       SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Write KeyFrame matrixValue
+                       jointsLocalMatrix.Set(jointData);
+
+                       SysTryReturnResult(NID_UI_ANIM, fread(&jointData[0], sizeof(float), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Write KeyFrame _time
+                       pMeshControllerImpl->AddKeyFrame(tizenStringJointName, jointData[0], jointsLocalMatrix);
+               }
+       }
+
+       SysTryReturnResult(NID_UI_ANIM, fread(jointData, sizeof(float), MATRIX4_SIZE, pFile) == MATRIX4_SIZE, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Raed __bindShapeMatrix
+       jointsLocalMatrix.Set(jointData);
+
+       pMeshControllerImpl->SetBindShapeMatrix(jointsLocalMatrix);//Set __bindShapeMatrix
+
+       intsData = pMeshControllerImpl->GetMesh()->GetVertexCount() * 4;
+       jointIDsWeightArray = new (std::nothrow) float[intsData];
+       SysTryReturnResult(NID_UI_ANIM, jointIDsWeightArray != null, E_OUT_OF_MEMORY, "%s. Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnResult(NID_UI_ANIM, fread(jointIDsWeightArray, sizeof(float), intsData, pFile) == intsData, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read __pIDs to file
+       pMeshControllerImpl->SetIdsPointer(jointIDsWeightArray); //Set __pIDs to file
+
+       SysTryReturnResult(NID_UI_ANIM, fread(jointIDsWeightArray, sizeof(float), intsData, pFile) == intsData, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); //Read __pWeights to file
+       pMeshControllerImpl->SetWeightsPointer(jointIDsWeightArray); //Set __pWeights to file
+       delete[] jointIDsWeightArray;
+       jointIDsWeightArray = null;
+
+       SysTryReturnResult(NID_UI_ANIM, fread(&intsData, sizeof(uint32_t), 1, pFile) == 1, E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA)); // Read __physicsControll to file
+       pMeshControllerImpl->SetPhysicsControll(static_cast<bool>(intsData));
+
+       pMeshControllerImpl->Construct();
+       return E_SUCCESS;
+}
+
 Mesh*
-_MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
+_MeshImpl::LoadMeshN(const Tizen::Base::String& fileName, bool loadWithoutController)
  {
        result r;
-       int quantityReadFromFile;
        int32_t intsData;
        char* charNameMesh;
+       MeshController* pMeshController;
+       _MeshControllerImpl* pMeshControllerImpl;
+
+       //Local Program Version Variables
+       int32_t majorVersion;
+       int32_t minorVersion;
+       int32_t release;
+       //------------------------
 
        FILE* pFile;
        std::wstring wStr(fileName.GetPointer());
        std::string str(wStr.begin(), wStr.end());
 
-       pFile = fopen(str.c_str(), "r");
+       pFile = fopen(str.c_str(), "rb");
        SysTryReturn(NID_UI_ANIM, pFile != null, null, E_INVALID_ARG, "%s Error occurred while opening file for reading: %s", GetErrorMessage(E_INVALID_ARG), str.c_str());
 
        _MeshImpl* pMeshImpl;
@@ -525,13 +648,19 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
 
        Header localCapacity;
 
-       quantityReadFromFile = fread(&localCapacity, sizeof(localCapacity), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread(&localCapacity, sizeof(localCapacity), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
 
-       quantityReadFromFile += fread(&pMeshImpl->__countOfAllocatedVertex, sizeof(int32_t), 1, pFile);
+       //Reading Current Program Version
+       SysTryCatch(NID_UI_ANIM, fread(&majorVersion, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+       SysTryCatch(NID_UI_ANIM, fread(&minorVersion, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+       SysTryCatch(NID_UI_ANIM, fread(&release, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+       //-------------------------------
 
-       quantityReadFromFile += fread(&pMeshImpl->__countOfAllocatedIndex, sizeof(int32_t), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__countOfAllocatedVertex, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
 
-       quantityReadFromFile += fread(&intsData, sizeof(int32_t), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__countOfAllocatedIndex, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
+
+       SysTryCatch(NID_UI_ANIM, fread(&intsData, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        pMeshImpl->__geoType = static_cast<Mesh::GeometryType> (intsData);
 
        if (localCapacity.isVerticesEnabled)
@@ -539,7 +668,7 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
                r  = pMeshImpl->AllocVertices(pMeshImpl->__countOfAllocatedVertex);
                SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
                intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_VERTICES);
-               quantityReadFromFile += fread(&pMeshImpl->__pVertices[0], sizeof(float), intsData, pFile);
+               SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__pVertices[0], sizeof(float), intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        }
        else
        {
@@ -553,7 +682,7 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
                r = pMeshImpl->AllocColors();
                SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
                intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_COLORS);
-               quantityReadFromFile += fread(&pMeshImpl->__pColors[0], sizeof(float), intsData, pFile);
+               SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__pColors[0], sizeof(float), intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        }
 
        if (localCapacity.isNormalEnabled)
@@ -561,7 +690,7 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
                r = pMeshImpl->AllocNormals();
                SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
                intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_NORMALS);
-               quantityReadFromFile += fread(&pMeshImpl->__pNormals[0], sizeof(float), intsData, pFile);
+               SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__pNormals[0], sizeof(float), intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        }
 
        if (localCapacity.isTextureCoordinateEnabled)
@@ -569,30 +698,40 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
                r = pMeshImpl->AllocTextureCoordinates();
                SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
                intsData = pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_TEXTCOORDINATES;
-               quantityReadFromFile += fread(&pMeshImpl->__pTexCoordinates[0], sizeof(float), intsData, pFile);
+               SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__pTexCoordinates[0], sizeof(float), intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        }
 
-       quantityReadFromFile += fread(&pMeshImpl->__countOfIndex, sizeof(int32_t), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__countOfIndex, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
 
        if (localCapacity.isIndexEnabled)
        {
                r = pMeshImpl->AllocIndices(pMeshImpl->__countOfAllocatedIndex);
                SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
                intsData = pMeshImpl->__countOfAllocatedIndex;
-               quantityReadFromFile += fread(&pMeshImpl->__pIndices[0], sizeof(uint16_t), intsData, pFile);
+               SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__pIndices[0], sizeof(uint16_t), intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        }
 
-       quantityReadFromFile += fread(&pMeshImpl->__countOfVertex, sizeof(int32_t), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread(&pMeshImpl->__countOfVertex, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
 
-       quantityReadFromFile += fread (&intsData, sizeof(int32_t), 1, pFile);
+       SysTryCatch(NID_UI_ANIM, fread (&intsData, sizeof(int32_t), 1, pFile) == 1, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        charNameMesh = new (std::nothrow) char[intsData + 1];
        SysTryCatch(NID_UI_ANIM, charNameMesh != null, , E_OUT_OF_MEMORY, "%s Memory allocation failed while reading Mesh name: %s", GetErrorMessage(E_OUT_OF_MEMORY), str.c_str());
-       quantityReadFromFile += fread (charNameMesh, 1, intsData, pFile);
+       SysTryCatch(NID_UI_ANIM, fread (charNameMesh, 1, intsData, pFile) == intsData, , E_INVALID_DATA, "%s. The requested data to read from file is invalid", GetErrorMessage(E_INVALID_DATA));
        charNameMesh[intsData] = '\0';
        pMeshImpl->__name.assign(charNameMesh, intsData);
        delete[] charNameMesh;
        charNameMesh = null;
 
+       if (localCapacity.isMeshController && (!loadWithoutController))
+       {
+               pMeshController = pMesh->CreateMeshController();
+               SysTryCatch(NID_UI_ANIM, pMeshController != null, ,E_OUT_OF_MEMORY, "%s. Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+               pMeshControllerImpl = pMeshImpl->GetMeshControllerImpl();
+
+               r = _MeshImpl::LoadMeshController(pFile, pMeshControllerImpl);
+               SysTryCatch(NID_UI_ANIM,  r == E_SUCCESS, ,E_OUT_OF_MEMORY, "%s Memory allocation failed while reading MeshController", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
        fclose(pFile);
        return pMesh;
 
@@ -601,7 +740,84 @@ _MeshImpl::LoadMeshN(const Tizen::Base::String& fileName)
                pMesh = null;
                fclose(pFile);
                return null;
+}
+
+result
+_MeshImpl::SaveMeshController(FILE* pFile)
+{
+       int quantityWriteToFile;
+       float animDuration;
+       uint32_t intsData;
+       uint32_t arraySizeJoint;
+       std::string stdStringJointName;
+       _Math::Matrix4 _valueKeyFrame;
 
+       _MeshControllerImpl::Joints& joints = *GetMeshControllerImpl()->GetJoints();
+
+       quantityWriteToFile = fwrite(joints[0]->GetLocal().GetPointer(), sizeof(float), MATRIX4_SIZE, pFile);
+
+       quantityWriteToFile = fwrite(joints[0]->GetInvertBindMatrix().GetPointer(), sizeof(float), MATRIX4_SIZE, pFile);
+
+       stdStringJointName = WideToStd(joints[0]->GetName());
+       intsData = stdStringJointName.size();
+       quantityWriteToFile += fwrite(&intsData, sizeof(uint32_t), 1, pFile);//MeshController Joints's name size
+       quantityWriteToFile += fwrite(stdStringJointName.c_str(), 1, intsData, pFile);//Write MeshController Joints's name to file
+
+       animDuration = GetMeshControllerImpl()->GetAnimationDuration();
+       quantityWriteToFile = fwrite(&animDuration, sizeof(float), 1, pFile); //Write __animationDuration to file
+
+       arraySizeJoint = joints[0]->GetKeyFrameCount(); // KeyFrame size
+       quantityWriteToFile += fwrite(&arraySizeJoint, sizeof(uint32_t), 1, pFile); //Write KeyFrame size to file
+       for (int j = 0; j < arraySizeJoint; ++j)
+       {
+               joints[0]->GetKeyFrame(j, animDuration, _valueKeyFrame);
+               quantityWriteToFile += fwrite(_valueKeyFrame.GetPointer(), sizeof(float), MATRIX4_SIZE, pFile); //Write KeyFrame matrixValue
+
+               quantityWriteToFile += fwrite(&animDuration, sizeof(float), 1, pFile); //Write KeyFrame _time
+       }
+
+       arraySizeJoint = GetMeshControllerImpl()->GetJointsCount(); //Joints size
+       SysTryReturnResult(NID_UI_ANIM, arraySizeJoint > 0, E_OPERATION_FAILED, "%s. Propagating", GetErrorMessage(E_OPERATION_FAILED));
+       quantityWriteToFile += fwrite(&arraySizeJoint, sizeof(uint32_t), 1, pFile); //Write Joint size
+
+       for (int count = 1; count < arraySizeJoint; ++count)
+       {
+               quantityWriteToFile = fwrite(joints[count]->GetLocal().GetPointer(), sizeof(float), MATRIX4_SIZE, pFile);
+
+               quantityWriteToFile = fwrite(joints[count]->GetInvertBindMatrix().GetPointer(), sizeof(float), MATRIX4_SIZE, pFile);
+
+               stdStringJointName = WideToStd(joints[count]->GetName());
+               intsData = stdStringJointName.size();
+               quantityWriteToFile += fwrite(&intsData, sizeof(uint32_t), 1, pFile);//MeshController Joints's name size
+               quantityWriteToFile += fwrite(stdStringJointName.c_str(), 1, intsData, pFile);//Write MeshController Joints's name to file
+
+               stdStringJointName = WideToStd(joints[count]->GetParent()->GetName());
+               intsData = stdStringJointName.size();
+               quantityWriteToFile += fwrite(&intsData, sizeof(uint32_t), 1, pFile);//MeshController Parents's name size
+               quantityWriteToFile += fwrite(stdStringJointName.c_str(), 1, intsData, pFile);//Write MeshController Parents's name to file
+
+               intsData = joints[count]->GetKeyFrameCount(); // KeyFrame size
+               quantityWriteToFile += fwrite(&intsData, sizeof(uint32_t), 1, pFile); //Write KeyFrame size to file
+               for (int j = 0; j < intsData; ++j)
+               {
+                       joints[count]->GetKeyFrame(j, animDuration, _valueKeyFrame);
+                       quantityWriteToFile += fwrite(_valueKeyFrame.GetPointer(), sizeof(float), MATRIX4_SIZE, pFile); //Write KeyFrame matrixValue
+
+                       quantityWriteToFile += fwrite(&animDuration, sizeof(float), 1, pFile); //Write KeyFrame _time
+               }
+       }
+
+       quantityWriteToFile = fwrite(GetMeshControllerImpl()->GetBindShapeMatrix().GetPointer(), sizeof(float), MATRIX4_SIZE, pFile);//Write __bindShapeMatrix to file
+
+       intsData = GetCountOfVertices() * APPROPRIATE_COUNT_COLORS;
+       quantityWriteToFile = fwrite(GetMeshControllerImpl()->GetIdsPointer(), sizeof(float), intsData, pFile); //Write __pIDs to file
+
+       quantityWriteToFile = fwrite(GetMeshControllerImpl()->GetWeightsPointer(), sizeof(float), intsData, pFile); //Write __pWeights to file
+
+       intsData = ((GetMeshControllerImpl()->GetPhysicsControll())?1:0);
+       quantityWriteToFile = fwrite(&intsData, sizeof(uint32_t), 1, pFile);// Write __physicsControll to file
+
+       return E_SUCCESS;
 }
 
 result
@@ -616,7 +832,7 @@ _MeshImpl::SaveMesh(const Tizen::Base::String& fileName)
        std::wstring wStr(fileName.GetPointer());
        std::string str(wStr.begin(), wStr.end());
 
-       pFile = fopen(str.c_str(), "w");
+       pFile = fopen(str.c_str(), "wb");
        r = E_OPERATION_FAILED;
        SysTryReturn(NID_UI_ANIM, pFile != null, r, r, "%s Error occurred while saving Mesh to file: %s", GetErrorMessage(r), str.c_str());
 
@@ -625,6 +841,11 @@ _MeshImpl::SaveMesh(const Tizen::Base::String& fileName)
 
        quantityWriteToFile = fwrite(&capacity, sizeof(capacity), 1, pFile);
 
+       // Saving Program Version
+       quantityWriteToFile += fwrite(&MAJOR_VERSION, sizeof(int32_t), 1, pFile);
+       quantityWriteToFile += fwrite(&MINOR_VERSION, sizeof(int32_t), 1, pFile);
+       quantityWriteToFile += fwrite(&RELEASE, sizeof(int32_t), 1, pFile);
+
        intsData = __countOfAllocatedVertex;
        quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
 
@@ -673,8 +894,16 @@ _MeshImpl::SaveMesh(const Tizen::Base::String& fileName)
        quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
        quantityWriteToFile += fwrite(__name.c_str(), 1, intsData, pFile);
 
+       if (capacity.isMeshController)
+       {
+               r = SaveMeshController(pFile);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "%s. MeshController wasn't saved", GetErrorMessage(E_OPERATION_FAILED));
+               }
+       }
+
        fclose(pFile);
-       AppLog("SaveMesh completed debug");
        return E_SUCCESS;
 
        CATCH:
@@ -683,7 +912,7 @@ _MeshImpl::SaveMesh(const Tizen::Base::String& fileName)
 }
 
 MeshController*
-_MeshImpl::CreateMeshController()
+_MeshImpl::CreateMeshController(void)
 {
        SysTryReturn(NID_UI_ANIM, __pMeshController == null, __pMeshController, E_ALREADY_SET, "MeshController is already created!") //TODO: check english
 
@@ -700,7 +929,7 @@ _MeshImpl::GetMeshController(void)
 }
 
 _MeshControllerImpl*
-_MeshImpl::GetMeshControllerImpl(void)
+_MeshImpl::GetMeshControllerImpl(void) const
 {
        return (__pMeshController)?_MeshControllerImpl::GetInstance(*__pMeshController):null;
 }
index 67463f8..1d393cc 100644 (file)
 #include "FUiAnim_MathMatrix4.h"
 
 #include "FUiAnim_MaterialImpl.h"
+#include "FUiAnim_MaterialParser.h"
+#include "FUiAnim_LightParser.h"
+
 
 #include "FUiAnimShaderProgram.h" //tempo
 #include "FUiAnimShader.h" //tempo
 #include <FGrpFloatMatrix4.h> //tempo
 
 #include <map>
+#include <sstream>
+
+
 
 namespace Tizen { namespace Ui { namespace Animations {
 
+const int MAJOR_VERSION = 0;
+const int MINOR_VERSION = 1;
+const int RELEASE = 0;
+
 using namespace _ImportCollada;
 using namespace _ImportCollada::LibraryGeometries;
 using namespace _ImportCollada::LibraryImages;
 using namespace Graphics;
 
-static const char vs_TestSkinning[] =
-               "uniform mat4 u_mvp;\n"
-               "uniform mat4 u_inv_modelview;\n"
-               "attribute vec4 a_position;\n"
-               "attribute vec3 a_normal;\n"
-               "varying   vec3 v_normal;\n"
-
-               "attribute vec4 a_weights;\n"
-               "attribute vec4 a_joints_ids;\n"
-
-               "attribute vec2 a_texcoord;\n"
-               "varying   vec2 v_texcoord;\n"
-
-               "uniform mat4 u_joints_matrices[64];\n"
-
-               "vec4 GetPos(vec4 vert){\n"
-               "    mat4 matrix = u_joints_matrices[int(a_joints_ids[0])] * a_weights[0] +\n"
-               "                  u_joints_matrices[int(a_joints_ids[1])] * a_weights[1] +\n"
-               "                  u_joints_matrices[int(a_joints_ids[2])] * a_weights[2] +\n"
-               "                  u_joints_matrices[int(a_joints_ids[3])] * a_weights[3];\n"
-               "    return matrix * vert;\n"
-               "}\n"
-
-               "void main()\n"
-               "{\n"
-               "       v_texcoord = a_texcoord;\n"
-               "       v_normal = normalize(mat3(u_inv_modelview) * a_normal);\n"
-               "       gl_Position = u_mvp * GetPos(a_position);\n"
-               "}\n";
-
-static const char fs_TestSkinning[] =
-               "precision mediump float;\n"
-               "uniform sampler2D u_tex2d;\n"
-               "varying   vec3 v_normal;\n"
-               "varying   vec2 v_texcoord;\n"
-               "void main()\n"
-               "{\n"
-               "       vec3 col = texture2D(u_tex2d, v_texcoord).xyz * max(0, dot(v_normal, normalize(vec3(0, 0, 1))));\n"
-               "       gl_FragColor = vec4(col.zyx, 1);\n"
-               "}\n";
-
-static const char vs_TestRed[] =
-               "uniform mat4 u_mvp;\n"
-               "uniform mat4 u_inv_modelview;\n"
-               "attribute vec4 a_position;\n"
-               "attribute vec4 a_normal;\n"
-               "varying   vec4 v_normal;\n"
-               "void main()\n"
-               "{\n"
-               "       v_normal = normalize(u_inv_modelview * a_normal);\n"
-               "       gl_Position = u_mvp * a_position;\n"
-               "}\n";
-
-static const char fs_TestRed[] =
-               "precision mediump float;\n"
-               "varying   vec4 v_normal;\n"
-               "void main()\n"
-               "{\n"
-               "       vec3 col = vec3(0.5, 0.5, 0.5) * max(0, dot(normalize(v_normal.xyz), normalize(vec3(-1, -1, 0))));\n"
-               "       gl_FragColor = vec4(col, 1);\n"
-               "}\n";
-
-static const char vs_Test[] =
-       "uniform mat4 u_mvp;\n"
-       "uniform mat4 u_inv_modelview;\n"
-       "attribute vec4 a_position;\n"
-       "attribute vec4 a_normal;\n"
-       "varying   vec4 v_normal;\n"
-       "void main()\n"
-       "{\n"
-       "       v_normal = normalize(u_inv_modelview * a_normal);\n"
-       "       gl_Position = u_mvp * a_position;\n"
-       "}\n";
-
-static const char fs_Test[] =
-       "precision mediump float;\n"
-       "uniform vec4 u_materialdiffuse;\n"
-       "varying   vec4 v_normal;\n"
-       "void main()\n"
-       "{\n"
-       "       vec3 col = u_materialdiffuse.xyz * max(0, dot(normalize(v_normal.xyz), normalize(vec3(-1, -1, 0))));\n"
-       "       gl_FragColor = vec4(col, 1);\n"
-       "}\n";
-
-static const char vs_TestTexture[] =
-       "uniform mat4 u_mvp;\n"
-       "uniform mat4 u_inv_modelview;\n"
-       "attribute vec4 a_position;\n"
-       "attribute vec4 a_normal;\n"
-       "attribute vec2 a_texcoord;\n"
-
-       "varying   vec4 v_normal;\n"
-       "varying   vec2 v_texcoord;\n"
-       "void main()\n"
-       "{\n"
-       "       v_texcoord = a_texcoord;\n"
-       "       v_normal = normalize(u_inv_modelview * a_normal);\n"
-       "       gl_Position = u_mvp * a_position;\n"
-       "}\n";
-
-static const char fs_TestTexture[] =
-       "precision mediump float;\n"
-       "uniform sampler2D u_tex2d;\n"
-       "varying   vec4 v_normal;\n"
-       "varying   vec2 v_texcoord;\n"
-       "void main()\n"
-       "{\n"
-       "       vec3 col = texture2D(u_tex2d, v_texcoord).xyz * max(0, dot(normalize(v_normal.xyz), normalize(vec3(0, 0, -1))));\n"
-       "       gl_FragColor = vec4(col.zyx, 1);\n"
-       "}\n";
-
 struct Vertex
 {
        FloatPoint3 pos;
@@ -216,7 +115,6 @@ FloatPoint MathVector2ToFloatVector2(const  _Math::Vector2& vector)
        return result;
 }
 
-
 FloatMatrix4 MathMatrixToFloatMatrix(const _Math::Matrix4& matrix)
 {
        FloatMatrix4 result;
@@ -281,7 +179,8 @@ _ModelImporterImpl::_ModelImporterImpl(const std::string& fileName, bool visualS
        return;
 }
 
-_ModelImporterImpl::~_ModelImporterImpl(void) {
+_ModelImporterImpl::~_ModelImporterImpl(void)
+{
        if (colladaAssets != null)
        {
                delete colladaAssets;
@@ -291,34 +190,22 @@ _ModelImporterImpl::~_ModelImporterImpl(void) {
 }
 
 _Math::Matrix4
-_ModelImporterImpl::UseUpAxis(const _Math::Matrix4& matrix, bool inversed)
+_ModelImporterImpl::UseUpAxis(const _Math::Matrix4& matrix)
 {
        if (colladaAssets != null)
        {
                if (colladaAssets->upAxis == ColladaAssets::X_UP)
                {
-                       if (inversed)
-                       {
-                               return matrix * xUp.GetInversed();      
-                       }
                        return xUp * matrix;
                }
 
                if (colladaAssets->upAxis == ColladaAssets::Y_UP)
                {
-                       if (inversed)
-                       {
-                               return matrix * yUp.GetInversed();      
-                       }
-                       return yUp * matrix;
+                       return  yUp * matrix;
                }
 
                if (colladaAssets->upAxis == ColladaAssets::Z_UP)
                {
-                       if (inversed)
-                       {
-                               return  matrix * zUp.GetInversed();     
-                       }
                        return zUp * matrix;
                }
        }
@@ -350,17 +237,30 @@ _ModelImporterImpl::ApplyUpAxis(Mesh& mesh)
                for (int i = 0; i < mesh.GetVertexCount(); i++)
                {
                        FloatPoint3 vec4(mesh.GetVertex(i));
-                       _Math::Vector4 point(vec4.x, vec4.y, vec4.z, 1);
+                       _Math::Vector4 point(vec4.x, vec4.y, vec4.z, 1.0f);
 
                        point = upAxisMatrix * point;
 
                        FloatPoint3 vec3(point.x, point.y, point.z);
                        mesh.SetVertex(i, vec3);
                }
+
+               if (mesh.IsNormalEnabled())
+               {
+                       for (int i = 0; i < mesh.GetVertexCount(); i++)
+                       {
+                               FloatPoint3 vec4(mesh.GetNormal(i));
+                               _Math::Vector4 point(vec4.x, vec4.y, vec4.z, 0.0f);
+
+                               point = upAxisMatrix * point;
+
+                               FloatPoint3 vec3(point.x, point.y, point.z);
+                               mesh.SetNormal(i, vec3);
+                       }
+               }
        }
 }
 
-
 void
 _ModelImporterImpl::LoadMesh(Mesh& pMesh, GeometryMesh::Indexes& VertexIndices, _Math::Vector3* vertices, ColladaIndices* colladaIndices)
 {
@@ -496,7 +396,6 @@ _ModelImporterImpl::LoadMesh(Mesh& pMesh, GeometryMesh::Indexes& VertexIndices,
 
        //Vertices & Normals
        pMesh.ReserveVertices(listVertices.size());
-//     pMesh.ReserveNormals();
        unsigned int index = 0;
        for (std::list<Vertex>::iterator i = listVertices.begin(); i != listVertices.end(); i++, index++)
        {
@@ -626,8 +525,6 @@ _ModelImporterImpl::LoadMesh(Mesh& pMesh, GeometryMesh::Indexes& VertexIndices,
 
        //Vertices & Normals & Texture Coordinates
        pMesh.ReserveVertices(listVertices.size());
-//     pMesh.ReserveNormals();
-//     pMesh.ReserveTextureCoordinates();
        unsigned int index = 0;
        for (std::list<Vertex>::iterator i = listVertices.begin(); i != listVertices.end(); i++, index++)
        {
@@ -680,7 +577,7 @@ _ModelImporterImpl::LoadMeshCollada(const std::string& modelName, std::string& m
        Mesh* pMesh = new (std::nothrow) Mesh();
        SysTryReturn(NID_UI_ANIM, pMesh != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
 
-       pMesh->SetName(Tizen::Base::String(modelName.c_str()));
+       pMesh->SetName(modelName.c_str());
        pMesh->SetGeometryType(Mesh::GEO_TYPE_TRIANGLES);
 
        if (normals == null)
@@ -703,27 +600,194 @@ _ModelImporterImpl::LoadMeshCollada(const std::string& modelName, std::string& m
 }
 
 Mesh*
-_ModelImporterImpl::LoadMeshN(const Tizen::Base::String& fileName)
+_ModelImporterImpl::LoadMeshN(const Tizen::Base::String& fileName, bool loadWithoutController)
 {
        AppLog("LoadBin...");
-       Mesh* pMesh = _MeshImpl::LoadMeshN(fileName);
+       Mesh* pMesh = _MeshImpl::LoadMeshN(fileName, loadWithoutController);
        AppLog("Return mesh!!!!");
        return pMesh;
 }
 
+Mesh*
+_ModelImporterImpl::LoadMeshWithControllerCollada(const std::string& modelName)
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryControllers != null, null, E_INVALID_DATA, "pLibraryControllers: not parsed.");
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryGeometries != null, null, E_INVALID_DATA, "pLibraryGeometries: not parsed.");
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryVisualScenes != null, null, E_INVALID_DATA, "pLibraryVisualScenes: not parsed.");
+
+       _ImportCollada::LibraryControllers::ControllerSkin* controller = null;
+
+       unsigned int controllerCount = colladaAssets->pLibraryControllers->GetControllersCount();
+       for (unsigned int i = 0; i < controllerCount; i++)
+       {
+               controller = dynamic_cast<_ImportCollada::LibraryControllers::ControllerSkin*>(colladaAssets->pLibraryControllers->GetControllerByNumber(i));
+
+               if ((modelName.size() <= 0) || (modelName.compare(controller->GetGeonetryID().c_str() + 1) == 0))
+               {
+                       const std::string& constrollerId = controller->GetId();
+                       unsigned int sceneCount = colladaAssets->pLibraryVisualScenes->GetSceneCount();
+                       for (unsigned int j = 0; j < sceneCount; j++)
+                       {
+                               LibraryVisualScenes::VisualScene* pScene = colladaAssets->pLibraryVisualScenes->GetSceneByNumb(j);
+
+                               LibraryVisualScenes::Instance* pInstance = pScene->GetInstanceByUrl(constrollerId);
+                               if ((pInstance != null) && (pInstance->GetType() == LibraryVisualScenes::Instance::CONTROLLER))
+                               {
+                                       LibraryVisualScenes::InstanceController* pInstanceController = dynamic_cast<LibraryVisualScenes::InstanceController*>(pInstance);
+                                       std::string boneName(pInstanceController->GetRootBoneID(0).c_str() + 1);
+                                       LibraryVisualScenes::Node* pSceletonRootNode = pScene->GetFirstNode()->FindNode(boneName);
+
+                                       Mesh* pMesh;
+                                       CreateController(pInstanceController->GetUrl().c_str() + 1, pSceletonRootNode, &pMesh, true);
+
+                                       return pMesh;
+                               }
+                       }
+               }
+       }
+
+       return null;
+}
+
 Material*
-_ModelImporterImpl::LoadMaterial(const std::string& materialId, std::string& texureId, LibraryEffects::Effect::ShaderType& shaderType)
+_ModelImporterImpl::LoadMaterialN(const Tizen::Base::String& fileName)
 {
-       Material* pMaterial = new (std::nothrow) Material();
-       SysTryReturn(NID_UI_ANIM, pMaterial != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-       pMaterial->SetName(Tizen::Base::String(materialId.c_str()));
+       AppLog("LoadingXml...");
+       Material* pMaterial = _MaterialParser::LoadMaterialN(fileName);
+       return pMaterial;
+}
 
-       _MaterialImpl* pMaterialImpl = _MaterialImpl::GetInstance(*pMaterial);
+Light*
+_ModelImporterImpl::LoadLightN(const Tizen::Base::String& fileName)
+{
+       AppLog("LoadingXml...");
+       Light* pLight = _LightParser::LoadLightN(fileName);
+       return pLight;
+}
+
+Light*
+_ModelImporterImpl::LoadLightCollada(const std::string& lightId)
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryLights != null, null, E_INVALID_DATA, "pLibraryLights: not parsed.");
 
+       unsigned int count = colladaAssets->pLibraryLights->GetAbientsCount();
+
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryLights::Light* colladaLight = colladaAssets->pLibraryLights->GetAmbientByNumber(i);
+               if ((lightId.size() <= 0) || (lightId.compare(colladaLight->GetId().c_str()) == 0)){
+                       Light* light = new Light(); //TODO: SYSTRY
+                       light->SetAmbient(FloatVector4(colladaLight->GetR(), colladaLight->GetG(), colladaLight->GetB(), 1.0f));
+
+                       //light->SetType(Light::LIGHT_TYPE_AMBIENT); //?????????????
+                       light->SetName(lightId.c_str());
+
+                       return light;
+               }
+       }
+
+       count = colladaAssets->pLibraryLights->GetDirectionalsCount();
+       for (unsigned int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryLights::Light* colladaLight = colladaAssets->pLibraryLights->GetDirectionalByNumber(i);
+               if ((lightId.size() <= 0) || (lightId.compare(colladaLight->GetId().c_str()) == 0)){
+                       Light* light = new Light(); //TODO: SYSTRY
+                       light->SetDiffuse(FloatVector4(colladaLight->GetR(), colladaLight->GetG(), colladaLight->GetB(), 1.0f));
+                       light->SetDirection(FloatPoint3(0, 0, -1));
+
+                       light->SetType(Light::LIGHT_TYPE_DIRECTIONAL);
+                       light->SetName(lightId.c_str());
+                       return light;
+               }
+       }
+
+       count = colladaAssets->pLibraryLights->GetPointsCount();
+       for (unsigned int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryLights::Point* colladaLight = colladaAssets->pLibraryLights->GetPointByNumber(i);
+               if ((lightId.size() <= 0) || (lightId.compare(colladaLight->GetId().c_str()) == 0)){
+                       Light* light = new Light(); //TODO: SYSTRY
+                       light->SetDiffuse(FloatVector4(colladaLight->GetR(), colladaLight->GetG(), colladaLight->GetB(), 1.0f));
+
+                       light->SetConstantAttenuation(colladaLight->GetConstantAttenuation());
+                       light->SetLinearAttenuation(colladaLight->GetLinearAttenuation());
+                       light->SetQuadraticAttenuation(colladaLight->GetQuadraticAttenuation());
+
+                       light->SetType(Light::LIGHT_TYPE_POINT);
+                       light->SetName(lightId.c_str());
+                       return light;
+               }
+       }
+
+       count = colladaAssets->pLibraryLights->GetSpotsCount();
+       for (unsigned int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryLights::Spot* colladaLight = colladaAssets->pLibraryLights->GetSpotByNumber(i);
+               if ((lightId.size() <= 0) || (lightId.compare(colladaLight->GetId().c_str()) == 0)){
+                       Light* light = new Light(); //TODO: SYSTRY
+                       light->SetDiffuse(FloatVector4(colladaLight->GetR(), colladaLight->GetG(), colladaLight->GetB(), 1.0f));
+                       light->SetDirection(FloatPoint3(0, 0, -1));
+
+                       light->SetConstantAttenuation(colladaLight->GetConstantAttenuation());
+                       light->SetLinearAttenuation(colladaLight->GetLinearAttenuation());
+                       light->SetQuadraticAttenuation(colladaLight->GetQuadraticAttenuation());
+
+                       light->SetCutOff(colladaLight->GetFalloffAngle()); //TODO: Check: Same type?
+                       light->SetExponent(colladaLight->GetFalloffExponent());//TODO: Check: Same type?
+
+                       light->SetType(Light::LIGHT_TYPE_SPOT);
+                       light->SetName(lightId.c_str());
+                       return light;
+               }
+       }
+
+       return null;
+}
+
+Camera*
+_ModelImporterImpl::LoadCameraCollada(const std::string& cameraId)
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryCameras != null, null, E_INVALID_DATA, "pLibraryCameras: not parsed.");
+
+       _ImportCollada::LibraryCameras::Camera* cameraCollada = null;
+
+       if (cameraId.size() <= 0)
+       {
+               cameraCollada = colladaAssets->pLibraryCameras->GetCameraByNumb(0);
+       }
+       else
+       {
+               cameraCollada = colladaAssets->pLibraryCameras->GetCameraById(cameraId);
+       }
+
+       if (cameraCollada != null)
+       {
+               Camera* camera = null;
+
+               //TODO: create camera & set parameters!
+
+               return camera;
+       }
+
+       return null;
+}
+
+Material*
+_ModelImporterImpl::LoadMaterial(const std::string& materialId, std::string& texureId, LibraryEffects::Effect::ShaderType& shaderType)
+{
        SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryMaterials != null, null, E_INVALID_DATA, "LibraryMaterials: not parsed.");
        SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryEffects != null, null, E_INVALID_DATA, "LibraryEffects not parsed.");
 
-       _ImportCollada::LibraryMaterials::Material* pColladaMaterial = colladaAssets->pLibraryMaterials->GetMaterialById(materialId);
+       _ImportCollada::LibraryMaterials::Material* pColladaMaterial = null;
+       if (materialId.size() <= 0)
+       {
+               pColladaMaterial = colladaAssets->pLibraryMaterials->GetMaterialByNumber(0);
+       }
+       else
+       {
+               pColladaMaterial = colladaAssets->pLibraryMaterials->GetMaterialById(materialId);
+       }
        SysTryReturn(NID_UI_ANIM, pColladaMaterial != null, null, E_INVALID_DATA, "Material %s not found.", materialId.c_str());
 
        std::string effectName = pColladaMaterial->GetEffectName();
@@ -731,13 +795,19 @@ _ModelImporterImpl::LoadMaterial(const std::string& materialId, std::string& tex
        LibraryEffects::Effect* pColladaEffect = colladaAssets->pLibraryEffects->GetEffectById(effectName.c_str() + 1);
        SysTryReturn(NID_UI_ANIM, pColladaEffect != null, null, E_INVALID_DATA, "Effect '%s' not found.", effectName.c_str() + 1);
 
+       Material* pMaterial = new (std::nothrow) Material();
+       SysTryReturn(NID_UI_ANIM, pMaterial != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+       pMaterial->SetName(materialId.c_str());
+
+       _MaterialImpl* pMaterialImpl = _MaterialImpl::GetInstance(*pMaterial);
+
        //set data
-       pMaterialImpl->SetName(Tizen::Base::String(pColladaMaterial->GetEffectName().c_str()));
+       pMaterialImpl->SetName(pColladaMaterial->GetId().c_str());
 
-       pMaterialImpl->SetAmbient(pColladaEffect->GetAmbient().GetVector4().GetPointer());
-       pMaterialImpl->SetDiffuse(pColladaEffect->GetDiffuse().GetVector4().GetPointer());
-       pMaterialImpl->SetEmissive(pColladaEffect->GetEmissive().GetVector4().GetPointer());
-       pMaterialImpl->SetSpecular(pColladaEffect->GetSpecular().GetVector4().GetPointer());
+       pMaterialImpl->SetAmbient(pColladaEffect->GetAmbient().GetPointer());
+       pMaterialImpl->SetDiffuse(pColladaEffect->GetDiffuse().GetPointer());
+       pMaterialImpl->SetEmissive(pColladaEffect->GetEmissive().GetPointer());
+       pMaterialImpl->SetSpecular(pColladaEffect->GetSpecular().GetPointer());
 
        pMaterialImpl->SetShininess(pColladaEffect->GetShininess());
 
@@ -773,12 +843,20 @@ _ModelImporterImpl::LoadScene(const std::string& sceneId, VisualElement& pSceneR
        SysTryReturn(NID_UI_ANIM, pLibVisScene != null, null, E_INVALID_DATA, "Library of visual scenes was not parsed.");
        SysTryReturn(NID_UI_ANIM, pLibGeoms != null, null, E_INVALID_DATA, "Library of geometries was not parsed.");
 
-       LibraryVisualScenes::VisualScene* pVisScene = pLibVisScene->GetSceneByID(sceneId);
+       LibraryVisualScenes::VisualScene* pVisScene = null;
+       if (sceneId.size() <= 0)
+       {
+               pVisScene = pLibVisScene->GetSceneByNumb(0);
+       }
+       else
+       {
+               pVisScene = pLibVisScene->GetSceneByID(sceneId);
+       }
        SysTryReturn(NID_UI_ANIM, pVisScene != null, null, E_OBJ_NOT_FOUND, "Scene '%s' not found.", sceneId.c_str());
 
        Scene* pScene = new (std::nothrow) Scene();
        pScene->Construct(pSceneRootVisualElement);
-       pScene->SetName(Tizen::Base::String(sceneId.c_str()));
+       pScene->SetName(sceneId.c_str());
 
        LibraryVisualScenes::Node* pNode = pVisScene->GetFirstNode();
 
@@ -801,7 +879,6 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
        {
                _Math::Matrix4 globalMatrix;
                globalMatrix.Set(pNode->GetGlobalMatrix());
-               globalMatrix.Transpose();
 
                for (unsigned int i = 0; i < instancesCount; i++)
                {
@@ -819,48 +896,48 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
 
                                //===================================================================================Set global matrix
                                FloatMatrix4 floatMatrix4;
-                               memcpy(floatMatrix4.matrix, UseUpAxis(globalMatrix).m, sizeof(float) * 16);
-                               pVisElem->SetTransformMatrix(floatMatrix4);
+                               memcpy(floatMatrix4.matrix, UseUpAxis(globalMatrix).GetTransposed().m, sizeof(float) * 16);
+                               pVisElem->SetProperty(L"transform", floatMatrix4);
 
                                //===================================================================================Set mesh
                                std::string geomId(pInstanceGeometry->GetUrl().c_str() + 1);
                                std::string matId;
                                Mesh* pMesh = LoadMeshCollada(geomId, matId);
-                               ApplyUpAxis(*pMesh);
                                pVisElem->SetMesh(pMesh);
 
                                //===================================================================================SetMaterial
                                matId = pInstanceGeometry->pBindMaterial->GetTargetBySymbol(matId);
-                               std::string textureId;
-                               LibraryEffects::Effect::ShaderType shaderType;
-                               Material* pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
+                               int materialIndex = pScene->ContainsMaterial(matId.c_str() + 1);
+
+                               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)
                                {
+                                       pScene->AddMaterial(pMaterial);
                                        pVisElem->SetMaterial(pMaterial);
                                }
 
-                               //===================================================================================Set shader
-                               Shader vert;
-                               Shader frag;
+                               pScene->AddMesh(pMesh);
+
 
-                               if (textureId.compare("") == 0)
+                               if (pMesh != null)
                                {
-                                       vert.Construct(Shader::SHADER_VERTEX, vs_Test);
-                                       frag.Construct(Shader::SHADER_FRAGMENT, fs_Test);
+                                       delete pMesh;
+                                       pMesh = null;
                                }
-                               else
+
+                               if (pMaterial != null)
                                {
-                                       vert.Construct(Shader::SHADER_VERTEX, vs_TestTexture);
-                                       frag.Construct(Shader::SHADER_FRAGMENT, fs_TestTexture);
+                                       delete pMaterial;
+                                       pMaterial = null;
                                }
-
-                               ShaderProgram *pProgram = new ShaderProgram();
-                               pProgram->Construct(vert,frag);
-                               pVisElem->SetShaderProgram(pProgram);
-
-                               pScene->AddMesh(pMesh);
-                               delete pMesh;
-                               delete pMaterial;
                        }
 
                        if ((pInstance->GetType() == LibraryVisualScenes::Instance::CONTROLLER) && 1)
@@ -878,39 +955,23 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
                                LibraryVisualScenes::Node* pSceletonRootNode = pRootNode->FindNode(boneName);                           
 
                                //===================================================================================Set global matrix
-                               _Math::Matrix4 m = pSceletonRootNode->GetGlobalMatrix().GetTransposed();
-                               //globalMatrix = globalMatrix * m;
 
-                               FloatMatrix4 floatMatrix4;
-                               memcpy(floatMatrix4.matrix, m.m, sizeof(float) * 16);
-                               pVisElem->SetTransformMatrix(floatMatrix4);
+                               _Math::Matrix4 matrix;
+                               if (pSceletonRootNode->Parent() != null)
+                               {
+                                       matrix.Set(pSceletonRootNode->Parent()->GetGlobalMatrix());
+                               }
 
+                               FloatMatrix4 floatMatrix4;
+                               memcpy(floatMatrix4.matrix, UseUpAxis(matrix).GetTransposed().m, sizeof(float) * 16);
+                               pVisElem->SetProperty(L"transform", floatMatrix4);
 
                                //----------------------------------------------------------------------Controller
                                Mesh* pMesh;
-                               CreateController(pInstanceController->GetUrl().c_str() + 1, pSceletonRootNode, &pMesh);
+                               CreateController(pInstanceController->GetUrl().c_str() + 1, pSceletonRootNode, &pMesh, false);
                                
                                pVisElem->SetMesh(pMesh);
 
-                               // //shader
-                               // Shader vert;
-                               // Shader frag;
-
-                               // if (pMesh->GetMeshController()->IsGpuSkinning())
-                               // {
-                               //      vert.Construct(Shader::SHADER_VERTEX, vs_TestSkinning);
-                               //      frag.Construct(Shader::SHADER_FRAGMENT, fs_TestSkinning);
-                               // }
-                               // else
-                               // {
-                               //      vert.Construct(Shader::SHADER_VERTEX, vs_TestTexture);
-                               //      frag.Construct(Shader::SHADER_FRAGMENT, fs_TestTexture);
-                               // }
-
-                               // ShaderProgram *pProgram = new ShaderProgram();
-                               // pProgram->Construct(vert,frag);
-                               // pVisElem->SetShaderProgram(pProgram);
-
                                pScene->AddMesh(pMesh);
                                delete pMesh;
 
@@ -925,13 +986,18 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
 }
 
 void
-_ModelImporterImpl::CreateController(const std::string& controllerName, LibraryVisualScenes::Node* pSceletonRootNode, Mesh** ppMesh)
+_ModelImporterImpl::CreateController(const std::string& controllerName, LibraryVisualScenes::Node* pSceletonRootNode, Mesh** ppMesh, bool useUpAxis)
 {
        _MeshControllerImpl* pMeshControllerImpl = null;
 
        std::list<std::string> jointNames;
        _JointImpl* pRootJoint = GetSkeleton(pSceletonRootNode, jointNames);
 
+       if (useUpAxis)
+       {
+               pRootJoint->SetLocal(UseUpAxis(pRootJoint->GetLocal()));
+       }
+
        if (pRootJoint != null)
        {
                AppLog(controllerName.c_str());
@@ -948,7 +1014,7 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
 
                pMesh->CreateMeshController();
                pMeshControllerImpl = pMeshImpl->GetMeshControllerImpl();
-               pMeshControllerImpl->SetBindShapeMatrix( UseUpAxis( contollerSkin->GetBindShapeMatrix() ) );
+               pMeshControllerImpl->SetBindShapeMatrix( contollerSkin->GetBindShapeMatrix() );
                pMeshControllerImpl->SetSkeleton(pRootJoint);
 
                //----------------------------------------------------------------InvertBindMatrix
@@ -959,7 +1025,7 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
                        _JointImpl* pJoint = pRootJoint->Find(jointName);
                        if (pJoint != null)
                        {
-                               pJoint->SetInvertBindMatrix(UseUpAxis(contollerSkin->jibms[jointIndex].matrix, true));
+                               pJoint->SetInvertBindMatrix(contollerSkin->jibms[jointIndex].matrix);
                        }
                        else
                        {
@@ -986,7 +1052,15 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
                                        _JointImpl* pJoint = pRootJoint->Find(pNode->GetSID().c_str());
                                        if (pJoint)
                                        {
-                                               CreateAnimation(pNode, pJoint, pRootJoint == pJoint);
+                                               if (useUpAxis)
+                                               {
+                                                       CreateAnimation(pNode, pJoint, pRootJoint == pJoint);
+                                               }
+                                               else
+                                               {
+                                                       CreateAnimation(pNode, pJoint, false);
+                                               }
+
                                        }
                                }
                        }
@@ -1001,11 +1075,17 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
                if (colladaIndices.size() == vertexCount)
                {
                        unsigned int vertexIndex = 0;
+                       unsigned int zero = 0;
                        for (ColladaIndices::iterator it = colladaIndices.begin(); it != colladaIndices.end(); it++)
                        {
                                unsigned int oldVertexIndex = *it;
                                unsigned int weightsCount = contollerSkin->vjws[oldVertexIndex].size();
 
+                               if (weightsCount == 0)
+                               {
+                                       zero++;
+                               }
+
                                for (unsigned int weightIndex = 0; weightIndex < weightsCount; weightIndex++)
                                {
                                        std::string jointName = contollerSkin->vjws[oldVertexIndex][weightIndex].boneName;
@@ -1034,21 +1114,32 @@ _ModelImporterImpl::GetSkeleton(LibraryVisualScenes::Node* pRootNode, std::list<
                _Math::Matrix4 InvGlobalRoot = pRootNode->GetGlobalMatrix();
                InvGlobalRoot.Inverse();
 
-
                jointNames.push_back(pRootNode->GetID());
 
-               _JointImpl* pRootJoint = new (std::nothrow) _JointImpl(pRootNode->GetSID().c_str(), _Math::Matrix4::GetIdentity());
-                
-
+               _JointImpl* pRootJoint = new (std::nothrow) _JointImpl(pRootNode->GetSID().c_str(), pRootNode->GetLocalMatrix());
 
                LibraryVisualScenes::Node* pCurNode = pRootNode->Children();
                _JointImpl* pCurJoint = pRootJoint;
 
+               unsigned int emptyNameCount = 0;
                while ( pCurNode != null )
                {
-                       jointNames.push_back(pCurNode->GetID());
+                       std::string jointName = "";
+
+                       if ( (pCurNode->GetID().size() == 0) || (pCurNode->GetSID().size() == 0) )
+                       {
+                               std::stringstream ss;
+                               ss << "EmptyName" << emptyNameCount;
+                               ss >> jointName;
+                               emptyNameCount++;
+                       }
+                       else
+                       {
+                               jointNames.push_back(pCurNode->GetID());
+                               jointName = pCurNode->GetSID();
+                       }
 
-                       _JointImpl* pJoint = new (std::nothrow) _JointImpl(pCurNode->GetSID().c_str(), pCurNode->GetLocalMatrix());
+                       _JointImpl* pJoint = new (std::nothrow) _JointImpl(jointName.c_str(), pCurNode->GetLocalMatrix());
                        pCurJoint->AttachChild(*pJoint);
 
                        if (pCurNode->Children() != null)
@@ -1140,4 +1231,165 @@ _ModelImporterImpl::CreateAnimation(LibraryVisualScenes::Node* pNode, _JointImpl
        return E_SUCCESS;
 }
 
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetMeshNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryGeometries != null, null, E_INVALID_DATA, "LibraryGeometries: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int count = colladaAssets->pLibraryGeometries->GetGeometriesCount();
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < count; i++)
+       {
+               GeometryMesh* geometryMesh = null;
+               geometryMesh = (GeometryMesh*)colladaAssets->pLibraryGeometries->GetGeometryByNumber(i);
+               Tizen::Base::String* meshName = new Tizen::Base::String(geometryMesh->GetId().c_str());
+               pArrayList->Add(*meshName);
+       }
+
+       return pArrayList;
+}
+
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetMaterialNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryMaterials != null, null, E_INVALID_DATA, "pLibraryMaterials: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int count = colladaAssets->pLibraryMaterials->GetMaterialCount();
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryMaterials::Material* material = null;
+               material = colladaAssets->pLibraryMaterials->GetMaterialByNumber(i);
+               Tizen::Base::String* materialName = new Tizen::Base::String(material->GetId().c_str());
+               pArrayList->Add(*materialName);
+       }
+
+       return pArrayList;
+}
+
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetSceneNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryVisualScenes != null, null, E_INVALID_DATA, "pLibraryVisualScenes: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int count = colladaAssets->pLibraryVisualScenes->GetSceneCount();
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryVisualScenes::VisualScene* scene = null;
+               scene = colladaAssets->pLibraryVisualScenes->GetSceneByNumb(i);
+               Tizen::Base::String* sceneName = new Tizen::Base::String(scene->GetId().c_str());
+               pArrayList->Add(*sceneName);
+       }
+
+       return pArrayList;
+}
+
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetLightNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryLights != null, null, E_INVALID_DATA, "pLibraryLights: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int countAmbient = colladaAssets->pLibraryLights->GetAbientsCount();
+       int countDirectional = colladaAssets->pLibraryLights->GetDirectionalsCount();
+       int countPoint = colladaAssets->pLibraryLights->GetPointsCount();
+       int countSpot = colladaAssets->pLibraryLights->GetSpotsCount();
+
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(countAmbient + countDirectional + countPoint + countSpot)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < countAmbient; i++)
+       {
+               _ImportCollada::LibraryLights::Light* ambient = null;
+               ambient = colladaAssets->pLibraryLights->GetAmbientByNumber(i);
+               Tizen::Base::String* ambientName = new Tizen::Base::String(ambient->GetId().c_str());
+               pArrayList->Add(*ambientName);
+       }
+
+       for (int i = 0; i < countDirectional; i++)
+       {
+               _ImportCollada::LibraryLights::Light* directional = null;
+               directional = colladaAssets->pLibraryLights->GetDirectionalByNumber(i);
+               Tizen::Base::String* directionalName = new Tizen::Base::String(directional->GetId().c_str());
+               pArrayList->Add(*directionalName);
+       }
+
+       for (int i = 0; i < countPoint; i++)
+       {
+               _ImportCollada::LibraryLights::Point* point = null;
+               point = colladaAssets->pLibraryLights->GetPointByNumber(i);
+               Tizen::Base::String* pointName = new Tizen::Base::String(point->GetId().c_str());
+               pArrayList->Add(*pointName);
+       }
+
+       for (int i = 0; i < countSpot; i++)
+       {
+               _ImportCollada::LibraryLights::Spot* spot = null;
+               spot = colladaAssets->pLibraryLights->GetSpotByNumber(i);
+               Tizen::Base::String* spotName = new Tizen::Base::String(spot->GetId().c_str());
+               pArrayList->Add(*spotName);
+       }
+
+       return pArrayList;
+}
+
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetCameraNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryCameras != null, null, E_INVALID_DATA, "pLibraryCameras: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int count = colladaAssets->pLibraryCameras->GetCameraCount();
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryCameras::Camera* camera = null;
+               camera = colladaAssets->pLibraryCameras->GetCameraByNumb(i);
+               Tizen::Base::String* cameraName = new Tizen::Base::String(camera->GetId().c_str());
+               pArrayList->Add(*cameraName);
+       }
+
+       return pArrayList;
+}
+
+Tizen::Base::Collection::IList*
+_ModelImporterImpl::GetMeshWithControllerNamesN()
+{
+       SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryControllers != null, null, E_INVALID_DATA, "pLibraryControllers: not parsed.");
+
+       Tizen::Base::Collection::ArrayList* pArrayList = new (std::nothrow) Tizen::Base::Collection::ArrayList(Tizen::Base::Collection::SingleObjectDeleter);
+       SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int count = colladaAssets->pLibraryControllers->GetControllersCount();
+       SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < count; i++)
+       {
+               _ImportCollada::LibraryControllers::ControllerSkin* controller = null;
+               controller = static_cast<_ImportCollada::LibraryControllers::ControllerSkin*>(colladaAssets->pLibraryControllers->GetControllerByNumber(i));
+               Tizen::Base::String* controllerName = new Tizen::Base::String(controller->GetGeonetryID().c_str() + 1);
+               pArrayList->Add(*controllerName);
+       }
+
+       return pArrayList;
+}
+
+
 }}}
index c1249cb..ccbf061 100644 (file)
@@ -28,6 +28,9 @@
 #include <FGrpFloatRectangle.h>
 #include "FUiAnim_MatrixUtil.h"
 #include "FUiAnim_Plane.h"
+#include "FUiAnim_MathTools.h"
+#include "FUiAnim_MathAdapterFunctions.h"
+
 
 #include "math/FUiAnim_MathVector3.h"
 #include "math/FUiAnim_MathMatrix4.h"
@@ -187,9 +190,49 @@ _Ray::Intersect(const _Plane& plane, Tizen::Graphics::FloatPoint& output) const
        return E_SUCCESS;
 }
 
+bool
+_Ray::Intersect(const _Math::OrientedBox& ob, float& deep) const
+{
+       const _Math::Matrix3& a1Matrix = 1 / (ob.GetMaxABC() * ob.GetMaxABC()) *  ob.GetOrientedAMatrix();
+       //const _Math::Vector3& direction = (__pointEnd - __pointBegin);
+       const _Math::Vector3& oVector = position - ob.GetPosition();
+
+       const float a1 = (direction * a1Matrix).Dot(direction);
+       const float c1 = (oVector * a1Matrix).Dot(oVector) - 1.f;
+       const float b1 = (oVector * a1Matrix).Dot(direction) + (direction * a1Matrix).Dot(oVector);
+       const float determinant = b1 * b1 - 4.f * a1 * c1;
+
+       if (determinant < 0.f || _Math::Equal(a1, 0))
+       {
+               return false;
+       }
+       else
+       {
+               float deep1 = (-b1 + sqrtf(determinant)) / (2.f * a1);
+               float deep2 = (-b1 - sqrtf(determinant)) / (2.f * a1);
+               if (deep1 > deep2)
+               {
+                       if (deep2 < 0)
+                       {
+                               return false;
+                       }
+                       deep = deep2;
+               }
+               else
+               {
+                       if(deep1 < 0)
+                       {
+                               return false;
+                       }
+                       deep = deep1;
+               }
+               return true;
+       }
+}
+
 
 void
-_Ray::print(void)
+_Ray::print(void) const
 {
        AppLog("Pos %.3f %.3f %.3f", position.x, position.y, position.z);
        AppLog("Dir %.3f %.3f %.3f", direction.x, direction.y, direction.z);
@@ -259,46 +302,26 @@ _Ray::MakeRayLocal(const _Ray globalRay, const FloatMatrix4& toTop)
 }
 
 
-_Ray&
-_Ray::MakeRayLocal(const FloatPoint& point, const FloatMatrix4& toTop)
-{
-       //make from top matrix
-       //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixToTop().matrix[0][0]) );
-//     _Math::Matrix4 fromTop(&(toTop.matrix[0][0]));
-//     fromTop.Transpose();
-//     fromTop.Inverse();
+//_Ray&
+//_Ray::MakeRayLocal(const FloatPoint& point, const FloatMatrix4& toTop)
+//{
 //
-//     //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixFromTop().matrix[0][0]) );
+//     FloatMatrix4 fromTop(toTop);
+//     _MatrixUtilInvert(fromTop);
 //
-//     //Transpose to convert into Matrix4
-//     //fromTop.Transpose();
-//     //Invert to convert from toTop to FfromTop
-//     //fromTop.Inverse();
+//     position.x = point.x;
+//     position.y = point.y;
+//     position.z = 0.0f;
 //
-//     Position = fromTop * globalRay.Position;
+//     direction.x = point.x;
+//     direction.y = point.y;
+//     direction.z = 1.0f;
 //
-//     //because Mat4 * vec3 treats vec3 as point
-//     _Math::Vector4 direction(globalRay.Direction.x, globalRay.Direction.y, globalRay.Direction.z, 0.0f);
-//     _Math::Vector4 directionT = fromTop * direction;
+//     _MatrixUtilTransform(fromTop, &position.x, &position.y, &position.z);
+//     _MatrixUtilTransformDirection(fromTop, &direction.x, &direction.y, &direction.z);
 //
-//     Direction.Set(directionT.x, directionT.y, directionT.z);
-
-       FloatMatrix4 fromTop(toTop);
-       _MatrixUtilInvert(fromTop);
-
-       position.x = point.x;
-       position.y = point.y;
-       position.z = 0.0f;
-
-       direction.x = point.x;
-       direction.y = point.y;
-       direction.z = 1.0f;
-
-       _MatrixUtilTransform(fromTop, &position.x, &position.y, &position.z);
-       _MatrixUtilTransformDirection(fromTop, &direction.x, &direction.y, &direction.z);
-
-       return *this;
-}
+//     return *this;
+//}
 
 _Ray&
 _Ray::MakeRayGlobal(const _VisualElementImpl* pVEImpl, FloatPoint point)
@@ -314,7 +337,7 @@ _Ray::MakeRayGlobal(const _VisualElementImpl* pVEImpl, FloatPoint point)
        _ViewInfo* pView = pRoot->GetView();
 
        SysTryReturn(NID_UI_ANIM, pView, *this, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] this VisualElement does not have any view");
-       SysTryReturn(NID_UI_ANIM, CalculatePVInv(*pView, pvInv), *this, E_OBJ_NOT_FOUND, "Ray cannot Projection View for this VisualElement (check VE to be connected to main tree, frame layer and other adjustments)");
+       SysTryReturn(NID_UI_ANIM, CalculatePVInv(*pView, pvInv), *this, E_OBJ_NOT_FOUND, "Ray cannot stat Projection View for this VisualElement (check VE to be connected to main tree, frame layer and other adjustments)");
 
        FloatRectangle* pViewport = pView->GetViewport();
        if(pViewport)
index 34f8fdb..fead9f1 100644 (file)
@@ -33,6 +33,7 @@ class _ViewInfo;
 
 namespace _Math {
 class Matrix4;
+class OrientedBox;
 }
 
 
@@ -60,16 +61,24 @@ public:
        std::pair<bool, float> Intersect(const BoundingVolume& boundingVolume) const;
 
        result Intersect(const _Plane& plane, Tizen::Graphics::FloatPoint& output) const;
+       /**
+        * Performs intersection with given Oriented Box.
+        * Returns flag indicating intersection state and distance in case of intersection
+        *
+        * @return flag indicating intersection state and distance in case of intersection
+        * @param ob Oriented Box to test
+        */
+       bool Intersect(const _Math::OrientedBox& ob, float& deep) const;
 
        _Ray& operator = (_Ray& rhs);
 
        _Ray& Set(const _Ray& rhs);
        _Ray& Set(const _Math::Vector3& position, const _Math::Vector3& direction);
 
-       void print(void);
+       void print(void) const;
 
        _Ray& MakeRayLocal(const _Ray globalRay, const Tizen::Graphics::FloatMatrix4& toTop);
-       _Ray& MakeRayLocal(const Tizen::Graphics::FloatPoint& point, const Tizen::Graphics::FloatMatrix4& toTop);
+//     _Ray& MakeRayLocal(const Tizen::Graphics::FloatPoint& point, const Tizen::Graphics::FloatMatrix4& toTop);
        _Ray& MakeRayGlobal(const _VisualElementImpl* pVEImpl, Tizen::Graphics::FloatPoint point);
 //     _Ray& MakeRayGlobal(const _RootVisualElement* pRoot, const _View& view, Tizen::Graphics::FloatPoint point);
        _Ray& MakeRayGlobal(const _ViewInfo& view, Tizen::Graphics::FloatPoint point);
index cf243ab..7aee7e6 100644 (file)
 #include "FUiAnimLight.h"
 #include "FUiAnimShaderProgram.h"
 #include "FUiAnimShader.h" //for  ShaderProgram compile
+#include "FUiAnimVisualElementSurface.h"
+
+//Surface loading
+#ifndef BUILD_UI_CORE
+       #include "FMediaImage.h"
+       #include "FGrpBitmap.h"
+#else
+       #include "UcUtils.h"
+#endif
+#include "FUiCtrlFrame.h"
 
 #include "FUiAnim_MeshImpl.h"
 #include "FUiAnim_MaterialImpl.h"
 #include <cstdlib>
 #include <string.h>
 #include <fstream>
-//#define LOCAL_XML_ENCODING "ISO-8859-1" //xml encoding
+
 #define LOCAL_XML_ENCODING "UTF-8" //xml encoding
-#define SCENE_DESCTRIPTOR_FILE_EXTENSION ".are"
+#define SCENE_DESCTRIPTOR_FILE_EXTENSION ".scn"
 
 #define SCENE_MESH_RESOURCE_FILE_NAME "_mesh"
-#define SCENE_MESH_RESOURCE_FILE_EXTENSION ".bin"
+#define SCENE_MESH_RESOURCE_FILE_EXTENSION ".msh"
 
 #define SCENE_MATERIAL_RESOURCE_FILE_NAME "_material"
-#define SCENE_MATERIAL_RESOURCE_FILE_EXTENSION ".xml"
+#define SCENE_MATERIAL_RESOURCE_FILE_EXTENSION ".mtr"
 
 #define SCENE_LIGHT_RESOURCE_FILE_NAME "_light"
-#define SCENE_LIGHT_RESOURCE_FILE_EXTENSION ".xml"
+#define SCENE_LIGHT_RESOURCE_FILE_EXTENSION ".lgh"
 
 #define SCENE_VERTEX_SHADER_RESOURCE_FILE_NAME "_shader"
 #define SCENE_VERTEX_SHADER_RESOURCE_FILE_EXTENSION ".vert"
@@ -74,6 +84,8 @@
 #define SCENE_FRAGMENT_SHADER_RESOURCE_FILE_NAME "_shader"
 #define SCENE_FRAGMENT_SHADER_RESOURCE_FILE_EXTENSION ".frag"
 
+#define MAX_RES_FILES_COUNT 10000
+
 // Declare xml node for XML parser
 #define XML_ELM_SCENE                                  "Scene"
 #define XML_ELM_NAME                                   "name"
@@ -81,6 +93,7 @@
 #define XML_ELM_ID                                             "id"
 #define XML_ELM_SRC_FILE_NAME                  "sourceFileName"
 #define XML_ELM_MODEL_NAME_IN_SOURCE   "modelNameInSourceFile"
+#define XML_ELM_VERSION                                        "version"
 #define XML_ELM_MESHS                                  "Meshes"
 #define XML_ELM_MESH                                   "Mesh"
 #define XML_ELM_MATERIALS                              "Materials"
 #define XML_ELM_SHADER_PROGRAM                 "ShaderProgram"
 #define XML_ELM_VERTEX_SHADER                  "VertexShader"
 #define XML_ELM_FRAGMENT_SHADER                        "FragmentShader"
-#define XML_ELM_TEXTURE_FILE_NAMES             "TextureFileNames"
-#define XML_ELM_TEXTURE_FILE_NAME              "TextureFileName"
-#define XML_ELM_TEXTURE_FILE_NAME_             "textureFileName"
-#define XML_ELM_VISUAL_ELEMENT                 "VisualElements"
-
-
-
-
-
-#define MAX_RES_FILES_COUNT 10000
+#define XML_ELM_SURFACES                               "Surfaces"
+#define XML_ELM_SURFACE                                        "Surface"
+#define XML_ELM_VISUAL_ELEMENTS                        "VisualElements"
+#define XML_ELM_VISUAL_ELEMENT                 "VisualElement"
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
@@ -109,6 +116,10 @@ using namespace Tizen::Ui::Animations;
 
 namespace Tizen { namespace Ui { namespace Animations {
 
+extern const int MAJOR_VERSION;
+extern const int MINOR_VERSION;
+extern const int RELEASE;
+
 _SceneImpl::_SceneImpl(void)
        : _name()
        , _pSceneRootVisualElement(null)
@@ -117,7 +128,7 @@ _SceneImpl::_SceneImpl(void)
        , _materials()
        , _lights()
        , _shaderPrograms()
-       , _textureFileNames()
+       , _surfaces()
 {
 }
 
@@ -197,7 +208,7 @@ _SceneImpl::ResetScene(void)
        RemoveAllMaterial();
        RemoveAllLight();
        RemoveAllShaderProgram();
-       RemoveAllTextureFileName();
+       RemoveAllSurface();
 
        return E_SUCCESS;
 }
@@ -1613,42 +1624,379 @@ _SceneImpl::GetShaderProgramByHashCodeN(int code) const
        return GetShaderProgramAtN(shaderProgramIndex);
 }
 
-//==========================================================================================TEXTURE
+//==========================================================================================Surface
+
+result
+_SceneImpl::AddSurface(const VisualElementSurface* pSurface, const Tizen::Base::String& sourceFileName)
+{
+       SysTryReturnResult(NID_UI_ANIM, pSurface != null, E_INVALID_ARG, \
+                       "[E_INVALID_ARG] Surface pointer is null.");
+
+       SysTryReturnResult(NID_UI_ANIM, !(ContainsSurface(pSurface) >= 0), E_INVALID_ARG, \
+                       "[E_INVALID_ARG] Surface \"%d\" already exists in scene \"%ls\".", (int)pSurface, _name.GetPointer());
+
+       VisualElementSurface* pSurfaceCopy = new (std::nothrow) VisualElementSurface(*pSurface);
+       SysTryReturnResult(NID_UI_ANIM, pSurfaceCopy != null, E_OUT_OF_MEMORY, \
+                       "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       surfaceDescriptor.pSurface = pSurfaceCopy;
+       surfaceDescriptor.sourceFileName = sourceFileName;
+
+       return _surfaces.Add( surfaceDescriptor);
+}
+
+result
+_SceneImpl::RemoveSurface(const Tizen::Base::String& surfaceName)
+{
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(surfaceName);
+       SysTryReturnResult(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%ls\" not found in scene \"%ls\".", surfaceName.GetPointer(), _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+       if (surfaceDescriptor.pSurface != null)
+       {
+               delete surfaceDescriptor.pSurface;
+               surfaceDescriptor.pSurface = null;
+       }
+
+       return _surfaces.RemoveAt(surfaceIndex);
+}
+
+result
+_SceneImpl::RemoveSurface(const VisualElementSurface* pSurface)
+{
+       SysTryReturnResult(NID_UI_ANIM, pSurface != null, E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(pSurface);
+
+       SysTryReturnResult(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%d\" not found in scene \"%ls\".", (int)pSurface, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+       if (surfaceDescriptor.pSurface != null)
+       {
+               delete surfaceDescriptor.pSurface;
+               surfaceDescriptor.pSurface = null;
+       }
+
+       return _surfaces.RemoveAt(surfaceIndex);
+}
 
 result
-_SceneImpl::AddTextureFileName(const String& textureFileName)
+_SceneImpl::RemoveAllSurface(void)
 {
-       return _textureFileNames.Add(textureFileName);
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       int count = _surfaces.GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               _surfaces.GetAt(i, surfaceDescriptor);
+               if (surfaceDescriptor.pSurface != null)
+               {
+                       delete surfaceDescriptor.pSurface;
+                       surfaceDescriptor.pSurface = null;
+               }
+       }
+       _surfaces.RemoveAll();
+
+       return E_SUCCESS;
+}
+
+VisualElementSurface*
+_SceneImpl::GetSurfaceN(const Tizen::Base::String& surfaceName) const
+{
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(surfaceName);
+
+       SysTryReturn(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), null, E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%ls\" not found in scene \"%ls\".", surfaceName.GetPointer(), _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       if (surfaceDescriptor.pSurface == null)
+       {
+               return null;
+       }
+
+       VisualElementSurface* pSurfaceCopy = new (std::nothrow) VisualElementSurface(*surfaceDescriptor.pSurface);
+       SysTryReturn(NID_UI_ANIM, pSurfaceCopy != null, null, E_OUT_OF_MEMORY, \
+                               "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+       return pSurfaceCopy;
 }
 
 int
-_SceneImpl::GetTextureFileNameCount(void) const
+_SceneImpl::ContainsSurface(const Tizen::Base::String& surfaceName) const
 {
-       return _textureFileNames.GetCount();
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       int surfaceIndex = -1;
+       int count = _surfaces.GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               _surfaces.GetAt(i, surfaceDescriptor);
+               if (surfaceDescriptor.pSurface != null)
+               {
+                       if (surfaceDescriptor.name == surfaceName)
+                       {
+                               surfaceIndex = i;
+                               break;
+                       }
+               }
+       }
+
+       return surfaceIndex;
 }
 
-String
-_SceneImpl::GetTextureFileNameAt(int index) const
+int
+_SceneImpl::ContainsSurface(const VisualElementSurface* pSurface) const
+{
+       SysTryReturn(NID_UI_ANIM, pSurface != null, -1, E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       int surfaceIndex = -1;
+       int count = _surfaces.GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               _surfaces.GetAt(i, surfaceDescriptor);
+               if (surfaceDescriptor.pSurface != null)
+               {
+                       if (surfaceDescriptor.pSurface->GetHashCode() == pSurface->GetHashCode())
+                       {
+                               surfaceIndex = i;
+                               break;
+                       }
+               }
+       }
+
+       return surfaceIndex;
+}
+
+int
+_SceneImpl::GetSurfaceCount(void) const
+{
+       return _surfaces.GetCount();
+}
+
+VisualElementSurface*
+_SceneImpl::GetSurfaceAtN(int index) const
+{
+       SysTryReturn(NID_UI_ANIM, (index >= 0) && (index < GetSurfaceCount()), null, E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface #%d not found in scene \"%ls\".", index, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(index, surfaceDescriptor);
+
+       if (surfaceDescriptor.pSurface == null)
+       {
+               return null;
+       }
+
+       VisualElementSurface* pSurfaceCopy = new (std::nothrow) VisualElementSurface(*surfaceDescriptor.pSurface);
+       SysTryReturn(NID_UI_ANIM, pSurfaceCopy != null, null, E_OUT_OF_MEMORY, \
+                               "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+       return pSurfaceCopy;
+}
+
+Tizen::Base::String
+_SceneImpl::GetSurfaceNameAt(int index) const
+{
+       SysTryReturn(NID_UI_ANIM, (index >= 0) && (index < GetSurfaceCount()), null, E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface #%d not found in scene \"%ls\".", index, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(index, surfaceDescriptor);
+
+       return surfaceDescriptor.name;
+}
+
+//not for public
+//for JNI interface:
+Tizen::Base::String
+_SceneImpl::GetSurfaceSourceFileName(const Tizen::Base::String surfaceName) const
 {
-       SysTryReturn(NID_UI_ANIM, (index >= 0) && (index < GetTextureFileNameCount()), String(L""), E_OBJ_NOT_FOUND, \
-                                       "[E_OBJ_NOT_FOUND] Texture File Name #%d not found in scene \"%ls\".", index, _name.GetPointer());
-       String textureFileName;
-       _textureFileNames.GetAt(index, textureFileName);
-       return textureFileName;
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(surfaceName);
+
+       SysTryReturn(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), String(L""), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%ls\" not found in scene \"%ls\".", surfaceName.GetPointer(), _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       return surfaceDescriptor.sourceFileName;
 }
+
 result
-_SceneImpl::RemoveTextureFileNameAt(int index)
+_SceneImpl::SetSurfaceSourceFileName(const Tizen::Base::String surfaceName, const Tizen::Base::String sourceFileName)
+{
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(surfaceName);
+
+       SysTryReturnResult(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%ls\" not found in scene \"%ls\".", surfaceName.GetPointer(), _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       surfaceDescriptor.sourceFileName = sourceFileName;
+
+       return _surfaces.SetAt(surfaceDescriptor, surfaceIndex);
+}
+
+Tizen::Base::String
+_SceneImpl::GetSurfaceNameByHashCode(int code) const
+{
+       SysTryReturn(NID_UI_ANIM, code != null, String(L""), E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       int count = _surfaces.GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               _surfaces.GetAt(i, surfaceDescriptor);
+               if (surfaceDescriptor.pSurface != null)
+               {
+                       if (surfaceDescriptor.pSurface->GetHashCode() == code)
+                       {
+                               return surfaceDescriptor.name;
+                       }
+               }
+       }
+
+       SysTryReturn(NID_UI_ANIM, false, String(L""), E_OBJ_NOT_FOUND, \
+                       "[E_OBJ_NOT_FOUND] Surface \"%d\" not found in scene \"%ls\".", code, _name.GetPointer());
+
+       return String(L"");
+}
+
+Tizen::Base::String
+_SceneImpl::GetSurfaceSourceFileName(const VisualElementSurface* pSurface) const
 {
-       SysTryReturnResult(NID_UI_ANIM, (index >= 0) && (index < GetTextureFileNameCount()), E_OBJ_NOT_FOUND, \
-                                               "[E_OBJ_NOT_FOUND] Texture File Name #%d not found in scene \"%ls\".", index, _name.GetPointer());
-       return _textureFileNames.RemoveAt(index);
+       SysTryReturn(NID_UI_ANIM, pSurface != null, String(L""), E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(pSurface);
+
+       SysTryReturn(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), String(L""), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%p\" not found in scene \"%ls\".", pSurface, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       return surfaceDescriptor.sourceFileName;
 }
 
 result
-_SceneImpl::RemoveAllTextureFileName(void)
+_SceneImpl::SetSurfaceSourceFileName(const VisualElementSurface* pSurface, const Tizen::Base::String sourceFileName)
 {
-       _textureFileNames.RemoveAll();
-       return E_SUCCESS;
+       SysTryReturnResult(NID_UI_ANIM, pSurface != null, E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       int surfaceIndex = -1;
+       surfaceIndex = ContainsSurface(pSurface);
+
+       SysTryReturnResult(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%p\" not found in scene \"%ls\".", pSurface, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       surfaceDescriptor.sourceFileName = sourceFileName;
+
+       return _surfaces.SetAt(surfaceDescriptor, surfaceIndex);
+}
+
+Tizen::Base::String
+_SceneImpl::GetSurfaceName(const VisualElementSurface* pSurface) const
+{
+       SysTryReturn(NID_UI_ANIM, pSurface != null, String(L""), E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       int surfaceIndex = ContainsSurface(pSurface);
+
+       SysTryReturn(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), String(L""), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%p\" not found in scene \"%ls\".", pSurface, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       return surfaceDescriptor.name;
+}
+
+result
+_SceneImpl::SetSurfaceName(const VisualElementSurface* pSurface, const Tizen::Base::String surfaceName)
+{
+       SysTryReturnResult(NID_UI_ANIM, pSurface != null, E_INVALID_ARG, \
+                               "[E_INVALID_ARG] Surface pointer is null.");
+
+       int surfaceIndex = ContainsSurface(pSurface);
+
+       SysTryReturnResult(NID_UI_ANIM, (surfaceIndex >= 0) && (surfaceIndex < GetSurfaceCount()), E_OBJ_NOT_FOUND, \
+                               "[E_OBJ_NOT_FOUND] Surface \"%p\" not found in scene \"%ls\".", pSurface, _name.GetPointer());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(surfaceIndex, surfaceDescriptor);
+
+       surfaceDescriptor.name = surfaceName;
+
+       return _surfaces.SetAt(surfaceDescriptor, surfaceIndex);
+}
+
+int
+_SceneImpl::GetSurfaceCodeAt(int index) const
+{
+       SysTryReturn(NID_UI_ANIM, (index >= 0) && (index < GetSurfaceCount()), 0, E_OBJ_NOT_FOUND, \
+                       "[E_OBJ_NOT_FOUND] Surface index %d out of range [0,%d].", index, GetSurfaceCount());
+
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       _surfaces.GetAt(index, surfaceDescriptor);
+
+       if (surfaceDescriptor.pSurface != null)
+               return surfaceDescriptor.pSurface->GetHashCode();
+       return 0;
+}
+
+int
+_SceneImpl::ContainsSurface(int code) const
+{
+       _SceneSurfaceDescriptor surfaceDescriptor;
+       int surfaceIndex = -1;
+       int count = _surfaces.GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               _surfaces.GetAt(i, surfaceDescriptor);
+               if (surfaceDescriptor.pSurface != null)
+               {
+                       if (surfaceDescriptor.pSurface->GetHashCode() == code)
+                       {
+                               surfaceIndex = i;
+                               break;
+                       }
+               }
+       }
+
+       return surfaceIndex;
+}
+
+VisualElementSurface*
+_SceneImpl::GetSurfaceByHashCodeN(int code) const
+{
+       int surfaceIndex = ContainsSurface(code);
+       return GetSurfaceAtN(surfaceIndex);
 }
 
 //=====================Save/Load
@@ -1707,6 +2055,7 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
        _SceneMaterialDescriptor materialDescriptor;
        _SceneLightDescriptor lightDescriptor;
        _SceneShaderProgramDescriptor shaderProgramDescriptor;
+       _SceneSurfaceDescriptor surfaceDescriptor;
        int count;
        IList* childrenVisualElementList = null;
        VisualElement* pChildVisualElement = null;
@@ -1766,9 +2115,11 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
        tempWString = _name.GetPointer();
        tempString = ConvertWStringToString(tempWString);
 
-       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
-                                            BAD_CAST tempString.c_str());
+       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
+       SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
+                                       "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
+       rc = xmlTextWriterWriteFormatAttribute(writer, BAD_CAST XML_ELM_VERSION, "%d.%d.%d", MAJOR_VERSION, MINOR_VERSION, RELEASE);
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
@@ -1812,7 +2163,7 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                        tempWString = meshDescriptor.pMesh->GetName().GetPointer();
                        tempString = ConvertWStringToString(tempWString);
 
-                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tempString.c_str());
+                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
                        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
                }
@@ -1842,7 +2193,10 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
 
                if(meshDescriptor.pMesh != null)
                {
-                       meshDescriptor.pMesh->SaveMesh(tempTString);
+                       if (meshDescriptor.pMesh->SaveMesh(tempTString) != E_SUCCESS)
+                       {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to save Mesh #%d to %ls", i, tempTString.GetPointer());
+                       }
                }
 
                //close "Mesh" element
@@ -1893,7 +2247,7 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                        tempWString = materialDescriptor.pMaterial->GetName().GetPointer();
                        tempString = ConvertWStringToString(tempWString);
 
-                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tempString.c_str());
+                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
                        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
                }
@@ -1916,8 +2270,10 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
 
                if (materialDescriptor.pMaterial != null)
                {
-                       _MaterialParser::SaveMaterial(materialDescriptor.pMaterial, tempTString);
-                       //TODO://materialDescriptor.pMaterial->SaveMaterialToXml(tempTString);
+                       if (_MaterialParser::SaveMaterial(materialDescriptor.pMaterial, tempTString) != E_SUCCESS)
+                       {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to save Material #%d to %ls", i, tempTString.GetPointer());
+                       }
                }
 
                //close "Material" element
@@ -1967,7 +2323,7 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                        tempWString = lightDescriptor.pLight->GetName().GetPointer();
                        tempString = ConvertWStringToString(tempWString);
 
-                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tempString.c_str());
+                       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
                        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
                }
@@ -1989,8 +2345,10 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
 
                if (lightDescriptor.pLight != null)
                {
-                       _LightParser::SaveLight(lightDescriptor.pLight, tempTString);
-                       //TODO://lightDescriptor.pLight->SaveLightToXml(tempTString);
+                       if (_LightParser::SaveLight(lightDescriptor.pLight, tempTString) != E_SUCCESS)
+                       {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to save Light #%d to %ls", i, tempTString.GetPointer());
+                       }
                }
 
                //close "Light" element
@@ -2045,7 +2403,7 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                }
                tempString = ConvertWStringToString(tempWString);
 
-               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tempString.c_str());
+               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
@@ -2068,13 +2426,18 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                        tempWString = shaderProgramDescriptor.vertexShader.GetPointer();
                        tempString = ConvertWStringToString(tempWString);
 
-                       vertex.write(tempString.c_str(), tempString.length());
+                       vertex.write(tempString.c_str(), tempString.length() + 1);
                        vertex.close();
                }
+               else
+               {
+                       SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to save VertexShader #%d to %s", i, tempString.c_str());
+               }
 
 ////for UTF-8 shader saving in .are
 //             rc = xmlTextWriterWriteElement(writer, BAD_CAST XML_ELM_VERTEX_SHADER, BAD_CAST tempString.c_str());
-//             SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+//             SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
+                                               "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
                tempTString.Format(resourceFilesPath.GetLength() + xmlFileName.GetLength() + fragmentShaderResFileName.GetLength() + fragmentShaderResFileExtension.GetLength() + 8 + 2, \
                                                L"%ls%ls%ls%04d%ls", resourceFilesPath.GetPointer(), xmlFileName.GetPointer(), fragmentShaderResFileName.GetPointer(), i, fragmentShaderResFileExtension.GetPointer());
@@ -2087,14 +2450,18 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                        tempWString = shaderProgramDescriptor.fragmentShader.GetPointer();
                        tempString = ConvertWStringToString(tempWString);
 
-                       fragment.write(tempString.c_str(), tempString.length());
+                       fragment.write(tempString.c_str(), tempString.length() + 1);
                        fragment.close();
                }
-
+               else
+               {
+                       SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to save FragmentShader #%d to %s", i, tempString.c_str());
+               }
 
 ////for UTF-8 shader saving in .are
 //             rc = xmlTextWriterWriteElement(writer, BAD_CAST XML_ELM_FRAGMENT_SHADER, BAD_CAST tempString.c_str());
-//             SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+//             SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
+                                               "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
                //close "ShaderProgram" element
                rc = xmlTextWriterEndElement(writer);
@@ -2106,12 +2473,12 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
-       //open "TextureFileNames" element
-       rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_TEXTURE_FILE_NAMES);
+       //open "Surfaces" element
+       rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_SURFACES);
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
-       //write TextureFileNames
-       count = _textureFileNames.GetCount();
+       //write Surfaces
+       count = _surfaces.GetCount();
        rc = xmlTextWriterWriteFormatAttribute(writer, BAD_CAST XML_ELM_COUNT, "%d", count);
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
@@ -2123,8 +2490,8 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
        }
        for (int i = 0; i < count; i++)
        {
-               //open "TextureFileName" element
-               rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_TEXTURE_FILE_NAME);
+               //open "Surface" element
+               rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_SURFACE);
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
@@ -2132,30 +2499,42 @@ _SceneImpl::SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::St
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
-               _textureFileNames.GetAt(i, tempTString);
-               tempWString = tempTString.GetPointer();
+               _surfaces.GetAt(i, surfaceDescriptor);
+               tempWString = surfaceDescriptor.name.GetPointer();
+               tempString = ConvertWStringToString(tempWString);
+
+               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_NAME, BAD_CAST tempString.c_str());
+               SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
+                                               "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+
+               tempWString = surfaceDescriptor.sourceFileName.GetPointer();
                tempString = ConvertWStringToString(tempWString);
 
-               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "textureFileName", BAD_CAST tempString.c_str());
+               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST XML_ELM_SRC_FILE_NAME, BAD_CAST tempString.c_str());
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
+               if (surfaceDescriptor.sourceFileName.IsEmpty())
+               {
+                       SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Empty Surface Image sourceFileName #%d", i);
+               }
+
                rc = xmlTextWriterWriteString(writer, BAD_CAST "");
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
-               //close "TextureFileName" element
+               //close "Surface" element
                rc = xmlTextWriterEndElement(writer);
                SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                                "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
        }
-       //close "TextureFileNames" element
+       //close "Surfaces" element
        rc = xmlTextWriterEndElement(writer);
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
        //open "VisualElements" element
-       rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_VISUAL_ELEMENT);
+       rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_VISUAL_ELEMENTS);
        SysTryCatch(NID_UI_ANIM, rc >= 0, , E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
        //write root children VisualElements
@@ -2226,6 +2605,7 @@ _SceneImpl::__SaveSceneVisualElementTree(const xmlTextWriterPtr writer, const Vi
        Material* pMaterial = null;
        Light* pLight = null;
        ShaderProgram* pShaderProgram = null;
+       VisualElementSurface* pSurface = null;
        VisualElement* pChildVisualElement = null;
        int rc;
        std::string tempString;
@@ -2233,7 +2613,7 @@ _SceneImpl::__SaveSceneVisualElementTree(const xmlTextWriterPtr writer, const Vi
        String tempTString;
 
        //open "VisualElement" element
-       rc = xmlTextWriterStartElement(writer, BAD_CAST "VisualElement");
+       rc = xmlTextWriterStartElement(writer, BAD_CAST XML_ELM_VISUAL_ELEMENT);
        SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
@@ -2273,6 +2653,10 @@ _SceneImpl::__SaveSceneVisualElementTree(const xmlTextWriterPtr writer, const Vi
        rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "materialId", BAD_CAST tempString.c_str());
        SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+       
+       String paramName;
+       std::string tempStringName;
+       std::wstring tempWStringName;
 
        pLight = pVisualElement->GetLightN(0); // WARNING: VE can have more than one light.
 
@@ -2311,8 +2695,81 @@ _SceneImpl::__SaveSceneVisualElementTree(const xmlTextWriterPtr writer, const Vi
        SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
+       pSurface = pVisualElement->GetSurfaceN();
+       if (pSurface != null)
+       {
+               tempTString.Format(50,L"%d", ContainsSurface(pSurface));
+               delete pSurface;
+               pSurface = null;
+       }
+       else
+       {
+               tempTString.Format(50,L"%d", -1);
+       }
+       tempWString = tempTString.GetPointer();
+       tempString = ConvertWStringToString(tempWString);
+
+       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "surfaceId", BAD_CAST tempString.c_str());
+       SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
+                                       "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+
+       String extraSurfaceParamName;
+
+       for (int i = 0; i < EXTRA_SURFACE_MAX; i++)
+       {
+               extraSurfaceParamName.Format(14 + 1 + 2, L"extraSurfaceId%1d", i);
+               tempWStringName = extraSurfaceParamName.GetPointer();
+               tempStringName = ConvertWStringToString(tempWStringName);
+
+               pSurface = pVisualElement->GetExtraSurfaceN((ExtraSurfaceIndex)i);
+               if (pSurface != null)
+               {
+                       tempTString.Format(50,L"%d", ContainsSurface(pSurface));
+                       delete pSurface;
+                       pSurface = null;
+               }
+               else
+               {
+                       tempTString.Format(50,L"%d", -1);
+               }
+               tempWString = tempTString.GetPointer();
+               tempString = ConvertWStringToString(tempWString);
+
+               rc = xmlTextWriterWriteAttribute(writer, BAD_CAST tempStringName.c_str(), BAD_CAST tempString.c_str());
+               SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
+                                               "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+
+               extraSurfaceParamName.Format(21 + 1 + 2, L"extraSurfaceOpacity%1d", i);
+               tempWStringName = extraSurfaceParamName.GetPointer();
+               tempStringName = ConvertWStringToString(tempWStringName);
+
+               rc = xmlTextWriterWriteFormatAttribute(writer, BAD_CAST tempStringName.c_str(), "%f",  pVisualElement->GetExtraSurfaceOpacity((ExtraSurfaceIndex)i) );
+               SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
+                                               "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+
+       }
+
+       pSurface = pVisualElement->GetAlphaMaskN();
+       if (pSurface != null)
+       {
+               tempTString.Format(50,L"%d", ContainsSurface(pSurface));
+               delete pSurface;
+               pSurface = null;
+       }
+       else
+       {
+               tempTString.Format(50,L"%d", -1);
+       }
+       tempWString = tempTString.GetPointer();
+       tempString = ConvertWStringToString(tempWString);
+
+       rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "alphaMaskId", BAD_CAST tempString.c_str());
+       SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
+                                       "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
+
+
        //save current ve content
-       rc = xmlTextWriterWriteFormatAttribute(writer, BAD_CAST "name", "%ls", pVisualElement->GetName().GetPointer());
+       rc = xmlTextWriterWriteFormatAttribute(writer, BAD_CAST XML_ELM_NAME, "%ls", pVisualElement->GetName().GetPointer());
        SysTryReturnResult(NID_UI_ANIM, rc >= 0, E_SYSTEM, \
                                        "Failed to write with XmlWriter while saving scene \"%ls\"", _name.GetPointer());
 
@@ -2439,19 +2896,21 @@ struct __SceneSAXParsingUserData
                parsingResult = E_SUCCESS;
                pCurrentParentVisualElement = null;
 
+               pDisplayContext = null;
+
                currentMeshId = -1;
                currentMaterialId = -1;
                currentLightId = -1;
                currentShaderProgramId = -1;
-               currentTexturFileNameId = -1;
+               currentSurfaceId = -1;
 
                isScene = false;
                isMeshes = false; isMesh = false;
                isMaterials = false; isMaterial = false;
                isLights = false; isLight = false;
                isShaderPrograms = false; isShaderProgram = false; isVertexShader = false; isFragmentShader = false;
-               isTextureFileNames = false; isTextureFileName = false;
-               isVisualElements = false; isVisualElement = false;
+               isSurfaces = false; isSurface = false;
+               isVisualElements = false; isVisualElementCount = 0;
        }
        void Clear(void)
        {
@@ -2465,9 +2924,9 @@ struct __SceneSAXParsingUserData
                materialDescriptor.Clear();
                lightDescriptor.Clear();
                shaderProgramDescriptor.Clear();
+               surfaceDescriptor.Clear();
 
                shaderProgramName.Clear();
-               texfureFileName.Clear();
        }
 
        result parsingResult;
@@ -2476,19 +2935,19 @@ struct __SceneSAXParsingUserData
        int currentMaterialId;
        int currentLightId;
        int currentShaderProgramId;
-       int currentTexturFileNameId;
+       int currentSurfaceId;
 
        _SceneMeshDescriptor meshDescriptor;
        _SceneMaterialDescriptor materialDescriptor;
        _SceneLightDescriptor lightDescriptor;
        _SceneShaderProgramDescriptor shaderProgramDescriptor;
+       _SceneSurfaceDescriptor surfaceDescriptor;
 
        VisualElement* pCurrentParentVisualElement;
 
        String filesPath, scenePrefix, resourceFilesPath;
 
        String shaderProgramName;
-       String texfureFileName;
 
        _SceneImpl* pSceneImpl;
 
@@ -2497,15 +2956,20 @@ struct __SceneSAXParsingUserData
        bool isMaterials, isMaterial;
        bool isLights, isLight;
        bool isShaderPrograms, isShaderProgram, isVertexShader, isFragmentShader;
-       bool isTextureFileNames, isTextureFileName;
-       bool isVisualElements, isVisualElement;
+       bool isSurfaces, isSurface;
+       bool isVisualElements;
+       int isVisualElementCount;
+
+       DisplayContext* pDisplayContext;
 
 //     ArrayListT<  __SceneVisualElementDescriptor > children;
 };
 
 Scene*
-_SceneImpl::LoadSceneN(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix, VisualElement& sceneRootVisualElement) //in format: home/abc/scenespath/ or c:\\abc\\scenepath\\     ..
+_SceneImpl::LoadSceneN(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix, VisualElement& sceneRootVisualElement, const DisplayContext* pDisplayContext) //in format: home/abc/scenespath/ or c:\\abc\\scenepath\\     ..
 {
+       SysTryReturn(NID_UI_ANIM, pDisplayContext, null, E_INVALID_ARG, "Display context is null");
+
        std::string tempString;
        std::wstring tempWString;
        String tempTString;
@@ -2559,6 +3023,8 @@ _SceneImpl::LoadSceneN(const Tizen::Base::String filesPath, const Tizen::Base::S
        pUserData->resourceFilesPath = resourceFilesPath;
        pUserData->pCurrentParentVisualElement = pScene->GetRootVisualElement();
 
+       pUserData->pDisplayContext = const_cast<DisplayContext*>(pDisplayContext);
+
        //start parsing
        rc = xmlSAXUserParseFile(&sceneSAXHandler, (void*)pUserData, tempString.c_str());
        err = xmlGetLastError();
@@ -2724,7 +3190,7 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                                pUserDataT->currentShaderProgramId = atoi((const char*) pAttributes[i+1]);
                                                continue;
                                        }
-                                       if (attributeName.CompareTo("name") == 0)
+                                       if (attributeName.CompareTo(XML_ELM_NAME) == 0)
                                        {
                                                pUserDataT->shaderProgramName = (const char*) pAttributes[i+1];
                                                continue;
@@ -2760,13 +3226,13 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
 //             }
 //     }
 
-       if (pUserDataT->isTextureFileNames && !pUserDataT->isTextureFileName)
+       if (pUserDataT->isSurfaces && !pUserDataT->isSurface)
        {
-               if (elementName.CompareTo(XML_ELM_TEXTURE_FILE_NAME) == 0)
+               if (elementName.CompareTo(XML_ELM_SURFACE) == 0)
                {
-                       pUserDataT->isTextureFileName = true;
-                       pUserDataT->currentTexturFileNameId = -1;
-                       pUserDataT->texfureFileName.Clear();
+                       pUserDataT->isSurface = true;
+                       pUserDataT->currentSurfaceId = -1;
+                       pUserDataT->surfaceDescriptor.Clear();
 
                        if (pAttributes != null)
                        {
@@ -2776,12 +3242,17 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                        //attributeValue = (const char*) pAttributes[i+1];
                                        if (attributeName.CompareTo(XML_ELM_ID) == 0)
                                        {
-                                               pUserDataT->currentTexturFileNameId = atoi((const char*) pAttributes[i+1]);
+                                               pUserDataT->currentSurfaceId = atoi((const char*) pAttributes[i+1]);
                                                continue;
                                        }
-                                       if (attributeName.CompareTo(XML_ELM_TEXTURE_FILE_NAME_) == 0)
+                                       if (attributeName.CompareTo(XML_ELM_NAME) == 0)
+                                       {
+                                               pUserDataT->surfaceDescriptor.name = (const char*) pAttributes[i+1];
+                                               continue;
+                                       }
+                                       if (attributeName.CompareTo(XML_ELM_SRC_FILE_NAME) == 0)
                                        {
-                                               pUserDataT->texfureFileName = (const char*) pAttributes[i+1];
+                                               pUserDataT->surfaceDescriptor.sourceFileName = (const char*) pAttributes[i+1];
                                                continue;
                                        }
                                }
@@ -2793,9 +3264,9 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
 
        if (pUserDataT->isVisualElements)
        {
-               if (elementName.CompareTo("VisualElement") == 0)
+               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENT) == 0)
                {
-                       pUserDataT->isVisualElement = true;
+                       pUserDataT->isVisualElementCount++;
                        _SceneVisualElementDescriptor veDescr;
                        if (pAttributes != null)
                        {
@@ -2820,13 +3291,48 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                                veDescr.lightId = atoi((const char*) pAttributes[i+1]);
                                                continue;
                                        }
+                                       if (attributeName.CompareTo("surfaceId") == 0)
+                                       {
+                                               veDescr.surfaceId = atoi((const char*) pAttributes[i+1]);
+                                               continue;
+                                       }
+                                       String extraSurfaceParamName;
+                                       for (int j = 0; j < EXTRA_SURFACE_MAX; j++)
+                                       {
+                                               extraSurfaceParamName.Format(14 + 1 + 2, L"extraSurfaceId%1d", j);
+                                               if (attributeName.CompareTo(extraSurfaceParamName) == 0)
+                                               {
+                                                       veDescr.extraSurfaceId[j] = -1;
+                                                       veDescr.extraSurfaceId[j] = atoi((const char*) pAttributes[i+1]);
+
+                                                       AppLog("VE %ls extraSurface%d Id=%d attr name=\"%ls\" value=\"%s\"",
+                                                                       veDescr.name.GetPointer(), j, veDescr.extraSurfaceId[j], extraSurfaceParamName.GetPointer(), pAttributes[i+1]);
+                                                       continue;
+                                               }
+
+                                               extraSurfaceParamName.Format(21 + 1 + 2, L"extraSurfaceOpacity%1d", j);
+                                               if (attributeName.CompareTo(extraSurfaceParamName) == 0)
+                                               {
+                                                       veDescr.extraSurfaceOpacity[j] = 0.0f;
+                                                       sscanf((const char*) pAttributes[i+1], "%f", &(veDescr.extraSurfaceOpacity[j]));
+
+                                                       AppLog("VE %ls extraSurface%d Opacity=%f attr name=\"%ls\" value=\"%s\"",
+                                                                       veDescr.name.GetPointer(), j, veDescr.extraSurfaceOpacity[j], extraSurfaceParamName.GetPointer(), pAttributes[i+1]);
+                                                       continue;
+                                               }
+                                       }
+                                       if (attributeName.CompareTo("alphaMaskId") == 0)
+                                       {
+                                               veDescr.alphaMaskId = atoi((const char*) pAttributes[i+1]);
+                                               continue;
+                                       }
                                        if (attributeName.CompareTo("shaderProgramId") == 0)
                                        {
                                                veDescr.shaderProgramId = atoi((const char*) pAttributes[i+1]);
                                                continue;
                                        }
 
-                                       if (attributeName.CompareTo("name") == 0)
+                                       if (attributeName.CompareTo(XML_ELM_NAME) == 0)
                                        {
                                                veDescr.name = (const char*) pAttributes[i+1];
                                                continue;
@@ -2971,11 +3477,13 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                {
                                        Mesh* pMesh = pUserDataT->pSceneImpl->GetMeshAtN(veDescr.meshId);
                                        pVisualElement->SetMesh(pMesh);
+                                       delete pMesh;
                                }
                                if (veDescr.materialId != -1)
                                {
                                        Material* pMaterial = pUserDataT->pSceneImpl->GetMaterialAtN(veDescr.materialId);
                                        pVisualElement->SetMaterial(pMaterial);
+                                       delete pMaterial;
                                }
                                if (veDescr.lightId != -1)
                                {
@@ -2983,12 +3491,36 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                        if(pLight)
                                        {
                                                pVisualElement->AddLight(*pLight);
+                                               delete pLight;
                                        }
                                }
                                if (veDescr.shaderProgramId != -1)
                                {
                                        ShaderProgram* pShaderProgram = pUserDataT->pSceneImpl->GetShaderProgramAtN(veDescr.shaderProgramId);
                                        pVisualElement->SetShaderProgram(pShaderProgram);
+                                       delete pShaderProgram;
+                               }
+                               if (veDescr.surfaceId != -1)
+                               {
+                                       VisualElementSurface* pSurface = pUserDataT->pSceneImpl->GetSurfaceAtN(veDescr.surfaceId);
+                                       pVisualElement->SetSurface(pSurface);
+                                       delete pSurface;
+                               }
+                               for (int i = 0; i < EXTRA_SURFACE_MAX; i++)
+                               {
+                                       if (veDescr.extraSurfaceId[i] != -1)
+                                       {
+                                               VisualElementSurface* pSurface = pUserDataT->pSceneImpl->GetSurfaceAtN(veDescr.extraSurfaceId[i]);
+                                               pVisualElement->SetExtraSurface((ExtraSurfaceIndex)i, pSurface);
+                                               pVisualElement->SetExtraSurfaceOpacity((ExtraSurfaceIndex)i, veDescr.extraSurfaceOpacity[i]);
+                                               delete pSurface;
+                                       }
+                               }
+                               if (veDescr.alphaMaskId != -1)
+                               {
+                                       VisualElementSurface* pSurface = pUserDataT->pSceneImpl->GetSurfaceAtN(veDescr.alphaMaskId);
+                                       pVisualElement->SetAlphaMask(pSurface);
+                                       delete pSurface;
                                }
 
                                pUserDataT->pCurrentParentVisualElement->AttachChild(pVisualElement);
@@ -3006,7 +3538,7 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
        }
 
        //create empty recourses in scene lists, to save id structure
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
                if (elementName.CompareTo(XML_ELM_MESHS) == 0)
                {
@@ -3034,7 +3566,7 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
                if (elementName.CompareTo(XML_ELM_MATERIALS) == 0)
                {
@@ -3061,7 +3593,7 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
                if (elementName.CompareTo(XML_ELM_LIGHTS) == 0)
                {
@@ -3088,7 +3620,7 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
                if (elementName.CompareTo(XML_ELM_SHADER_PROGRAMS) == 0)
                {
@@ -3116,11 +3648,11 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
-               if (elementName.CompareTo(XML_ELM_TEXTURE_FILE_NAMES) == 0)
+               if (elementName.CompareTo(XML_ELM_SURFACES) == 0)
                {
-                       pUserDataT->isTextureFileNames = true;
+                       pUserDataT->isSurfaces = true;
                        if (pAttributes != null)
                        {
                                for (int i = 0; pAttributes[i] != null; i+=2)
@@ -3129,11 +3661,12 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                        if (attributeName.CompareTo(XML_ELM_COUNT) == 0)
                                        {
                                                count = atoi((const char*) pAttributes[i+1]);
-                                               attributeValue.Clear();
+                                               _SceneSurfaceDescriptor surfaceDescriptor;
+                                               surfaceDescriptor.Clear();
 
                                                for (int j = 0; j < count; j++)
                                                {
-                                                       pUserDataT->pSceneImpl->_textureFileNames.Add(attributeValue);
+                                                       pUserDataT->pSceneImpl->_surfaces.Add(surfaceDescriptor);
                                                }
                                                break;
                                        }
@@ -3143,9 +3676,9 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isTextureFileNames && !pUserDataT->isVisualElements)
+       if (pUserDataT->isScene && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms  && !pUserDataT->isSurfaces && !pUserDataT->isVisualElements)
        {
-               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENT) == 0)
+               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENTS) == 0)
                {
                        pUserDataT->isVisualElements = true;
                        return;
@@ -3159,7 +3692,6 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                        pUserDataT->isScene = true;
                        if (pAttributes != null)
                        {
-
                                for (int i = 0; pAttributes[i] != null; i+=2)
                                {
                                        attributeName = (const char*) pAttributes[i];
@@ -3169,6 +3701,23 @@ __LoadSceneOnStartElement(void* pUserData, const xmlChar* pName, const xmlChar *
                                                pUserDataT->pSceneImpl->SetName(attributeValue);
                                                break;
                                        }
+
+                                       if (attributeName.CompareTo(XML_ELM_VERSION) == 0)
+                                       {
+                                               attributeValue = (const char*) pAttributes[i+1];
+                                               int majorVer = 0;
+                                               int minorVer = 0;
+                                               int releaseVer = 0;
+                                               sscanf((const char*) pAttributes[i+1], "%d.%d.%d", &majorVer, &minorVer, &releaseVer);
+                                               if (majorVer != MAJOR_VERSION || minorVer != MINOR_VERSION || releaseVer != RELEASE)
+                                               {
+                                                       SysLogException(NID_UI_ANIM, E_INVALID_FORMAT, "Wrong scene format version. Expected \"%d.%d.%d\", got \"%d.%d.%d\".",
+                                                                       MAJOR_VERSION, MINOR_VERSION, RELEASE, majorVer, minorVer, releaseVer);
+                                                       pUserDataT->parsingResult = E_INVALID_FORMAT;
+                                                       return;
+                                               }
+                                               break;
+                                       }
                                }
                        }
                        return;
@@ -3194,45 +3743,53 @@ __LoadSceneOnContent(void* pUserData, const xmlChar* pContent, int length)
                return;
        }
 
-       if (pUserDataT->isVertexShader)
-       {
-               char* pVertexUtf8Text = new char[length + 2];
-               if (pVertexUtf8Text != null)
-               {
-                       strncpy(pVertexUtf8Text, (const char*)pContent, length);
-                       pVertexUtf8Text[length] = '\0';
-                       Tizen::Base::Utility::StringUtil::Utf8ToString(pVertexUtf8Text, pUserDataT->shaderProgramDescriptor.vertexShader);
-               }
-               else
-               {
-                       SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-                       pUserDataT->parsingResult = E_OUT_OF_MEMORY;
-               }
-
-//             pUserDataT->shaderProgramDescriptor.vertexShader = (const char*)pContent;
-//             pUserDataT->shaderProgramDescriptor.vertexShader.SetLength(length);
-               return;
-       }
-
-       if (pUserDataT->isFragmentShader)
-       {
-               char* pFragmentUtf8Text = new char[length + 2];
-               if (pFragmentUtf8Text != null)
-               {
-                       strncpy(pFragmentUtf8Text, (const char*)pContent, length);
-                       pFragmentUtf8Text[length] = '\0';
-                       Tizen::Base::Utility::StringUtil::Utf8ToString(pFragmentUtf8Text, pUserDataT->shaderProgramDescriptor.fragmentShader);
-               }
-               else
-               {
-                       SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-                       pUserDataT->parsingResult = E_OUT_OF_MEMORY;
-               }
+//     if (pUserDataT->isVertexShader)
+//     {
+//             char* pVertexUtf8Text = new char[length + 2];
+//             if (pVertexUtf8Text != null)
+//             {
+//                     strncpy(pVertexUtf8Text, (const char*)pContent, length);
+//                     pVertexUtf8Text[length] = '\0';
+//#ifndef BUILD_UI_CORE
+//                     Tizen::Base::Utility::StringUtil::Utf8ToString(pVertexUtf8Text, pUserDataT->shaderProgramDescriptor.vertexShader);
+//#else
+//                     pUserDataT->shaderProgramDescriptor.vertexShader = String(pVertexUtf8Text);
+//#endif
+//             }
+//             else
+//             {
+//                     SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+//                     pUserDataT->parsingResult = E_OUT_OF_MEMORY;
+//             }
+//
+////           pUserDataT->shaderProgramDescriptor.vertexShader = (const char*)pContent;
+////           pUserDataT->shaderProgramDescriptor.vertexShader.SetLength(length);
+//             return;
+//     }
 
-//             pUserDataT->shaderProgramDescriptor.fragmentShader = (const char*)pContent;
-//             pUserDataT->shaderProgramDescriptor.fragmentShader.SetLength(length);
-               return;
-       }
+//     if (pUserDataT->isFragmentShader)
+//     {
+//             char* pFragmentUtf8Text = new char[length + 2];
+//             if (pFragmentUtf8Text != null)
+//             {
+//                     strncpy(pFragmentUtf8Text, (const char*)pContent, length);
+//                     pFragmentUtf8Text[length] = '\0';
+//#ifndef BUILD_UI_CORE
+//                     Tizen::Base::Utility::StringUtil::Utf8ToString(pFragmentUtf8Text, pUserDataT->shaderProgramDescriptor.fragmentShader);
+//#else
+//                     pUserDataT->shaderProgramDescriptor.fragmentShader = String(pFragmentUtf8Text);
+//#endif
+//             }
+//             else
+//             {
+//                     SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+//                     pUserDataT->parsingResult = E_OUT_OF_MEMORY;
+//             }
+//
+////           pUserDataT->shaderProgramDescriptor.fragmentShader = (const char*)pContent;
+////           pUserDataT->shaderProgramDescriptor.fragmentShader.SetLength(length);
+//             return;
+//     }
 }
 
 void
@@ -3248,11 +3805,11 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                return;
        }
 
-       if (pUserDataT->isVisualElements &&  pUserDataT->isVisualElement)
+       if (pUserDataT->isVisualElements &&  pUserDataT->isVisualElementCount > 0)
        {
-               if (elementName.CompareTo("VisualElement") == 0)
+               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENT) == 0)
                {
-                       pUserDataT->isVisualElement = false;
+                       pUserDataT->isVisualElementCount--;
                        if (pUserDataT->pCurrentParentVisualElement != null && pUserDataT->pCurrentParentVisualElement != pUserDataT->pSceneImpl->GetRootVisualElement())
                        {
                                pUserDataT->pCurrentParentVisualElement = pUserDataT->pCurrentParentVisualElement->GetParent();
@@ -3277,7 +3834,7 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        String meshFileName;
                        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 = ModelImporter::LoadMeshN(meshFileName, "");
 
                        if (pUserDataT->meshDescriptor.pMesh != null)
                        {
@@ -3292,6 +3849,7 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        }
                        else
                        {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load Mesh #%d from %ls", pUserDataT->currentMeshId, meshFileName.GetPointer() );
                                pUserDataT->pSceneImpl->_meshes.SetAt(pUserDataT->meshDescriptor, pUserDataT->currentMeshId);
                        }
                        return;
@@ -3310,8 +3868,6 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        materialFileName.Format(pUserDataT->resourceFilesPath.GetLength() + pUserDataT->scenePrefix.GetLength() + materialResFileName.GetLength() + materialResFileExtension.GetLength() + 8 + 2, \
                                        L"%ls%ls%ls%04d%ls", pUserDataT->resourceFilesPath.GetPointer(), pUserDataT->scenePrefix.GetPointer(), materialResFileName.GetPointer(), pUserDataT->currentMaterialId, materialResFileExtension.GetPointer());
                        pUserDataT->materialDescriptor.pMaterial = _MaterialParser::LoadMaterialN(materialFileName);
-                       //TODO://pUserDataT->materialDescriptor.pMaterial = ModelImporter::LoadMaterialN(ModelImporter::BIN, materialFileName, "", null);
-                       //pUserDataT->materialDescriptor.pMaterial = null;
 
                        if (pUserDataT->materialDescriptor.pMaterial != null)
                        {
@@ -3326,6 +3882,7 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        }
                        else
                        {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load Material #%d from %ls", pUserDataT->currentMaterialId, materialFileName.GetPointer() );
                                pUserDataT->pSceneImpl->_materials.SetAt(pUserDataT->materialDescriptor, pUserDataT->currentMaterialId);
                        }
                        return;
@@ -3344,8 +3901,6 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        lightFileName.Format(pUserDataT->resourceFilesPath.GetLength() + pUserDataT->scenePrefix.GetLength() + lightResFileName.GetLength() + lightResFileExtension.GetLength() + 8 + 2, \
                                        L"%ls%ls%ls%04d%ls", pUserDataT->resourceFilesPath.GetPointer(), pUserDataT->scenePrefix.GetPointer(), lightResFileName.GetPointer(), pUserDataT->currentLightId, lightResFileExtension.GetPointer());
                        pUserDataT->lightDescriptor.pLight = _LightParser::LoadLightN(lightFileName);
-                       //TODO://pUserDataT->lightDescriptor.pLight = ModelImporter::LoadLightN(ModelImporter::BIN, lightFileName, "", null);
-                       //pUserDataT->lightDescriptor.pLight = null;
 
                        if (pUserDataT->lightDescriptor.pLight != null)
                        {
@@ -3360,6 +3915,7 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                        }
                        else
                        {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load Light #%d from %ls", pUserDataT->currentLightId, lightFileName.GetPointer() );
                                pUserDataT->pSceneImpl->_lights.SetAt(pUserDataT->lightDescriptor, pUserDataT->currentLightId);
                        }
                        return;
@@ -3391,21 +3947,18 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
 
                        if (vertex.good())
                        {
-                               std::filebuf* pVertexFileBuf = vertex.rdbuf();
-                               if (pVertexFileBuf != null)
-                               {
-                                       std::size_t vertexSize = pVertexFileBuf->pubseekoff (0, vertex.end, vertex.in);
-                                       pVertexFileBuf->pubseekpos (0, vertex.in);
-                                       char* pVertexText = new (std::nothrow) char[vertexSize+2];
-                                       if (pVertexText != null)
-                                       {
-                                               pVertexFileBuf->sgetn(pVertexText, vertexSize);
-                                               pVertexText[vertexSize] = '\0';
-                                               pUserDataT->shaderProgramDescriptor.vertexShader = pVertexText;
-                                       }
-                               }
+                               std::string vertexText;
+
+                               std::getline(vertex, vertexText, '\0');
+
+                               pUserDataT->shaderProgramDescriptor.vertexShader = vertexText.c_str();
+
                                vertex.close();
                        }
+                       else
+                       {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load VertexShader #%d from %s", pUserDataT->currentShaderProgramId, tempString.c_str() );
+                       }
 
                        String fragmentShaderResFileName = SCENE_FRAGMENT_SHADER_RESOURCE_FILE_NAME;
                        String fragmentShaderResFileExtension = SCENE_FRAGMENT_SHADER_RESOURCE_FILE_EXTENSION;
@@ -3420,21 +3973,19 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
 
                        if (fragment.good())
                        {
-                               std::filebuf* pFragmentFileBuf = fragment.rdbuf();
-                               if (pFragmentFileBuf != null)
-                               {
-                                       std::size_t fragmentSize = pFragmentFileBuf->pubseekoff (0, fragment.end, fragment.in);
-                                       pFragmentFileBuf->pubseekpos (0, fragment.in);
-                                       char* pFragmentText = new (std::nothrow) char[fragmentSize+2];
-                                       if (pFragmentText != null)
-                                       {
-                                               pFragmentFileBuf->sgetn(pFragmentText, fragmentSize);
-                                               pFragmentText[fragmentSize] = '\0';
-                                               pUserDataT->shaderProgramDescriptor.fragmentShader = pFragmentText;
-                                       }
-                               }
+
+                               std::string fragmentText;
+
+                               std::getline(fragment, fragmentText, '\0');
+
+                               pUserDataT->shaderProgramDescriptor.fragmentShader = fragmentText.c_str();
+
                                fragment.close();
                        }
+                       else
+                       {
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load FragmentShader #%d from %s", pUserDataT->currentShaderProgramId, tempString.c_str() );
+                       }
 
                        //shader loaded to String, build'em
 
@@ -3485,12 +4036,69 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
 //             }
 //     }
 
-       if (pUserDataT->isTextureFileNames && pUserDataT->isTextureFileName)
+       if (pUserDataT->isSurfaces && pUserDataT->isSurface)
        {
-               if (elementName.CompareTo(XML_ELM_TEXTURE_FILE_NAME) == 0)
+               if (elementName.CompareTo(XML_ELM_SURFACE) == 0)
                {
-                       pUserDataT->isTextureFileName = false;
-                       pUserDataT->pSceneImpl->_textureFileNames.SetAt(pUserDataT->texfureFileName, pUserDataT->currentTexturFileNameId);
+                       pUserDataT->isSurface = false;
+
+                       String surfaceFileAbsolutePath;
+                       surfaceFileAbsolutePath.Format(pUserDataT->resourceFilesPath.GetLength() + pUserDataT->surfaceDescriptor.sourceFileName.GetLength()+ 2 , L"%ls%ls", pUserDataT->resourceFilesPath.GetPointer(), pUserDataT->surfaceDescriptor.sourceFileName.GetPointer());
+
+                       if (!pUserDataT->surfaceDescriptor.sourceFileName.IsEmpty())
+                       {
+                               VisualElementSurface* pSurface = new VisualElementSurface();
+
+                               if (!pSurface)
+                               {
+                                       SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+                                       pUserDataT->parsingResult = E_OUT_OF_MEMORY;
+                                       return;
+                               }
+
+//Surface loading
+#ifndef BUILD_UI_CORE
+                               Tizen::Media::Image image;
+                               image.Construct();
+
+                               Tizen::Graphics::Bitmap* pBitmap = image.DecodeN(surfaceFileAbsolutePath, BITMAP_PIXEL_FORMAT_ARGB8888);
+                               if (pBitmap != null)
+                               {
+                                       pSurface->Construct(*(pUserDataT->pDisplayContext), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight()));
+
+                                       Tizen::Graphics::Canvas canvas;
+                                       Tizen::Graphics::BufferInfo bufferInfo;
+                                       pSurface->GetBufferInfo(bufferInfo);
+                                       canvas.Construct(bufferInfo);
+                                       canvas.DrawBitmap(Point(0, 0), *pBitmap);
+
+                                       delete pBitmap;
+                                       pBitmap = null;
+                               }
+                               else
+                               {
+                                       SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Failed to load Surface Image #%d from %ls", pUserDataT->currentSurfaceId, surfaceFileAbsolutePath.GetPointer() );
+                                       delete pSurface;
+                                       pSurface = null;
+                               }
+#else
+                               tempWString = surfaceFileAbsolutePath.GetPointer();
+                               tempString = ConvertWStringToString(tempWString);
+                               pSurface = UiCore::LoadTextureN(pUserDataT->pDisplayContext, tempString.c_str());
+#endif
+
+                               pUserDataT->surfaceDescriptor.pSurface = pSurface;
+                       }
+                       else
+                       {
+                               pUserDataT->surfaceDescriptor.pSurface = null;
+                               SysLogException(NID_UI_ANIM, E_OPERATION_FAILED, "Empty Surface Image file name #%d", pUserDataT->currentLightId );
+                       }
+
+                       pUserDataT->pSceneImpl->_surfaces.SetAt(pUserDataT->surfaceDescriptor, pUserDataT->currentSurfaceId);
+
+                       //pUserDataT->surfaceDescriptor.pSurface = null; //todp: remove clear
+
                        return;
                }
        }
@@ -3537,25 +4145,25 @@ __LoadSceneOnEndElement(void* pUserData, const xmlChar* pName)
                }
        }
 
-       if (pUserDataT->isTextureFileNames && !pUserDataT->isTextureFileName)
+       if (pUserDataT->isSurfaces && !pUserDataT->isSurface)
        {
-               if (elementName.CompareTo(XML_ELM_TEXTURE_FILE_NAMES) == 0)
+               if (elementName.CompareTo(XML_ELM_SURFACES) == 0)
                {
-                       pUserDataT->isTextureFileNames = false;
+                       pUserDataT->isSurfaces = false;
                        return;
                }
        }
 
-       if (pUserDataT->isVisualElements && !pUserDataT->isVisualElement)
+       if (pUserDataT->isVisualElements && pUserDataT->isVisualElementCount == 0)
        {
-               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENT) == 0)
+               if (elementName.CompareTo(XML_ELM_VISUAL_ELEMENTS) == 0)
                {
                        pUserDataT->isVisualElements = false;
                        return;
                }
        }
 
-       if (pUserDataT->isScene && !pUserDataT->isVisualElements && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms && !pUserDataT->isTextureFileNames)
+       if (pUserDataT->isScene && !pUserDataT->isVisualElements && !pUserDataT->isMeshes && !pUserDataT->isMaterials && !pUserDataT->isLights && !pUserDataT->isShaderPrograms && !pUserDataT->isSurfaces)
        {
                if (elementName.CompareTo(XML_ELM_SCENE) == 0)
                {
index 9be2bf5..5ab28a1 100644 (file)
@@ -49,6 +49,11 @@ const wchar_t* VeAttrNormal                                  = L"a_normal";
 const wchar_t* VeAttrWeights                           = L"a_weights"; //skinning
 const wchar_t* VeAttrJoints                                    = L"a_joints_ids"; //skinning
 
+const wchar_t* VeAttrJointIndex0                       = L"a_jointIndex0"; //skinning
+const wchar_t* VeAttrJointIndex1                       = L"a_jointIndex1"; //skinning
+const wchar_t* VeAttrJointIndex2                       = L"a_jointIndex2"; //skinning
+const wchar_t* VeAttrJointIndex3                       = L"a_jointIndex3"; //skinning
+
 const wchar_t* VeUniformMVP                                    = L"u_mvp";
 const wchar_t* VeUniformColor                          = L"u_color";
 const wchar_t* VeUniformTex2D                          = L"u_tex2d";
@@ -56,7 +61,7 @@ const wchar_t* VeUniformOpacity                               = L"u_opacity";
 const wchar_t* VeUniformMV                                     = L"u_modelview";
 const wchar_t* VeUniformInvMV                          = L"u_inv_modelview";
 
-const wchar_t* VeUniformJointsMatrices         = L"u_joints_matrices"; //skinning
+const wchar_t* VeUniformJointsMatrices         = L"u_joints_matrices[0]"; //skinning
 
 const wchar_t* VeUniformLightType                      = L"u_light[%d].type";
 const wchar_t* VeUniformLightAmbient           = L"u_light[%d].ambient";
@@ -222,6 +227,13 @@ _ShaderProgramImpl::MakeUniformLocationTable(void)
        MoveUniformItem(UNIFORM_MAT4_ARRAY_JOINTSMATRICES, VeUniformJointsMatrices);
 
        Tizen::Base::String str;
+
+//     for (int i = 0; i < MAX_JOINT_COUNT; i++)
+//     {
+//             str.Format(MAX_STRING_LENGHT, VeUniformJointsMatrices, i);
+//             MoveUniformItem(UNIFORM_MAT4_ARRAY_JOINTSMATRICES + i, str.GetPointer());
+//     }
+
        for (int i = 0; i < MAX_LIGHT_COUNT; i++)
        {
                int offset = (UNIFORM_VEC3_LIGHT_ATTENUATION - UNIFORM_INT_LIGHT_TYPE + 1) * i + (UNIFORM_SAMPLER2D_EXTRA_SURFACE - UNIFORM_FLOAT_EXTRA_SURFACE_OPACITY+1)*(EXTRA_SURFACE_MAX - 1);
@@ -273,8 +285,8 @@ _ShaderProgramImpl::MakeUniformLocationTable(void)
        MoveUniformItem(UNIFORM_INT_ACTIVE_LIGHT_COUNT, VeUniformActiveLightCount);
        MoveUniformItem(UNIFORM_VEC3_EYE_POSITION, VeUniformEyePosition);
        MoveUniformItem(UNIFORM_BOOL_USE_TEXTURE, VeUniformUseTexture);
-
        MoveUniformItem(UNIFORM_SAMPLER2D_ALPHA_MASK, VeUniformTex2DAlphaMask);
+
        MoveUniformItem(UNIFORM_INT_EXTRA_SURFACE_COUNT, VeUniformExtraSurfaceCount);
        MoveUniformItem(UNOFORM_INT_ALPHA_MASK_COUNT, VeUniformAlphaMaskCount);
 }
index 23076eb..e6517e7 100644 (file)
@@ -42,6 +42,11 @@ extern const wchar_t* VeAttrNormal;
 extern const wchar_t* VeAttrWeights;
 extern const wchar_t* VeAttrJoints;
 
+extern const wchar_t* VeAttrJointIndex0;
+extern const wchar_t* VeAttrJointIndex1;
+extern const wchar_t* VeAttrJointIndex2;
+extern const wchar_t* VeAttrJointIndex3;
+
 extern const wchar_t* VeUniformMVP;
 extern const wchar_t* VeUniformColor;
 extern const wchar_t* VeUniformTex2D;
@@ -91,6 +96,10 @@ enum AttributeLocation
 
        ATTRIBUTE_VEC4_WEIGHTS,                         /**< Attribute for joints weights*/
        ATTRIBUTE_VEC4_JOINTS,                          /**< Attribute for skeletal joints*/
+       ATTRIBUTE_INT_INDEX0,                           /**< Attribute for skeletal joints*/
+       ATTRIBUTE_INT_INDEX1,                           /**< Attribute for skeletal joints*/
+       ATTRIBUTE_INT_INDEX2,                           /**< Attribute for skeletal joints*/
+       ATTRIBUTE_INT_INDEX3,                           /**< Attribute for skeletal joints*/
 
        ATTRIBUTE_LOCATION_MAX                          /**< Maximum of attribute location */
 };
diff --git a/src/ui/animations/FUiAnim_SkeletonModelProcessing.cpp b/src/ui/animations/FUiAnim_SkeletonModelProcessing.cpp
new file mode 100644 (file)
index 0000000..2cc74e7
--- /dev/null
@@ -0,0 +1,304 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FUiAnim_SkeletonModelProcessing.h>
+#include <FUiAnim_MathAdapterFunctions.h>
+#include <set>
+
+#include <FUiAnim_MeshControllerImpl.h>
+
+using namespace Tizen::Ui::Animations::_Math;
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+_SkeletonModelProcessing::_SkeletonModelProcessing(void)
+{}
+
+_SkeletonModelProcessing::~_SkeletonModelProcessing(void)
+{}
+
+void
+_SkeletonModelProcessing::GetBonesForRootBone(Tizen::Ui::Animations::_JointImpl& bone, std::vector<Tizen::Ui::Animations::_JointImpl*>& bones)
+{
+       int childrenCount = bone.GetChildrenCount();
+       for (int i = 0; i < childrenCount; ++i)
+       {
+               _JointImpl* childElement = dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(bone.GetChildAt(i));
+               bones.push_back(childElement);
+               GetBonesForRootBone(*childElement, bones);
+       }
+       return;
+}
+
+bool
+_SkeletonModelProcessing::PrepareData(Tizen::Ui::Animations::_JointImpl& rootBone, const float* weightsList, const float* pIDs, const std::vector<_Math::Vector3>& vertices, std::vector<Tizen::Ui::Animations::_JointImpl*>& Joints, const std::vector<int>& vertexIndices)
+{
+       std::set<unsigned short> uniqueIndices;
+       bool fakeVertexesFlag = false;
+       int indicesSize = vertexIndices.size();
+
+       for (int i = 0; i < indicesSize; i++)
+       {
+               uniqueIndices.insert(vertexIndices[i]);
+       }
+
+       std::set<unsigned short>::iterator itEnd = uniqueIndices.end();
+       if (vertices.size() != uniqueIndices.size())
+       {
+               fakeVertexesFlag = true;
+       }
+
+       std::vector<Tizen::Ui::Animations::_JointImpl*> bones;
+       bones.clear();
+
+       bones.push_back(&rootBone);
+       GetBonesForRootBone(rootBone, bones);
+
+       std::vector<Tizen::Ui::Animations::_JointImpl*>::iterator itr;
+       int k = 0;
+    //=================Creates data structure=================
+       std::vector<Tizen::Ui::Animations::_JointImpl*>::const_iterator endBones = bones.end();
+       int bonesCount = bones.size();
+       int weightsCount = vertices.size() * 4;
+       __bonesForVertex.resize(bonesCount);
+
+       for (itr = bones.begin(); itr != endBones; itr++)
+       {
+               if (*itr == null)
+               {
+                       continue;
+               }
+               for (int b = 0; b < bonesCount; b++)
+               {
+                       if((**itr).GetName() == Joints[b]->GetName())
+                       {
+                               for(int i = 0; i < weightsCount; ++i)
+                               {
+                                       if (b == (int)pIDs[i])
+                                       {
+                                               if (fakeVertexesFlag == false || uniqueIndices.find((int)i / (int)4) != itEnd)
+                                               {
+                                                       if (Equal(weightsList[i], 0.f))
+                                                       {
+                                                               continue;
+                                                       }
+                                                       __bonesForVertex[k].weight.push_back(weightsList[i]);
+                                                       __bonesForVertex[k].vertex.push_back(vertices[(int)i / (int)4]);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (__bonesForVertex[k].bone == null)//maybe redundant
+               {
+                       __bonesForVertex[k].bone = bones[k];
+               }
+               k++;
+       }
+
+       for (std::vector<SkeletData>::size_type i = 0; i < __bonesForVertex.size(); ++i)
+       {
+               if (__bonesForVertex[i].vertex.size() != 0)
+               {
+                       __bones.push_back(__bonesForVertex[i].bone);
+               }
+       }
+
+       for (int i = 0; i < bonesCount; ++i)
+       {
+               if (__bonesForVertex[i].vertex.size() != 0)
+               {
+                       __centerContainer.push_back(_Math::FindOrientedBox(__bonesForVertex[i].vertex));
+               }
+       }
+
+       for (int i = 0; i < bonesCount; ++i)
+       {
+               if (__bonesForVertex[i].vertex.size() > 0)
+               {
+                       int childrenCount = __bonesForVertex[i].bone->GetChildrenCount();
+                       if (!(childrenCount == 0))
+                       {
+                               for (int b = 0; b < childrenCount; ++b)
+                               {
+                                       for (int j = 0; j < bonesCount; ++j)
+                                       {
+                                               if (dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(__bonesForVertex[i].bone->GetChildAt(b))->GetName() == __bonesForVertex[j].bone->GetName())
+                                               {
+                                                       if (__bonesForVertex[j].vertex.size() == 0)
+                                                       {
+                                                               if(!IgnoreFakeBone(i, *dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(__bonesForVertex[i].bone->GetChildAt(b))))
+                                                               {
+                                                                       //return false;
+                                                               }
+                                                               break;
+                                                       }
+                                                       int mb = i;
+                                                       for (int b = 0; b <= i; ++b)
+                                                       {
+                                                               if (__bonesForVertex[b].vertex.size() == 0)
+                                                               {
+                                                                       mb--;
+                                                               }
+                                                       }
+                                                       __indexes.push_back(mb);
+                                                       mb = j;
+                                                       for (int b = 0; b <= j; ++b)
+                                                       {
+                                                               if (__bonesForVertex[b].vertex.size() == 0)
+                                                               {
+                                                                       mb--;
+                                                               }
+                                                       }
+                                                       __indexes.push_back(mb);
+                                               }
+                                       }
+                          }
+                  }
+               }
+               else if (i == 0)
+               {
+                       std::vector<int> tempBone;
+                       if(!IgnoreRootFakeBone(*dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(__bonesForVertex[i].bone->GetChildAt(0)), tempBone))
+                       {
+                               return false;
+                       }
+                       if (tempBone.size() > 1)
+                       {
+                               for (std::vector<int>::size_type it = 0; it < tempBone.size() - 1; ++it)
+                               {
+                                       __indexes.push_back(tempBone[it]);
+                                       __indexes.push_back(tempBone[it + 1]);
+                               }
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+       }
+       return true;
+}
+
+bool
+_SkeletonModelProcessing::IgnoreFakeBone(int j, Tizen::Ui::Animations::_JointImpl& bone)
+{
+       int childrenCount = bone.GetChildrenCount();
+       if (!(childrenCount == 0))
+       {
+               for(int b = 0; b < childrenCount; ++b)
+               {
+                       for (std::vector<SkeletData>::size_type i = 0; i < __bonesForVertex.size(); ++i)
+                       {
+                               if (dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(bone.GetChildAt(b))->GetName() == __bonesForVertex[i].bone->GetName())
+                               {
+                                       if (__bonesForVertex[i].vertex.size() == 0)
+                                       {
+                                               IgnoreFakeBone(j, *dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(bone.GetChildAt(b)));
+                                       }
+                                       else
+                                       {
+                                               int mb = j;
+                                               for (int b = 0; b <= j; ++b)
+                                               {
+                                                       if (__bonesForVertex[b].vertex.size() == 0)
+                                                       {
+                                                               mb--;
+                                                       }
+                                               }
+                                               __indexes.push_back(mb);
+                                               mb = i;
+                                               for (std::vector<SkeletData>::size_type b = 0; b <= i; ++b)
+                                               {
+                                                       if (__bonesForVertex[b].vertex.size() == 0)
+                                                       {
+                                                               mb--;
+                                                       }
+                                               }
+                                               __indexes.push_back(mb);
+                                       }
+                               }
+                       }
+               }
+       }
+       else
+       {
+               return false;
+       }
+       return true;
+}
+
+bool
+_SkeletonModelProcessing::IgnoreRootFakeBone(Tizen::Ui::Animations::_JointImpl& bone, std::vector<int>& tempBone)
+{
+       int childrenCount = bone.GetChildrenCount();
+       if (!(childrenCount == 0))
+       {
+               for (int b = 0; b < childrenCount; ++b)
+               {
+                       for (std::vector<SkeletData>::size_type i = 0; i < __bonesForVertex.size(); i++)
+                       {
+                               if (dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(bone.GetChildAt(b))->GetName() == __bonesForVertex[i].bone->GetName())
+                               {
+                                       if (__bonesForVertex[i].vertex.size() == 0)
+                                       {
+                                               IgnoreRootFakeBone(*dynamic_cast<Tizen::Ui::Animations::_JointImpl*>(bone.GetChildAt(b)), tempBone);
+                                       }
+                                       else
+                                       {
+                                               int mb = i;
+                                               for (std::vector<SkeletData>::size_type b = 0; b <= i; b++)
+                                               {
+                                                       if (__bonesForVertex[b].vertex.size() == 0)
+                                                       {
+                                                               mb--;
+                                                       }
+                                               }
+                                               tempBone.push_back(mb);
+                                       }
+                               }
+                       }
+               }
+       }
+       else
+       {
+               return false;
+       }
+       return true;
+}
+
+_SkeletonModelProcessing::OrientedBoxes
+_SkeletonModelProcessing::GetOrientedBoxes(void) const
+{
+       return __centerContainer;
+}
+
+const _SkeletonModelProcessing::Indices&
+_SkeletonModelProcessing::GetIndixes(void) const
+{
+       return __indexes;
+}
+
+_SkeletonModelProcessing::Bones
+_SkeletonModelProcessing::GetBones(void)
+{
+       return __bones;
+}
+
+
+}}} // Tizen::Ui::Animations
diff --git a/src/ui/animations/FUiAnim_SkeletonModelProcessing.h b/src/ui/animations/FUiAnim_SkeletonModelProcessing.h
new file mode 100644 (file)
index 0000000..e4c3678
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef _FUI_ANIM_SKELETON_MODEL_PROC_H_
+#define _FUI_ANIM_SKELETON_MODEL_PROC_H_
+
+#include <math.h>
+#include <vector>
+#include <FUiAnim_MathMatrix3.h>
+#include <FUiAnim_MathMatrix4.h>
+#include <FUiAnim_MathVector3.h>
+#include <FUiAnim_MathTools.h>
+#include <FUiAnim_JointImpl.h>
+//#include <FUiAnim_MeshControllerImpl.h>
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+
+class _SkeletonModelProcessing
+{
+public:
+       typedef std::vector<Tizen::Ui::Animations::_Math::OrientedBox> OrientedBoxes;
+       typedef std::vector<int> Indices;
+       typedef std::vector<Tizen::Ui::Animations::_JointImpl*> Bones;
+
+public:
+       _SkeletonModelProcessing(void);
+       virtual ~_SkeletonModelProcessing(void);
+
+       bool PrepareData(Tizen::Ui::Animations::_JointImpl& rootBone, const float* weightsList, const float* pIDs, const std::vector<Tizen::Ui::Animations::_Math::Vector3>& vertices, std::vector<Tizen::Ui::Animations::_JointImpl*>& Joints, const std::vector<int>& vertexIndices);
+       OrientedBoxes GetOrientedBoxes(void) const;
+       const Indices& GetIndixes(void) const;
+       Bones GetBones(void);
+
+private:
+    //not impl
+       _SkeletonModelProcessing& operator=(const _SkeletonModelProcessing& rhs);
+       //not impl
+       _SkeletonModelProcessing(const _SkeletonModelProcessing& rhs);
+
+private:
+       struct SkeletData
+       {
+               Tizen::Ui::Animations::_JointImpl* bone;
+               std::vector<Tizen::Ui::Animations::_Math::Vector3> vertex;
+               std::vector<float> weight;
+
+               SkeletData(void)
+                       : bone(0)
+                       , vertex()
+                       , weight()
+               {
+
+               }
+       };
+
+private:
+       void GetBonesForRootBone(Tizen::Ui::Animations::_JointImpl& bone, std::vector<Tizen::Ui::Animations::_JointImpl*>& bones);
+       bool IgnoreFakeBone(int j, Tizen::Ui::Animations::_JointImpl& bone);
+       bool IgnoreRootFakeBone(Tizen::Ui::Animations::_JointImpl& bone, std::vector<int>& tempBone);
+
+       std::vector<SkeletData> __bonesForVertex;
+       OrientedBoxes __centerContainer;
+       Indices __indexes;
+
+       Bones __bones;
+};
+
+}}} // Tizen::Ui::Animations
+
+#endif //_FUI_ANIM_PHYS_INTERNAL_UTILS_SKELETON_MODEL_PROC_H_
index d8f3180..eb2f8e2 100644 (file)
@@ -26,8 +26,8 @@
 #define _FUI_ANIM_INTERNAL_TRANSACTION_NODE_H_
 
 #include <FBaseErrorDefine.h>
-#include <FBaseColArrayList.h>
 #include <FBaseColArrayListT.h>
+#include <FBaseColArrayList.h>
 #include <FBaseColHashMapT.h>
 
 #include "FUiAnim_VisualElementAnimationImpl.h"
index e393fa0..b334a09 100644 (file)
@@ -98,6 +98,7 @@
 #include "FUiAnim_Ray.h"
 #include "FUiAnim_Plane.h"
 #include "FUiAnimBoundingVolume.h"
+#include <FUiAnim_MathTools.h>
 //#include "FUi_Matrix4f.h"
 //#include "FGrpFloatRectangle.h"
 //#include "FUiAnim_NativeLayer.h"
@@ -1565,6 +1566,20 @@ _VisualElementImpl::SetExtraSurfaceOpacity(ExtraSurfaceIndex extraSurfaceIndex,
        return E_SUCCESS;
 }
 
+float
+_VisualElementImpl::GetExtraSurfaceOpacity(const ExtraSurfaceIndex extraSurfaceIndex) const
+{
+       SysTryReturnResult(NID_UI_ANIM, (extraSurfaceIndex >= 0 && extraSurfaceIndex < EXTRA_SURFACE_MAX), E_INVALID_ARG, "invalit extraSurfaceIndex");
+       SysTryReturnResult(NID_UI_ANIM, GetSharedData().pExtraSurfaceList[extraSurfaceIndex], E_OBJ_NOT_FOUND, "EXTRA_SURFACE_%d not exist.", extraSurfaceIndex+1);
+
+       if (GetSharedData().pExtraSurfaceList[extraSurfaceIndex] != null)
+       {
+               return GetSharedData().extraSurfaceOpacity[extraSurfaceIndex];
+       }
+
+       return 0.0f;
+}
+
 VisualElementSurface*
 _VisualElementImpl::GetAlphaMaskN(void) const
 {
@@ -1694,7 +1709,7 @@ _VisualElementImpl::SetContentBoundsI(const FloatRectangle& contentBounds)
        if (unlikely(RectUtilIsEqual(__contentBounds, contentBounds)))
                return E_SUCCESS;
 
-       SysTryReturnResult(NID_UI_ANIM, contentBounds.width > 0.0f && contentBounds.height > 0.0f, E_INVALID_ARG, "Invalid argument(s) is used. The size of contents bounds must be greater than 0.0f.");
+       SysTryReturnResult(NID_UI_ANIM, contentBounds.width >= 0.0f && contentBounds.height >= 0.0f, E_INVALID_ARG, "Invalid argument(s) is used. The size of contents bounds must be greater than or equal to 0.0f.");
 
        __contentBounds = contentBounds;
        __useContentBounds = (__contentBounds.x != 0.0f || __contentBounds.y != 0.0f || __contentBounds.width != 1.0f || __contentBounds.height != 1.0f);
@@ -7132,6 +7147,8 @@ _VisualElementImpl::GetRenderObjectProperty(const Tizen::Base::String& property)
 int
 _VisualElementImpl::HitTestI(const FloatPoint& point, const _Ray* pGlobalRay)
 {
+       int hitTestRes = HITTEST_NOWHERE;
+
        if (!IsVisibleI())
        {
                return HITTEST_NOWHERE;
@@ -7177,6 +7194,8 @@ _VisualElementImpl::HitTestI(const FloatPoint& point, const _Ray* pGlobalRay)
                                pClipSource = pClipSource->GetClipSource();
                        }
                }
+
+               hitTestRes = HITTEST_MATCH;
        }
        else // mesh is assigned - do 3D HitTest
        {
@@ -7187,45 +7206,93 @@ _VisualElementImpl::HitTestI(const FloatPoint& point, const _Ray* pGlobalRay)
                }
                else
                {
-                       localRay.MakeRayLocal(point, this->GetRenderObject()->GetMatrixToTop()); //make local ray for mesh
+                       _Ray globalRay;
+                       globalRay.MakeRayGlobal(this, point);
+                       localRay.MakeRayLocal(globalRay, this->GetRenderObject()->GetMatrixToTop()); //make local ray for mesh
                }
 
-               std::pair<bool, float> intersect = localRay.Intersect(pMesh->GetBoundingVolume());
 
-               if (intersect.first) // box intersected
+               //gets information from Mesh and MeshController
+               MeshController* pMeshController = pMesh->GetMeshController();
+
+               if (pMeshController) //if model is skeletal
                {
-                       //hit VE mesh triangles?
-                       Intersections intesections;
+                       _Ray localBoneRay;
+                       _MeshControllerImpl* pMeshControllerImpl = _MeshControllerImpl::GetInstance(*pMeshController);
+                       int count = pMeshControllerImpl->__bones.size();
+                       FloatMatrix4 globalBoneTransform;
+                       FloatMatrix4 initBoneTransform;
+                       float dist = std::numeric_limits<float>::infinity();
 
-                       if (!__SearchTriangleIntersection(localRay, pMesh, intesections, true)) //get all intersected triangle
+                       for (int i = 0; i < count; i++)
                        {
-                               //no triangles intercected
-                               return HITTEST_NOWHERE;
+                               memcpy(&(globalBoneTransform.matrix[0][0]), pMeshControllerImpl->__bones[i]->GetGlobal().m, sizeof(float)*16);
+                               globalBoneTransform.Transpose();
+                               //_MatrixUtilInvert(globalBoneTransform);
+                               localBoneRay.MakeRayLocal(localRay, globalBoneTransform);
+
+                               memcpy(&(initBoneTransform.matrix[0][0]), pMeshControllerImpl->__bones[i]->GetInvertBindMatrix().m, sizeof(float)*16);
+                               initBoneTransform.Transpose();
+
+                               localBoneRay.MakeRayLocal(localBoneRay, initBoneTransform);
+
+                               if (localBoneRay.Intersect(pMeshControllerImpl->__orientedBoxes[i], dist))
+                               {
+                                       hitTestRes = HITTEST_MATCH;
+                                       if (__nearestDistance > dist)
+                                       {
+                                               __nearestDistance = dist;
+                                               __pNearestVEImpl = this;
+                                       }
+                               }
                        }
-                       //find nearest intersection
-                       DistToPoint nearestIntersection = *intesections.begin();
-                       for (Intersections::iterator it = ++intesections.begin(); it != intesections.end(); it++)
+
+
+               }
+               else //simple mesh model
+               {
+                       std::pair<bool, float> intersect = localRay.Intersect(pMesh->GetBoundingVolume());
+
+                       if (intersect.first) // box intersected
                        {
-                               if (it->first < nearestIntersection.first)
+                               //hit VE mesh triangles?
+                               Intersections intesections;
+
+                               if (__SearchTriangleIntersection(localRay, pMesh, intesections, true)) //get all intersected triangle
                                {
-                                       nearestIntersection = *it;
+                                       //find nearest intersection
+                                       DistToPoint nearestIntersection = *intesections.begin();
+                                       for (Intersections::iterator it = ++intesections.begin(); it != intesections.end(); it++)
+                                       {
+                                               if (it->first < nearestIntersection.first)
+                                               {
+                                                       nearestIntersection = *it;
+                                               }
+                                       }
+                                       //test if nearest intersection in this mesh are closer than previously founded
+                                       if (__nearestDistance > nearestIntersection.first)
+                                       {
+                                               __nearestDistance = nearestIntersection.first;
+                                               __pNearestVEImpl = this;
+                                       }
+
+                                       hitTestRes = HITTEST_MATCH;
+                               }
+                               else
+                               {
+                                       //no triangles intercected
+                                       hitTestRes = HITTEST_NOWHERE;
                                }
                        }
-                       //test if nearest intersection in this mesh are closer than previously founded
-                       if (__nearestDistance > nearestIntersection.first)
+                       else
                        {
-                               __nearestDistance = nearestIntersection.first;
-                               __pNearestVEImpl = this;
+                               hitTestRes = HITTEST_NOWHERE;
                        }
                }
-               else // box not intersected
-               {
-                       return HITTEST_NOWHERE;
-               }
        }
 
 
-       return HITTEST_MATCH;
+       return hitTestRes;
 }
 
 _VisualElementImpl*
index 7c408b8..a7ee0a4 100644 (file)
@@ -58,23 +58,27 @@ ColladaAssets::Construct(const std::string& fileName, LibsForParsing libsForPars
        SysTryReturnResult(NID_UI, __doc != null, E_OPERATION_FAILED, "Xml file parsing error.");
 
        __root = xmlDocGetRootElement(__doc);
-       SysTryCatch(NID_UI, __root != null, xmlFreeDoc(__doc), E_INVALID_DATA, "Root element not found.");
+       SysTryCatch(NID_UI, __root != null, , E_INVALID_DATA, "Root element not found.");
 
        Parse(__root, libsForParsing);
        xmlFreeDoc(__doc);
        __doc = null;
+       __root = null;
+
        return E_SUCCESS;
 
 CATCH:
+       xmlFreeDoc(__doc);
+       __root = null;
+       __doc = null;
        return E_INVALID_DATA;
 }
 
 ColladaAssets::~ColladaAssets(void)
 {
-       __root = null;
-
        if (__doc)
        {
+               __root = null;
                xmlFreeDoc(__doc);
                __doc = null;
        }
index 99505f1..7f61f1f 100644 (file)
@@ -70,4 +70,21 @@ LibraryCameras::GetCameraById(std::string id)
        return null;
 }
 
+Camera*
+LibraryCameras::GetCameraByNumb(unsigned int index)
+{
+       if (index < __cameras.size())
+       {
+               return __cameras[index];
+       }
+       return null;
+}
+
+unsigned int
+LibraryCameras::GetCameraCount()
+{
+       return __cameras.size();
+}
+
+
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryCameras
index aa53a15..54535a4 100644 (file)
@@ -40,6 +40,8 @@ public:
        virtual ~LibraryCameras(void);
 
        Camera* GetCameraById(std::string id);
+       Camera* GetCameraByNumb(unsigned int index);
+       unsigned int GetCameraCount();
 private:
        typedef std::vector<Camera*> Cameras;
 
index c8a31f2..bae533e 100644 (file)
@@ -27,6 +27,8 @@
 #include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
 #include "FUiAnim_ImportColladaTools.h"
 
+using namespace Tizen::Ui::Animations::_Math;
+
 namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada { namespace LibraryEffects {
 
 Effect::Effect(xmlNodePtr root)
@@ -149,25 +151,25 @@ Effect::GetDiffuseImageId()
        return "";
 }
 
-_Math::ColorEx
+Vector4
 Effect::GetAmbient()
 {
        return GetColorFromMaterialData(pCommonShaderData->__ambient);
 }
 
-_Math::ColorEx
+Vector4
 Effect::GetDiffuse()
 {
        return GetColorFromMaterialData(pCommonShaderData->__diffuse);
 }
 
-_Math::ColorEx
+Vector4
 Effect::GetEmissive()
 {
        return GetColorFromMaterialData(pCommonShaderData->__emission);
 }
 
-_Math::ColorEx
+Vector4
 Effect::GetSpecular()
 {
        return GetColorFromMaterialData(pCommonShaderData->__specular);
@@ -180,14 +182,15 @@ Effect::GetShininess()
 }
 
 
-_Math::ColorEx
+Vector4
 Effect::GetColorFromMaterialData(CommonShaderData::commonColorOrTextureType param)
 {
-       _Math::ColorEx color(1.0f, 1.0f, 1.0f, 1.0f);
+       Vector4 color(1.0f, 1.0f, 1.0f, 1.0f);
 
        if (param.type == CommonShaderData::commonColorOrTextureType::COLOR)
        {
-               color = _Math::ColorEx(param.colorValue);
+               //TODO check if order is correct
+               color = Vector4(param.colorValue.x, param.colorValue.y, param.colorValue.z, param.colorValue.w);
        }
 
        if (param.type == CommonShaderData::commonColorOrTextureType::PARAM)
@@ -195,7 +198,8 @@ Effect::GetColorFromMaterialData(CommonShaderData::commonColorOrTextureType para
                NewParam* float4 = GetParamBySid(param.stringValue);
                if (float4 != NULL)
                {
-                       color = _Math::ColorEx(float4->__floats);
+                       //TODO need *255?
+                       color = Vector4(float4->__floats[0], float4->__floats[1], float4->__floats[2], float4->__floats[3]);
                }
        }
 
index 11aaaf6..8433502 100644 (file)
@@ -29,7 +29,7 @@
 #include <string>
 #include <vector>
 
-#include "FUiAnim_MathColor.h"
+#include <math/FUiAnim_MathVector4.h>
 #include "FUiAnim_ImportColladaLibEffNewParam.h"
 #include "FUiAnim_ImportColladaLibEffCommonShaderData.h"
 
@@ -48,11 +48,11 @@ public:
 
        std::string GetDiffuseImageId(void);
 
-       _Math::ColorEx GetAmbient(void);
-       _Math::ColorEx GetDiffuse(void);
-       _Math::ColorEx GetEmissive(void);
-       _Math::ColorEx GetSpecular(void);
-       float GetShininess(void);
+       Tizen::Ui::Animations::_Math::Vector4 GetAmbient();
+       Tizen::Ui::Animations::_Math::Vector4 GetDiffuse();
+       Tizen::Ui::Animations::_Math::Vector4 GetEmissive();
+       Tizen::Ui::Animations::_Math::Vector4 GetSpecular();
+       float GetShininess();
 
 public:
        enum ShaderType {NONE, PHONG, LAMBERT, BLINN, CONSTANT};
@@ -61,7 +61,7 @@ public:
        CommonShaderData* pCommonShaderData;
 
 private:
-       _Math::ColorEx GetColorFromMaterialData(CommonShaderData::commonColorOrTextureType param);
+       Tizen::Ui::Animations::_Math::Vector4 GetColorFromMaterialData(CommonShaderData::commonColorOrTextureType param);
        float GetFloatFromMaterialData(CommonShaderData::commonFloatOrParamType param);
 
 private:
index d9ab3df..35fa7ba 100644 (file)
@@ -57,4 +57,23 @@ LightWithAttenuation::~LightWithAttenuation(void)
        return;
 }
 
+float
+LightWithAttenuation::GetConstantAttenuation()
+{
+       return __constantAttenuation;
+}
+
+float
+LightWithAttenuation::GetLinearAttenuation()
+{
+       return __linearAttenuation;
+}
+
+float
+LightWithAttenuation::GetQuadraticAttenuation()
+{
+       return __quadraticAttenuation;
+}
+
+
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryLights
index d97fee3..0d64075 100644 (file)
@@ -35,6 +35,10 @@ class LightWithAttenuation
 public:
        LightWithAttenuation(xmlNodePtr root);
        virtual ~LightWithAttenuation(void);
+
+       float GetConstantAttenuation();
+       float GetLinearAttenuation();
+       float GetQuadraticAttenuation();
 private:
        float __constantAttenuation;
        float __linearAttenuation;
index 6f88762..c43263b 100644 (file)
@@ -52,4 +52,17 @@ Spot::~Spot(void)
        return;
 }
 
+float
+Spot::GetFalloffAngle()
+{
+       return __falloffAngle;
+}
+
+float
+Spot::GetFalloffExponent()
+{
+       return __falloffExponent;
+}
+
+
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryLights
index 2a6707d..5260dbc 100644 (file)
 
 namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada { namespace LibraryLights {
 
-class Spot : public LightWithAttenuation
+class Spot
+       : public LightWithAttenuation
 {
 public:
        Spot(xmlNodePtr root);
        virtual ~Spot(void);
+
+       float GetFalloffAngle();
+       float GetFalloffExponent();
 private:
        float __falloffAngle;
        float __falloffExponent;
index fd56b2a..18158ab 100644 (file)
@@ -74,4 +74,10 @@ LibraryVisualScenes::GetSceneByNumb(unsigned int numb)
        return null;
 }
 
+unsigned int
+LibraryVisualScenes::GetSceneCount()
+{
+       return __visualScenes.size();
+}
+
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
index 5cd4154..8e7b7de 100644 (file)
@@ -40,6 +40,7 @@ public:
 
        VisualScene* GetSceneByID(std::string VisualSceneID);
        VisualScene* GetSceneByNumb(unsigned int numb);
+       unsigned int GetSceneCount();
 
 private:
        typedef std::vector<VisualScene*> VisualScenes;
index a7386ce..a09fa65 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada { namespace LibraryVisualScenes {
 
-Node::Node(Node* parent, const xmlNodePtr root)
+Node::Node(Node* parent, const xmlNodePtr root, InstancesList& instancesList)
        : __transformations()
        , __id("")
        , __sid("")
@@ -53,13 +53,13 @@ Node::Node(Node* parent, const xmlNodePtr root)
        xmlNodePtr nodeNext = Tools::FindFirst(root->next, "node", false);
        if(nodeNext)
        {
-               __pNext = new Node(parent, nodeNext);
+               __pNext = new Node(parent, nodeNext, instancesList);
        }
 
        xmlNodePtr nodeChildren = Tools::FindFirst(root->children, "node", false);
        if(nodeChildren)
        {
-               __pChild = new Node(this, nodeChildren);
+               __pChild = new Node(this, nodeChildren, instancesList);
        }
 
        xmlNodePtr cur = root->children;
@@ -100,17 +100,25 @@ Node::Node(Node* parent, const xmlNodePtr root)
        }
 
        xmlNodePtr curInstanceController = Tools::FindFirst(root->children, "instance_controller", false);
-       if(curInstanceController)
+       while(curInstanceController != null)
        {
                InstanceController* instanceController = new InstanceController(curInstanceController);
                __instances.push_back(instanceController);
+               InstancesListElement instanceListElement{this, instanceController};
+               instancesList.push_back(instanceListElement);
+
+               curInstanceController = Tools::FindFirst(curInstanceController->next, "instance_controller", false);
        }
 
        xmlNodePtr curInstanceGeometry = Tools::FindFirst(root->children, "instance_geometry", false);
-       if(curInstanceGeometry)
+       while(curInstanceGeometry != null)
        {
                InstanceGeometry* instanceGeometry = new InstanceGeometry(curInstanceGeometry);
                __instances.push_back(instanceGeometry);
+               InstancesListElement instanceListElement{this, instanceGeometry};
+               instancesList.push_back(instanceListElement);
+
+               curInstanceGeometry = Tools::FindFirst(curInstanceGeometry->next, "instance_geometry", false);
        }
        return;
 }
@@ -161,13 +169,13 @@ Node::SetTransformationData(const std::string& transfSid, const std::string& tra
 }
 
 const std::string&
-Node::GetID(void)
+Node::GetID(void) const
 {
        return __id;
 }
 
 const std::string&
-Node::GetSID(void)
+Node::GetSID(void) const
 {
        return __sid;
 }
@@ -191,12 +199,12 @@ Node::Parent(void)
 }
 
 _Math::Matrix4
-Node::GetLocalMatrix(void)
+Node::GetLocalMatrix(void) const
 {
        _Math::Matrix4 matrix;
        matrix.Identity();
 
-       Transformations::iterator i;
+       Transformations::const_iterator i;
        for (i = __transformations.begin(); i != __transformations.end(); ++i)
        {
                Transform* transform = (*i);
@@ -208,7 +216,7 @@ Node::GetLocalMatrix(void)
 }
 
 _Math::Matrix4
-Node::GetGlobalMatrix(void)
+Node::GetGlobalMatrix(void) const
 {
        if (__pParent == null){
                return GetLocalMatrix();
@@ -260,5 +268,19 @@ Node::GetInstanceByIndex(unsigned int index)
        return null;
 }
 
+Instance*
+Node::GetInstanceByControllerName(const std::string controllerName)
+{
+       unsigned int count = __instances.size();
+       for (unsigned int i = 0; i < count; i++)
+       {
+               if (controllerName.compare(__instances[i]->GetUrl().c_str() + 1) == 0)
+               {
+                       return __instances[i];
+               }
+       }
+
+       return null;
+}
 
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
index 22c6261..844e30e 100644 (file)
@@ -26,6 +26,7 @@
 #define _FUI_ANIM_INTERNAL_IMPORT_COLLADA_LIB_VIS_SCEN_NODE_H_
 
 #include <vector>
+#include <list>
 #include <libxml/tree.h>
 
 #include "FUiAnim_ImportColladaLibVisScenTransform.h"
@@ -38,24 +39,32 @@ namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada
 class Node
 {
 public:
-       Node(Node* parent, const xmlNodePtr root);
+       struct InstancesListElement{
+               Node* pNode;
+               Instance* pInstance;
+       };
+       typedef std::list<InstancesListElement> InstancesList;
+
+public:
+       Node(Node* parent, const xmlNodePtr root, InstancesList& instancesList);
        virtual ~Node(void);
 
        bool SetTransformationData(const std::string& transfSid, const std::string& transfParam, const float* value);
 
-       const std::string& GetID(void);
-       const std::string& GetSID(void);
+       const std::string& GetID(void) const;
+       const std::string& GetSID(void) const;
 
        Node* Next(void);
        Node* Children(void);
        Node* Parent(void);
 
-       _Math::Matrix4 GetLocalMatrix(void);
-       _Math::Matrix4 GetGlobalMatrix(void);
+       _Math::Matrix4 GetLocalMatrix(void) const;
+       _Math::Matrix4 GetGlobalMatrix(void) const;
        Node* FindNode(std::string nodeName);
 
        unsigned int GetInstancesCount(void);
        Instance* GetInstanceByIndex(unsigned int index);
+       Instance* GetInstanceByControllerName(const std::string controllerName);
 
 private:
        typedef std::vector<Transform*> Transformations;
index 734617b..cb577bd 100644 (file)
@@ -30,13 +30,14 @@ namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada
 VisualScene::VisualScene(const xmlNodePtr root)
        : __id("")
        , __pFirstNode(null)
+       , __instancesList()
 {
        __id = Tools::GetAttrValueAsString(root, "id");
 
        xmlNodePtr node = Tools::FindFirst(root->children, "node", false);
        if (node)
        {
-               __pFirstNode = new Node(null, node);
+               __pFirstNode = new Node(null, node, __instancesList);
        }
        return;
 }
@@ -87,4 +88,16 @@ VisualScene::GetNodeByID(const std::string& id)
        return FindNodeByID(__pFirstNode, id);
 }
 
+Instance*
+VisualScene::GetInstanceByUrl(const std::string& url)
+{
+       for(Node::InstancesList::iterator i = __instancesList.begin(); i != __instancesList.end(); i++)
+       {
+               if (url.compare(i->pInstance->GetUrl().c_str() + 1) == 0)
+               {
+                       return i->pInstance;
+               }
+       }
+       return null;
+}
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
index b91167b..4c0b784 100644 (file)
@@ -29,6 +29,7 @@
 #include <libxml/tree.h>
 
 #include "FUiAnim_ImportColladaLibVisScenNode.h"
+#include "FUiAnim_ImportColladaLibVisScenInstance.h"
 
 namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada { namespace LibraryVisualScenes {
 
@@ -50,9 +51,12 @@ public:
        Node* GetFirstNode(void);
        Node* GetNodeByID(const std::string& id);
 
+       Instance* GetInstanceByUrl(const std::string& url);
 private:
        std::string __id;
        Node* __pFirstNode;
+
+       Node::InstancesList __instancesList;
 };
 
 }}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
index 1b26cbc..17d3474 100644 (file)
@@ -62,9 +62,8 @@ _GlContext* _GlContext::__pInstance = null;
 _GlContext*
 _GlContext::CreateN(Handle nativeDisplay, Handle window)
 {
-       #ifndef BUILD_UI_CORE
        SysAssertf(nativeDisplay, "Invalid display");
-       #endif
+
        _GlContext* pGlContext = null;
 
 #ifndef BUILD_UI_CORE
@@ -364,7 +363,11 @@ _GlContext::InitGL(void)
        glDisable(GL_STENCIL_TEST);
        glDisable(GL_DEPTH_TEST);
 
+#ifdef LINUX
+       glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+#else
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+#endif
        glClearStencil(0);
 
        glActiveTexture(GL_TEXTURE0);
@@ -735,6 +738,22 @@ _GlContext::GetShaderProgramInfo(_ShaderProgramImpl* pShaderProgram)
 
        pShaderProgram->__attributeLocation[ATTRIBUTE_VEC4_WEIGHTS] = glGetAttribLocation(pShaderProgram->__program, weightsName.c_str());
        pShaderProgram->__attributeLocation[ATTRIBUTE_VEC4_JOINTS] = glGetAttribLocation(pShaderProgram->__program, jointsName.c_str());
+
+       std::wstring jointIndex0W(VeAttrJointIndex0);
+       std::string jointIndex0(jointIndex0W.begin(), jointIndex0W.end());
+       pShaderProgram->__attributeLocation[ATTRIBUTE_INT_INDEX0] = glGetAttribLocation(pShaderProgram->__program, jointIndex0.c_str());
+
+       std::wstring jointIndex1W(VeAttrJointIndex1);
+       std::string jointIndex1(jointIndex1W.begin(), jointIndex1W.end());
+       pShaderProgram->__attributeLocation[ATTRIBUTE_INT_INDEX1] = glGetAttribLocation(pShaderProgram->__program, jointIndex1.c_str());
+
+       std::wstring jointIndex2W(VeAttrJointIndex2);
+       std::string jointIndex2(jointIndex2W.begin(), jointIndex2W.end());
+       pShaderProgram->__attributeLocation[ATTRIBUTE_INT_INDEX2] = glGetAttribLocation(pShaderProgram->__program, jointIndex2.c_str());
+
+       std::wstring jointIndex3W(VeAttrJointIndex3);
+       std::string jointIndex3(jointIndex3W.begin(), jointIndex3W.end());
+       pShaderProgram->__attributeLocation[ATTRIBUTE_INT_INDEX3] = glGetAttribLocation(pShaderProgram->__program, jointIndex3.c_str());
 }
 
 void
index 4fba802..7429535 100644 (file)
@@ -11,7 +11,7 @@
 #include "FUiAnim_GlRenderManager.h"
 #include "FUiAnim_X11Window.h"
 #include "FUiAnim_X11.h"
-#ifdef USE_ECORE_X
+#if defined(USE_ECORE_X)
 #include "FUiAnim_EcoreX.h"
 #endif
 
index 8195c53..ee8e4a1 100644 (file)
@@ -28,7 +28,7 @@
 #include <X11/Xlib.h>
 #include "FUiAnim_NativeWindow.h"
 
-#define ENABLE_ROTATE
+//#define ENABLE_ROTATE //cause "enlighting" module crash on application start
 
 namespace Tizen { namespace Ui { namespace Animations {
 
index b41e075..63fe120 100644 (file)
 
 namespace Tizen { namespace Ui { namespace Animations {
 
-
 #define APPROPRIATE_COUNT_VERTICES 3
 #define APPROPRIATE_COUNT_NORMALS 3
 #define APPROPRIATE_COUNT_COLORS 4
 #define APPROPRIATE_COUNT_TEXTCOORDINATES 2
+#define MATRIX4_SIZE 16
 
 class _Mutex;
 class _JointImpl;
@@ -78,7 +78,7 @@ public:
        static _MeshImpl* GetInstance(Mesh& mesh);
        static const _MeshImpl* GetInstance(const Mesh& mesh);
 
-       static Mesh* LoadMeshN(const Tizen::Base::String& fileName);
+       static Mesh* LoadMeshN(const Tizen::Base::String& fileName, bool loadWithoutController);
 
        result SetVertex(int arrayIndex, const Tizen::Graphics::FloatPoint3& point);
        result SetTextureCoord(int arrayIndex, const Tizen::Graphics::FloatPoint& textureCoord);
@@ -166,10 +166,10 @@ public:
 
        result SaveMesh(const Tizen::Base::String& fileName);
 
-       MeshController* CreateMeshController();
+       MeshController* CreateMeshController(void);
 
        MeshController* GetMeshController(void);
-       _MeshControllerImpl* GetMeshControllerImpl(void);
+       _MeshControllerImpl* GetMeshControllerImpl(void) const;
 
 protected:
        virtual ~_MeshImpl(void);
@@ -178,6 +178,9 @@ private:
     result AllocTextureCoordinates(void);
     result AllocNormals(void);
     result AllocColors(void);
+    std::string WideToStd(const Tizen::Base::String tizenString);
+    result SaveMeshController(FILE* pFile);
+    static result LoadMeshController(FILE* pFile,  _MeshControllerImpl* pMeshControllerImpl);
 
 private:
     _Mutex* __pLock;
@@ -198,10 +201,6 @@ private:
 
        BoundingVolume __boundingVolume;
 
-       // temp pos
-//     float __minPos[3];//x,y,z
-//     float __maxPos[3];//x,y,z
-
        MeshController* __pMeshController;
 
     friend class Mesh;
@@ -234,8 +233,9 @@ struct Header
                bool isTextureCoordinateEnabled;
                bool isColorEnabled;
                bool isNormalEnabled;
+               bool isMeshController;
                void SetMeshArrays(const _MeshImpl& rhs);
        };
-//static Header capacity;
+
 }}} //namespace Tizen { namespace Ui { namespace Animations {
 #endif // _FUI_ANIM_MESH_IMPL_H_
index 8783c47..2046f06 100644 (file)
@@ -31,6 +31,7 @@
 #include "FUiAnimMesh.h"
 #include "FUiAnimMaterial.h"
 #include "FUiAnimScene.h"
+#include "FUiAnimCamera.h"
 
 #include "FUiAnim_ImportColladaColladaAssets.h"
 #include "library-visual-scenes/FUiAnim_ImportColladaLibVisScenNode.h"
 
 namespace Tizen { namespace Ui { namespace Animations {
 
+extern const int MAJOR_VERSION;
+extern const int MINOR_VERSION;
+extern const int RELEASE;
+
 typedef std::list< unsigned int > ColladaIndices;
 
 class _OSP_EXPORT_ _ModelImporterImpl
@@ -52,15 +57,36 @@ public:
        virtual ~_ModelImporterImpl(void);
 
        Mesh* LoadMeshCollada(const std::string& modelName, std::string& materialId, ColladaIndices* colladaIndices = null);
-       static Mesh* LoadMeshN(const Tizen::Base::String& fileName);
+       static Mesh* LoadMeshN(const Tizen::Base::String& fileName, bool loadWithoutController);
+
+       Mesh* LoadMeshWithControllerCollada(const std::string& modelName);
 
        Material* LoadMaterial(const std::string& materialId, std::string& texureId, _ImportCollada::LibraryEffects::Effect::ShaderType& shaderType);
+
        std::string LoadTextureName(const std::string& imageId);
+
        Scene* LoadScene(const std::string& sceneId, VisualElement& pSceneRootVisualElement);
 
-private:
-       _Math::Matrix4 UseUpAxis(const _Math::Matrix4& floatPoint, bool inversed = false);
+       static Material* LoadMaterialN(const Tizen::Base::String& fileName);
+
+       static Light* LoadLightN(const Tizen::Base::String& fileName);
+
+       Light* LoadLightCollada(const std::string& lightId);
+
+       Camera* LoadCameraCollada(const std::string& cameraId);
+
+       //-------------------------------------- GetNames
+       Tizen::Base::Collection::IList* GetMeshNamesN();
+       Tizen::Base::Collection::IList* GetMaterialNamesN();
+       Tizen::Base::Collection::IList* GetSceneNamesN();
+       Tizen::Base::Collection::IList* GetLightNamesN();
+       Tizen::Base::Collection::IList* GetCameraNamesN();
+       Tizen::Base::Collection::IList* GetMeshWithControllerNamesN();
+
        void ApplyUpAxis(Mesh& mesh);
+private:
+       _Math::Matrix4 UseUpAxis(const _Math::Matrix4& floatPoint);
+
 
        virtual void LoadMesh(Mesh& mesh, _ImportCollada::LibraryGeometries::GeometryMesh::Indexes& VertexIndices, _Math::Vector3* vertices, ColladaIndices* colladaIndices = null);
        virtual void LoadMesh(Mesh& mesh, _ImportCollada::LibraryGeometries::GeometryMesh::Indexes& VertexIndices, _Math::Vector3* vertices,
@@ -69,7 +95,7 @@ private:
                                                                           _ImportCollada::LibraryGeometries::GeometryMesh::Indexes& NormalIndices, _Math::Vector3* normals,
                                                                           _ImportCollada::LibraryGeometries::GeometryMesh::Indexes& TexCooIndices, _Math::Vector2* texCoords, ColladaIndices* colladaIndices = null);
 
-       void CreateController(const std::string& controllerName, _ImportCollada::LibraryVisualScenes::Node* pSceletonRootNode,  Mesh** ppMesh);
+       void CreateController(const std::string& controllerName, _ImportCollada::LibraryVisualScenes::Node* pSceletonRootNode,  Mesh** ppMesh, bool useUpAxis);
 
        void WalkingTheTree(_ImportCollada::LibraryVisualScenes::Node* pRootNode, _ImportCollada::LibraryVisualScenes::Node* pNode, Scene* pScene);
 
index 14e38c8..9c4279f 100644 (file)
@@ -36,6 +36,7 @@
 
 
 #include "FUiAnimVisualElement.h"
+#include "FUiAnimTypes.h"
 
 namespace Tizen { namespace Base { namespace Collection {
 class IList;
@@ -52,6 +53,9 @@ class Mesh;
 class Material;
 class Light;
 class ShaderProgram;
+class VisualElementSurface;
+
+class DisplayContext;
 
 class Scene;
 
@@ -176,6 +180,37 @@ typedef struct __SceneShaderProgramDescriptor
 
 } _SceneShaderProgramDescriptor;
 
+typedef struct __SceneSurfaceDescriptor
+{
+       __SceneSurfaceDescriptor& operator = (const __SceneSurfaceDescriptor& obj)
+       {
+               sourceFileName = obj.sourceFileName;
+               name = obj.name;
+               pSurface = obj.pSurface;
+               return *this;
+       }
+       bool operator == (const  __SceneSurfaceDescriptor& obj) const
+       {
+               return (sourceFileName == obj.sourceFileName) && (name == obj.name)  \
+                               && (pSurface == obj.pSurface);
+       }
+       bool operator != (const  __SceneSurfaceDescriptor& obj) const
+       {
+               return !(*this == obj);
+       }
+       void Clear(void)
+       {
+               sourceFileName.Clear();
+               name.Clear();
+               pSurface = null;
+       }
+
+       Tizen::Base::String sourceFileName;
+       Tizen::Base::String name;
+       VisualElementSurface* pSurface;
+
+} _SceneSurfaceDescriptor;
+
 typedef struct __SceneVisualElementDescriptor
 {
        __SceneVisualElementDescriptor& operator = (const __SceneVisualElementDescriptor& obj)
@@ -186,6 +221,12 @@ typedef struct __SceneVisualElementDescriptor
                materialId = obj.materialId;
                lightId = obj.lightId;
                shaderProgramId = obj.shaderProgramId;
+               surfaceId = obj.surfaceId;
+               for (int i = 0; i < (int)(EXTRA_SURFACE_MAX); i++)
+               {
+                       extraSurfaceId[i] = obj.extraSurfaceId[i];
+               }
+               alphaMaskId = obj.alphaMaskId;
 
                anchor = obj.anchor;
                anchorZ = obj.anchorZ;
@@ -204,7 +245,14 @@ typedef struct __SceneVisualElementDescriptor
        }
        bool operator == (const  __SceneVisualElementDescriptor& obj) const
        {
+               bool extSurf = true;
+               for (int i = 0; i < (int)(EXTRA_SURFACE_MAX); i++)
+               {
+                       extSurf = extSurf && (extraSurfaceId[i] == obj.extraSurfaceId[i]);
+               }
+
                return (name == obj.name) && (meshId == obj.meshId) && (materialId == obj.materialId) && (lightId == obj.lightId) \
+                               && (surfaceId == obj.surfaceId) && (alphaMaskId == obj.alphaMaskId) && extSurf \
                                && (shaderProgramId == obj.shaderProgramId) && (transformMatrix == obj.transformMatrix) && (bounds == obj.bounds) \
                                && (opacity == obj.opacity) && (showState == obj.showState) && (clipChildrenEnabled == obj.clipChildrenEnabled);
        }
@@ -224,6 +272,12 @@ typedef struct __SceneVisualElementDescriptor
                materialId = -1;
                lightId = -1;
                shaderProgramId = -1;
+               surfaceId = -1;
+               for (int i = 0; i < (int)(EXTRA_SURFACE_MAX); i++)
+               {
+                       extraSurfaceId[i] = -1;
+               }
+               alphaMaskId = -1;
 
                anchor.SetPosition(0.0f, 0.0f);
                anchorZ = 0.0f;
@@ -244,6 +298,10 @@ typedef struct __SceneVisualElementDescriptor
        int materialId;
        int lightId;
        int shaderProgramId;
+       int surfaceId;
+       int extraSurfaceId[(int)(EXTRA_SURFACE_MAX)];
+       float extraSurfaceOpacity[(int)(EXTRA_SURFACE_MAX)];
+       int alphaMaskId;
 
        Tizen::Graphics::FloatPoint anchor;
        float anchorZ;
@@ -310,7 +368,6 @@ public:
        int GetMeshCodeAt(int index) const;
        int ContainsMesh(int code) const;
        Mesh* GetMeshByHashCodeN(int code) const;
-       //todo:repeat to other
 
        //-----------Material API
        result AddMaterial(const Material* pMaterial);
@@ -378,15 +435,35 @@ public:
        int ContainsShaderProgram(int code) const;
        ShaderProgram* GetShaderProgramByHashCodeN(int code) const;
 
-       //-----------TextureFileName API
-       result AddTextureFileName(const Tizen::Base::String& textureFileName);
-       int GetTextureFileNameCount(void) const;
-       Tizen::Base::String GetTextureFileNameAt(int index) const;
-       result RemoveTextureFileNameAt(int index);
-       result RemoveAllTextureFileName(void);
+       //-----------Surface
+       result AddSurface(const VisualElementSurface* pSurface, const Tizen::Base::String& sourceFileName);
+       result RemoveSurface(const Tizen::Base::String& surfaceName);
+       result RemoveSurface(const VisualElementSurface* pSurface);
+       result RemoveAllSurface(void);
+       VisualElementSurface* GetSurfaceN(const Tizen::Base::String& surfaceName) const;
+       int ContainsSurface(const Tizen::Base::String& surfaceName) const; //index = [0,n-1], or -1 if not exist
+       int ContainsSurface(const VisualElementSurface* pSurface) const;
+       int GetSurfaceCount(void) const;
+       VisualElementSurface* GetSurfaceAtN(int index) const;
+       Tizen::Base::String GetSurfaceNameAt(int index) const;
+
+       //not for public
+       //for JNI interface:
+       Tizen::Base::String GetSurfaceSourceFileName(const Tizen::Base::String meshName) const;
+       result SetSurfaceSourceFileName(const Tizen::Base::String surfaceName, const Tizen::Base::String sourceFileName);
+       Tizen::Base::String GetSurfaceNameByHashCode(int code) const;
+
+       Tizen::Base::String GetSurfaceSourceFileName(const VisualElementSurface* pSurface) const;
+       result SetSurfaceSourceFileName(const VisualElementSurface* pSurface, const Tizen::Base::String sourceFileName);
+       Tizen::Base::String GetSurfaceName(const VisualElementSurface* pSurface) const;
+       result SetSurfaceName(const VisualElementSurface* pSurface, const Tizen::Base::String surfaceName);
+       int GetSurfaceCodeAt(int index) const;
+       int ContainsSurface(int code) const;
+       VisualElementSurface* GetSurfaceByHashCodeN(int code) const;
+       //-----------------
 
        result SaveScene(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix) const;
-       static Scene* LoadSceneN(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix, VisualElement& pSceneRootVisualElement);
+       static Scene* LoadSceneN(const Tizen::Base::String filesPath, const Tizen::Base::String resourceFilesPath, const Tizen::Base::String scenePrefix, VisualElement& pSceneRootVisualElement, const DisplayContext* pDisplayContext);
 
 protected:
 
@@ -398,8 +475,7 @@ protected:
        Tizen::Base::Collection::ArrayListT< _SceneMaterialDescriptor > _materials;
        Tizen::Base::Collection::ArrayListT< _SceneLightDescriptor > _lights;
        Tizen::Base::Collection::ArrayListT< _SceneShaderProgramDescriptor > _shaderPrograms;
-
-       Tizen::Base::Collection::ArrayListT< Tizen::Base::String >  _textureFileNames;
+       Tizen::Base::Collection::ArrayListT< _SceneSurfaceDescriptor > _surfaces;
 
 private:
        result __SaveSceneVisualElementTree(const xmlTextWriterPtr writer, const VisualElement* pVisualElement) const;
index 9944d1f..7527c6e 100644 (file)
 #ifndef _FUI_ANIM_INTERNAL_SHADER_PROGRAM_GENERATOR_H_
 #define _FUI_ANIM_INTERNAL_SHADER_PROGRAM_GENERATOR_H_
 
+#include <FUiAnimShader.h>
 #include <FUiAnimShaderProgram.h>
+#include "FUiAnim_ShaderProgramImpl.h"
+#include <FBase.h>
 #include <string>
 
 namespace Tizen { namespace Ui { namespace Animations
index 22462bf..3113444 100644 (file)
@@ -288,6 +288,7 @@ public:
        result SetAlphaMask(const VisualElementSurface* pAlphaMaskSurface);
     result SetExtraSurface(ExtraSurfaceIndex extraSurfaceIndex, VisualElementSurface* pExtraSurface);
     result SetExtraSurfaceOpacity(ExtraSurfaceIndex extraSurfaceIndex, float opacity);
+    float GetExtraSurfaceOpacity(const ExtraSurfaceIndex extraSurfaceIndex) const;
 
     VisualElementSurface* GetAlphaMaskN(void) const;
        VisualElementSurface* GetExtraSurfaceN(ExtraSurfaceIndex extraSurfaceIndex) const;