From 62d283b45652e139c7237cca927ed20e9ec361bb Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 24 May 2023 14:25:45 +0900 Subject: [PATCH] [NUI.Avatar] Introduce NUI.Avatar repository Signed-off-by: Eunki, Hong --- .../Properties/AssemblyInfo.cs | 4 + src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.csproj | 14 + src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.sln | 85 ++ .../AREmojiDefaultBlendShapeNameMapper.cs | 106 +++ .../Common/AREmojiDefaultJointNameMapper.cs | 85 ++ .../src/public/Common/AvatarEnums.cs | 763 ++++++++++++++++++ .../public/Common/AvatarPropertyNameMapper.cs | 169 ++++ .../src/public/Controls/Avatar.cs | 80 ++ .../src/public/Controls/AvatarView.cs | 128 +++ .../MotionIndex/AvatarBlendShapeIndex.cs | 167 ++++ .../MotionIndex/AvatarJointTransformIndex.cs | 170 ++++ 11 files changed, 1771 insertions(+) create mode 100755 src/Tizen.NUI.Avatar/Properties/AssemblyInfo.cs create mode 100755 src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.csproj create mode 100755 src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.sln create mode 100644 src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultBlendShapeNameMapper.cs create mode 100644 src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultJointNameMapper.cs create mode 100755 src/Tizen.NUI.Avatar/src/public/Common/AvatarEnums.cs create mode 100755 src/Tizen.NUI.Avatar/src/public/Common/AvatarPropertyNameMapper.cs create mode 100755 src/Tizen.NUI.Avatar/src/public/Controls/Avatar.cs create mode 100755 src/Tizen.NUI.Avatar/src/public/Controls/AvatarView.cs create mode 100644 src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarBlendShapeIndex.cs create mode 100644 src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarJointTransformIndex.cs diff --git a/src/Tizen.NUI.Avatar/Properties/AssemblyInfo.cs b/src/Tizen.NUI.Avatar/Properties/AssemblyInfo.cs new file mode 100755 index 00000000000..37e3f1f4a91 --- /dev/null +++ b/src/Tizen.NUI.Avatar/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using Tizen.NUI; + +// Xamarin.Forms.Loader.dll Xamarin.Forms.Xaml.XamlLoader.Load(object, string), kzu@microsoft.com +[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.Avatar")] \ No newline at end of file diff --git a/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.csproj b/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.csproj new file mode 100755 index 00000000000..89e2515f85c --- /dev/null +++ b/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + $(NoWarn);CS0618;CA1054;CA1056 + + + + + + + + + diff --git a/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.sln b/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.sln new file mode 100755 index 00000000000..0d87c5d8403 --- /dev/null +++ b/src/Tizen.NUI.Avatar/Tizen.NUI.Avatar.sln @@ -0,0 +1,85 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31515.178 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Avatar", "Tizen.NUI.Avatar.csproj", "{C6CEE887-775A-4623-8BF8-DCA18C363D63}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Scene3D", "..\Tizen.NUI.Scene3D\Tizen.NUI.Scene3D.csproj", "{F6CEE887-775A-4623-8BF8-DCA18C363D62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI", "..\Tizen.NUI\Tizen.NUI.csproj", "{F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{CE90CD24-82F7-45A3-96B2-2E3C97D25C30}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.SystemSettings", "..\Tizen.System.SystemSettings\Tizen.System.SystemSettings.csproj", "{D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{6D5FFD69-6DCC-4953-85E9-C23AC18B190E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\Tizen.System.Information\Tizen.System.Information.csproj", "{A951EAFE-D191-4F45-9AEF-7D97C382A747}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{E1E30AEC-AD46-4E53-B9B1-780A68B59963}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased", "..\Tizen.Applications.ComponentBased\Tizen.Applications.ComponentBased.csproj", "{70341AA2-1324-4215-9DB8-BFB13389D932}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ThemeManager", "..\Tizen.Applications.ThemeManager\Tizen.Applications.ThemeManager.csproj", "{F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Tracer", "..\Tizen.Tracer\Tizen.Tracer.csproj", "{6DABE78F-1816-4F2E-8966-F909173194C8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C6CEE887-775A-4623-8BF8-DCA18C363D63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6CEE887-775A-4623-8BF8-DCA18C363D63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6CEE887-775A-4623-8BF8-DCA18C363D63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6CEE887-775A-4623-8BF8-DCA18C363D63}.Release|Any CPU.Build.0 = Release|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Release|Any CPU.Build.0 = Release|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Release|Any CPU.Build.0 = Release|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Release|Any CPU.Build.0 = Release|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Release|Any CPU.Build.0 = Release|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Release|Any CPU.Build.0 = Release|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Release|Any CPU.Build.0 = Release|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Release|Any CPU.Build.0 = Release|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Release|Any CPU.Build.0 = Release|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Release|Any CPU.Build.0 = Release|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {83C85CFB-3AB8-403A-9F6D-CC2783C6C559} + EndGlobalSection +EndGlobal diff --git a/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultBlendShapeNameMapper.cs b/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultBlendShapeNameMapper.cs new file mode 100644 index 00000000000..df09f9ab705 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultBlendShapeNameMapper.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +namespace Tizen.NUI.Avatar +{ + internal class AREmojiDefaultBlendShapeNameMapper : AvatarPropertyNameMapper + { + public AREmojiDefaultBlendShapeNameMapper() : base() + { + customIndexCounter = (uint)arEmojiBlendShapeNameList.Count; + foreach (var indexNamePair in arEmojiBlendShapeNameList) + { + base.SetPropertyName((uint)indexNamePair.Item1, indexNamePair.Item2); + } + foreach (var customName in arEmojiCustomBlendShapeNameList) + { + // We can ensure that default name list is always unique + base.SetPropertyName(customIndexCounter++, customName); + } + } + + #region AR Emoji BlendShape name list + private static readonly List<(BlendShapeType, string)> arEmojiBlendShapeNameList = new() + { + (BlendShapeType.EyeBlinkLeft, "EyeBlink_Left"), + (BlendShapeType.EyeSquintLeft, "EyeSquint_Left"), + (BlendShapeType.EyeDownLeft, "EyeDown_Left"), + (BlendShapeType.EyeInLeft, "EyeIn_Left"), + (BlendShapeType.EyeOpenLeft, "EyeOpen_Left"), + (BlendShapeType.EyeOutLeft, "EyeOut_Left"), + (BlendShapeType.EyeUpLeft, "EyeUp_Left"), + + (BlendShapeType.EyeBlinkRight, "EyeBlink_Right"), + (BlendShapeType.EyeSquintRight, "EyeSquint_Right"), + (BlendShapeType.EyeDownRight, "EyeDown_Right"), + (BlendShapeType.EyeInRight, "EyeIn_Right"), + (BlendShapeType.EyeOpenRight, "EyeOpen_Right"), + (BlendShapeType.EyeOutRight, "EyeOut_Right"), + (BlendShapeType.EyeUpRight, "EyeUp_Right"), + + (BlendShapeType.JawForward, "JawFwd"), + (BlendShapeType.JawOpen, "JawOpen"), + (BlendShapeType.JawChew, "JawChew"), + (BlendShapeType.JawLeft, "JawLeft"), + (BlendShapeType.JawRight, "JawRight"), + + (BlendShapeType.MouthLeft, "MouthLeft"), + (BlendShapeType.MouthFrownLeft, "MouthFrown_Left"), + (BlendShapeType.MouthSmileLeft, "MouthSmile_Left"), + (BlendShapeType.MouthDimpleLeft, "MouthDimple_Left"), + + (BlendShapeType.MouthRight, "MouthRight"), + (BlendShapeType.MouthFrownRight, "MouthFrown_Right"), + (BlendShapeType.MouthSmileRight, "MouthSmile_Right"), + (BlendShapeType.MouthDimpleRight, "MouthDimple_Right"), + + (BlendShapeType.LipsStretchLeft, "LipsStretch_Left"), + (BlendShapeType.LipsStretchRight, "LipsStretch_Right"), + (BlendShapeType.LipsUpperClose, "LipsUpperClose"), + (BlendShapeType.LipsLowerClose, "LipsLowerClose"), + (BlendShapeType.LipsUpperUp, "LipsUpperUp"), + (BlendShapeType.LipsLowerDown, "LipsLowerDown"), + (BlendShapeType.LipsUpperOpen, "LipsUpperOpen"), + (BlendShapeType.LipsLowerOpen, "LipsLowerOpen"), + (BlendShapeType.LipsFunnel, "LipsFunnel"), + (BlendShapeType.LipsPucker, "LipsPucker"), + + (BlendShapeType.BrowDownLeft, "BrowsDown_Left"), + (BlendShapeType.BrowDownRight, "BrowsDown_Right"), + (BlendShapeType.BrowUpCenter, "BrowsUp_Center"), + (BlendShapeType.BrowUpLeft, "BrowsUp_Left"), + (BlendShapeType.BrowUpRight, "BrowsUp_Right"), + (BlendShapeType.CheekSquintLeft, "CheekSquint_Left"), + (BlendShapeType.CheekSquintRight, "CheekSquint_Right"), + (BlendShapeType.ChinLowerRaise, "ChinLowerRaise"), + (BlendShapeType.ChinUpperRaise, "ChinUpperRaise"), + + (BlendShapeType.TongueOut, "Tongue_Out"), + (BlendShapeType.TongueUp, "Tongue_Up"), + (BlendShapeType.TongueDown, "Tongue_Down"), + (BlendShapeType.TongueLeft, "Tongue_Left"), + (BlendShapeType.TongueRight, "Tongue_Right"), + + (BlendShapeType.Sneer, "Sneer"), + (BlendShapeType.Puff, "Puff"), + (BlendShapeType.PuffLeft, "Puff_Left"), + (BlendShapeType.PuffRight, "Puff_Right"), + }; + private static readonly List arEmojiCustomBlendShapeNameList = new List + { + "HAPPY_48", + "HAPPY_49", + "HAPPY_50", + "HAPPY_51", + "HAPPY_52", + "ANGRY_53", + "ANGRY_54", + "ANGRY_55", + "DISGUST_56", + "DISGUST_57", + "SAD_58", + "SURPRISE_59", + "SURPRISE_60", + }; + #endregion + + } +} \ No newline at end of file diff --git a/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultJointNameMapper.cs b/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultJointNameMapper.cs new file mode 100644 index 00000000000..05a0349fbf6 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/internal/Common/AREmojiDefaultJointNameMapper.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +namespace Tizen.NUI.Avatar +{ + internal class AREmojiDefaultJointNameMapper : AvatarPropertyNameMapper + { + public AREmojiDefaultJointNameMapper() : base() + { + customIndexCounter = (uint)arEmojiJointNameList.Count; + foreach (var indexNamePair in arEmojiJointNameList) + { + base.SetPropertyName((uint)indexNamePair.Item1, indexNamePair.Item2); + } + } + + #region AR Emoji Joint name list + private static readonly List<(JointType, string)> arEmojiJointNameList = new() + { + (JointType.Head, "head_JNT"), + (JointType.Neck, "neck_JNT"), + (JointType.EyeLeft, "l_eye_JNT"), + (JointType.EyeRight, "r_eye_JNT"), + + (JointType.ShoulderLeft, "l_arm_JNT"), + (JointType.ElbowLeft, "l_forearm_JNT"), + (JointType.WristLeft, "l_hand_JNT"), + + (JointType.ShoulderRight, "r_arm_JNT"), + (JointType.ElbowRight, "r_forearm_JNT"), + (JointType.WristRight, "r_hand_JNT"), + + (JointType.HipLeft, "l_upleg_JNT"), + (JointType.KneeLeft, "l_leg_JNT"), + (JointType.AnkleLeft, "l_foot_JNT"), + (JointType.ForeFootLeft, "l_toebase_JNT"), + + (JointType.HipRight, "r_upleg_JNT"), + (JointType.KneeRight, "r_leg_JNT"), + (JointType.AnkleRight, "r_foot_JNT"), + (JointType.ForeFootRight, "r_toebase_JNT"), + + (JointType.FingerThumb1Left, "l_handThumb1_JNT"), + (JointType.FingerThumb2Left, "l_handThumb2_JNT"), + (JointType.FingerThumb3Left, "l_handThumb3_JNT"), + (JointType.FingerThumb4Left, "l_handThumb4_JNT"), + (JointType.FingerIndex1Left, "l_handIndex1_JNT"), + (JointType.FingerIndex2Left, "l_handIndex2_JNT"), + (JointType.FingerIndex3Left, "l_handIndex3_JNT"), + (JointType.FingerIndex4Left, "l_handIndex4_JNT"), + (JointType.FingerMiddle1Left, "l_handMiddle1_JNT"), + (JointType.FingerMiddle2Left, "l_handMiddle2_JNT"), + (JointType.FingerMiddle3Left, "l_handMiddle3_JNT"), + (JointType.FingerMiddle4Left, "l_handMiddle4_JNT"), + (JointType.FingerRing1Left, "l_handRing1_JNT"), + (JointType.FingerRing2Left, "l_handRing2_JNT"), + (JointType.FingerRing3Left, "l_handRing3_JNT"), + (JointType.FingerRing4Left, "l_handRing4_JNT"), + (JointType.FingerPinky1Left, "l_handPinky1_JNT"), + (JointType.FingerPinky2Left, "l_handPinky2_JNT"), + (JointType.FingerPinky3Left, "l_handPinky3_JNT"), + (JointType.FingerPinky4Left, "l_handPinky4_JNT"), + + (JointType.FingerThumb1Right, "r_handThumb1_JNT"), + (JointType.FingerThumb2Right, "r_handThumb2_JNT"), + (JointType.FingerThumb3Right, "r_handThumb3_JNT"), + (JointType.FingerThumb4Right, "r_handThumb4_JNT"), + (JointType.FingerIndex1Right, "r_handIndex1_JNT"), + (JointType.FingerIndex2Right, "r_handIndex2_JNT"), + (JointType.FingerIndex3Right, "r_handIndex3_JNT"), + (JointType.FingerIndex4Right, "r_handIndex4_JNT"), + (JointType.FingerMiddle1Right, "r_handMiddle1_JNT"), + (JointType.FingerMiddle2Right, "r_handMiddle2_JNT"), + (JointType.FingerMiddle3Right, "r_handMiddle3_JNT"), + (JointType.FingerMiddle4Right, "r_handMiddle4_JNT"), + (JointType.FingerRing1Right, "r_handRing1_JNT"), + (JointType.FingerRing2Right, "r_handRing2_JNT"), + (JointType.FingerRing3Right, "r_handRing3_JNT"), + (JointType.FingerRing4Right, "r_handRing4_JNT"), + (JointType.FingerPinky1Right, "r_handPinky1_JNT"), + (JointType.FingerPinky2Right, "r_handPinky2_JNT"), + (JointType.FingerPinky3Right, "r_handPinky3_JNT"), + (JointType.FingerPinky4Right, "r_handPinky4_JNT"), + }; + #endregion + } +} \ No newline at end of file diff --git a/src/Tizen.NUI.Avatar/src/public/Common/AvatarEnums.cs b/src/Tizen.NUI.Avatar/src/public/Common/AvatarEnums.cs new file mode 100755 index 00000000000..eb617481aaa --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/Common/AvatarEnums.cs @@ -0,0 +1,763 @@ +/* + * Copyright(c) 2023 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. + * + */ + +using System; +using System.Runtime.InteropServices; +using System.ComponentModel; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// The type of predefined skeletal joint. We can customize each type name by "TODO_mapper" + /// TODO : Explain me + /// TODO : Need to check each joint exist in AR Emoji + /// Note : This is temperal name of joints. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum JointType + { + #region Head + /// + /// Head joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + Head = 0, + + /// + /// Neck joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + Neck, + + /// + /// EyeLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeLeft, + + /// + /// EyeRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeRight, + #endregion + + #region Left Upper Body + /// + /// ShoulderLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ShoulderLeft, + + /// + /// ElbowLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ElbowLeft, + + /// + /// WristLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + WristLeft, + #endregion + + #region Right Upper Body + /// + /// ShoulderRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ShoulderRight, + + /// + /// ElbowRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ElbowRight, + + /// + /// WristRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + WristRight, + #endregion + + #region Left Lower Body + /// + /// HipLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + HipLeft, + + /// + /// KneeLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + KneeLeft, + + /// + /// AnkleLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + AnkleLeft, + + /// + /// ForeFootLeft joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ForeFootLeft, + #endregion + + #region Right Lower Body + /// + /// HipRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + HipRight, + + /// + /// KneeRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + KneeRight, + + /// + /// AnkleRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + AnkleRight, + + /// + /// ForeFootRight joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ForeFootRight, + #endregion + + #region Left Hand Finger + /// + /// FingerThumb1Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb1Left, + + /// + /// FingerThumb2Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb2Left, + + /// + /// FingerThumb3Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb3Left, + + /// + /// FingerThumb4Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb4Left, + + /// + /// FingerIndex1Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex1Left, + + /// + /// FingerIndex2Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex2Left, + + /// + /// FingerIndex3Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex3Left, + + /// + /// FingerIndex4Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex4Left, + + /// + /// FingerMiddle1Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle1Left, + + /// + /// FingerMiddle2Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle2Left, + + /// + /// FingerMiddle3Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle3Left, + + /// + /// FingerMiddle4Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle4Left, + + /// + /// FingerRing1Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing1Left, + + /// + /// FingerRing2Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing2Left, + + /// + /// FingerRing3Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing3Left, + + /// + /// FingerRing4Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing4Left, + + /// + /// FingerPinky1Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky1Left, + + /// + /// FingerPinky2Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky2Left, + + /// + /// FingerPinky3Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky3Left, + + /// + /// FingerPinky4Left joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky4Left, + #endregion + + #region Right Hand Finger + /// + /// FingerThumb1Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb1Right, + + /// + /// FingerThumb2Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb2Right, + + /// + /// FingerThumb3Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb3Right, + + /// + /// FingerThumb4Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerThumb4Right, + + /// + /// FingerIndex1Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex1Right, + + /// + /// FingerIndex2Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex2Right, + + /// + /// FingerIndex3Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex3Right, + + /// + /// FingerIndex4Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerIndex4Right, + + /// + /// FingerMiddle1Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle1Right, + + /// + /// FingerMiddle2Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle2Right, + + /// + /// FingerMiddle3Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle3Right, + + /// + /// FingerMiddle4Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerMiddle4Right, + + /// + /// FingerRing1Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing1Right, + + /// + /// FingerRing2Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing2Right, + + /// + /// FingerRing3Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing3Right, + + /// + /// FingerRing4Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerRing4Right, + + /// + /// FingerPinky1Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky1Right, + + /// + /// FingerPinky2Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky2Right, + + /// + /// FingerPinky3Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky3Right, + + /// + /// FingerPinky4Right joint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + FingerPinky4Right, + #endregion + + /// + /// Max value of default joint. It will be used when we determine the motion index is default or custom. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + DefaultJointMax, + } + + /// + /// The type of predefined blendshape. We can customize each type name by "TODO_mapper" + /// TODO : Explain me + /// TODO : Need to check each joint exist in AR Emoji + /// Note : This is temperal name of joints. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum BlendShapeType + { + #region Left Eyes + /// + /// EyeBlinkLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeBlinkLeft = 0, + + /// + /// EyeSquintLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeSquintLeft, + + /// + /// EyeDownLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeDownLeft, + + /// + /// EyeInLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeInLeft, + + /// + /// EyeOpenLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeOpenLeft, + + /// + /// EyeOutLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeOutLeft, + + /// + /// EyeUpLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeUpLeft, + #endregion + + #region Right Eyes + /// + /// EyeBlinkRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeBlinkRight, + + /// + /// EyeSquintRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeSquintRight, + + /// + /// EyeDownRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeDownRight, + + /// + /// EyeInRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeInRight, + + /// + /// EyeOpenRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeOpenRight, + + /// + /// EyeOutRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeOutRight, + + /// + /// EyeUpRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + EyeUpRight, + #endregion + + #region Mouth and Jaw + /// + /// JawForward blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + JawForward, + + /// + /// JawOpen blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + JawOpen, + + /// + /// JawChew blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + JawChew, + + /// + /// JawLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + JawLeft, + + /// + /// JawRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + JawRight, + + /// + /// MouthLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthLeft, + + /// + /// MouthFrownLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthFrownLeft, + + /// + /// MouthSmileLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthSmileLeft, + + /// + /// MouthDimpleLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthDimpleLeft, + + /// + /// MouthRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthRight, + + /// + /// MouthFrownRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthFrownRight, + + /// + /// MouthSmileRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthSmileRight, + + /// + /// MouthDimpleRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + MouthDimpleRight, + #endregion + + #region Lips + /// + /// LipsStretchLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsStretchLeft, + + /// + /// LipsStretchRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsStretchRight, + + /// + /// LipsUpperClose blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsUpperClose, + + /// + /// LipsLowerClose blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsLowerClose, + + /// + /// LipsUpperUp blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsUpperUp, + + /// + /// LipsLowerDown blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsLowerDown, + + /// + /// LipsUpperOpen blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsUpperOpen, + + /// + /// LipsLowerOpen blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsLowerOpen, + + /// + /// LipsFunnel blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsFunnel, + + /// + /// LipsPucker blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + LipsPucker, + #endregion + + #region Eyebrows, Cheeks, and Chin + /// + /// BrowDownLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + BrowDownLeft, + + /// + /// BrowDownRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + BrowDownRight, + + /// + /// BrowUpCenter blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + BrowUpCenter, + + /// + /// BrowUpLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + BrowUpLeft, + + /// + /// BrowUpRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + BrowUpRight, + + /// + /// CheekSquintLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + CheekSquintLeft, + + /// + /// CheekSquintRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + CheekSquintRight, + + /// + /// ChinLowerRaise blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ChinLowerRaise, + + /// + /// ChinUpperRaise blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + ChinUpperRaise, + #endregion + + #region Tongue + /// + /// TongueOut blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TongueOut, + + /// + /// TongueUp blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TongueUp, + + /// + /// TongueDown blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TongueDown, + + /// + /// TongueLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TongueLeft, + + /// + /// TongueRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TongueRight, + #endregion + + #region ETC + /// + /// Sneer blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + Sneer, + + /// + /// Puff blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + Puff, + + /// + /// PuffLeft blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + PuffLeft, + + /// + /// PuffRight blendshape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + PuffRight, + #endregion + /// + /// Max value of default blendshape. It will be used when we determine the motion index is default or custom. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + DefaultBlendShapeMax, + } +} diff --git a/src/Tizen.NUI.Avatar/src/public/Common/AvatarPropertyNameMapper.cs b/src/Tizen.NUI.Avatar/src/public/Common/AvatarPropertyNameMapper.cs new file mode 100755 index 00000000000..1208f9d0468 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/Common/AvatarPropertyNameMapper.cs @@ -0,0 +1,169 @@ +using System.Collections.Generic; +/* + * Copyright(c) 2023 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. + * + */ + +using System; +using System.Runtime.InteropServices; +using System.ComponentModel; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// TODO : Explain more detail + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AvatarPropertyNameMapper + { + /// + /// Create an initialized AvatarPropertyNameMapper. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarPropertyNameMapper() + { + mapper = new Dictionary(); + customIndexCounter = 0u; + } + + /// + /// Copy constructor. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarPropertyNameMapper(AvatarPropertyNameMapper rhs) + { + if (rhs != null) + { + mapper = new Dictionary(rhs.Mapper); + customIndexCounter = rhs.customIndexCounter; + } + else + { + mapper = new Dictionary(); + customIndexCounter = 0u; + } + } + + /// + /// Get current mapper information. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Dictionary Mapper + { + get + { + return mapper; + } + } + + /// + /// TODO : Explain me. + /// + /// The index of property what we want to set + /// The index of property, or uint.MaxValue if not exist + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public string this[uint index] + { + set + { + SetPropertyName(index, value); + } + get + { + return GetPropertyName(index); + } + } + + /// + /// TODO : Explain me. + /// + /// The name of custom property + /// The index of property matched with name. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public uint RegisterCustomProperty(string name) + { + uint ret = GetPropertyIndexByName(name); + if (ret >= customIndexCounter) + { + ret = customIndexCounter++; + SetPropertyName(ret, name); + } + return ret; + } + + /// + /// TODO : Explain me. + /// + /// The name of property what we want to get index + /// The index of property, or uint.MaxValue if not exist + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetPropertyIndexByName(string name) + { + // TODO : Do this without iteration + foreach (var pair in mapper) + { + if (pair.Value == name) + { + return pair.Key; + } + } + return uint.MaxValue; + } + + /// + /// Mapper between index and property name + /// + internal Dictionary mapper = null; + + /// + /// The counter of index. It will be increased one when we register custom index. + /// + internal uint customIndexCounter = 0; + + /// + /// TODO : Explain me. + /// + /// The index of property what we want to set + /// The name of property what we want to set + /// + /// New property will be added if we use index that not exist in mapper. + /// + internal void SetPropertyName(uint index, string name) + { + mapper.TryAdd(index, name); + } + + /// + /// TODO : Explain me. + /// + /// The index of property what we want to set + /// The name of property, or null if not exist + internal string GetPropertyName(uint index) + { + string ret = null; + mapper.TryGetValue(index, out ret); + return ret; + } + } +} diff --git a/src/Tizen.NUI.Avatar/src/public/Controls/Avatar.cs b/src/Tizen.NUI.Avatar/src/public/Controls/Avatar.cs new file mode 100755 index 00000000000..aadacf626f1 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/Controls/Avatar.cs @@ -0,0 +1,80 @@ +/* + * Copyright(c) 2023 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. + * + */ + +using System; +using System.Runtime.InteropServices; +using System.ComponentModel; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// Avatar is a Class to show 3D avatar objects. + /// It is subclass of Model s.t. we can control Avatar like models animation easly. + /// For example, + /// + /// Avatar supports AR Emoji. + /// TODO : Explain more detail + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Avatar : Model + { + /// + /// Create an initialized AvatarModel. + /// + /// avatar model file url.(e.g. glTF, and DLI). + /// The url to derectory containing resources: binary, image etc. + /// + /// If resourceDirectoryUrl is empty, the parent directory url of avatarModelUrl is used for resource url. + /// + /// http://tizen.org/privilege/mediastorage for local files in media storage. + /// http://tizen.org/privilege/externalstorage for local files in external storage. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Avatar(string avatarModelUrl, string resourceDirectoryUrl = "") : base(avatarModelUrl, resourceDirectoryUrl) + { + } + + /// + /// Create an initialized AvatarModel. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Avatar() : base() + { + } + + /// + /// Copy constructor. + /// + /// Source object to copy. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Avatar(Avatar avatarModel) : base(avatarModel) + { + } + + private static readonly AREmojiDefaultJointNameMapper defaultJointNameMapper = new(); + private static readonly AREmojiDefaultBlendShapeNameMapper defaultBlendShapeNameMapper = new(); + + internal AvatarPropertyNameMapper JointMapper { get; set; } = new AvatarPropertyNameMapper(defaultJointNameMapper); + internal AvatarPropertyNameMapper BlendShapeMapper { get; set; } = new AvatarPropertyNameMapper(defaultBlendShapeNameMapper); + } +} diff --git a/src/Tizen.NUI.Avatar/src/public/Controls/AvatarView.cs b/src/Tizen.NUI.Avatar/src/public/Controls/AvatarView.cs new file mode 100755 index 00000000000..c203aef4c7c --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/Controls/AvatarView.cs @@ -0,0 +1,128 @@ +/* + * Copyright(c) 2022 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. + * + */ + +using System; +using System.Runtime.InteropServices; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// AvatarView + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AvatarView : View + { + /// + /// Create an initialized AvatarView. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarView() : base() + { + } + + /// + /// Create an initialized AvatarView. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public string ResourceUrl + { + get + { + return InternalResourceUrl; + } + set + { + InternalResourceUrl = value; + } + } + + internal string InternalResourceUrl + { + get + { + return resourceUrl; + } + set + { + resourceUrl = value; + if (string.IsNullOrEmpty(resourceUrl)) + { + rootSceneView?.Dispose(); + rootAvatar?.Dispose(); + rootSceneView = null; + } + else + { + if (rootSceneView == null) + { + rootSceneView = new SceneView() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + UseFramebuffer = true, + FramebufferMultiSamplingLevel = 4, + }; + this.Add(rootSceneView); + } + rootAvatar = new Avatar(resourceUrl) + { + Size = new Size(3.0f, 3.0f, 3.0f), + }; + rootSceneView.Add(rootAvatar); + } + } + } + + /// + /// you can override it to clean-up your own resources. + /// + /// DisposeTypes + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + rootSceneView?.Dispose(); + rootAvatar?.Dispose(); + resourceUrl = null; + } + + base.Dispose(type); + } + + private string resourceUrl; + private SceneView rootSceneView; + private Avatar rootAvatar; + } +} diff --git a/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarBlendShapeIndex.cs b/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarBlendShapeIndex.cs new file mode 100644 index 00000000000..32fa6adce10 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarBlendShapeIndex.cs @@ -0,0 +1,167 @@ +/* + * Copyright(c) 2023 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. + * + */ + +using System; +using System.ComponentModel; +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// Specialized to control avatar joint transform. + /// + /// + /// + /// AvatarJointTransformIndex position = new AvatarJointTransformIndex(avatar.JointMapper, JointType.Head, MotionTransformIndex.TransformTypes.Position); + /// + /// // We can change the property later. + /// AvatarJointTransformIndex orientation = new AvatarJointTransformIndex(avatar.JointMapper); + /// orientation.AvatarJointType = JointType.Neck; + /// orientation.TransformType = MotionTransformIndex.TransformTypes.Orientation; + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AVatarBlendShapeIndex : BlendShapeIndex + { + /// + /// Create an initialized avatar blend shape index. + /// + /// Name mapper for this index + [EditorBrowsable(EditorBrowsableState.Never)] + public AVatarBlendShapeIndex(AvatarPropertyNameMapper mapper) : base() + { + nameMapper = mapper; + } + + /// + /// Create an initialized avatar blend shape index with input blend shape ID. + /// + /// Name mapper for this index + /// Blend shape ID for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AVatarBlendShapeIndex(AvatarPropertyNameMapper mapper, PropertyKey blendShapeId) : base(new PropertyKey(GetPropertyNameFromMapper(mapper, blendShapeId))) + { + nameMapper = mapper; + } + + /// + /// Create an initialized avatar blend shape index with blend shape type. + /// + /// Name mapper for this index + /// Type of blend shape for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AVatarBlendShapeIndex(AvatarPropertyNameMapper mapper, BlendShapeType blendShapeType) : this(mapper, (uint)blendShapeType) + { + } + + /// + /// Create an initialized avatar joint transform index with blend shape type. + /// + /// Name mapper for this index + /// Type of blend shape for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AVatarBlendShapeIndex(AvatarPropertyNameMapper mapper, uint blendShapeType) : base(new PropertyKey(GetPropertyNameFromMapper(mapper, blendShapeType))) + { + nameMapper = mapper; + this.blendShapeType = blendShapeType; + } + + /// + /// Get the name of given index. + /// + /// Name mapper for given index + /// Target ID what we want to get name + /// Name, or null if invalid + private static string GetPropertyNameFromMapper(AvatarPropertyNameMapper mapper, PropertyKey id) + { + if (id == null) + { + return ""; + } + if (id.Type == PropertyKey.KeyType.String) + { + return id.StringKey; + } + return mapper.GetPropertyName((uint)id.IndexKey); + } + + /// + /// Get the name of given JointType. + /// + /// Name mapper for given index + /// Type of joint what we want to get name + /// Name, or null if invalid + private static string GetPropertyNameFromMapper(AvatarPropertyNameMapper mapper, uint blendShapeType) + { + return mapper.GetPropertyName(blendShapeType) ?? ""; + } + + internal AvatarPropertyNameMapper nameMapper = null; + internal uint blendShapeType; + + /// + /// TODO : Explain me + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarPropertyNameMapper NameMapper + { + get + { + return nameMapper; + } + set + { + nameMapper = value; + if (nameMapper != null) + { + using PropertyKey blendShapeId = new(GetPropertyNameFromMapper(nameMapper, blendShapeType)); + base.BlendShapeId = blendShapeId; + } + } + } + + /// + /// Hijack property to control Avatar specified logic. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new PropertyKey BlendShapeId + { + get + { + return base.BlendShapeId; + } + set + { + if(value != null) + { + if (value.Type == PropertyKey.KeyType.Index) + { + blendShapeType = (uint)value.IndexKey; + } + using PropertyKey blendShapeId = new(GetPropertyNameFromMapper(nameMapper, value)); + base.BlendShapeId = blendShapeId; + } + else + { + base.BlendShapeId = value; + } + } + } + } +} diff --git a/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarJointTransformIndex.cs b/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarJointTransformIndex.cs new file mode 100644 index 00000000000..5c7ddd2d534 --- /dev/null +++ b/src/Tizen.NUI.Avatar/src/public/MotionIndex/AvatarJointTransformIndex.cs @@ -0,0 +1,170 @@ +/* + * Copyright(c) 2023 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. + * + */ + +using System; +using System.ComponentModel; +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Avatar +{ + /// + /// Specialized to control avatar joint transform. + /// + /// + /// + /// AvatarJointTransformIndex position = new AvatarJointTransformIndex(avatar.JointMapper, JointType.Head, MotionTransformIndex.TransformTypes.Position); + /// + /// // We can change the property later. + /// AvatarJointTransformIndex orientation = new AvatarJointTransformIndex(avatar.JointMapper); + /// orientation.AvatarJointType = JointType.Neck; + /// orientation.TransformType = MotionTransformIndex.TransformTypes.Orientation; + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AvatarJointTransformIndex : MotionTransformIndex + { + /// + /// Create an initialized avatar joint transform index. + /// + /// Name mapper for this index + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarJointTransformIndex(AvatarPropertyNameMapper mapper) : base() + { + nameMapper = mapper; + } + + /// + /// Create an initialized avatar joint transform index with input node id, and transform type. + /// + /// Name mapper for this index + /// Node ID for this motion index + /// Transform property type for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarJointTransformIndex(AvatarPropertyNameMapper mapper, PropertyKey modelNodeId, TransformTypes transformType) : base(new PropertyKey(GetPropertyNameFromMapper(mapper, modelNodeId)), transformType) + { + nameMapper = mapper; + } + + /// + /// Create an initialized avatar joint transform index with input node id, and transform type. + /// + /// Name mapper for this index + /// Type of joint for this motion index + /// Transform property type for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarJointTransformIndex(AvatarPropertyNameMapper mapper, JointType jointType, TransformTypes transformType) : this(mapper, (uint)jointType, transformType) + { + } + + /// + /// Create an initialized avatar joint transform index with input node id, and transform type. + /// + /// Name mapper for this index + /// Type of joint for this motion index + /// Transform property type for this motion index + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarJointTransformIndex(AvatarPropertyNameMapper mapper, uint jointType, TransformTypes transformType) : base(new PropertyKey(GetPropertyNameFromMapper(mapper, jointType)), transformType) + { + nameMapper = mapper; + this.jointType = jointType; + } + + /// + /// Get the name of given index. + /// + /// Name mapper for given index + /// Target ID what we want to get name + /// Name, or null if invalid + private static string GetPropertyNameFromMapper(AvatarPropertyNameMapper mapper, PropertyKey id) + { + if (id == null) + { + return ""; + } + if (id.Type == PropertyKey.KeyType.String) + { + return id.StringKey; + } + return mapper.GetPropertyName((uint)id.IndexKey); + } + + /// + /// Get the name of given JointType. + /// + /// Name mapper for given index + /// Type of joint what we want to get name + /// Name, or null if invalid + private static string GetPropertyNameFromMapper(AvatarPropertyNameMapper mapper, uint jointType) + { + return mapper.GetPropertyName(jointType) ?? ""; + } + + internal AvatarPropertyNameMapper nameMapper = null; + internal uint jointType; + + /// + /// TODO : Explain me + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public AvatarPropertyNameMapper NameMapper + { + get + { + return nameMapper; + } + set + { + nameMapper = value; + if (nameMapper != null) + { + using PropertyKey nodeId = new(GetPropertyNameFromMapper(nameMapper, jointType)); + base.ModelNodeId = nodeId; + } + } + } + + /// + /// Hijack property to control Avatar specified logic. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new PropertyKey ModelNodeId + { + get + { + return base.ModelNodeId; + } + set + { + if(value != null) + { + if (value.Type == PropertyKey.KeyType.Index) + { + jointType = (uint)value.IndexKey; + } + using PropertyKey nodeId = new(GetPropertyNameFromMapper(nameMapper, value)); + base.ModelNodeId = nodeId; + } + else + { + base.ModelNodeId = value; + } + } + } + } +}