コード例 #1
0
        void CreateBoneOverview(GameSkeleton skeleton)
        {
            var boneIndexsUsed = _meshNode.Geometry.GetUniqeBlendIndices();

            Bones.Clear();

            if (skeleton == null)
            {
                return;
            }

            for (int i = 0; i < skeleton.BoneCount; i++)
            {
                var parentBoneId = skeleton.GetParentBone(i);
                if (parentBoneId == -1)
                {
                    Bones.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i], boneIndexsUsed));
                }
                else
                {
                    var treeParent = GetParent(Bones, parentBoneId);

                    if (treeParent != null)
                    {
                        treeParent.Children.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i], boneIndexsUsed));
                    }
                }
            }

            Bones = FilterHelper.FilterBoneList("", true, Bones);
        }
コード例 #2
0
        void CreateBoneOverview(GameSkeleton skeleton)
        {
            SelectedBone = null;
            Bones.Clear();
            BoneCount = 0;

            if (skeleton == null)
            {
                return;
            }

            BoneCount = skeleton.BoneCount;
            for (int i = 0; i < skeleton.BoneCount; i++)
            {
                var parentBoneId = skeleton.GetParentBone(i);
                if (parentBoneId == -1)
                {
                    Bones.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i]));
                }
                else
                {
                    var treeParent = GetParent(Bones, parentBoneId);

                    if (treeParent != null)
                    {
                        treeParent.Children.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i]));
                    }
                }
            }
        }
コード例 #3
0
        protected virtual Serializer Deserialize(Serializer serializer)
        {
            Bones.Clear();
            PrimaryBoneID = "";

            List <XElement> subObjects = (from el
                                          in serializer.SerializedData.Elements("dataitem").Elements("object")
                                          select el).ToList();

            for (int i = 0; i < subObjects.Count; i++)
            {
                if ((Type.GetType((string)subObjects[i].Attribute("type")) != null) &&
                    (Type.GetType((string)subObjects[i].Attribute("type")).GetInterfaces().Contains(typeof(IBone))))
                {
                    ReinstateBone(subObjects[i]);
                }
            }

            WorldPosition = serializer.GetDataItem <Vector2>("world-position");
            Rotation      = serializer.GetDataItem <float>("rotation");
            Scale         = serializer.GetDataItem <float>("scale");
            Mirror        = serializer.GetDataItem <bool>("mirror");
            Tint          = serializer.GetDataItem <Color>("tint");
            RenderDepth   = serializer.GetDataItem <float>("render-depth");
            RenderLayer   = serializer.GetDataItem <int>("render-layer");
            Visible       = serializer.GetDataItem <bool>("visible");

            return(serializer);
        }
コード例 #4
0
 internal void RebuildSkeleton(Model3D model)
 {
     Bones.Clear();
     foreach (var boneName in BoneNames)
     {
         Bones.Add(model.Find <Node3D>(boneName));
     }
 }
コード例 #5
0
        private bool Get3DSettings()
        {
            bool getstatus = mProtocol.Get3Dsettings();

            if (getstatus)
            {
                mUpAxis = mProtocol.Settings3D.axisUpwards;

                Rotation.ECoordinateAxes xAxis, yAxis, zAxis;
                Rotation.GetCalibrationAxesOrder(mUpAxis, out xAxis, out yAxis, out zAxis);

                mCoordinateSystemChange = Rotation.GetAxesOrderRotation(xAxis, yAxis, zAxis);

                // Save marker settings
                mMarkers.Clear();
                foreach (Settings3DLabel marker in mProtocol.Settings3D.labels3D)
                {
                    LabeledMarker newMarker = new LabeledMarker();
                    newMarker.Label    = marker.Name;
                    newMarker.Position = Vector3.zero;
                    newMarker.Color.r  = (marker.ColorRGB) & 0xFF;
                    newMarker.Color.g  = (marker.ColorRGB >> 8) & 0xFF;
                    newMarker.Color.b  = (marker.ColorRGB >> 16) & 0xFF;

                    newMarker.Color /= 255;

                    newMarker.Color.a = 1F;

                    Markers.Add(newMarker);
                }

                // Save bone settings
                if (mProtocol.Settings3D.bones != null)
                {
                    Bones.Clear();

                    //Save bone settings
                    foreach (var settingsBone in mProtocol.Settings3D.bones)
                    {
                        Bone bone = new Bone();
                        bone.From       = settingsBone.from;
                        bone.FromMarker = GetMarker(settingsBone.from);
                        bone.To         = settingsBone.to;
                        bone.ToMarker   = GetMarker(settingsBone.to);
                        bone.Color.r    = (settingsBone.color) & 0xFF;
                        bone.Color.g    = (settingsBone.color >> 8) & 0xFF;
                        bone.Color.b    = (settingsBone.color >> 16) & 0xFF;
                        bone.Color     /= 255;
                        bone.Color.a    = 1F;
                        mBones.Add(bone);
                    }
                }

                return(true);
            }
            return(false);
        }
コード例 #6
0
        private void SetForLevelExitSequence()
        {
            _motionEngine.VerticalMovementIsEnabled = false;

            Bones.Clear();
            PrimaryBoneID = "";
            CreateBonesFromDataManager(Definitions.Avatar_Skeleton_Front);
            SkinBones(AvatarComponentManager.FrontFacingAvatarSkin(CustomSkinSlotIndex));

            AnimationEngine.Sequence = AnimationDataManager.Sequences["player-front-win"];
        }
コード例 #7
0
        private async Task LoadBonesLookupAsync()
        {
            Int64 startTicks = Log.VIEWMODEL("(DogDetailViewModel) Enter", Common.LOG_APPNAME);

            Bones.Clear();

            //ProgrammingLanguages.Add(new NullLookupItem());
            Bones.Add(new NullLookupItem {
                DisplayMember = " - "
            });

            var lookup = await _BoneLookupDataService
                         .GetBoneLookupAsync();

            foreach (var lookupItem in lookup)
            {
                Bones.Add(lookupItem);
            }

            Log.VIEWMODEL("(DogDetailViewModel) Exit", Common.LOG_APPNAME, startTicks);
        }
コード例 #8
0
        // private async void OpenDetailView(OpenDetailViewEventArgs args)
        // {
        // Int64 startTicks = Log.EVENT("(BoneDetailViewModel) Enter", Common.LOG_APPNAME);

        // await LoadAsync(args.Id);

        // Log.EVENT("(BoneDetailViewModel) Exit", Common.LOG_APPNAME, startTicks);
        // }

        #endregion

        #region Public Methods

        public override async Task LoadAsync(int id)
        {
            Int64 startTicks = Log.VIEWMODEL("(BoneDetailViewModel) Enter Id:({id})", Common.LOG_APPNAME);

            Id = id;

            foreach (var wrapper in Bones)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            Bones.Clear();

            var items = await _BoneDataService.AllAsync();

            foreach (var model in items)
            {
                var wrapper = new BoneWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                Bones.Add(wrapper);
            }

            Log.VIEWMODEL("(BoneDetailViewModel) Exit", Common.LOG_APPNAME, startTicks);
        }
コード例 #9
0
 internal virtual void Reset()
 {
     Bones.Clear();
     Grids.Clear();
 }
コード例 #10
0
 /// <summary>
 /// Clears all bones and dummy bones.
 /// </summary>
 public void Clear()
 {
     Bones.Clear();
     DummyBones.Clear();
 }
コード例 #11
0
ファイル: FSKA.cs プロジェクト: week9/Switch-Toolbox
        private void LoadAnimData(ResU.SkeletalAnim ska)
        {
            Nodes.Clear();
            Bones.Clear();

            CanLoop = ska.FlagsAnimSettings.HasFlag(ResU.SkeletalAnimFlags.Looping);

            foreach (ResU.BoneAnim bn in ska.BoneAnims)
            {
                BoneAnimNode bone = new BoneAnimNode(bn.Name, false);
                bone.BoneAnimU = bn;
                bone.UseSegmentScaleCompensate = bn.ApplySegmentScaleCompensate;

                Bones.Add(bone);
                //    Nodes.Add(bone);

                if (ska.FlagsRotate == ResU.SkeletalAnimFlagsRotate.EulerXYZ)
                {
                    bone.RotType = Animation.RotationType.EULER;
                }
                else
                {
                    bone.RotType = Animation.RotationType.QUATERNION;
                }


                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Scale))
                {
                    bone.XSCA.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.X, IsKeyed = true
                    });
                    bone.YSCA.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.Y, IsKeyed = true
                    });
                    bone.ZSCA.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.Z, IsKeyed = true
                    });
                }
                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Rotate))
                {
                    bone.XROT.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.X, IsKeyed = true
                    });
                    bone.YROT.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.Y, IsKeyed = true
                    });
                    bone.ZROT.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.Z, IsKeyed = true
                    });
                    bone.WROT.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.W, IsKeyed = true
                    });
                }
                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Translate))
                {
                    bone.XPOS.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.X, IsKeyed = true
                    });
                    bone.YPOS.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.Y, IsKeyed = true
                    });
                    bone.ZPOS.Keys.Add(new KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.Z, IsKeyed = true
                    });
                }

                for (int curve = 0; curve < bn.Curves.Count; curve++)
                {
                    Animation.KeyGroup keyGroup = CurveHelper.CreateTrackWiiU(bn.Curves[curve]);
                    keyGroup.AnimDataOffset = bn.Curves[curve].AnimDataOffset;
                    switch (keyGroup.AnimDataOffset)
                    {
                    case (int)TrackType.XPOS: bone.XPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YPOS: bone.YPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZPOS: bone.ZPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.XROT: bone.XROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YROT: bone.YROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZROT: bone.ZROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.WROT: bone.WROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.XSCA: bone.XSCA.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YSCA: bone.YSCA.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZSCA: bone.ZSCA.Keys.AddRange(keyGroup.Keys); break;

                    default: throw new Exception("Unknown Anim Offset " + keyGroup.AnimDataOffset);
                    }
                }
            }
        }
コード例 #12
0
        public void Read(SkeletalAnim ska)
        {
            Nodes.Clear();
            Bones.Clear();

            FrameCount   = ska.FrameCount;
            SkeletalAnim = ska;
            foreach (BoneAnim bn in ska.BoneAnims)
            {
                FSKANode bonean = new FSKANode(bn);

                Animation.KeyNode bone = new Animation.KeyNode("");
                Bones.Add(bone);
                if (ska.FlagsRotate == SkeletalAnimFlagsRotate.EulerXYZ)
                {
                    bone.RotType = Animation.RotationType.EULER;
                }
                else
                {
                    bone.RotType = Animation.RotationType.QUATERNION;
                }

                bone.Text = bonean.Text;


                for (int Frame = 0; Frame < ska.FrameCount; Frame++)
                {
                    if (Frame == 0)
                    {
                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Scale))
                        {
                            bone.XSCA.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.sca.X
                            });
                            bone.YSCA.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.sca.Y
                            });
                            bone.ZSCA.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.sca.Z
                            });
                        }
                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Rotate))
                        {
                            bone.XROT.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.rot.X
                            });
                            bone.YROT.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.rot.Y
                            });
                            bone.ZROT.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.rot.Z
                            });
                            bone.WROT.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.rot.W
                            });
                        }
                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Translate))
                        {
                            bone.XPOS.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.pos.X
                            });
                            bone.YPOS.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.pos.Y
                            });
                            bone.ZPOS.Keys.Add(new KeyFrame()
                            {
                                Frame = 0, Value = bonean.pos.Z
                            });
                        }
                    }
                    foreach (FSKATrack track in bonean.tracks)
                    {
                        KeyFrame frame = new KeyFrame();
                        frame.InterType = Animation.InterpolationType.HERMITE;
                        frame.Frame     = Frame;

                        FSKAKey left  = track.GetLeft(Frame);
                        FSKAKey right = track.GetRight(Frame);
                        float   value;

                        value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                        // interpolate the value and apply
                        switch (track.flag)
                        {
                        case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;

                        case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;

                        case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;

                        case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;

                        case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;

                        case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;

                        case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;

                        case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;

                        case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
                        }
                    }
                }
            }
        }