Exemple #1
0
        private static void ReadBoneAnimations(RAnimation renderAnimation, SsbhAnimTrackDecoder decoder, AnimGroup animGroup)
        {
            foreach (AnimNode animNode in animGroup.Nodes)
            {
                RTransformAnimation tfrmAnim = new RTransformAnimation()
                {
                    Name = animNode.Name
                };
                foreach (AnimTrack track in animNode.Tracks)
                {
                    object[] transform = decoder.ReadTrack(track);

                    if (track.Name.Equals("Transform"))
                    {
                        for (int i = 0; i < transform.Length; i++)
                        {
                            AnimTrackTransform t = (AnimTrackTransform)transform[i];
                            tfrmAnim.Transform.Keys.Add(new RKey <Matrix4>()
                            {
                                Frame         = i,
                                Value         = GetMatrix((AnimTrackTransform)transform[i]),
                                AbsoluteScale = t.CompensateScale
                            });
                        }
                    }
                }
                renderAnimation.TransformNodes.Add(tfrmAnim);
            }
        }
Exemple #2
0
        public IRenderable GetRenderableNode()
        {
            if (animation == null)
            {
                return(null);
            }
            RAnimation renderAnimation = new RAnimation()
            {
                FrameCount = (int)animation.FrameCount
            };

            SSBHAnimTrackDecoder decoder = new SSBHAnimTrackDecoder(animation);

            foreach (AnimGroup animGroup in animation.Animations)
            {
                // Material Animations
                if (animGroup.Type == ANIM_TYPE.Material)
                {
                    foreach (AnimNode animNode in animGroup.Nodes)
                    {
                        foreach (AnimTrack track in animNode.Tracks)
                        {
                            object[] MaterialAnim = decoder.ReadTrack(track);
                        }
                    }
                }
                // Visibility Animations
                if (animGroup.Type == ANIM_TYPE.Visibilty)
                {
                    foreach (AnimNode animNode in animGroup.Nodes)
                    {
                        RVisibilityAnimation visAnim = new RVisibilityAnimation()
                        {
                            MeshName = animNode.Name
                        };
                        foreach (AnimTrack track in animNode.Tracks)
                        {
                            if (track.Name.Equals("Visibility"))
                            {
                                object[] Visibility = decoder.ReadTrack(track);

                                for (int i = 0; i < Visibility.Length; i++)
                                {
                                    visAnim.Visibility.Keys.Add(new RKey <bool>()
                                    {
                                        Frame = i,
                                        Value = ((AnimTrackBool)Visibility[i]).Value
                                    });
                                }
                            }
                        }
                        renderAnimation.VisibilityNodes.Add(visAnim);
                    }
                }
                // Bone Animations
                if (animGroup.Type == ANIM_TYPE.Transform)
                {
                    foreach (AnimNode animNode in animGroup.Nodes)
                    {
                        RTransformAnimation tfrmAnim = new RTransformAnimation()
                        {
                            Name = animNode.Name
                        };
                        foreach (AnimTrack track in animNode.Tracks)
                        {
                            if (track.Name.Equals("Transform"))
                            {
                                object[] Transform = decoder.ReadTrack(track);
                                for (int i = 0; i < Transform.Length; i++)
                                {
                                    AnimTrackTransform t = (AnimTrackTransform)Transform[i];
                                    tfrmAnim.Transform.Keys.Add(new RKey <Matrix4>()
                                    {
                                        Frame = i,
                                        Value = GetMatrix((AnimTrackTransform)Transform[i])
                                    });
                                }
                            }
                        }
                        renderAnimation.TransformNodes.Add(tfrmAnim);
                    }
                }
            }



            return(renderAnimation);
        }