Beispiel #1
0
        private static void ReadVisAnimations(RAnimation renderAnimation, SsbhAnimTrackDecoder decoder, AnimGroup animGroup)
        {
            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 = (bool)visibility[i]
                            });
                        }
                    }
                }
                renderAnimation.VisibilityNodes.Add(visAnim);
            }
        }
Beispiel #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);
        }