Ejemplo n.º 1
0
 void DoModel(ModelFile mdl)
 {
     if (mdl.Hardpoints.Count > 0)
     {
         if (ImGui.TreeNode(ImGuiExt.Pad("Hardpoints")))
         {
             Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
             foreach (var hp in mdl.Hardpoints)
             {
                 HardpointGizmo gz = null;
                 foreach (var gizmo in gizmos)
                 {
                     if (gizmo.Definition == hp)
                     {
                         gz = gizmo;
                         break;
                     }
                 }
                 if (hp is RevoluteHardpointDefinition)
                 {
                     Theme.Icon("rev", Color4.LightSeaGreen);
                 }
                 else
                 {
                     Theme.Icon("fix", Color4.Purple);
                 }
                 ImGui.SameLine();
                 if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray))
                 {
                     gz.Enabled = !gz.Enabled;
                 }
                 ImGui.SameLine();
                 ImGui.Text(hp.Name);
             }
             ImGui.TreePop();
         }
         else
         {
             Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
         }
     }
     else
     {
         Theme.Icon("hardpoint", Color4.CornflowerBlue);
         ImGui.SameLine();
         ImGui.Text("Hardpoints");
     }
 }
Ejemplo n.º 2
0
        void DoNode(NodeReference reference, int idx, Vector4 enabled, Vector4 disabled)
        {
            var    col   = instance.NodeEnabled(reference) ? enabled : disabled;
            string label = null;

            if (reference.IsAttachmentNode)
            {
                label = string.Format("Attachment##{0}", idx);
            }
            else
            {
                label = string.Format("{0}##{1}", reference.Node.NodeName, idx);
            }
            ImGui.PushStyleColor(ImGuiCol.Text, col);
            string icon;
            Color4 color;

            NodeIcon(reference.Node, out icon, out color);
            if (reference.Children.Count > 0)
            {
                if (ImGui.TreeNodeEx(ImGuiExt.Pad(label), ImGuiTreeNodeFlags.OpenOnDoubleClick | ImGuiTreeNodeFlags.OpenOnArrow))
                {
                    Theme.RenderTreeIcon(label.Split('#')[0], icon, color);
                    int j = 0;
                    foreach (var child in reference.Children)
                    {
                        DoNode(child, j++, enabled, disabled);
                    }
                    ImGui.TreePop();
                }
                else
                {
                    Theme.RenderTreeIcon(label.Split('#')[0], icon, color);
                }
            }
            else
            {
                Theme.Icon(icon, color);
                ImGui.SameLine();

                if (ImGui.Selectable(label, selectedReference == reference))
                {
                    selectedReference = reference;
                }
            }
            ImGui.PopStyleColor();
        }
Ejemplo n.º 3
0
 void HierachyPanel()
 {
     if (!(drawable is SphFile))
     {
         ImGui.Text("Level of Detail");
         ImGui.Checkbox("Use Distance", ref useDistance);
         if (useDistance)
         {
             ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f", 1);
         }
         else
         {
             ImGui.Combo("Level", ref level, levels);
         }
         ImGui.Separator();
     }
     if (selectedNode != null)
     {
         ImGui.Text(selectedNode.Con.ChildName);
         ImGui.Text(selectedNode.Con.GetType().Name);
         ImGui.Text("Origin: " + selectedNode.Con.Origin.ToString());
         var euler = selectedNode.Con.Rotation.GetEuler();
         ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                  MathHelper.RadiansToDegrees(euler.X),
                                  MathHelper.RadiansToDegrees(euler.Y),
                                  MathHelper.RadiansToDegrees(euler.Z)));
         ImGui.Separator();
     }
     if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), TreeNodeFlags.DefaultOpen))
     {
         Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
         foreach (var n in cons)
         {
             DoConstructNode(n);
         }
         if (!(drawable is SphFile))
         {
             DoModel(rootModel);
         }
         ImGui.TreePop();
     }
     else
     {
         Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
     }
 }
Ejemplo n.º 4
0
        void ColladaTree(ColladaObject obj, ref int i)
        {
            string tree_icon = "dummy";

            if (obj.Geometry != null)
            {
                tree_icon = "fix";
            }
            if (obj.Children.Count > 0)
            {
                var flags = TreeNodeFlags.OpenOnDoubleClick |
                            TreeNodeFlags.DefaultOpen |
                            TreeNodeFlags.OpenOnArrow;
                if (obj == selected)
                {
                    flags |= TreeNodeFlags.Selected;
                }
                var open = ImGui.TreeNodeEx(ImGuiExt.Pad(obj.Name + "##" + i++), flags);
                if (ImGuiNative.igIsItemClicked(0))
                {
                    selected = obj;
                }
                ColladaContextMenu();
                Theme.RenderTreeIcon(obj.Name, tree_icon, Color4.White);
                if (open)
                {
                    foreach (var child in obj.Children)
                    {
                        ColladaTree(child, ref i);
                    }
                    ImGui.TreePop();
                }
                i += 500;
            }
            else
            {
                if (ImGui.Selectable(ImGuiExt.Pad(obj.Name + "##" + i++), obj == selected))
                {
                    selected = obj;
                }
                ColladaContextMenu();
                Theme.RenderTreeIcon(obj.Name, tree_icon, Color4.White);
            }
        }
Ejemplo n.º 5
0
        void FLTree(OutModel mdl, ref int i)
        {
            var flags = ImGuiTreeNodeFlags.OpenOnDoubleClick |
                        ImGuiTreeNodeFlags.DefaultOpen |
                        ImGuiTreeNodeFlags.OpenOnArrow;

            if (mdl == selected)
            {
                flags |= ImGuiTreeNodeFlags.Selected;
            }
            var open = ImGui.TreeNodeEx(ImGuiExt.Pad(mdl.Name + "##" + i++), flags);

            if (ImGui.IsItemClicked(0))
            {
                selected = mdl;
            }
            ImGui.SameLine();
            Theme.RenderTreeIcon(mdl.Name, "fix", Color4.LightPink);
            if (open)
            {
                if (ImGui.TreeNode("LODs"))
                {
                    for (int j = 0; j < mdl.LODs.Count; j++)
                    {
                        ImGui.Selectable(string.Format("{0}: {1}", j, mdl.LODs[j].Name));
                    }
                    ImGui.TreePop();
                }
                foreach (var child in mdl.Children)
                {
                    FLTree(child, ref i);
                }
                ImGui.TreePop();
            }
            i += 500;
        }
Ejemplo n.º 6
0
        void HierarchyPanel()
        {
            if (!(drawable is DF.DfmFile) && !(drawable is SphFile))
            {
                //Sur
                if (ImGui.Button("Open Sur"))
                {
                    var file = FileDialog.Open(SurFilters);
                    surname = System.IO.Path.GetFileName(file);
                    LibreLancer.Physics.Sur.SurFile sur;
                    try
                    {
                        using (var f = System.IO.File.OpenRead(file))
                        {
                            sur = new LibreLancer.Physics.Sur.SurFile(f);
                        }
                    }
                    catch (Exception)
                    {
                        sur = null;
                    }
                    if (sur != null)
                    {
                        ProcessSur(sur);
                    }
                }
                if (surs != null)
                {
                    ImGui.Separator();
                    ImGui.Text("Sur: " + surname);
                    ImGui.Checkbox("Show Hull", ref surShowHull);
                    ImGui.Checkbox("Show Hardpoints", ref surShowHps);
                    ImGui.Separator();
                }
            }
            if (ImGuiExt.Button("Apply Hardpoints", _isDirtyHp))
            {
                if (drawable is ModelFile)
                {
                    hprefs.Nodes[0].HardpointsToNodes(vmsModel.Root.Hardpoints);
                }
                else if (drawable is CmpFile)
                {
                    foreach (var mdl in vmsModel.AllParts)
                    {
                        var node = hprefs.Nodes.First((x) => x.Name == mdl.Path);
                        node.HardpointsToNodes(mdl.Hardpoints);
                    }
                }
                if (_isDirtyHp)
                {
                    _isDirtyHp = false;
                    parent.DirtyCountHp--;
                }
                popups.OpenPopup("Apply Complete");
            }
            if (vmsModel.AllParts.Length > 1 && ImGuiExt.Button("Apply Parts", _isDirtyPart))
            {
                WriteConstructs();
                if (_isDirtyPart)
                {
                    _isDirtyPart = false;
                    parent.DirtyCountPart--;
                }
                popups.OpenPopup("Apply Complete##Parts");
            }
            if (ImGuiExt.ToggleButton("Filter", doFilter))
            {
                doFilter = !doFilter;
            }
            if (doFilter)
            {
                ImGui.InputText("##filter", filterText.Pointer, (uint)filterText.Size, ImGuiInputTextFlags.None, filterText.Callback);
                currentFilter = filterText.GetText();
            }
            else
            {
                currentFilter = null;
            }

            ImGui.Separator();
            if (selectedNode != null)
            {
                ImGui.Text(selectedNode.Construct.ChildName);
                ImGui.Text(selectedNode.Construct.GetType().Name);
                ImGui.Text("Origin: " + selectedNode.Construct.Origin.ToString());
                var euler = selectedNode.Construct.Rotation.GetEuler();
                ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                         MathHelper.RadiansToDegrees(euler.X),
                                         MathHelper.RadiansToDegrees(euler.Y),
                                         MathHelper.RadiansToDegrees(euler.Z)));
                ImGui.Separator();
            }

            if (!vmsModel.Root.Active)
            {
                var col = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled];
                ImGui.PushStyleColor(ImGuiCol.Text, col);
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
                if (vmsModel.Root.Children != null)
                {
                    foreach (var n in vmsModel.Root.Children)
                    {
                        DoConstructNode(n);
                    }
                }

                DoModel(vmsModel.Root);
                //if (!(drawable is SphFile)) DoModel(rootModel, null);
                ImGui.TreePop();
            }
            else
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
            }
        }
Ejemplo n.º 7
0
        void DoModel(RigidModelPart part)
        {
            //Hardpoints
            bool open = ImGui.TreeNode(ImGuiExt.Pad("Hardpoints"));
            var  act  = NewHpMenu(part.Path);

            switch (act)
            {
            case ContextActions.NewFixed:
            case ContextActions.NewRevolute:
                newIsFixed = act == ContextActions.NewFixed;
                addTo      = part;
                newHpBuffer.Clear();
                popups.OpenPopup("New Hardpoint");
                break;
            }
            Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
            if (open)
            {
                List <Action> addActions = new List <Action>();
                foreach (var hp in part.Hardpoints)
                {
                    if (doFilter)
                    {
                        if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }
                    }
                    HardpointGizmo gz = null;
                    foreach (var gizmo in gizmos)
                    {
                        if (gizmo.Hardpoint == hp)
                        {
                            gz = gizmo;
                            break;
                        }
                    }
                    if (hp.Definition is RevoluteHardpointDefinition)
                    {
                        Theme.Icon("rev", Color4.LightSeaGreen);
                    }
                    else
                    {
                        Theme.Icon("fix", Color4.Purple);
                    }
                    ImGui.SameLine();
                    if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray))
                    {
                        gz.Enabled = !gz.Enabled;
                    }
                    ImGui.SameLine();
                    ImGui.Selectable(ImGuiExt.IDSafe(hp.Name));
                    var action = EditDeleteHpMenu(part.Path + hp.Name);
                    if (action == ContextActions.Delete)
                    {
                        hpDelete     = hp;
                        hpDeleteFrom = part.Hardpoints;
                        popups.OpenPopup("Confirm Delete");
                    }
                    if (action == ContextActions.Edit)
                    {
                        hpEditing = hp;
                    }
                    if (action == ContextActions.MirrorX)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.X   = -newHp.Definition.Position.X;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            -1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorY)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Y   = -newHp.Definition.Position.Y;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, -1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorZ)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Z   = -newHp.Definition.Position.Z;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, -1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                }
                foreach (var action in addActions)
                {
                    action();
                }
                ImGui.TreePop();
            }
        }
Ejemplo n.º 8
0
        void DoConstructNode(RigidModelPart cn)
        {
            var n      = ImGuiExt.IDSafe(string.Format("{0} ({1})", cn.Construct.ChildName, ConType(cn.Construct)));
            var tflags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick;

            if (selectedNode == cn)
            {
                tflags |= ImGuiTreeNodeFlags.Selected;
            }
            var icon  = "fix";
            var color = Color4.LightYellow;

            if (cn.Construct is PrisConstruct)
            {
                icon  = "pris";
                color = Color4.LightPink;
            }
            if (cn.Construct is SphereConstruct)
            {
                icon  = "sphere";
                color = Color4.LightGreen;
            }
            if (cn.Construct is RevConstruct)
            {
                icon  = "rev";
                color = Color4.LightCoral;
            }
            bool mdlVisible = cn.Active;

            if (!mdlVisible)
            {
                var disabledColor = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled];
                ImGui.PushStyleColor(ImGuiCol.Text, disabledColor);
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad(n), tflags))
            {
                if (!mdlVisible)
                {
                    ImGui.PopStyleColor();
                }
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = cn;
                }
                ConstructContext(cn, mdlVisible);
                Theme.RenderTreeIcon(n, icon, color);
                if (cn.Children != null)
                {
                    foreach (var child in cn.Children)
                    {
                        DoConstructNode(child);
                    }
                }

                DoModel(cn);
                ImGui.TreePop();
            }
            else
            {
                if (!mdlVisible)
                {
                    ImGui.PopStyleColor();
                }
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = cn;
                }
                ConstructContext(cn, mdlVisible);
                Theme.RenderTreeIcon(n, icon, color);
            }
        }
Ejemplo n.º 9
0
        void DoModel(ModelFile mdl, AbstractConstruct con)
        {
            //Hardpoints
            bool open = ImGui.TreeNode(ImGuiExt.Pad("Hardpoints"));
            var  act  = NewHpMenu(mdl.Path);

            switch (act)
            {
            case ContextActions.NewFixed:
            case ContextActions.NewRevolute:
                newIsFixed   = act == ContextActions.NewFixed;
                addTo        = mdl.Hardpoints;
                addConstruct = con;
                newHpBuffer.Clear();
                popups.OpenPopup("New Hardpoint");
                break;
            }
            Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
            if (open)
            {
                foreach (var hp in mdl.Hardpoints)
                {
                    if (doFilter)
                    {
                        if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }
                    }
                    HardpointGizmo gz = null;
                    foreach (var gizmo in gizmos)
                    {
                        if (gizmo.Definition == hp)
                        {
                            gz = gizmo;
                            break;
                        }
                    }
                    if (hp is RevoluteHardpointDefinition)
                    {
                        Theme.Icon("rev", Color4.LightSeaGreen);
                    }
                    else
                    {
                        Theme.Icon("fix", Color4.Purple);
                    }
                    ImGui.SameLine();
                    if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray))
                    {
                        gz.Enabled = !gz.Enabled;
                    }
                    ImGui.SameLine();
                    ImGui.Selectable(hp.Name);
                    var action = EditDeleteHpMenu(mdl.Path + hp.Name);
                    if (action == ContextActions.Delete)
                    {
                        hpDelete     = hp;
                        hpDeleteFrom = mdl.Hardpoints;
                        popups.OpenPopup("Confirm Delete");
                    }
                    if (action == ContextActions.Edit)
                    {
                        hpEditing = hp;
                    }
                }
                ImGui.TreePop();
            }
        }
Ejemplo n.º 10
0
        void HierachyPanel()
        {
            if (!(drawable is DF.DfmFile) && !(drawable is SphFile))
            {
                //Sur
                if (ImGui.Button("Open Sur"))
                {
                    var file = FileDialog.Open(SurFilters);
                    surname = System.IO.Path.GetFileName(file);
                    LibreLancer.Physics.Sur.SurFile sur;
                    try
                    {
                        using (var f = System.IO.File.OpenRead(file))
                        {
                            sur = new LibreLancer.Physics.Sur.SurFile(f);
                        }
                    }
                    catch (Exception)
                    {
                        sur = null;
                    }
                    if (sur != null)
                    {
                        ProcessSur(sur);
                    }
                }
                if (surs != null)
                {
                    ImGui.Separator();
                    ImGui.Text("Sur: " + surname);
                    ImGui.Checkbox("Show Hull", ref surShowHull);
                    ImGui.Checkbox("Show Hardpoints", ref surShowHps);
                    ImGui.Separator();
                }
            }
            if (ImGui.Button("Apply Hardpoints"))
            {
                if (drawable is CmpFile)
                {
                    var cmp = (CmpFile)drawable;
                    foreach (var kv in cmp.Models)
                    {
                        var node = hprefs.Nodes.Where((x) => x.Name == kv.Key).First();
                        node.HardpointsToNodes(kv.Value.Hardpoints);
                    }
                }
                else if (drawable is ModelFile)
                {
                    hprefs.Nodes[0].HardpointsToNodes(((ModelFile)drawable).Hardpoints);
                }
                popups.OpenPopup("Apply Complete");
            }
            if ((drawable is CmpFile) && ((CmpFile)drawable).Parts.Count > 1 && ImGui.Button("Apply Parts"))
            {
                WriteConstructs();
                popups.OpenPopup("Apply Complete##Parts");
            }
            if (ImGuiExt.ToggleButton("Filter", doFilter))
            {
                doFilter = !doFilter;
            }
            if (doFilter)
            {
                ImGui.InputText("##filter", filterText.Pointer, (uint)filterText.Size, ImGuiInputTextFlags.None, filterText.Callback);
                currentFilter = filterText.GetText();
            }
            else
            {
                currentFilter = null;
            }

            ImGui.Separator();
            if (selectedNode != null)
            {
                ImGui.Text(selectedNode.Con.ChildName);
                ImGui.Text(selectedNode.Con.GetType().Name);
                ImGui.Text("Origin: " + selectedNode.Con.Origin.ToString());
                var euler = selectedNode.Con.Rotation.GetEuler();
                ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                         MathHelper.RadiansToDegrees(euler.X),
                                         MathHelper.RadiansToDegrees(euler.Y),
                                         MathHelper.RadiansToDegrees(euler.Z)));
                ImGui.Separator();
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), ImGuiTreeNodeFlags.DefaultOpen))
            {
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
                foreach (var n in cons)
                {
                    DoConstructNode(n);
                }
                if (!(drawable is SphFile))
                {
                    DoModel(rootModel, null);
                }
                ImGui.TreePop();
            }
            else
            {
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
            }
        }