Skeletal animation refactoring: GPU skinning (max 64 joints); New class _JointImpl...
authorm.kucher <m.kucher@samsung.com>
Tue, 26 Nov 2013 14:20:38 +0000 (16:20 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Wed, 27 Nov 2013 08:12:20 +0000 (08:12 +0000)
Change-Id: Ia6cba5adfe069443f2589b2364dd36fd1209a8b3
Signed-off-by: m.kucher <m.kucher@samsung.com>
Signed-off-by: Dae Young Ryu <karzia@samsung.com>
21 files changed:
inc/FUiAnimMeshController.h
inc/FUiAnimModelImporter.h
src/ui/CMakeLists.txt
src/ui/animations/FUiAnimMesh.cpp
src/ui/animations/FUiAnimMeshController.cpp
src/ui/animations/FUiAnim_GlContext.h
src/ui/animations/FUiAnim_GlRenderManager.cpp
src/ui/animations/FUiAnim_GlRenderManager.h
src/ui/animations/FUiAnim_JointImpl.cpp [new file with mode: 0644]
src/ui/animations/FUiAnim_JointImpl.h [new file with mode: 0644]
src/ui/animations/FUiAnim_MeshController.cpp [deleted file]
src/ui/animations/FUiAnim_MeshController.h [deleted file]
src/ui/animations/FUiAnim_MeshControllerImpl.cpp [new file with mode: 0644]
src/ui/animations/FUiAnim_MeshControllerImpl.h [new file with mode: 0644]
src/ui/animations/FUiAnim_MeshImpl.cpp
src/ui/animations/FUiAnim_ModelImporterImpl.cpp
src/ui/animations/FUiAnim_ShaderProgramImpl.cpp
src/ui/animations/FUiAnim_ShaderProgramImpl.h
src/ui/animations/platform/FUiAnim_GlContext.cpp
src/ui/inc/FUiAnim_MeshImpl.h
src/ui/inc/FUiAnim_ModelImporterImpl.h

index ecaa7a9..fe9b5de 100644 (file)
@@ -16,7 +16,7 @@
 //
 
 /**
- * @file       FUiMeshController.h
+ * @file       FUiAnimMeshController.h
  * @brief      This is the header file for the MeshController class.
  *
  * This header file contains the declarations of the MeshController class.
 #include <FBaseObject.h>
 
 namespace Tizen { namespace Ui { namespace Animations {
-
-class _MeshControllerImpl;
-class VisualElement;
-
+class _JointImpl;
 
 class _OSP_EXPORT_ MeshController
        : public Tizen::Base::Object
 {
 public:
-       void StartAnimation(unsigned int repeatCount);
+       void StartAnimation(void);
        void StopAnimation(void);
 
-       VisualElement* GetRootJoint(void);
+       _JointImpl* GetSkeletonRoot(void);
+       void SetGpuSkinning(bool value);
+       bool IsGpuSkinning(void);
+
 private:
        MeshController(void);
        virtual ~MeshController(void);
 
 private:
-       _MeshControllerImpl* __pMeshController;
+       class _MeshControllerImpl* __pMeshControllerImpl;
        friend class _MeshControllerImpl;
-       friend class _MeshImpl;
+
 };
 
 }}} //Tizen::Ui::Animations
index 6aad962..fc37709 100644 (file)
@@ -51,8 +51,6 @@ public:
         * @param[in]   modelFormat                     Format of file(COLLADA or Binary)
         * @param[in]   fileName                        Name of file
         * @param[in]   modelName                       Id of geometry in COLLADA file
-        * @param[in]   inverseY                        Flip model vertically
-        *
         */
        static Mesh* LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName);
 
index 23c8ecc..ce88e6d 100644 (file)
@@ -829,8 +829,10 @@ SET (${this_target}_SOURCE_FILES
        animations/FUiAnim_SceneImpl.cpp
        animations/FUiAnimScene.cpp
 #=====================================================
+       animations/FUiAnim_JointImpl.cpp
+
        animations/FUiAnimMeshController.cpp
-       animations/FUiAnim_MeshController.cpp
+       animations/FUiAnim_MeshControllerImpl.cpp
 #=====================================================
        animations/math/FUiAnim_MathAdapterFunctions.cpp
        animations/math/FUiAnim_MathCommon.cpp
index 8639b9e..d82aeba 100644 (file)
@@ -1,3 +1,26 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnimMesh.cpp
+ * @brief      This file is the implementation of Mesh class
+ *
+ * This file contains implementation of Mesh class.
+ */
 
 #include <FBaseSysLog.h>
 
@@ -25,7 +48,7 @@ namespace Tizen { namespace Ui { namespace Animations{
 #define CHECK_PARAMETER_CONSTRUCTED(__MESH) \
        SysAssertf((__MESH).__pMeshImpl, "Not yet constructed! Construct() should be called before use.");
 
-Mesh::Mesh()
+Mesh::Mesh(void)
        :__pMeshImpl(null)
 {
        __pMeshImpl = new (std::nothrow)_MeshImpl(*this);
@@ -34,18 +57,18 @@ Mesh::Mesh()
 Mesh::Mesh(const Mesh& mesh)
     :__pMeshImpl(mesh.__pMeshImpl)
 {
-    if(__pMeshImpl)
+    if (__pMeshImpl != null)
     {
         __pMeshImpl->AddRef();
     }
 }
 
-Mesh::~Mesh()
+Mesh::~Mesh(void)
 {
-    if(__pMeshImpl)
+    if (__pMeshImpl != null)
     {
         __pMeshImpl->Release();
-        __pMeshImpl = NULL;
+        __pMeshImpl = null;
     }
 }
 
index bfb1f2d..1e35431 100644 (file)
 //
 
 /**
- * @file       FUiMeshController.cpp
+ * @file       FUiAnimMeshController.cpp
  * @brief      This file contains implementation of MeshController class
  *
  * This file contains implementation MeshController class.
  */
 
 #include "FUiAnimMeshController.h"
-#include "FUiAnim_MeshController.h"
+#include "FUiAnim_MeshControllerImpl.h"
 
 namespace Tizen { namespace Ui { namespace Animations {
 
 MeshController::MeshController(void)
 {
-       __pMeshController = new (std::nothrow) _MeshControllerImpl();
+       __pMeshControllerImpl = new (std::nothrow) _MeshControllerImpl();
+       return;
 }
 
 MeshController::~MeshController(void)
 {
-       if (__pMeshController != null)
+       if (__pMeshControllerImpl != null)
        {
-               delete __pMeshController;
-               __pMeshController = null;
+               delete __pMeshControllerImpl;
+               __pMeshControllerImpl = null;
        }
+       return;
 }
 
 void
-MeshController::StartAnimation(unsigned int repeatCount)
+MeshController::StartAnimation(void)
 {
-       if (__pMeshController != null)
+       if (__pMeshControllerImpl != null)
        {
-               __pMeshController->StartAnimation(repeatCount);
+               __pMeshControllerImpl->StartAnimation();
        }
+       return;
 }
 
 void
 MeshController::StopAnimation(void)
 {
-       if (__pMeshController != null)
+       if (__pMeshControllerImpl != null)
        {
-               __pMeshController->StopAnimation();
+               __pMeshControllerImpl->StopAnimation();
        }
+       return;
 }
 
-VisualElement*
-MeshController::GetRootJoint(void)
+_JointImpl*
+MeshController::GetSkeletonRoot(void)
 {
-       return __pMeshController->GetRootJoint();
+       return __pMeshControllerImpl->GetRoot();
+}
+
+void
+MeshController::SetGpuSkinning(bool value)
+{
+       __pMeshControllerImpl->SetGPUSkinning(value);
+       return;
+}
+
+bool
+MeshController::IsGpuSkinning()
+{
+       return __pMeshControllerImpl->IsGpuSkinning();
 }
 
 }}} //Tizen::Ui::Animations
index 5dd057a..ae8f639 100644 (file)
@@ -100,6 +100,7 @@ private:
        void LoadTexture(TextureInfo& textureInfo, bool create);
 
        void PrepareDefaultShaders(void);
+       void PrepareDefaultWithSkinningShaders(void);
 
 protected:
        Handle __nativeDisplay; //TODO remove
@@ -120,6 +121,12 @@ protected:
        ShaderProgram* __pTextureOpacityShader;
        ShaderProgram* __pLightShader;
 
+       ShaderProgram* __pColorShaderWithSkinning;
+       ShaderProgram* __pUniformColorShaderWithSkinning;
+       ShaderProgram* __pTextureShaderWithSkinning;
+       ShaderProgram* __pTextureOpacityShaderWithSkinning;
+       ShaderProgram* __pLightShaderWithSkinning;
+
 private:
 #ifndef VE_USE_GL_MULTI_CONTEXT
        static _GlContext* __pInstance;
index 12e0b6c..87f5a34 100644 (file)
@@ -56,6 +56,7 @@
 #include "FUiAnim_LightImpl.h"
 #include "FUiAnim_MaterialImpl.h"
 
+#include "FUiAnim_MeshControllerImpl.h" //skinning
 
 #include "FUiAnim_Debug.h"
 
@@ -120,6 +121,13 @@ _GlRenderManager::_RenderObject::_RenderObject(void)
        , __aTexCoord(-1)
        , __aColor(-1)
        , __aNormal(-1)
+
+       , __GPUSkinning(false)
+       , __aWeights(-1)
+       , __aJointIds(-1)
+       , __pWeights(null)
+       , __pJointIds(null)
+       , __jointsCount(0)
 {
        Construct();
 }
@@ -187,6 +195,9 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
        __invModelview.Invert();
        __invModelview.Transpose();             // TODO: optimize
 
+       __GPUSkinning = false; //skinning
+       __isMesh = false;
+
        __activeLightCount = 0;
 
        Object*     pObj = null;
@@ -294,9 +305,18 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
                _MeshImpl* pMeshImpl = _MeshImpl::GetInstance(*pNode->__pMesh);
                _AutoMutex meshLock(*pMeshImpl->__pLock);
 
-               if (pMeshImpl->GetMeshControllerImpl() != null)
+               _MeshControllerImpl* meshController = pMeshImpl->GetMeshControllerImpl();
+               if (meshController != null)
                {
-                       pMeshImpl->GetMeshControllerImpl()->Calculate();//TODO: GetImpl
+                       __GPUSkinning = meshController->IsGpuSkinning();
+
+                       __pWeights = meshController->GetWeightsPointer();
+                       __pJointIds = meshController->GetIdsPointer();
+                       __pJointsMatrices = meshController->GetMatricesPointer();
+
+                       __jointsCount = meshController->GetJointsCount();
+
+                       meshController->Calculate();
                }
 
                __isMesh = true;
@@ -344,25 +364,51 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
 
                        if (_FloatCompare(pNode->__opacity, 1.0f))
                        {
-                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureShader;
+                               if (__GPUSkinning)
+                               {
+                                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureShaderWithSkinning;
+                               }
+                               else
+                               {
+                                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureShader;
+                               }
                        }
                        else
                        {
-                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureOpacityShader;
+                               if (__GPUSkinning)
+                               {
+                                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureOpacityShaderWithSkinning;
+                               }
+                               else
+                               {
+                                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pTextureOpacityShader;
+                               }
                        }
                }
                else
                {
                        __textureId = 0;
-
-                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pUniformColorShader;
+                       if (__GPUSkinning)
+                       {
+                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pUniformColorShaderWithSkinning;
+                       }
+                       else
+                       {
+                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pUniformColorShader;
+                       }
                }
 
                if (pMeshImpl->IsColorEnabled())
                {
                        __pColors = pMeshImpl->__pColors;
-
-                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pColorShader;
+                       if (__GPUSkinning)
+                       {
+                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pColorShaderWithSkinning;
+                       }
+                       else
+                       {
+                               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pColorShader;
+                       }
                }
 
                if (pMeshImpl->IsNormalEnabled())
@@ -379,11 +425,17 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
 
        // TODO: check
        //if (pNode->__pLight && pNode->__pLight->IsEnabled())
-       if (__activeLightCount > 0)     
+       if (__activeLightCount > 0)
        {
                //__pLight = pNode->__pLight;
-
-               __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pLightShader;
+               if (__GPUSkinning)
+               {
+                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pLightShaderWithSkinning;
+               }
+               else
+               {
+                       __pProgram = _GlRenderManager::GetInstance()->__pGlContext->__pLightShader;
+               }
        }
 
        if (pNode->__pMaterial)
@@ -403,6 +455,9 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, const _Matrix4f& mvp,
        __aColor = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC4_COLOR];
        __aNormal = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC3_NORMAL];
 
+       __aWeights  = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC4_WEIGHTS];
+       __aJointIds = pProgramImpl->__attributeLocation[ATTRIBUTE_VEC4_JOINTS];
+
        return;
 }
 
@@ -766,6 +821,15 @@ _GlRenderManager::FlushRenderQueue(void)
                glVertexAttribPointer(__pRenderQueue[i].__aColor, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), __pRenderQueue[i].__pColors);
                glVertexAttribPointer(__pRenderQueue[i].__aNormal, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), __pRenderQueue[i].__pNormals);
 
+               //Skinning
+               if (__pRenderQueue[i].__GPUSkinning)
+               {
+                       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
+
+                       glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_ARRAY_JOINTSMATRICES], __pRenderQueue[i].__jointsCount, GL_FALSE, __pRenderQueue[i].__pJointsMatrices);
+               }
+
                // Set uniform
                glUniformMatrix4fv(pProgramImpl->__uniformLocation[UNIFORM_MAT4_MVP], 1, GL_FALSE, __pRenderQueue[i].__mvp.GetItems());
                glUniform1f(pProgramImpl->__uniformLocation[UNIFORM_FLOAT_OPACITY], __pRenderQueue[i].__opacity);
index 105f79e..5f45403 100644 (file)
@@ -206,6 +206,17 @@ private:
                int __aTexCoord;
                int __aColor;
                int __aNormal;
+
+               //Skinning
+               bool __GPUSkinning;
+               int __aWeights;
+               int __aJointIds;
+
+               const float* __pWeights;
+               const float* __pJointIds;
+
+               const float* __pJointsMatrices;
+               unsigned int __jointsCount;
        };
 
        RenderCommand __commandId;
diff --git a/src/ui/animations/FUiAnim_JointImpl.cpp b/src/ui/animations/FUiAnim_JointImpl.cpp
new file mode 100644 (file)
index 0000000..32f80bb
--- /dev/null
@@ -0,0 +1,211 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_JointImpl.cpp
+ * @brief      This file contains implementation of _JointImpl class
+ *
+ * This file contains implementation _JointImpl class.
+ */
+
+#include "FUiAnim_JointImpl.h"
+
+#include <FBaseTypes.h>
+
+namespace Tizen { namespace Ui { namespace Animations {
+
+_JointImpl::_JointImpl(const std::string& name, const _Math::Matrix4& local)
+       : __name(name)
+       , __local(local)
+       , __invBindMatrix() //identity
+       , __pParent(null)
+       , __keyFrames()
+{
+       return;
+}
+
+_JointImpl::~_JointImpl(void)
+{
+       for (Children::iterator i = __children.begin(); i != __children.end(); i++)
+       {
+               delete (*i);
+       }
+
+       __children.clear();
+
+       return;
+}
+
+const std::string&
+_JointImpl::GetName()
+{
+       return __name;
+}
+
+_JointImpl*
+_JointImpl::GetParent()
+{
+       return __pParent;
+}
+
+_JointImpl*
+_JointImpl::Find(const std::string& jointName)
+{
+       if (__name.compare(jointName) == 0){
+               return this;
+       }
+       for (Children::iterator i = __children.begin(); i != __children.end(); i++)
+       {
+               _JointImpl* result = (*i)->Find(jointName);
+               if (result != null)
+               {
+                       return result;
+               }
+       }
+
+       return null;
+}
+
+void
+_JointImpl::AttachChild(_JointImpl& child)
+{
+       child.__pParent = this;
+       __children.push_back(&child);
+}
+
+unsigned int
+_JointImpl::GetChildrenCount()
+{
+       return __children.size();
+}
+
+_JointImpl*
+_JointImpl::GetChildAt(unsigned int i)
+{
+       if (i < __children.size())
+       {
+               return __children[i];
+       }
+       return null;
+}
+
+void
+_JointImpl::SetInvertBindMatrix(const _Math::Matrix4& matrix)
+{
+       __invBindMatrix.Set(matrix);
+}
+
+_Math::Matrix4
+_JointImpl::GetInvertBindMatrix() const
+{
+       return __invBindMatrix;
+}
+
+_Math::Matrix4
+_JointImpl::GetGlobal() const
+{
+       _Math::Matrix4 global;
+       global.Identity();
+
+       if (__pParent != null)
+       {
+               global.Set(__pParent->GetGlobal());
+       }
+       global *= __local;
+
+       return global;
+}
+
+void
+_JointImpl::AddKeyFrame(float time, const _Math::Matrix4& value)
+{
+       KeyFrame keyFrame;
+       keyFrame.time = time;
+       keyFrame.value.Set(value);
+
+       if (__keyFrames.size() > 0)
+       {
+               for (KeyFrames::iterator i = __keyFrames.begin(); i != __keyFrames.end(); i++)
+               {
+                       if (time < i->time)
+                       {
+                               __keyFrames.insert(i, keyFrame);
+                               return;
+                       }
+               }
+       }
+       __keyFrames.push_back(keyFrame);
+}
+
+void
+_JointImpl::Animate(float time, bool animateChildren)
+{
+       KeyFrame* left = null;
+       KeyFrame* right = null;
+
+       //left.time <= time <= right.time
+       FindKeyFramesForTime(time, &left, &right);
+
+       if ((left == null) && (right == null)){ //TODO: SysTry
+               return;
+       }
+
+       if (left == null){ //time < firstKeyFrame.time
+               __local.Set(right->value);
+       }
+       else{
+               if (right == null){ //time > lastkeyFrame.time
+                       __local.Set(left->value);
+               }
+               else
+               {
+                       float t = (time - left->time) / (right->time - left->time);
+
+                       __local.Set(left->value);
+                       __local.Lerp(right->value, t);
+               }
+       }
+
+       if (animateChildren)
+       {
+               for (Children::iterator i = __children.begin(); i != __children.end(); i++)
+               {
+                       (*i)->Animate(time, animateChildren);
+               }
+       }
+}
+
+void
+_JointImpl::FindKeyFramesForTime(float time, KeyFrame** left, KeyFrame** right)
+{
+       *left = null;
+       *right = null;
+       if (__keyFrames.size() > 0)
+       {
+               for (KeyFrames::iterator i = __keyFrames.begin(); i != __keyFrames.end(); i++)
+               {
+                       *right = &(*i);
+                       if (time < (*right)->time){
+                               break;
+                       }
+                       *left = *right;
+                       *right = null;
+               }
+       }
+}
+
+}}} //Tizen::Ui::Animations
diff --git a/src/ui/animations/FUiAnim_JointImpl.h b/src/ui/animations/FUiAnim_JointImpl.h
new file mode 100644 (file)
index 0000000..28220ba
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_JointImpl.h
+ * @brief      This is the header file for the _JointImpl class.
+ *
+ * This header file contains the declarations of the _JointImpl class.
+ */
+
+#include <string>
+#include <vector>
+#include <list>
+
+#include <FUiAnim_MathMatrix4.h>
+
+#ifndef _FUI_ANIM_INTERNAL_JOINT_IMPL_H_
+#define _FUI_ANIM_INTERNAL_JOINT_IMPL_H_
+
+namespace Tizen { namespace Ui { namespace Animations {
+
+class KeyFrame{
+public:
+       float time;
+       _Math::Matrix4 value;
+};
+
+class _JointImpl
+{
+public:
+       typedef std::list<KeyFrame> KeyFrames;
+
+public:
+       _JointImpl(const std::string& name, const _Math::Matrix4& local);
+       virtual ~_JointImpl(void);
+
+       const std::string& GetName();
+       _JointImpl* GetParent();
+       _JointImpl* Find(const std::string& jointName);
+       void AttachChild(_JointImpl& child);
+       unsigned int GetChildrenCount();
+       _JointImpl* GetChildAt(unsigned int i);
+
+       void SetInvertBindMatrix(const _Math::Matrix4& matrix);
+       _Math::Matrix4 GetInvertBindMatrix() const;
+       _Math::Matrix4 GetGlobal() const;
+
+
+       void AddKeyFrame(float time, const _Math::Matrix4& value);
+       void Animate(float time, bool animateChildren);
+private:
+       void FindKeyFramesForTime(float time, KeyFrame** left, KeyFrame** right);
+
+private:
+       typedef std::vector<_JointImpl*> Children;
+
+       std::string __name;
+       _Math::Matrix4 __local;
+       _Math::Matrix4 __invBindMatrix;
+       _JointImpl* __pParent;
+       Children __children;
+       KeyFrames __keyFrames;
+};
+
+}}} //Tizen::Ui::Animations
+
+#endif // _FUI_ANIM_INTERNAL_JOINT_IMPL_H_
diff --git a/src/ui/animations/FUiAnim_MeshController.cpp b/src/ui/animations/FUiAnim_MeshController.cpp
deleted file mode 100644 (file)
index d23d751..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-#include "FUiAnim_MeshController.h"
-
-#include <FUiAnim_VisualElementImpl.h>
-#include <FUiAnimAnimationTransaction.h>
-
-#include <FBaseErrors.h>
-#include <FBaseSysLog.h>
-#include <string>
-
-#include "FGrpFloatPoint3.h"
-
-namespace Tizen { namespace Ui { namespace Animations {
-
-using namespace Tizen::Graphics;
-
-_MeshControllerImpl*
-_MeshControllerImpl::GetInstance(MeshController& mesh)
-{
-       return mesh.__pMeshController;
-}
-
-_MeshControllerImpl::_MeshControllerImpl(void)
-       : __pRootJoint(null)
-       , __pMeshImpl(null)
-       , __joints()
-       , __vertexControllers(null)
-       , __vertexControllersCount(0)
-{
-
-       return;
-}
-
-_MeshControllerImpl::~_MeshControllerImpl(void)
-{
-       for (unsigned int index = 0; index < __vertexControllersCount; index++)
-       {
-               if (__vertexControllers[index].weights != null)
-               {
-                       delete __vertexControllers[index].weights;
-               }
-               __vertexControllers[index].count = 0;
-       }
-       delete __vertexControllers;
-       __vertexControllersCount = 0;
-
-       for (Joints::iterator i = __joints.begin(); i != __joints.end(); i++)
-       {
-               delete i->second;
-       }
-
-       __joints.clear();
-       return;
-}
-
-result
-_MeshControllerImpl::Construct(_MeshImpl* pMeshImpl, VisualElement* pRootJoint, const _Math::Matrix4& bindShapeMatrix)
-{
-       SysTryReturnResult(NID_UI_ANIM, ((pRootJoint != null) && (pMeshImpl != null)), E_INVALID_ARG, "");
-
-       __pRootJoint = pRootJoint;
-       __pMeshImpl = pMeshImpl;
-
-       //SKELETON
-       AddNewJoint(__pRootJoint);
-       CollectJoints(__pRootJoint);
-
-       //MESH
-       __vertexControllersCount = __pMeshImpl->GetCountOfVertices();
-       __vertexControllers = new VertexController[__vertexControllersCount];
-       for (unsigned int index = 0; index < __vertexControllersCount; index++)
-       {
-               FloatPoint3 vertex = __pMeshImpl->GetVertex(index);
-               __vertexControllers[index].weights = null;
-               __vertexControllers[index].pos = bindShapeMatrix.GetTransposed() * _Math::Vector4(vertex.x, vertex.y, vertex.z, 1.0f);
-               //__vertexControllers[index].pos = bindShapeMatrix * _Math::Vector4(vertex.x, vertex.y, vertex.z, 1.0f);
-               __vertexControllers[index].count = 0;
-       }
-       return E_SUCCESS;
-
-}
-
-result
-_MeshControllerImpl::SetInvertBindMatrix(const std::string& jointName, const _Math::Matrix4& matrix)
-{
-       Joints::iterator i = __joints.find(jointName);
-       SysTryReturnResult(NID_UI_ANIM, i != __joints.end(), E_DATA_NOT_FOUND, "Joint %s not found.", jointName.c_str());
-       (*i).second->invBindMatrix.Set(matrix);
-       return E_SUCCESS;
-}
-
-result
-_MeshControllerImpl::SetAnimation(std::string jointName, VisualElementPropertyAnimation* pAnimation)
-{
-       Joints::iterator i = __joints.find(jointName);
-       SysTryReturnResult(NID_UI_ANIM, i != __joints.end(), E_DATA_NOT_FOUND, "Joint %s not found.", jointName.c_str());
-       (*i).second->pAnimation = pAnimation;
-       return E_SUCCESS;
-}
-
-result
-_MeshControllerImpl::SetJointWeightsCount(unsigned int vertexIndex, unsigned int count)
-{
-       SysTryReturnResult(NID_UI_ANIM, vertexIndex < __vertexControllersCount, E_INVALID_ARG, "Vertex not found or Construct() method not called."); //TODO: ok?
-       SysTryReturnResult(NID_UI_ANIM, __vertexControllers[vertexIndex].count == 0, E_ALREADY_SET, "Size of JointWeights array is already set");
-
-       __vertexControllers[vertexIndex].weights = new VertexWeight[count];
-       __vertexControllers[vertexIndex].count = count;
-
-       for (unsigned int index = 0; index < count; index++)
-       {
-               __vertexControllers[vertexIndex].weights[index].joint = null;
-               __vertexControllers[vertexIndex].weights[index].weight = 0;
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_MeshControllerImpl::SetJointWeight(unsigned int vertexIndex, unsigned int weightIndex, std::string jointName, float weightValue)
-{
-       SysTryReturnResult(NID_UI_ANIM, vertexIndex < __vertexControllersCount, E_INVALID_ARG, "Vertex not found or Construct() method not called."); //TODO: ok?
-       VertexController& vertexController = __vertexControllers[vertexIndex];
-       SysTryReturnResult(NID_UI_ANIM, vertexController.count > 0, E_ALREADY_SET, "Size of JointWeights array is not set");
-       SysTryReturnResult(NID_UI_ANIM, weightIndex < vertexController.count, E_INVALID_ARG, "weightIndex > count");
-
-       Joints::iterator i = __joints.find(jointName);
-       SysTryReturnResult(NID_UI_ANIM, i != __joints.end(), E_DATA_NOT_FOUND, "Joint %s not found.", jointName.c_str());
-
-       SysTryReturnResult(NID_UI_ANIM, (weightValue >= 0) && (weightValue <= 1), E_INVALID_ARG, "0 <= weightValue <= 1");
-
-       vertexController.weights[weightIndex].joint = (*i).second;
-       vertexController.weights[weightIndex].weight = weightValue;
-
-       return E_SUCCESS;
-}
-
-void
-_MeshControllerImpl::Calculate(void)
-{
-       if (__pMeshImpl != null)
-       {
-               FloatMatrix4 floatMatrix;
-               _Math::Matrix4 gMat;
-               gMat.Identity();
-
-               _VisualElementImpl* veImpl = _VisualElementImpl::GetInstance(*(__pRootJoint));
-               veImpl = veImpl->GetParent();
-               if (veImpl){
-                       floatMatrix = veImpl->GetRenderObject()->GetMatrixFromTop();
-                       gMat.Set(&(floatMatrix.matrix[0][0]));
-                       gMat.Transpose();
-               }
-
-               for (Joints::iterator it = __joints.begin(); it != __joints.end(); it++)
-               {
-                       _VisualElementImpl* veImpl = _VisualElementImpl::GetInstance(*(it->second->pVisualElement));
-
-                       FloatMatrix4 floatMatrix = veImpl->GetRenderObject()->GetMatrixToTop();
-
-                       it->second->globalMatrix.Set(&(floatMatrix.matrix[0][0]));
-                       it->second->globalMatrix.Transpose();
-
-                       it->second->globalMatrix = gMat * it->second->globalMatrix;
-               }
-
-               for (unsigned int i = 0; i < __vertexControllersCount; i++)
-               {
-                       _Math::Vector4 newVertex(0.0f);
-                       for (unsigned int j = 0; j < __vertexControllers[i].count; j++)
-                       {
-                               _Math::Matrix4& invBindMatrix = __vertexControllers[i].weights[j].joint->invBindMatrix;
-                               _Math::Matrix4& globalMatrix = __vertexControllers[i].weights[j].joint->globalMatrix;
-                               float weight = __vertexControllers[i].weights[j].weight;
-
-                               newVertex +=  globalMatrix * (weight * invBindMatrix *  __vertexControllers[i].pos);
-                       }
-                       __pMeshImpl->SetVertex(i, FloatPoint3(newVertex.x, newVertex.y, newVertex.z));
-               }
-       }
-}
-
-VisualElement*
-_MeshControllerImpl::GetRootJoint(void)
-{
-       return __pRootJoint;
-}
-
-void
-_MeshControllerImpl::CollectJoints(VisualElement* pVisualElement)
-{
-       Tizen::Base::Collection::IList* pChildren = pVisualElement->GetChildrenN();
-       unsigned int childrenCount = pChildren->GetCount();
-       for (unsigned int i = 0; i < childrenCount; i++){
-               VisualElement* pChild = static_cast<VisualElement*>(pChildren->GetAt(i));
-
-               AddNewJoint(pChild);
-
-               if (pChild->GetChildrenCount() > 0)
-               {
-                       CollectJoints(pChild);
-               }
-       }
-}
-
-void
-_MeshControllerImpl::AddNewJoint(VisualElement* pVisualelement)
-{
-       Joint* pJoint = new (std::nothrow) Joint();
-       //TODO: SysTry
-       pJoint->pVisualElement = pVisualelement;
-       pJoint->invBindMatrix.Set(_Math::Matrix4::GetIdentity());
-       //pJoint->globalMatrix.Set(0.0f);
-       pJoint->pAnimation = null;
-
-       //TODO: SysTry unique Joint name
-
-       std::wstring wstr(pVisualelement->GetName().GetPointer());
-       std::string jointName(wstr.begin(), wstr.end());
-
-       __joints.insert(std::make_pair(jointName, pJoint));  // NAME === COLLADA BONE SID!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-}
-
-void
-_MeshControllerImpl::StartAnimation(unsigned int repeatCount)
-{
-       StopAnimation();
-
-       for (Joints::iterator i = __joints.begin(); i != __joints.end(); i++)
-       {
-               VisualElement* ve = i->second->pVisualElement;
-               VisualElementPropertyAnimation* anim = i->second->pAnimation;
-               if (anim != null){
-
-                       anim->SetRepeatCount(repeatCount);
-                       ve->AddAnimation(*anim);
-               }
-       }
-}
-
-void
-_MeshControllerImpl::StopAnimation(void)
-{
-       for (Joints::iterator i = __joints.begin(); i != __joints.end(); i++)
-       {
-               i->second->pVisualElement->RemoveAllAnimations();
-       }
-}
-
-}}}
diff --git a/src/ui/animations/FUiAnim_MeshController.h b/src/ui/animations/FUiAnim_MeshController.h
deleted file mode 100644 (file)
index 06ac718..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <FUiAnimVisualElement.h>
-#include <string>
-#include <map>
-#include <FUiAnim_MeshImpl.h>
-#include <FUiAnim_MathVector4.h>
-#include <FUiAnim_MathMatrix4.h>
-
-#include <FUiAnimVisualElementPropertyAnimation.h>
-
-#ifndef _FUI_ANIM_INTERNAL_MESH_CONTROLLER_H_
-#define _FUI_ANIM_INTERNAL_MESH_CONTROLLER_H_
-
-namespace Tizen { namespace Ui { namespace Animations {
-
-
-struct Joint{
-       VisualElement* pVisualElement;
-       _Math::Matrix4 invBindMatrix;
-       _Math::Matrix4 globalMatrix;
-       VisualElementPropertyAnimation* pAnimation;
-};
-
-struct VertexWeight{
-       Joint* joint;
-       float weight;
-};
-
-struct VertexController{
-       VertexWeight* weights;
-       _Math::Vector4 pos;
-       unsigned int count;
-};
-
-//======================================================
-
-class _MeshControllerImpl {
-public:
-       static _MeshControllerImpl* GetInstance(MeshController& mesh);
-
-       result SetInvertBindMatrix(const std::string& jointName, const _Math::Matrix4& matrix);
-       result SetAnimation(std::string jointName, Tizen::Ui::Animations::VisualElementPropertyAnimation* pAnimation);
-
-       result SetJointWeightsCount(unsigned int vertexIndex, unsigned int count);
-       result SetJointWeight(unsigned int vertexIndex, unsigned int weightIndex, std::string jointName, float weightValue);
-
-       void Calculate();
-       VisualElement* GetRootJoint();
-
-       //animation methods
-
-       void StartAnimation(unsigned int repeatCount = 1);
-
-       void StopAnimation(void);
-
-private:
-       _MeshControllerImpl(void);
-       virtual ~_MeshControllerImpl(void);
-
-       result Construct(_MeshImpl* pMeshImpl, VisualElement* pRootJoint, const _Math::Matrix4& bindShapeMatrix);
-
-       void CollectJoints(VisualElement* pVisualelement);
-
-private:
-       VisualElement* __pRootJoint;
-       _MeshImpl* __pMeshImpl;
-
-       typedef std::map<std::string, Joint*> Joints;
-       Joints __joints;
-       void AddNewJoint(VisualElement* pVisualelement);
-
-       VertexController* __vertexControllers;
-       unsigned int __vertexControllersCount;
-
-       friend class _MeshImpl;
-       friend class MeshController;
-};
-
-}}}
-
-#endif //_FUI_ANIM_INTERNAL_MESH_CONTROLLER_H_
diff --git a/src/ui/animations/FUiAnim_MeshControllerImpl.cpp b/src/ui/animations/FUiAnim_MeshControllerImpl.cpp
new file mode 100644 (file)
index 0000000..4307fe3
--- /dev/null
@@ -0,0 +1,423 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_MeshControllerImpl.cpp
+ * @brief      This file contains implementation of _MeshControllerImpl class
+ *
+ * This file contains implementation _MeshControllerImpl class.
+ */
+
+#include "FUiAnim_MeshControllerImpl.h"
+
+#include <FUiAnim_JointImpl.h>
+#include <FUiAnim_VisualElementImpl.h>
+#include <FUiAnimAnimationTransaction.h>
+
+#include "FUiAnim_GlRenderManager.h" //FIXME delete
+#include "FUiAnim_DisplayManager.h"//FIXME delete
+
+#include <FBaseErrors.h>
+#include <FBaseSysLog.h>
+#include <string>
+
+#include "FGrpFloatPoint3.h"
+
+namespace Tizen { namespace Ui { namespace Animations {
+
+using namespace Tizen::Graphics;
+
+_MeshControllerImpl*
+_MeshControllerImpl::GetInstance(MeshController& mesh)
+{
+       return mesh.__pMeshControllerImpl;
+}
+
+MeshController*
+_MeshControllerImpl::CreatePublicInstance(void)
+{
+       return new (std::nothrow) MeshController();
+}
+
+result
+_MeshControllerImpl::DestroyPublicInstance(const MeshController& mesh)
+{
+       delete &mesh;
+       return E_SUCCESS;
+}
+
+_MeshControllerImpl::_MeshControllerImpl()
+       : __isConstructed(false)
+       , __pRoot(null)
+       , __pMeshImpl(null)
+       , __bindShapeMatrix()
+       , __joints()
+       , __pInitialPositions(null)
+       , __vertexCount(0)
+       , __gpuSkinning(false)
+       , __pGlobals(null)
+       , __pIDs(null)
+       , __pWeights(null)
+       , __animationStarted(false)
+       , __animationDuration(0)
+       , __animationTime(0)
+{
+       __prevTime = clock();
+       return;
+}
+
+_MeshControllerImpl::~_MeshControllerImpl(void)
+{
+       __joints.clear();
+
+       if (__pRoot != null)
+       {
+               delete __pRoot;
+       }
+
+       if (__pInitialPositions != null )
+       {
+               delete __pInitialPositions;
+       }
+
+       if (__pIDs != null)
+       {
+               delete[] __pIDs;
+       }
+
+       if (__pWeights != null)
+       {
+               delete[] __pWeights;
+       }
+
+       if (__pGlobals != null)
+       {
+               delete[] __pGlobals;
+       }
+
+       return;
+}
+
+result
+_MeshControllerImpl::SetMesh(_MeshImpl* pMesh)
+{
+       SysTryReturnResult(NID_UI, __pMeshImpl == null, E_ALREADY_SET, "Mesh already set !!!"); //TODO: english!
+
+       __pMeshImpl = pMesh;
+       __vertexCount = __pMeshImpl->GetCountOfVertices();
+
+       __pIDs = new float[__vertexCount * 4]; //TODO: systry
+       __pWeights = new float[__vertexCount * 4]; //TODO: systry
+
+       memset(__pIDs, 0.0f, __vertexCount * 4 * sizeof(float));
+       memset(__pWeights, 0.0f, __vertexCount * 4 * sizeof(float));
+
+       __pInitialPositions = new _Math::Vector4[__vertexCount];
+       for (unsigned int index = 0; index < __vertexCount; index++)
+       {
+               FloatPoint3 vertex = __pMeshImpl->GetVertex(index);
+               __pInitialPositions[index].Set(vertex.x, vertex.y, vertex.z, 1.0f);
+       }
+
+       return E_SUCCESS;
+}
+
+result _MeshControllerImpl::ResetMesh()
+{
+       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];
+
+               __pMeshImpl->SetVertex(index, FloatPoint3(vertex.x, vertex.y, vertex.z));
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::SetSkeleton(_JointImpl* pRootJoint)
+{
+       SysTryReturnResult(NID_UI, __pRoot == null, E_ALREADY_SET, "Skeleton already set!!!"); //TODO: english!
+       __pRoot = pRootJoint;
+
+       CollectJoints(pRootJoint);
+       __pGlobals = new _Math::Matrix4[__joints.size()];
+
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::SetBindShapeMatrix(const _Math::Matrix4& bindShapeMatrix)
+{
+       __bindShapeMatrix.Set(bindShapeMatrix);
+       __bindShapeMatrix.Transpose();
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::Construct()
+{
+       SysTryReturnResult(NID_UI, !__isConstructed, E_INVALID_OPERATION, "Already constructed!"); //TODO: Check error type
+
+       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);
+
+       //Jaksho na verteks ne vplyvae }|{odna kistka - zrobyty shob vplyvav root z vagoju 1.0
+       for (unsigned int vertexIndex = 0; vertexIndex < __vertexCount; vertexIndex++)
+       {
+               unsigned int vertexJointsCount = 0;
+               for (unsigned int i = 0; i < 4; i++)
+               {
+                       unsigned int id = (int) __pIDs[vertexIndex * 4 + i];
+                       if (id != 0)
+                       {
+                               vertexJointsCount++;
+                       }
+               }
+
+               if (vertexJointsCount == 0){
+
+                       AppLog("Vertex without Joint %i", vertexIndex);
+
+                       __pIDs[vertexIndex * 4 + 0] = 0;
+                       __pWeights[vertexIndex * 4 + 0] = 1.0f;
+               }
+
+       }
+
+       //weights sum == 1
+       for (unsigned int vertexIndex = 0; vertexIndex < __vertexCount; vertexIndex++)
+       {
+               float weightsSum = 0.0f;
+               for (unsigned int weightIndex = 0; weightIndex < 4; weightIndex++)
+               {
+                       weightsSum += __pWeights[vertexIndex * 4 + weightIndex];
+               }
+
+               for (unsigned int weightIndex = 0; weightIndex < 4; weightIndex++)
+               {
+                       __pWeights[vertexIndex * 4 + weightIndex] /= weightsSum;
+               }
+       }
+
+       __isConstructed = true;
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::SetJointWeight(unsigned int vertexIndex, const std::string& jointName, float weightValue)
+{
+       SysTryReturnResult(NID_UI, !__isConstructed, E_INVALID_OPERATION, "Already constructed!"); //TODO: Check error type
+
+       SysTryReturnResult(NID_UI_ANIM, vertexIndex < __vertexCount, E_INVALID_ARG, "Vertex not found."); //TODO: ok?
+
+       _JointImpl* pJoint = null;
+       unsigned int jointIndex = 0;
+       for (unsigned int i = 0; i < __joints.size(); i++){
+               if (jointName.compare(__joints[i]->GetName()) == 0){
+                       pJoint = __joints[i];
+                       jointIndex = i;
+                       break;
+               }
+       }
+
+       SysTryReturnResult(NID_UI_ANIM, pJoint != null, E_DATA_NOT_FOUND, "Joint %s not found.", jointName.c_str());
+
+       SysTryReturnResult(NID_UI_ANIM, (weightValue >= 0) && (weightValue <= 1), E_INVALID_ARG, "Invalid weights value: Vertex index = %i, Joint name: %s, weightValue = %f ", vertexIndex, jointName.c_str(), weightValue);
+
+       //Only 4 joints with max weights
+       for (unsigned int i = 0; i < 4; i++)
+       {
+               if (weightValue > __pWeights[vertexIndex * 4 + i])
+               {
+                       for (unsigned int j = 3; j > i; j--)
+                       {
+                               __pIDs[vertexIndex * 4 + j] = __pIDs[vertexIndex * 4 + j - 1];
+                               __pWeights[vertexIndex * 4 + j] = __pWeights[vertexIndex * 4 + j - 1];
+                       }
+
+                       __pIDs[vertexIndex * 4 + i] = jointIndex;
+                       __pWeights[vertexIndex * 4 + i] = weightValue;
+
+                       break;
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::Calculate()
+{
+       SysTryReturnResult(NID_UI, __isConstructed, E_INVALID_OPERATION, "Not constructed!"); //TODO: Check error type
+
+       clock_t curTime;
+       curTime = clock();
+
+       float dt = (float)(curTime - __prevTime) / CLOCKS_PER_SEC;
+       __prevTime = curTime;
+
+       AppLog("%f", dt);
+
+       if (__animationStarted)
+       {
+               __animationTime += dt;
+               __pRoot->Animate(__animationTime, true);
+
+               AppLog("%f : %f", __animationTime, __animationDuration);
+
+               if (__animationTime > __animationDuration)
+               {
+                       __animationTime = 0;
+               }
+               else
+               {
+                       //Post "update" message to renderer...
+               }
+       }
+
+       for (unsigned int jointIndex = 0; jointIndex < __joints.size(); jointIndex++)
+       {
+               __pGlobals[jointIndex].Set(__joints[jointIndex]->GetGlobal());
+               __pGlobals[jointIndex] = __pGlobals[jointIndex] * __joints[jointIndex]->GetInvertBindMatrix() * __bindShapeMatrix;
+               __pGlobals[jointIndex].Transpose();
+       }
+
+
+       unsigned int index0 = 0;
+       unsigned int index1 = 0;
+       unsigned int index2 = 0;
+       unsigned int index3 = 0;
+
+       if (! __gpuSkinning)
+       {
+               _Math::Vector4 newVertex(0.0f);
+               for (unsigned int i = 0; i < __vertexCount; i++)
+               {
+                       index0 = __pIDs[i * 4 + 0];
+                       index1 = __pIDs[i * 4 + 1];
+                       index2 = __pIDs[i * 4 + 2];
+                       index3 = __pIDs[i * 4 + 3];
+
+                       newVertex  = (__pGlobals[index0].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 0];
+                       newVertex += (__pGlobals[index1].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 1];
+                       newVertex += (__pGlobals[index2].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 2];
+                       newVertex += (__pGlobals[index3].GetTransposed() * __pInitialPositions[i]) * __pWeights[i * 4 + 3];
+
+                       __pMeshImpl->SetVertex(i, FloatPoint3(newVertex.x, newVertex.y, newVertex.z));
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+_JointImpl*
+_MeshControllerImpl::GetRoot()
+{
+       return __pRoot;
+}
+
+void
+_MeshControllerImpl::CollectJoints(_JointImpl* pJoint)
+{
+       __joints.push_back(pJoint);
+       unsigned int jointCount = pJoint->GetChildrenCount();
+       for (unsigned int i = 0; i < jointCount; i++)
+       {
+               _JointImpl* pChild = pJoint->GetChildAt(i);
+               if (pChild != null)
+               {
+                       CollectJoints(pChild);
+               }
+       }
+}
+
+result
+_MeshControllerImpl::SetAnimationDuration(float milliseconds)
+{
+       if (milliseconds > 0)//TODO SysTry milliseconds > 0
+       {
+               __animationDuration = milliseconds;
+       }
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::StartAnimation()
+{
+       //__animationTime = 0;
+       __animationStarted = true;
+
+       return E_SUCCESS;
+}
+
+result
+_MeshControllerImpl::StopAnimation()
+{
+       __animationTime = 0;
+       __pRoot->Animate(__animationTime, true); //TODO needed?
+       __animationStarted = false;
+       return E_SUCCESS;
+}
+
+bool
+_MeshControllerImpl::IsAnimating(void)
+{
+       return __animationStarted;
+}
+
+void
+_MeshControllerImpl::SetGPUSkinning(bool value)
+{
+       __gpuSkinning = value;
+}
+
+bool
+_MeshControllerImpl::IsGpuSkinning()
+{
+       return __gpuSkinning;
+}
+
+unsigned int
+_MeshControllerImpl::GetJointsCount()
+{
+       return __joints.size();
+}
+
+const float*
+_MeshControllerImpl::GetMatricesPointer()
+{
+       return __pGlobals->GetPointer();
+}
+
+const float*
+_MeshControllerImpl::GetIdsPointer()
+{
+       return __pIDs;
+}
+
+const float*
+_MeshControllerImpl::GetWeightsPointer()
+{
+       return __pWeights;
+}
+
+}}}
diff --git a/src/ui/animations/FUiAnim_MeshControllerImpl.h b/src/ui/animations/FUiAnim_MeshControllerImpl.h
new file mode 100644 (file)
index 0000000..8c78887
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_MeshControllerImpl.h
+ * @brief      This is the header file for the _MeshControllerImpl class.
+ *
+ * This header file contains the declarations of the _MeshControllerImpl class.
+ */
+
+#include "FUiAnimMeshController.h"
+
+#include <string>
+#include <vector>
+#include <FUiAnim_MeshImpl.h>
+#include <FUiAnim_JointImpl.h>
+#include <FUiAnim_MathVector4.h>
+#include <FUiAnim_MathMatrix4.h>
+
+#include <time.h>
+
+#ifndef _FUI_ANIM_INTERNAL_MESH_CONTROLLER_IMPL_H_
+#define _FUI_ANIM_INTERNAL_MESH_CONTROLLER_IMPL_H_
+
+namespace Tizen { namespace Ui { namespace Animations {
+
+//======================================================
+
+class _MeshControllerImpl {
+public:
+       static _MeshControllerImpl* GetInstance(MeshController& mesh);
+       static MeshController* CreatePublicInstance(void);
+       static result DestroyPublicInstance(const MeshController& mesh);
+
+       result SetMesh(_MeshImpl* pMesh);
+       result SetSkeleton(_JointImpl* pRootJoint);
+       result SetBindShapeMatrix(const _Math::Matrix4& bindShapeMatrix);
+
+       result SetJointWeight(unsigned int vertexIndex, const std::string& jointName, float weightValue);
+
+       result Construct();
+
+       result Calculate();
+       _JointImpl* GetRoot();
+
+       result ResetMesh(); //Set mesh vertices to initial positions
+
+       //animation methods
+       result SetAnimationDuration(float milliseconds);
+       result StartAnimation(void);
+       result StopAnimation(void);
+       bool IsAnimating(void);
+
+       //for renderer
+       void SetGPUSkinning(bool value);
+       bool IsGpuSkinning();
+       unsigned int GetJointsCount();
+       const float* GetMatricesPointer();
+       const float* GetIdsPointer();
+       const float* GetWeightsPointer();
+
+private:
+       _MeshControllerImpl(void);
+       virtual ~_MeshControllerImpl(void);
+
+       void CollectJoints(_JointImpl* pVisualelement);
+private:
+       bool __isConstructed;
+
+       _JointImpl* __pRoot;
+       _MeshImpl* __pMeshImpl;
+
+       _Math::Matrix4 __bindShapeMatrix;
+       typedef std::vector<_JointImpl*> Joints;
+       Joints __joints;
+
+       _Math::Vector4* __pInitialPositions;
+       unsigned int __vertexCount;
+
+       //GPU skinning
+       bool __gpuSkinning;
+       _Math::Matrix4* __pGlobals; //jointCount * 16; <= global * invBind * bindShape;
+       float* __pIDs; //vertexCount * 4
+       float* __pWeights; //vertexCount * 4
+
+       clock_t __prevTime;
+       bool __animationStarted;
+       float __animationDuration;
+       float __animationTime;
+
+       friend class MeshController;
+};
+
+}}}
+
+#endif //_FUI_ANIM_INTERNAL_MESH_CONTROLLER_IMPL_H_
index 8bda96f..91a94e9 100644 (file)
@@ -1,9 +1,31 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_MeshImpl.cpp
+ * @brief      This file contains implementation of _MeshImpl class
+ *
+ * This file contains implementation _MeshImpl class.
+ */
 
 #include <stdint.h>
 #include <string>
 #include <unique_ptr.h>
 
-#include "FUiAnim_MeshController.h"
 #include "FGrpFloatPoint3.h"
 #include "FGrpFloatDimension.h"
 #include "FGrpFloatPoint.h"
@@ -108,6 +130,12 @@ _MeshImpl::Clear()
        __boundingVolume.Reset();
        __hasBoundingVolume = false;
 
+       if(__pMeshController)
+       {
+               _MeshControllerImpl::DestroyPublicInstance(*__pMeshController);
+               __pMeshController = null;
+       }
+
        return ;
 }
 
@@ -691,21 +719,21 @@ _MeshImpl::SaveMeshToBin(const Tizen::Base::String& fileName)
 }
 
 MeshController*
-_MeshImpl::CreateMeshController(VisualElement* pRootJoint, const FloatMatrix4& bindShapeMatrix)
+_MeshImpl::CreateMeshController(_JointImpl* pRootJoint, const FloatMatrix4& bindShapeMatrix)
 {
        SysTryReturn(NID_UI_ANIM, __pMeshController == null, __pMeshController, E_ALREADY_SET, "MeshController is already created!") //TODO: check english
 
-       __pMeshController = new (std::nothrow) MeshController();
+       __pMeshController = _MeshControllerImpl::CreatePublicInstance();// new (std::nothrow) MeshController();
        //TODO: SYSTRY
 
        _MeshControllerImpl* pMeshController = _MeshControllerImpl::GetInstance(*__pMeshController);
        //TODO: SYSTRY
 
        _Math::Matrix4 matrix(&(bindShapeMatrix.matrix[0][0]));
-       if (pMeshController->Construct(this, pRootJoint, matrix) != E_SUCCESS){ //TODO: SysTry
-               delete __pMeshController;
-               __pMeshController = null;
-       }
+
+       pMeshController->SetMesh(this);
+       pMeshController->SetSkeleton(pRootJoint);
+       pMeshController->SetBindShapeMatrix(matrix);
 
        return __pMeshController;
 }
@@ -713,7 +741,7 @@ _MeshImpl::CreateMeshController(VisualElement* pRootJoint, const FloatMatrix4& b
 _MeshControllerImpl*
 _MeshImpl::GetMeshControllerImpl(void)
 {
-       return (__pMeshController)?__pMeshController->__pMeshController:null;
+       return (__pMeshController)?_MeshControllerImpl::GetInstance(*__pMeshController):null;
 }
 
 static _DyanamicPropertyString*
index 64523c0..a9d1e03 100644 (file)
@@ -25,6 +25,7 @@
 #include "FUiAnim_ModelImporterImpl.h"
 
 #include "FUiAnimVisualElement.h"
+#include "FUiAnim_JointImpl.h"
 
 #include "library-effects/FUiAnim_ImportColladaLibEffCommonShaderData.h"
 #include "library-images/FUiAnim_ImportColladaLibImgImage.h"
@@ -631,7 +632,7 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
                globalMatrix.Identity();
 
                LibraryVisualScenes::Node* parentNode = pNode;
-               while (parentNode != NULL)
+               while (parentNode != null)
                {
                        globalMatrix = parentNode->GetLocalMatrix() * globalMatrix;
                        parentNode = parentNode->Parent();
@@ -674,29 +675,23 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
                                }
 
                                //===================================================================================Set shader
+                               Shader vert;
+                               Shader frag;
+
                                if (textureId.compare("") == 0)
                                {
-                                       Shader vert;
                                        vert.Construct(Shader::SHADER_VERTEX, vs_Test);
-                                       Shader frag;
                                        frag.Construct(Shader::SHADER_FRAGMENT, fs_Test);
-
-                                       ShaderProgram *pProgram = new ShaderProgram();
-                                       pProgram->Construct(vert,frag);
-                                       pVisElem->SetShaderProgram(pProgram);
                                }
                                else
                                {
-                                       Shader vert;
                                        vert.Construct(Shader::SHADER_VERTEX, vs_TestTexture);
-                                       Shader frag;
                                        frag.Construct(Shader::SHADER_FRAGMENT, fs_TestTexture);
-
-                                       ShaderProgram *pProgram = new ShaderProgram();
-                                       pProgram->Construct(vert,frag);
-                                       pVisElem->SetShaderProgram(pProgram);
                                }
 
+                               ShaderProgram *pProgram = new ShaderProgram();
+                               pProgram->Construct(vert,frag);
+                               pVisElem->SetShaderProgram(pProgram);
 
                                pScene->AddMesh(pMesh);
                                delete pMesh;
@@ -705,8 +700,6 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
 
                        if (pInstance->GetType() == LibraryVisualScenes::Instance::CONTROLLER)
                        {
-                               AppLog("Controller!");
-                               //----------------------------------------------------------------------VE
                                VisualElement* pVisElem = new (std::nothrow) VisualElement();
                                pVisElem->Construct();
                                pVisElem->SetName(pNode->GetID().c_str());
@@ -719,22 +712,32 @@ _ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pRootNode, Library
                                std::string boneName(pInstanceController->GetRootBoneID(0).c_str() + 1);
                                LibraryVisualScenes::Node* pSceletonRootNode = pRootNode->FindNode(boneName);
 
-
                                //----------------------------------------------------------------------Controller
                                Mesh* pMesh;
                                CreateController(pInstanceController->GetUrl().c_str() + 1, pSceletonRootNode, &pMesh);
 
-                               ShaderProgram *pProgram = new ShaderProgram();
+                               //pVisElem->AttachChild(pMesh->GetMeshController()->GetSkeletonRoot());
+                               pVisElem->SetMesh(pMesh);
 
-                               Shader vert;
-                               vert.Construct(Shader::SHADER_VERTEX, vs_TestRed);
-                               Shader frag;
-                               frag.Construct(Shader::SHADER_FRAGMENT, fs_TestRed);
-                               pProgram->Construct(vert,frag);
-                               pVisElem->SetShaderProgram(pProgram);
+//                             //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);
 
-                               pVisElem->SetMesh(pMesh);
-                               //pVisElem->AttachChild(skeleton); //NO!!!
                                pScene->AddMesh(pMesh);
                                delete pMesh;
 
@@ -755,7 +758,7 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
        _MeshControllerImpl* pMeshControllerImpl = null;
 
        std::list<std::string> jointNames;
-       VisualElement* pRootJoint = GetSkeleton(pSceletonRootNode, jointNames);
+       _JointImpl* pRootJoint = GetSkeleton(pSceletonRootNode, jointNames);
 
        if (pRootJoint != null)
        {
@@ -773,82 +776,99 @@ _ModelImporterImpl::CreateController(const std::string& controllerName, LibraryV
 
                pMeshController = pMeshImpl->CreateMeshController(pRootJoint, MathMatrixToFloatMatrix(contollerSkin->GetBindShapeMatrix()));
                pMeshControllerImpl = _MeshControllerImpl::GetInstance(*pMeshController);
-
                //----------------------------------------------------------------InvertBindMatrix
                unsigned int jibmsCount = contollerSkin->jibms.size();
                for (unsigned int jointIndex = 0; jointIndex < jibmsCount;  jointIndex++)
                {
-                       pMeshControllerImpl->SetInvertBindMatrix(contollerSkin->jibms[jointIndex].boneName, contollerSkin->jibms[jointIndex].matrix);
+                       std::string jointName = contollerSkin->jibms[jointIndex].boneName;
+                       _JointImpl* pJoint = pRootJoint->Find(jointName);
+                       if (pJoint != null)
+                       {
+                               pJoint->SetInvertBindMatrix(contollerSkin->jibms[jointIndex].matrix);
+                       }
+                       else
+                       {
+                               AppLog("Joint %s is not found", jointName.c_str());
+                       }
                }
 
                //----------------------------------------------------------------animations
-               for (std::list<std::string>::iterator jointName = jointNames.begin(); jointName != jointNames.end(); jointName++)
+               if (colladaAssets->pLibraryAnimations != null)
                {
-                       LibraryVisualScenes::Node* pNode = pSceletonRootNode->FindNode(*jointName);
-                       if (pNode != null)
+                       LibraryAnimations::LibraryAnimations* pLibAnim = colladaAssets->pLibraryAnimations;
+                       LibraryAnimations::LibraryAnimations::Times::iterator firstTime = pLibAnim->__timeLine.begin();
+                       LibraryAnimations::LibraryAnimations::Times::iterator lastTime = pLibAnim->__timeLine.end();
+                       lastTime--;
+
+                       float animationDuration = *lastTime - *firstTime;
+                       pMeshControllerImpl->SetAnimationDuration(animationDuration);
+
+                       for (std::list<std::string>::iterator jointName = jointNames.begin(); jointName != jointNames.end(); jointName++)
                        {
-                               Tizen::Ui::Animations::VisualElementPropertyAnimation* anim = GetAnimationFor(pNode);
-                               if (anim != null)
+                               LibraryVisualScenes::Node* pNode = pSceletonRootNode->FindNode(*jointName);
+                               if (pNode != null)
                                {
-                                       pMeshControllerImpl->SetAnimation(pNode->GetSID(), anim);
+                                       _JointImpl* pJoint = pRootJoint->Find(pNode->GetSID());
+                                       if (pJoint)
+                                       {
+                                               CreateAnimation(pNode, pJoint);
+                                       }
                                }
                        }
                }
+               else
+               {
+                       AppLog("Library of animations was not parsed.");
+               }
 
                //----------------------------------------------------------------weights
                unsigned int vertexCount = (unsigned int)pMesh->GetVertexCount(); //TODO: warning: singed == unsigned //contollerSkin->vertexCount;
                if (colladaIndices.size() == vertexCount)
                {
                        unsigned int vertexIndex = 0;
-                       for (ColladaIndices::iterator it = colladaIndices.begin(); it != colladaIndices.end(); it++, vertexIndex++)
+                       for (ColladaIndices::iterator it = colladaIndices.begin(); it != colladaIndices.end(); it++)
                        {
                                unsigned int oldVertexIndex = *it;
                                unsigned int weightsCount = contollerSkin->vjws[oldVertexIndex].size();
-                               pMeshControllerImpl->SetJointWeightsCount(vertexIndex, weightsCount);
 
                                for (unsigned int weightIndex = 0; weightIndex < weightsCount; weightIndex++)
                                {
-                                       const std::string& jointName = contollerSkin->vjws[oldVertexIndex][weightIndex].boneName;
+                                       std::string jointName = contollerSkin->vjws[oldVertexIndex][weightIndex].boneName;
                                        float weight = contollerSkin->vjws[oldVertexIndex][weightIndex].weight;
 
-                                       pMeshControllerImpl->SetJointWeight(vertexIndex, weightIndex, jointName, weight);
+                                       pMeshControllerImpl->SetJointWeight(vertexIndex, jointName, weight);
                                }
+                               vertexIndex++;
                        }
                }
-       }
+               else
+               {
+                       AppLog("Error: colladaIndices.size() != vertexCount");
+               }
 
-}
+               pMeshControllerImpl->Construct();
+       }
 
-VisualElement*
-_ModelImporterImpl::CreateJoint(LibraryVisualScenes::Node& pNode)
-{
-       VisualElement* pJoint = new (std::nothrow)VisualElement();
-       //TODO: SysTry
-       pJoint->Construct();
-       pJoint->SetName(pNode.GetSID().c_str());
-       pJoint->SetImplicitAnimationEnabled(false);
-       pJoint->SetTransformMatrix(MathMatrixToFloatMatrix(pNode.GetLocalMatrix()));
-
-       return pJoint;
 }
 
-VisualElement*
+_JointImpl*
 _ModelImporterImpl::GetSkeleton(LibraryVisualScenes::Node* pRootNode, std::list<std::string>& jointNames)
 {
        if (pRootNode != null)
        {
                jointNames.push_back(pRootNode->GetID());
-               VisualElement* pRootJoint = CreateJoint(*pRootNode);
+
+               _JointImpl* pRootJoint = new (std::nothrow) _JointImpl(pRootNode->GetSID(), pRootNode->GetLocalMatrix());
 
                LibraryVisualScenes::Node* pCurNode = pRootNode->Children();
-               VisualElement* pCurJoint = pRootJoint;
+               _JointImpl* pCurJoint = pRootJoint;
 
                while ( pCurNode != null )
                {
                        jointNames.push_back(pCurNode->GetID());
-                       VisualElement* pJoint = CreateJoint(*pCurNode);
+                       _JointImpl* pJoint = new (std::nothrow) _JointImpl(pCurNode->GetSID(), pCurNode->GetLocalMatrix());
 
-                       pCurJoint->AttachChild(pJoint);
+                       pCurJoint->AttachChild(*pJoint);
 
                        if (pCurNode->Children() != null)
                        {
@@ -888,12 +908,12 @@ _ModelImporterImpl::GetSkeleton(LibraryVisualScenes::Node* pRootNode, std::list<
 }
 
 
-Tizen::Ui::Animations::VisualElementPropertyAnimation*
-_ModelImporterImpl::GetAnimationFor(LibraryVisualScenes::Node* pNode)
+result
+_ModelImporterImpl::CreateAnimation(LibraryVisualScenes::Node* pNode, _JointImpl* pJoint)
 {
        LibraryAnimations::LibraryAnimations* pLibAnim = colladaAssets->pLibraryAnimations;
-       SysTryReturn(NID_UI_ANIM, pLibAnim != null, null, E_INVALID_DATA, "Library of animations was not parsed.");
-
+       SysTryReturnResult(NID_UI_ANIM, pLibAnim != null, E_INVALID_DATA, "Library of animations was not parsed.");
+       LibraryAnimations::LibraryAnimations::Times::iterator firstTime = pLibAnim->__timeLine.begin();
 
        LibraryAnimations::Animation::Channels channelsForJoint;
 
@@ -911,27 +931,7 @@ _ModelImporterImpl::GetAnimationFor(LibraryVisualScenes::Node* pNode)
        SysTryReturn(NID_UI_ANIM, count > 0, null, E_INVALID_DATA, "Node %s is not animated", pNode->GetID().c_str()); //TODO: eng
 
        //-----------------------------------------------------------------------------------------------------------
-
-       LibraryAnimations::LibraryAnimations::Times::iterator firstTime = pLibAnim->__timeLine.begin();
-       LibraryAnimations::LibraryAnimations::Times::iterator lastTime = pLibAnim->__timeLine.end();
-       lastTime--;
-
-       float minTime = *(firstTime);
-       float maxTime = *(lastTime);
-       float dt  = 1.0f / (maxTime - minTime);
-
-       //animation
-       Tizen::Ui::Animations::VisualElementPropertyAnimation* animation = new (std::nothrow) Tizen::Ui::Animations::VisualElementPropertyAnimation();
-       //TODO: SysTry
-       animation->SetDuration((maxTime - minTime) * 1000.0f);
-       animation->SetPropertyName(L"transform");
-
-       //start value
-       animation->SetStartValue(Variant(MathMatrixToFloatMatrix(pNode->GetLocalMatrix())));
-
-       //key frames
-       LibraryAnimations::LibraryAnimations::Times::iterator currentTime = firstTime;
-       for (++currentTime; currentTime != pLibAnim->__timeLine.end(); currentTime++)
+       for (LibraryAnimations::LibraryAnimations::Times::iterator currentTime = pLibAnim->__timeLine.begin(); currentTime != pLibAnim->__timeLine.end(); currentTime++)
        {
                float curTime = *currentTime;
 
@@ -946,16 +946,11 @@ _ModelImporterImpl::GetAnimationFor(LibraryVisualScenes::Node* pNode)
                        }
                }
 
-               if (currentTime != lastTime)
-               {
-                       animation->AddKeyFrame((curTime - minTime) * dt, Variant(MathMatrixToFloatMatrix(pNode->GetLocalMatrix())), null);
-               }
+               pJoint->AddKeyFrame(curTime - *firstTime, pNode->GetLocalMatrix());
        }
 
-       //end value
-       animation->SetEndValue(Variant(MathMatrixToFloatMatrix(pNode->GetLocalMatrix())));
 
-       return animation;
+       return E_SUCCESS;
 }
 
 }}}
index 0444582..2292f77 100644 (file)
@@ -45,6 +45,9 @@ const wchar_t* VeAttrTexCoord                         = L"a_texcoord";
 const wchar_t* VeAttrColor                                     = L"a_color";
 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* VeUniformMVP                                    = L"u_mvp";
 const wchar_t* VeUniformColor                          = L"u_color";
 const wchar_t* VeUniformTex2D                          = L"u_tex2d";
@@ -52,6 +55,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* VeUniformLightType                      = L"u_light[%d].type";
 const wchar_t* VeUniformLightAmbient           = L"u_light[%d].ambient";
@@ -207,6 +211,7 @@ _ShaderProgramImpl::MakeUniformLocationTable(void)
        MoveUniformItem(UNIFORM_MAT4_MODEL_VIEW, VeUniformMV);
        MoveUniformItem(UNIFORM_MAT4_INV_MODEL_VIEW, VeUniformInvMV);
 
+       MoveUniformItem(UNIFORM_MAT4_ARRAY_JOINTSMATRICES, VeUniformJointsMatrices);
 
        Tizen::Base::String str;
        for (int i = 0; i < MAX_LIGHT_COUNT; i++)
index 2af929f..d5a7a58 100644 (file)
@@ -38,6 +38,8 @@ extern const wchar_t* VeAttrPosition;
 extern const wchar_t* VeAttrTexCoord;
 extern const wchar_t* VeAttrColor;
 extern const wchar_t* VeAttrNormal;
+extern const wchar_t* VeAttrWeights;
+extern const wchar_t* VeAttrJoints;
 
 extern const wchar_t* VeUniformMVP;
 extern const wchar_t* VeUniformColor;
@@ -76,6 +78,10 @@ enum AttributeLocation
        ATTRIBUTE_VEC2_TEXTURE_COORD,           /**< Attribute for texture coordinate */
        ATTRIBUTE_VEC4_COLOR,                           /**< Attribute for color */
        ATTRIBUTE_VEC3_NORMAL,                          /**< Attribute for normal */
+
+       ATTRIBUTE_VEC4_WEIGHTS,                         /**< Attribute for joints weights*/
+       ATTRIBUTE_VEC4_JOINTS,                          /**< Attribute for skeletal joints*/
+
        ATTRIBUTE_LOCATION_MAX                          /**< Maximum of attribute location */
 };
 
@@ -88,6 +94,8 @@ enum UniformLocation
        UNIFORM_MAT4_MODEL_VIEW,                        /**< Uniform for model view matrix */
        UNIFORM_MAT4_INV_MODEL_VIEW,            /**< Uniform for inverted model view */
 
+       UNIFORM_MAT4_ARRAY_JOINTSMATRICES,      /**< Uniform for joints matrices */
+
        UNIFORM_VEC4_MATERIAL_AMBIENT,          /**< Uniform for material ambient */
        UNIFORM_VEC4_MATERIAL_DIFFUSE,          /**< Uniform for material diffuse */
        UNIFORM_VEC4_MATERIAL_SPECULAR,         /**< Uniform for material specular */
index 2b6f411..08192f7 100644 (file)
@@ -328,6 +328,7 @@ void
 _GlContext::InitGL(void)
 {
        PrepareDefaultShaders();
+       PrepareDefaultWithSkinningShaders();
 
        glDisable(GL_BLEND);
        glDisable(GL_STENCIL_TEST);
@@ -661,6 +662,15 @@ _GlContext::GetShaderProgramInfo(_ShaderProgramImpl* pShaderProgram)
        pShaderProgram->__attributeLocation[ATTRIBUTE_VEC2_TEXTURE_COORD] = glGetAttribLocation(pShaderProgram->__program, texCoordName.c_str());
        pShaderProgram->__attributeLocation[ATTRIBUTE_VEC4_COLOR] = glGetAttribLocation(pShaderProgram->__program, colorName.c_str());
        pShaderProgram->__attributeLocation[ATTRIBUTE_VEC3_NORMAL] = glGetAttribLocation(pShaderProgram->__program, normalName.c_str());
+
+       std::wstring weightsNameW(VeAttrWeights);
+       std::string weightsName(weightsNameW.begin(), weightsNameW.end());
+
+       std::wstring jointsNameW(VeAttrJoints);
+       std::string jointsName(jointsNameW.begin(), jointsNameW.end());
+
+       pShaderProgram->__attributeLocation[ATTRIBUTE_VEC4_WEIGHTS] = glGetAttribLocation(pShaderProgram->__program, weightsName.c_str());
+       pShaderProgram->__attributeLocation[ATTRIBUTE_VEC4_JOINTS] = glGetAttribLocation(pShaderProgram->__program, jointsName.c_str());
 }
 
 void
@@ -1143,4 +1153,317 @@ _GlContext::PrepareDefaultShaders(void)
        __pLightShader->Construct(vertexLight, fragmentLight);
 }
 
+void
+_GlContext::PrepareDefaultWithSkinningShaders(void)
+{
+       static const char strVertexShader_uniform_color[] =
+                       "uniform mat4 u_mvp;\n"
+                       "attribute vec4 a_position;\n"
+
+                       "attribute vec4 a_weights;\n"
+                       "attribute vec4 a_joints_ids;\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"
+                       "       gl_Position = u_mvp * GetPos(a_position);\n"
+                       "}\n";
+       static const char strFragmentShader_uniform_color[] =
+                       "precision mediump float;\n"
+                       "uniform vec4 u_color;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor = u_color;\n"
+                       "}\n";
+
+       static const char strVertexShader_color[] =
+                       "uniform mat4 u_mvp;\n"
+                       "attribute vec4 a_position;\n"
+                       "attribute vec4 a_color;\n"
+                       "varying vec4 v_color;\n"
+
+                       "attribute vec4 a_weights;\n"
+                       "attribute vec4 a_joints_ids;\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_color = a_color;\n"
+                       "       gl_Position = u_mvp * GetPos(a_position);\n"
+                       "}\n";
+       static const char strFragmentShader_color[] =
+                       "precision mediump float;\n"
+                       "varying vec4 v_color;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor = v_color;\n"
+                       "}\n";
+
+       static const char strVertexShader_texture[] =
+                       "uniform mat4 u_mvp;\n"
+                       "attribute vec4 a_position;\n"
+                       "attribute vec4 a_texcoord;\n"
+                       "varying vec2 v_texcoord;\n"
+
+                       "attribute vec4 a_weights;\n"
+                       "attribute vec4 a_joints_ids;\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.xy;\n"
+                       "       gl_Position = u_mvp * GetPos(a_position);\n"
+                       "}\n";
+       static const char strFragmentShader_texture[] =
+                       "precision highp float;\n"
+                       "uniform sampler2D u_tex2d;\n"
+                       "uniform float u_opacity;\n"
+                       "varying vec2 v_texcoord;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor.rgba = texture2D(u_tex2d, v_texcoord).bgra;\n"
+                       "}\n";
+
+       static const char strFragmentShader_texture_bgra[] =
+                       "precision highp float;\n"
+                       "uniform sampler2D u_tex2d;\n"
+                       "uniform float u_opacity;\n"
+                       "varying vec2 v_texcoord;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor = texture2D(u_tex2d, v_texcoord);\n"
+                       "}\n";
+
+       static const char strFragmentShader_texture_opacity[] =
+                       "precision highp float;\n"
+                       "uniform sampler2D u_tex2d;\n"
+                       "uniform float u_opacity;\n"
+                       "varying vec2 v_texcoord;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor.rgba = (texture2D(u_tex2d, v_texcoord) * u_opacity).bgra;\n"
+                       "}\n";
+       static const char strFragmentShader_texture_opacity_bgra[] =
+                       "precision highp float;\n"
+                       "uniform sampler2D u_tex2d;\n"
+                       "uniform float u_opacity;\n"
+                       "varying vec2 v_texcoord;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor = texture2D(u_tex2d, v_texcoord) * u_opacity;\n"
+                       "}\n";
+
+       static const char strVertexShader_light[] =
+                       "struct light\n"
+                       "{\n"
+                       "       int type;\n"
+                       "       vec4 ambient;\n"
+                       "       vec4 diffuse;\n"
+                       "       vec4 specular;\n"
+                       "       vec4 position;\n"
+                       "       vec3 direction;\n"
+                       "       float exponent;\n"
+                       "       float cutoff;\n"
+                       "       vec3 attenuation;\n"
+                       "};\n"
+                       "struct material\n"
+                       "{\n"
+                       "       vec4 ambient;\n"
+                       "       vec4 diffuse;\n"
+                       "       vec4 specular;\n"
+                       "       vec4 emissive;\n"
+                       "       float shininess;\n"
+                       "};\n"
+                       "\n"
+                       "const float c_zero = 0.0;\n"
+                       "const float c_one = 1.0;\n"
+                       "const int indx_zero = 0;\n"
+                       "const int indx_one = 1;\n"
+                       "\n"
+                       "uniform mat4 u_mvp;\n"
+                       "uniform mat4 u_modelview;\n"
+                       "//uniform mat3 u_inv_modelview;\n"
+                       "uniform mat4 u_inv_modelview;\n"
+                       "\n"
+                       "uniform material u_material;\n"
+                       "uniform light u_light;\n"
+                       "\n"
+                       "attribute vec4 a_position;\n"
+                       "attribute vec4 a_texcoord;\n"
+                       "attribute vec4 a_color;\n"
+                       "attribute vec3 a_normal;\n"
+                       "\n"
+                       "varying vec2 v_texcoord;\n"
+                       "varying vec4 v_color;\n"
+                       "\n"
+                       "vec4\n"
+                       "do_lighting()\n"
+                       "{\n"
+                       "       vec3 lightdir, n, h;\n"
+                       "       vec4 color = vec4(c_zero, c_zero, c_zero, c_zero);\n"
+                       "       float ndotl, ndoth, attenuation;\n"
+                       "\n"
+                       "       n = normalize((u_inv_modelview * vec4(a_normal, 1.0)).xyz);\n"
+                       "\n"
+                       "       if (u_light.type < 2)\n"
+                       "       {\n"
+                       "               vec3 distance;\n"
+                       "               float spot_factor;\n"
+                       "\n"
+                       "               // point or spot case\n"
+                       "               lightdir = u_light.position.xyz - (u_modelview * a_position).xyz;\n"
+                       "\n"
+                       "               // compute distance attenuation\n"
+                       "               distance.x = c_one;\n"
+                       "               distance.z = dot(lightdir, lightdir);\n"
+                       "               distance.y = sqrt(distance.z);\n"
+                       "\n"
+                       "               attenuation = c_one / dot(distance, u_light.attenuation);"
+                       "\n"
+                       "               lightdir = normalize(lightdir);\n"
+                       "\n"
+                       "               if (u_light.cutoff < 180.0)\n"
+                       "               {\n"
+                       "                       // compute spot factor\n"
+                       "                       spot_factor = dot(-lightdir, normalize(u_light.direction));\n"
+                       "\n"
+                       "                       if (spot_factor >= cos(radians(u_light.cutoff)))\n"
+                       "                               spot_factor = pow(spot_factor, u_light.exponent);\n"
+                       "                       else\n"
+                       "                               spot_factor = c_zero;\n"
+                       "\n"
+                       "                       attenuation *= spot_factor;\n"
+                       "               }\n"
+                       "       }\n"
+                       "       else\n"
+                       "       {\n"
+                       "               // directional light\n"
+                       "               lightdir = normalize(u_light.position.xyz);\n"
+                       "               attenuation = c_one;\n"
+                       "       }\n"
+                       "\n"
+                       "       if (attenuation > c_zero)\n"
+                       "       {\n"
+                       "               color = u_light.ambient * u_material.ambient;\n"
+                       "\n"
+                       "               ndotl = max(c_zero, dot(n, lightdir));\n"
+                       "               color += ndotl * u_light.diffuse * u_material.diffuse;\n"
+                       "\n"
+                       "               h = normalize(lightdir + vec3(c_zero, c_zero, c_one));\n"
+                       "               ndoth = dot(n, h);\n"
+                       "\n"
+                       "               if (ndoth > c_zero)\n"
+                       "               {\n"
+                       "                       color += pow(ndoth, u_material.shininess) * u_material.specular * u_light.specular;\n"
+                       "               }\n"
+                       "\n"
+                       "               color *= attenuation;\n"
+                       "       }\n"
+                       "\n"
+                       "       color += u_material.emissive;\n"
+                       "//     color += u_material.emissive + u_material.ambient * u_scene_ambient; //todo\n"
+                       "\n"
+                       "       color.a = u_material.diffuse.a;\n"
+                       "\n"
+                       "       return color;\n"
+                       "}\n"
+                       "\n"
+
+                       "attribute vec4 a_weights;\n"
+                       "attribute vec4 a_joints_ids;\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\n"
+                       "main()\n"
+                       "{\n"
+                       "       v_color = do_lighting();\n"
+                       "       v_texcoord = a_texcoord.xy;\n"
+                       "       gl_Position = u_mvp * GetPos(a_position);\n"
+                       "}\n";
+       static const char strFragmentShader_light[] =
+                       "precision highp float;\n"
+                       "uniform sampler2D u_tex2d;\n"
+                       "varying vec2 v_texcoord;\n"
+                       "varying vec4 v_color;\n"
+                       "void main()\n"
+                       "{\n"
+                       "       gl_FragColor.rgba = texture2D(u_tex2d, v_texcoord).bgra * v_color;\n"
+                       "}\n";
+
+       Shader vertexColor, fragmentColor;
+       Shader vertexUniformColor, fragmentUniformColor;
+       Shader vertexTexture, fragmentTexture, fragmentOpacityTexture;
+       Shader vertexLight, fragmentLight;
+
+       __pColorShaderWithSkinning = new (std::nothrow) ShaderProgram;
+       __pUniformColorShaderWithSkinning = new (std::nothrow) ShaderProgram;
+       __pTextureShaderWithSkinning = new (std::nothrow) ShaderProgram;
+       __pTextureOpacityShaderWithSkinning = new (std::nothrow) ShaderProgram;
+       __pLightShaderWithSkinning = new (std::nothrow) ShaderProgram;
+
+       // for color
+       vertexColor.Construct(Shader::SHADER_VERTEX, strVertexShader_color);
+       fragmentColor.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_color);
+
+       __pColorShaderWithSkinning->Construct(vertexColor, fragmentColor);
+
+       vertexUniformColor.Construct(Shader::SHADER_VERTEX, strVertexShader_uniform_color);
+       fragmentUniformColor.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_uniform_color);
+
+       __pUniformColorShaderWithSkinning->Construct(vertexUniformColor, fragmentUniformColor);
+
+       // for texture
+       if (IsSupportedBGRA())
+       {
+               vertexTexture.Construct(Shader::SHADER_VERTEX, strVertexShader_texture);
+               fragmentTexture.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_texture_bgra);
+
+               fragmentOpacityTexture.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_texture_opacity_bgra);
+       }
+       else
+       {
+               vertexTexture.Construct(Shader::SHADER_VERTEX, strVertexShader_texture);
+               fragmentTexture.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_texture);
+
+               fragmentOpacityTexture.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_texture_opacity);
+       }
+
+       __pTextureShaderWithSkinning->Construct(vertexTexture, fragmentTexture);
+       __pTextureOpacityShaderWithSkinning->Construct(vertexTexture, fragmentOpacityTexture);
+
+       vertexLight.Construct(Shader::SHADER_VERTEX, strVertexShader_light);
+       fragmentLight.Construct(Shader::SHADER_FRAGMENT, strFragmentShader_light);
+
+       __pLightShaderWithSkinning->Construct(vertexLight, fragmentLight);
+}
+
 }}}            // Tizen::Ui::Animations
index f2b8ba3..2722da5 100644 (file)
@@ -1,3 +1,27 @@
+//
+// 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.
+//
+
+/**
+ * @file       FUiAnim_MeshImpl.h
+ * @brief      This is the header file for the _MeshImpl class.
+ *
+ * This header file contains the declarations of the _MeshImpl class.
+ */
+
 #ifndef _FUI_ANIM_MESH_IMPL_H_
 #define _FUI_ANIM_MESH_IMPL_H_
 
@@ -15,7 +39,7 @@
 #include <string>
 #include <algorithm>
 
-#include "FUiAnim_MeshController.h"
+#include "FUiAnim_MeshControllerImpl.h"
 #include "FUiAnimMeshController.h"
 
 namespace Tizen { namespace Ui { namespace Animations {
@@ -27,7 +51,7 @@ namespace Tizen { namespace Ui { namespace Animations {
 #define APPROPRIATE_COUNT_TEXTCOORDINATES 2
 
 class _Mutex;
-class VisualElement;
+class _JointImpl;
 class _DynamicKeyString;
 
 EXTERN_DYNAMIC_PROPERTY(L"count",                                                      MeshPropName                                                    , 1)    //String
@@ -42,7 +66,6 @@ EXTERN_DYNAMIC_PROPERTY(L"index.#index",                                      MeshPropVertexIndex                                             , 7)    //int
 //EXTERN_DYNAMIC_PROPERTY(L"bone.index.#index",                                MeshPropBoneIndex                                               , 10)   //int
 //EXTERN_DYNAMIC_PROPERTY(L"bone.weight.#index",                       MeshPropBoneWeight                                              , 11)   //float
 
-
 class _OSP_EXPORT_ _MeshImpl
        : public RefObject
 {
@@ -70,9 +93,9 @@ public:
        int GetIndex(int arrayIndex) const;
 
        result SetGeometryType(Mesh::GeometryType type);
-       Mesh::GeometryType GetGeometryType() const;
+       Mesh::GeometryType GetGeometryType(void) const;
 
-       void Clear();
+       void Clear(void);
 
        result AdjustBoundingVolume(bool rebuild);
        BoundingVolume& GetBoundingVolume();
@@ -85,43 +108,43 @@ public:
        result AllocVertices(int count);
        result AllocIndices(int count);
 
-    int GetCountOfAllocatedVertices() const
+    int GetCountOfAllocatedVertices(void) const
     {
         return __countOfAllocatedVertex;
     }
 
-    int GetCountOfVertices() const
+    int GetCountOfVertices(void) const
     {
         return __countOfVertex;
     }
 
-    int GetCountOfAllocatedIndices() const
+    int GetCountOfAllocatedIndices(void) const
     {
         return __countOfAllocatedIndex;
     }
 
-    int GetCountOfIndices() const
+    int GetCountOfIndices(void) const
     {
         return __countOfIndex;
     }
 
-    bool IsVerticesEnabled() const
+    bool IsVerticesEnabled(void) const
     {
        return (__pVertices)?true:false;
     }
-       bool IsIndexEnabled() const
+       bool IsIndexEnabled(void) const
        {
                return (__pIndices)?true:false;
        }
-       bool IsTextureCoordinateEnabled() const
+       bool IsTextureCoordinateEnabled(void) const
        {
                return (__pTexCoordinates)?true:false;
        }
-       bool IsColorEnabled() const
+       bool IsColorEnabled(void) const
        {
                return (__pColors)?true:false;
        }
-       bool IsNormalEnabled() const
+       bool IsNormalEnabled(void) const
        {
                return (__pNormals)?true:false;
        }
@@ -133,7 +156,7 @@ public:
                __name = name;
        }
 
-       std::string GetName()
+       std::string GetName(void)
        {
                return __name;
        }
@@ -144,17 +167,17 @@ public:
 
        result SaveMeshToBin(const Tizen::Base::String& fileName);
 
-       MeshController* CreateMeshController(VisualElement* pRootJoint, const Tizen::Graphics::FloatMatrix4& bindShapeMatrix);
+       MeshController* CreateMeshController(_JointImpl* pRootJoint, const Tizen::Graphics::FloatMatrix4& bindShapeMatrix);
 
        _MeshControllerImpl* GetMeshControllerImpl(void);
 
 protected:
-       virtual ~_MeshImpl();
+       virtual ~_MeshImpl(void);
        //result GatherBoundingPosition(const Tizen::Graphics::FloatPoint3& pt);
 private:
-    result AllocTextureCoordinates();
-    result AllocNormals();
-    result AllocColors();
+    result AllocTextureCoordinates(void);
+    result AllocNormals(void);
+    result AllocColors(void);
 
 private:
     _Mutex* __pLock;
index e2065db..5769213 100644 (file)
@@ -37,7 +37,7 @@
 #include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
 #include "library-geometries/FUiAnim_ImportColladaLibGeomGeometryMesh.h"
 
-#include "FUiAnim_MeshController.h"
+#include "FUiAnim_MeshControllerImpl.h"
 #include "FUiAnimMeshController.h"
 
 namespace Tizen { namespace Ui { namespace Animations {
@@ -48,7 +48,6 @@ class _OSP_EXPORT_ _ModelImporterImpl
        : Tizen::Base::Object
 {
 public:
-
        _ModelImporterImpl(const std::string& fileName, bool visualScenes, bool geometries, bool controllers, bool anmations, bool materials, bool effects, bool images, bool lights, bool cameras);
        virtual ~_ModelImporterImpl(void);
 
@@ -72,10 +71,9 @@ private:
 
        void WalkingTheTree(_ImportCollada::LibraryVisualScenes::Node* pRootNode, _ImportCollada::LibraryVisualScenes::Node* pNode, Scene* pScene);
 
-       VisualElement* CreateJoint(_ImportCollada::LibraryVisualScenes::Node& pNode);
-       VisualElement* GetSkeleton(_ImportCollada::LibraryVisualScenes::Node* pRootNode, std::list<std::string>& jointNames);
+       _JointImpl* GetSkeleton(_ImportCollada::LibraryVisualScenes::Node* pRootNode, std::list<std::string>& jointNames);
 
-       Tizen::Ui::Animations::VisualElementPropertyAnimation* GetAnimationFor(_ImportCollada::LibraryVisualScenes::Node* pNode);
+       result CreateAnimation(_ImportCollada::LibraryVisualScenes::Node* pNode, _JointImpl* pJoint);
 private:
        _ImportCollada::ColladaAssets* colladaAssets;
 };