public FbxScene LoadScene(string fileName) { var native = FbxManagerLoadScene(NativePtr, new StringBuilder(fileName)); if (native == IntPtr.Zero) { throw new FbxImportException("An error has occured while loading scene"); } var scene = new FbxScene(native); createdScenes.Add(scene); return(scene); }
public FbxScene LoadScene(FbxImportOptions options) { var native = FbxManagerLoadScene(NativePtr, new StringBuilder(AssetBundle.Current.ToSystemPath(options.Path))); if (native == IntPtr.Zero) { throw new FbxImportException("An error has occured while loading scene"); } var scene = new FbxScene(native); createdScenes.Add(scene); return(scene); }
private void ImportAnimations(Model3D model, FbxScene scene) { if (scene.Animations == null) { return; } foreach (var animation in scene.Animations.List) { var n = model.TryFind <Node3D>(animation.TargetNodeId); var scaleKeys = Vector3KeyReducer.Default.Reduce(animation.ScaleKeys); if (scaleKeys.Count != 0) { GetOrAddAnimator <Vector3Animator>(animation, n, nameof(Node3D.Scale)).Keys.AddRange(scaleKeys); } var rotKeys = QuaternionKeyReducer.Default.Reduce(animation.RotationKeys); if (rotKeys.Count != 0) { if (n is Camera3D) { CorrectCameraAnimationKeys(rotKeys); } GetOrAddAnimator <QuaternionAnimator>(animation, n, nameof(Node3D.Rotation)).Keys.AddRange(rotKeys); } var posKeys = Vector3KeyReducer.Default.Reduce(animation.PositionKeys); if (posKeys.Count != 0) { GetOrAddAnimator <Vector3Animator>(animation, n, nameof(Node3D.Position)).Keys.AddRange(posKeys); } if (!model.Animations.Any(a => a.Id == animation.AnimationStackName)) { model.Animations.Add(new Animation { Id = animation.AnimationStackName, }); } } }