private static OutlineItem CreateOutlineItem(SceneNode sceneNode) { var item = new OutlineItem { Text = $"{sceneNode.GetType().Name} \"{sceneNode.Name}\"", Icon = MultiColorGlyphs.SceneNode, Children = new OutlineItemCollection(), ToolTip = ToolTipSceneNode, UserData = sceneNode, }; if (sceneNode is MeshNode) item.Icon = MultiColorGlyphs.Mesh; if (sceneNode.Children != null) foreach (var child in sceneNode.Children) if (child != null) item.Children.Add(CreateOutlineItem(child)); var mesh = (sceneNode as MeshNode)?.Mesh; if (mesh != null) item.Children.Add(CreateOutlineItem(mesh)); return item; }
private static OutlineItem CreateOutlineItem(Mesh mesh) { var item = new OutlineItem { Text = $"Mesh \"{mesh.Name}\"", Icon = MultiColorGlyphs.Mesh, Children = new OutlineItemCollection(), ToolTip = ToolTipSceneNode, UserData = mesh, }; foreach (var submesh in mesh.Submeshes) item.Children.Add(CreateOutlineItem(submesh)); foreach (var material in mesh.Materials) item.Children.Add(CreateOutlineItem(material)); if (mesh.Skeleton != null) item.Children.Add(CreateOutlineItem(mesh.Skeleton)); if (mesh.Animations != null) foreach (var animation in mesh.Animations) item.Children.Add(CreateOutlineItem(animation)); if (mesh.Occluder != null) item.Children.Add(CreateOutlineItem(mesh.Occluder)); return item; }
public static IEnumerable <OutlineItem> GetChildren(this OutlineItem item) { if (item?.Children == null) { return(LinqHelper.Empty <OutlineItem>()); } return(item.Children); }
/// <summary> /// Gets the leaves of the outline item. /// </summary> /// <param name="item">The outline item where to start the search.</param> /// <returns>The leaves of the outline item.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="item"/> is <see langword="null"/>. /// </exception> public static IEnumerable <OutlineItem> GetLeaves(this OutlineItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return(TreeHelper.GetLeaves(item, GetChildren)); }
/// <summary> /// Gets the outline item and its ancestors scene. /// </summary> /// <param name="item">The outline item.</param> /// <returns>The <paramref name="item"/> and its ancestors of the scene.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="item"/> is <see langword="null"/>. /// </exception> public static IEnumerable <OutlineItem> GetSelfAndAncestors(this OutlineItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return(TreeHelper.GetSelfAndAncestors(item, GetParentCallback)); }
/// <overloads> /// <summary> /// Gets the subtree (the given outline item and all of its descendants). /// </summary> /// </overloads> /// /// <summary> /// Gets the subtree (the given outline item and all of its descendants) using a depth-first /// search. /// </summary> /// <param name="item">The outline item.</param> /// <returns> /// The subtree (the given outline item and all of its descendants) in depth-first order. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="item"/> is <see langword="null"/>. /// </exception> public static IEnumerable <OutlineItem> GetSubtree(this OutlineItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return(TreeHelper.GetSubtree(item, GetChildrenCallback, true)); }
/// <summary> /// Gets the subtree (the given outline item and all of its descendants) using a depth-first or a /// breadth-first search. /// </summary> /// <param name="item">The outline item.</param> /// <param name="depthFirst"> /// If set to <see langword="true"/> then a depth-first search for descendants will be made; /// otherwise a breadth-first search will be made. /// </param> /// <returns>The subtree (the given outline item and all of its descendants).</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="item"/> is <see langword="null"/>. /// </exception> public static IEnumerable <OutlineItem> GetSubtree(this OutlineItem item, bool depthFirst) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return(TreeHelper.GetSubtree(item, GetChildren, depthFirst)); }
/// <summary> /// Gets the root item. /// </summary> /// <param name="item">The outline item.</param> /// <returns>The root item.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="item"/> is <see langword="null"/>. /// </exception> public static OutlineItem GetRoot(this OutlineItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } while (item.Parent != null) { item = item.Parent; } return(item); }
private static OutlineItem CreateOutlineItem(Skeleton skeleton, int boneIndex) { var item = new OutlineItem { Text = $"Bone {boneIndex} \"{skeleton.GetName(boneIndex)}\"", Icon = MultiColorGlyphs.Bone, Children = new OutlineItemCollection(), UserData = boneIndex, }; for (int bone = 0; bone < skeleton.NumberOfBones; bone++) if (skeleton.GetParent(bone) == boneIndex) item.Children.Add(CreateOutlineItem(skeleton, bone)); return item; }
//-------------------------------------------------------------- private void UpdateOutline() { if (Outline == null) { Outline = new Outline(); Outline.SelectedItems.CollectionChanged += OnOutlineSelectedItemsChanged; } Outline.RootItems.Clear(); if (State != ModelDocumentState.Loaded) return; var root = new OutlineItem { Text = Path.GetFileName(Uri.LocalPath), Icon = MultiColorGlyphs.Model, Children = new OutlineItemCollection(), IsSelected = true, ToolTip = ToolTipGeneral, }; Outline.RootItems.Add(root); if (ModelNode != null) root.Children.Add(CreateOutlineItem(ModelNode)); else if (Model != null) root.Children.Add(CreateOutlineItem(Model)); if (_assimpScene != null) root.Children.Add(CreateOutlineItem(_assimpScene)); if (_documentService.ActiveDocument == this) { // This document is active and can control tool windows. if (_outlineService != null) _outlineService.Outline = Outline; } }
private OutlineItem CreateOutlineItem(Model model) { var item = new OutlineItem { Text = $"Model \"{Path.GetFileNameWithoutExtension(Uri.LocalPath)}\"", Icon = MultiColorGlyphs.Model, Children = new OutlineItemCollection(), UserData = model, }; if (model.Root != null) item.Children.Add(CreateOutlineItem(model.Root)); return item; }
private static OutlineItem CreateOutlineItem(Assimp.Node node) { var item = new OutlineItem { Text = node.Name, Icon = node.HasMeshes ? MultiColorGlyphs.Mesh : MultiColorGlyphs.SceneNode, Children = new OutlineItemCollection(), ToolTip = ToolTipAssimpNode, UserData = node, }; if (node.HasChildren) foreach (var child in node.Children) item.Children.Add(CreateOutlineItem(child)); return item; }
private static OutlineItem CreateOutlineItem(Assimp.Scene scene) { var item = new OutlineItem { Text = "Assimp scene", Icon = MultiColorGlyphs.SceneNode, Children = new OutlineItemCollection(), ToolTip = ToolTipAssimpNode, UserData = scene, IsExpanded = false, }; item.Children.Add(CreateOutlineItem(scene.RootNode)); return item; }
private static OutlineItem CreateOutlineItem(ModelMeshPart meshPart) { var item = new OutlineItem { Text = "ModelMeshPart", Icon = MultiColorGlyphs.Mesh, UserData = meshPart, }; return item; }
private static OutlineItem CreateOutlineItem(ModelMesh mesh) { var item = new OutlineItem { Text = $"ModelMesh \"{mesh.Name}\"", Icon = MultiColorGlyphs.Mesh, Children = new OutlineItemCollection(), UserData = mesh, }; foreach (var meshPart in mesh.MeshParts) item.Children.Add(CreateOutlineItem(meshPart)); return item; }
private static OutlineItem CreateOutlineItem(ModelBone bone) { var item = new OutlineItem { Text = $"ModelBone \"{bone.Name}\"", Icon = MultiColorGlyphs.Bone, Children = new OutlineItemCollection(), UserData = bone, }; foreach (var mesh in bone.Meshes) item.Children.Add(CreateOutlineItem(mesh)); foreach (var child in bone.Children) item.Children.Add(CreateOutlineItem(child)); return item; }
private static OutlineItem CreateOutlineItem(Occluder occluder) { var item = new OutlineItem { Text = "Occluder", }; return item; }
private static OutlineItem CreateOutlineItem(Skeleton skeleton) { var item = new OutlineItem { Text = $"Skeleton \"{skeleton.Name}\"", Icon = MultiColorGlyphs.Skeleton, IsExpanded = false, Children = new OutlineItemCollection(), UserData = skeleton, }; for (int bone = 0; bone < skeleton.NumberOfBones; bone++) if (skeleton.GetParent(bone) == -1) item.Children.Add(CreateOutlineItem(skeleton, bone)); return item; }
private static OutlineItem CreateOutlineItem(KeyValuePair<string, SkeletonKeyFrameAnimation> animation) { var item = new OutlineItem { Text = $"Animation \"{animation.Key}\"", Icon = MultiColorGlyphs.Animation, UserData = animation, }; return item; }
private static OutlineItem CreateOutlineItem(Material material) { var item = new OutlineItem { Text = $"Material \"{material.Name}\"", Icon = MultiColorGlyphs.Texture, ToolTip = ToolTipSceneNode, UserData = material, }; return item; }
private static OutlineItem CreateOutlineItem(Submesh submesh) { var item = new OutlineItem { Text = "Submesh", Icon = MultiColorGlyphs.Mesh, ToolTip = ToolTipSceneNode, UserData = submesh, }; return item; }