示例#1
0
        /// <summary>
        /// Finds any scene objects that are mapped to bone transforms. Such object's transforms will be affected by
        /// skeleton bone animation.
        /// </summary>
        private void SetBoneMappings()
        {
            mappingInfo.Clear();

            SceneObjectMappingInfo rootMapping = new SceneObjectMappingInfo();

            rootMapping.sceneObject    = SceneObject;
            rootMapping.isMappedToBone = true;

            mappingInfo.Add(rootMapping);
            _native.MapCurveToSceneObject("", rootMapping.sceneObject);

            Bone[] childBones = FindChildBones();
            foreach (var entry in childBones)
            {
                AddBone(entry);
            }
        }
示例#2
0
        /// <summary>
        /// Registers a new bone component, creating a new transform mapping from the bone name to the scene object
        /// the component is attached to.
        /// </summary>
        /// <param name="bone">Bone component to register.</param>
        internal void AddBone(Bone bone)
        {
            if (_native == null)
            {
                return;
            }

            SceneObject currentSO = bone.SceneObject;

            SceneObjectMappingInfo newMapping = new SceneObjectMappingInfo();

            newMapping.sceneObject    = currentSO;
            newMapping.isMappedToBone = true;
            newMapping.bone           = bone;

            mappingInfo.Add(newMapping);
            _native.MapCurveToSceneObject(bone.Name, newMapping.sceneObject);
        }
示例#3
0
        /// <summary>
        /// Finds any curves that affect a transform of a specific scene object, and ensures that animation properly updates
        /// those transforms. This does not include curves referencing bones.
        /// </summary>
        private void UpdateSceneObjectMapping()
        {
            List <SceneObjectMappingInfo> newMappingInfos = new List <SceneObjectMappingInfo>();

            foreach (var entry in mappingInfo)
            {
                if (entry.isMappedToBone)
                {
                    newMappingInfos.Add(entry);
                }
                else
                {
                    _native.UnmapSceneObject(entry.sceneObject);
                }
            }

            if (primaryClip != null)
            {
                SceneObject root = SceneObject;

                Action <NamedVector3Curve[]> findMappings = x =>
                {
                    foreach (var curve in x)
                    {
                        if (curve.Flags.HasFlag(AnimationCurveFlags.ImportedCurve))
                        {
                            continue;
                        }

                        SceneObject currentSO = FindSceneObject(root, curve.Name);

                        bool found = false;
                        for (int i = 0; i < newMappingInfos.Count; i++)
                        {
                            if (newMappingInfos[i].sceneObject == currentSO)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            SceneObjectMappingInfo newMappingInfo = new SceneObjectMappingInfo();
                            newMappingInfo.isMappedToBone = false;
                            newMappingInfo.sceneObject    = currentSO;

                            newMappingInfos.Add(newMappingInfo);

                            _native.MapCurveToSceneObject(curve.Name, currentSO);
                        }
                    }
                };

                AnimationCurves curves = primaryClip.Curves;
                findMappings(curves.PositionCurves);
                findMappings(curves.RotationCurves);
                findMappings(curves.ScaleCurves);
            }

            mappingInfo = newMappingInfos;
        }
示例#4
0
        /// <summary>
        /// Registers a new bone component, creating a new transform mapping from the bone name to the scene object
        /// the component is attached to.
        /// </summary>
        /// <param name="bone">Bone component to register.</param>
        internal void AddBone(Bone bone)
        {
            switch (state)
            {
                case State.Active:
                    SceneObject currentSO = bone.SceneObject;

                    SceneObjectMappingInfo newMapping = new SceneObjectMappingInfo();
                    newMapping.sceneObject = currentSO;
                    newMapping.isMappedToBone = true;
                    newMapping.bone = bone;

                    mappingInfo.Add(newMapping);
                    _native.MapCurveToSceneObject(bone.Name, newMapping.sceneObject);
                    break;
            }
        }
示例#5
0
        /// <summary>
        /// Finds any curves that affect a transform of a specific scene object, and ensures that animation properly updates
        /// those transforms. This does not include curves referencing bones.
        /// </summary>
        private void UpdateSceneObjectMapping()
        {
            List<SceneObjectMappingInfo> newMappingInfos = new List<SceneObjectMappingInfo>();
            foreach(var entry in mappingInfo)
            {
                if (entry.isMappedToBone)
                    newMappingInfos.Add(entry);
                else
                    _native.UnmapSceneObject(entry.sceneObject);
            }

            if (primaryClip != null)
            {
                SceneObject root = SceneObject;

                Action<NamedVector3Curve[]> findMappings = x =>
                {
                    foreach (var curve in x)
                    {
                        if (curve.Flags.HasFlag(AnimationCurveFlags.ImportedCurve))
                            continue;

                        SceneObject currentSO = FindSceneObject(root, curve.Name);

                        bool found = false;
                        for (int i = 0; i < newMappingInfos.Count; i++)
                        {
                            if (newMappingInfos[i].sceneObject == currentSO)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            SceneObjectMappingInfo newMappingInfo = new SceneObjectMappingInfo();
                            newMappingInfo.isMappedToBone = false;
                            newMappingInfo.sceneObject = currentSO;

                            newMappingInfos.Add(newMappingInfo);

                            _native.MapCurveToSceneObject(curve.Name, currentSO);
                        }
                    }
                };

                AnimationCurves curves = primaryClip.Curves;
                findMappings(curves.PositionCurves);
                findMappings(curves.RotationCurves);
                findMappings(curves.ScaleCurves);
            }

            mappingInfo = newMappingInfos;
        }
示例#6
0
        /// <summary>
        /// Finds any scene objects that are mapped to bone transforms. Such object's transforms will be affected by
        /// skeleton bone animation.
        /// </summary>
        private void SetBoneMappings()
        {
            mappingInfo.Clear();

            SceneObjectMappingInfo rootMapping = new SceneObjectMappingInfo();
            rootMapping.sceneObject = SceneObject;
            rootMapping.isMappedToBone = true;

            mappingInfo.Add(rootMapping);
            _native.MapCurveToSceneObject("", rootMapping.sceneObject);

            Bone[] childBones = FindChildBones();
            foreach (var entry in childBones)
                AddBone(entry);
        }