public static void Export(Node node) { var dlg = new FileDialog { AllowedFileTypes = new string[] { Document.Current.GetFileExtension() }, Mode = FileDialogMode.Save, InitialDirectory = Project.Current.GetSystemDirectory(Document.Current.Path), }; if (dlg.RunModal()) { string assetPath; if (!Project.Current.TryGetAssetPath(dlg.FileName, out assetPath)) { AlertDialog.Show("Can't save the document outside the project directory"); } else { try { Document.WriteNodeToFile(assetPath, DocumentFormat.Tan, node); } catch (System.Exception e) { AlertDialog.Show(e.Message); } } } }
public static void Export(Node node) { var dlg = new FileDialog { AllowedFileTypes = new string[] { Document.Current.GetFileExtension() }, Mode = FileDialogMode.Save, InitialDirectory = Path.GetDirectoryName(Document.Current.FullPath), }; if (dlg.RunModal()) { if (!Project.Current.TryGetAssetPath(dlg.FileName, out var assetPath)) { AlertDialog.Show("Can't save the document outside the project directory"); } else { try { var clone = node.Clone().AsWidget; clone.Position = Vector2.Zero; clone.Visible = true; clone.LoadExternalScenes(); clone.ContentsPath = null; Document.ExportNodeToFile(dlg.FileName, assetPath, Document.Current.Format, clone); } catch (System.Exception e) { AlertDialog.Show(e.Message); } } } }
public static void TransformPropertyAndKeyframes <T>(Node node, string propertyId, Func <T, T> transformer) { var value = new Property <T>(node, propertyId).Value; SetProperty.Perform(node, propertyId, transformer(value)); foreach (var animation in node.Animators) { if (animation.TargetPropertyPath == propertyId) { foreach (var keyframe in animation.Keys.ToList()) { var newKeyframe = keyframe.Clone(); newKeyframe.Value = transformer((T)newKeyframe.Value); SetKeyframe.Perform(node, animation.TargetPropertyPath, animation.AnimationId, newKeyframe); } } } }
public static void Export(Node node) { var dlg = new FileDialog { AllowedFileTypes = new string[] { Document.Current.GetFileExtension() }, Mode = FileDialogMode.Save, InitialDirectory = Path.GetDirectoryName(Document.Current.FullPath), }; if (dlg.RunModal()) { if (!Project.Current.TryGetAssetPath(dlg.FileName, out var assetPath)) { AlertDialog.Show("Can't save the document outside the project directory"); } else { try { var clone = node.Clone().AsWidget; clone.Position = Vector2.Zero; clone.Visible = true; clone.LoadExternalScenes(); clone.ContentsPath = null; int removedAnimatorsCount = clone.RemoveDanglingAnimators(); Document.ExportNodeToFile(dlg.FileName, assetPath, Document.Current.Format, clone); if (removedAnimatorsCount != 0) { var message = "Your exported content has references to external animations. It's forbidden.\n"; if (removedAnimatorsCount == 1) { message += "1 dangling animator has been removed!"; } else { message += $"{removedAnimatorsCount} dangling animators have been removed!"; } Document.Current.ShowWarning(message); } } catch (System.Exception e) { AlertDialog.Show(e.Message); } } } }
protected void UpsampleNodeAnimation(Node node) { foreach (var a in node.Animations) { foreach (var m in a.Markers) { SetProperty.Perform(m, "Frame", m.Frame * 2); } } foreach (var a in node.Animators) { foreach (var k in a.Keys) { SetProperty.Perform(k, "Frame", k.Frame * 2); } } foreach (var n in node.Nodes) { UpsampleNodeAnimation(n); } }
public static bool IsValidNode(Node node) => (node is Widget) || (node is Bone) || (node is Audio) || (node is ImageCombiner);
private Lime.Node ImportNodes(FbxImporter.Node root, Lime.Node parent = null) { Node3D node = null; if (root == null) { return(null); } switch (root.Attribute.Type) { case NodeAttribute.FbxNodeType.MESH: var meshAttribute = root.Attribute as MeshAttribute; var mesh = new Mesh3D { Id = root.Name }; foreach (var submesh in meshAttribute.Submeshes) { mesh.Submeshes.Add(ImportSubmesh(submesh, root)); } if (platform == TargetPlatform.Unity) { mesh.CullMode = CullMode.CullCounterClockwise; } node = mesh; if (mesh.Submeshes.Count != 0) { mesh.SetLocalTransform(root.LocalTranform); mesh.RecalcBounds(); mesh.RecalcCenter(); } break; case NodeAttribute.FbxNodeType.CAMERA: var cam = root.Attribute as CameraAttribute; node = new Camera3D { Id = root.Name, FieldOfView = cam.FieldOfView * Mathf.DegToRad, AspectRatio = cam.AspectRatio, NearClipPlane = cam.NearClipPlane, FarClipPlane = cam.FarClipPlane, }; node.SetLocalTransform(CorrectCameraTransform(root.LocalTranform)); break; default: node = new Node3D { Id = root.Name }; node.SetLocalTransform(root.LocalTranform); break; } if (node != null) { if (parent != null) { parent.Nodes.Add(node); } foreach (var child in root.Children) { ImportNodes(child, node); } } return(node); }
private Lime.Node ImportNodes(FbxImporter.FbxNode root, Lime.Node parent = null) { Node3D node = null; if (root == null) { return(null); } switch (root.Attribute.Type) { case FbxNodeAttribute.FbxNodeType.Mesh: var meshAttribute = root.Attribute as FbxMeshAttribute; var mesh = new Mesh3D { Id = root.Name }; foreach (var submesh in meshAttribute.Submeshes) { mesh.Submeshes.Add(ImportSubmesh(submesh, root)); } node = mesh; if (mesh.Submeshes.Count != 0) { mesh.SetLocalTransform(root.LocalTranform); mesh.RecalcBounds(); mesh.RecalcCenter(); } break; case FbxNodeAttribute.FbxNodeType.Camera: var cam = root.Attribute as FbxCameraAttribute; node = new Camera3D { Id = root.Name, FieldOfView = cam.FieldOfView * Mathf.DegToRad, AspectRatio = cam.AspectRatio, NearClipPlane = cam.NearClipPlane, FarClipPlane = cam.FarClipPlane, ProjectionMode = cam.ProjectionMode, OrthographicSize = cam.OrthoZoom, }; node.SetLocalTransform(CorrectCameraTransform(root.LocalTranform)); break; default: node = new Node3D { Id = root.Name }; node.SetLocalTransform(root.LocalTranform); break; } if (node != null) { if (parent != null) { parent.Nodes.Add(node); } foreach (var child in root.Children) { ImportNodes(child, node); } } return(node); }