コード例 #1
0
ファイル: SkeletonBone.cs プロジェクト: zwiglm/NeoAxisEngine
        static double[] LoadKeyTimes(FbxNode node, AnimationTrackInfo animationTrack)
        {
            HashSet <double> keyFrames = new HashSet <double>();

            LoadKeyFrames(animationTrack, node.LclTranslation, keyFrames, XChannelName, YChannelName, ZChannelName);
            LoadKeyFrames(animationTrack, node.LclRotation, keyFrames, XChannelName, YChannelName, ZChannelName);
            LoadKeyFrames(animationTrack, node.LclScaling, keyFrames, XChannelName, YChannelName, ZChannelName);

            return(keyFrames.OrderBy(_ => _).ToArray());
        }
コード例 #2
0
ファイル: SkeletonBone.cs プロジェクト: zwiglm/NeoAxisEngine
        public AnimTrack LoadAnimationTrack(FbxNode node, AnimationTrackInfo animationTrack)
        {
            double[] times = LoadKeyTimes(node, animationTrack);
            var      ret   = new AnimTrack();

            ret.Layers = new AnimationLayer[animationTrack.GetLayerCount()];
            for (int i = 0; i < ret.Layers.Length; i++)
            {
                ret.Layers[i] = LoadLayer(node, animationTrack.GetLayer(i), times);
            }
            return(ret);
        }
コード例 #3
0
ファイル: SceneLoader.cs プロジェクト: zwiglm/NeoAxisEngine
        //void EnumerateNodeRecursive(FbxNode pNode)
        //{
        //	FbxMesh pMesh;
        //	if (IsNodeMesh(pNode, out pMesh))
        //	{
        //		CreateMaterialsFromNode(pNode);
        //		CreateMeshesFromNode(pNode, pMesh);
        //	}

        //	for (int j = 0; j < pNode.GetChildCount(); j++)
        //		EnumerateNodeRecursive(pNode.GetChild(j));
        //}

        void LoadAnimations(FbxScene scene)
        {
            FbxTime.EMode timeMode = scene.GetGlobalSettings().GetTimeMode();
            FrameRate = FbxTime.GetFrameRate(timeMode);

            int animationCount = FbxExtensions.GetAnimStackCount(scene);

            AnimationTracks = new List <AnimationTrackInfo>();
            for (int i = 0; i < animationCount; i++)
            {
                FbxAnimStack       pAnimStack      = FbxExtensions.GetAnimStack(scene, i);
                AnimationTrackInfo pAnimationTrack = new AnimationTrackInfo(pAnimStack, scene.GetRootNode());
                AnimationTracks.Add(pAnimationTrack);
            }
        }
コード例 #4
0
ファイル: SkeletonBone.cs プロジェクト: zwiglm/NeoAxisEngine
        //ToDo : ??? Только для одного Layer грузить? Хотя у Layers должны быть одинаковые отсчеты времени, если они должны смешиваться?
        static void LoadKeyFrames(AnimationTrackInfo animationTrack,
                                  FbxPropertyTFbxDouble3 transformProperty,
                                  HashSet <double> keyFrames, string xChannelName,
                                  string yChannelName, string zChannelName)
        {
            for (int i = 0; i < animationTrack.GetLayerCount(); i++)
            {
                FbxAnimLayer pAnimLayer = animationTrack.GetLayer(i);
                FbxAnimCurve pAnimCurve = null;

                pAnimCurve = transformProperty.GetCurve(pAnimLayer, xChannelName);
                if (pAnimCurve != null)
                {
                    for (int j = 0; j < pAnimCurve.KeyGetCount(); j++)
                    {
                        FbxAnimCurveKey key = pAnimCurve.KeyGet(j);
                        //ToDo :? Учитывать key.GetInterpolation();
                        double time = key.GetTime().GetSecondDouble();
                        keyFrames.Add(time);
                    }
                }

                pAnimCurve = transformProperty.GetCurve(pAnimLayer, yChannelName);
                if (pAnimCurve != null)
                {
                    for (int j = 0; j < pAnimCurve.KeyGetCount(); j++)
                    {
                        FbxAnimCurveKey key  = pAnimCurve.KeyGet(j);
                        double          time = key.GetTime().GetSecondDouble();
                        keyFrames.Add(time);
                    }
                }

                pAnimCurve = transformProperty.GetCurve(pAnimLayer, zChannelName);
                if (pAnimCurve != null)
                {
                    for (int j = 0; j < pAnimCurve.KeyGetCount(); j++)
                    {
                        FbxAnimCurveKey key  = pAnimCurve.KeyGet(j);
                        double          time = key.GetTime().GetSecondDouble();
                        keyFrames.Add(time);
                    }
                }
            }
        }