Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Merge some Meshes in a MeshGroup Upon Export #375

Open
2 tasks done
mechPenSketch opened this issue Jul 20, 2024 · 4 comments
Open
2 tasks done
Labels
Enhancement New feature or request Triage PR/Issue needs to be triaged.

Comments

@mechPenSketch
Copy link

mechPenSketch commented Jul 20, 2024

Validations

  • I have checked for similar feature requests and could not find any.
  • I have made sure this is not an already-existing feature.

Description

I separate lines and fills into different layers so that the future, if I want to update either, the other would not be affected in the process.

Each of the layers are added as a Mesh. I then created a MeshGroup and added them in as its children.

When I export my puppet, the two layers take up separate spaces on the atlas screen. If there is a way to lay the line layer onto the fill layer, that would save space.

Suggested solution

For every Mesh in a MeshGroup, if the mesh does not have any vertices, they will merge in the atlas by default.

  • Problem: new meshes start out with 4 vertices forming a rectangle around a mesh. Also, it cannot be edited to be without any meshes.

Alternative solution

I have few other ideas on this:

  1. Add an option to merge 2 Meshes into one (see below).
  2. Add a slow importing option, where you can select which group layers and/or regular layers from .psd or .kra should be added as a single Mesh node.
    • This can be reserved for another request.
  3. Let a Mesh take more than one texture as Albedo.
  4. Create a seperate .kra/.psd file where the lines and fills are merged.
  5. Add an option in Composite Node to merge all children mesh nodes on atlas.

Additional Context

  • A few more this to consider to decide on the solution:
    • How is a layer (aka the texture, or drawable) saved in relation to Mesh Node? Is it stored under the node, or separately as the node links to the texture?
  • In the first place, is keeping the lines and fills as separate layers in .kra an overkill?
@mechPenSketch mechPenSketch added Enhancement New feature or request Triage PR/Issue needs to be triaged. labels Jul 20, 2024
@mechPenSketch
Copy link
Author

mechPenSketch commented Jul 25, 2024

I think Solution 2 is the best, so I'll be elaborating on that:

  • First, on the Nodes panel, select a Mesh Node. The scene should have the "Edit Mesh" button on the bottom-left.
  • Next, drag another Node to the scene. "Edit Mesh" should be turned into "Copy Mesh". Another button "Merge Node" would appear beside "Copy Node"
    • From the looks of incViewportModelConfirmBar(), "Edit Mesh" and "Copy Mesh" share the same button.
      • What does it mean by "parameter is armed", and should it hide "Merge Node" too?
      • Since incTooltip(...) takes "Edit Mesh" and "Copy Mesh" as possible arguments, I should look into creator.widgets.tooltip too.
      • igButton(...) could be where the button is drawn. Need to look further in creator.widgets.button.
        • It's not there. Where else can it be in?
        • What does igButton(...) do? Does it draw the button? Can I draw another button by calling it again?
  • Drag into "Merge Node". The dragged node will merge into the selected node.
    • The Dragged Node should be a Mesh Node
      • Look at creator.panels.inspector's incInspectorTextureSlot(...) to see how the drag-drop is identified as an image.
        • void applyTextureToSlot(....) seems to be defined within incInspectorTextureSlot(...).
      • Where can I find the class ImGuiPayload, and what Data does it have?
      • Or look at creator.panels.nodes and see drag-drop data would be given when a node is dragged out.
      • But what if more than one node is dragged?
      • Maybe it doesn't need to be a Mesh as long as it is drawable?
    • On the selected node, the dragged node's Albedo, Emissive and Bumpmap will be laid on top of the selected's respective textures.
      • Look at creator.panels.inspector's incInspectorTextureSlot(...), line 696 to see how a texture is loaded into a slot.
      • Where can I find Drawable as a class? Is there a way I can combine two Drawables together?
    • The dragged node will be deleted.
      • Look at how a node is deleted in creator.panel.node, incDeleteChildrenWithHistory(Node[] ns) on line 376.
    • Merging will be recorded as an action.
      • It can be added into creator.actions.node.
        • ...except it already has merge(..) as a function, specifically for other actions.

@mechPenSketch
Copy link
Author

mechPenSketch commented Jul 30, 2024

To help me find igButton(...), I've decided to open Visual Studios. I haven't used it for a long time, so I brought it up to date, even accounting for CMake and DLang. However, there are syntax errors in the code, so vs can't go to where igButton(...) is defined.

To start, I want to look at lines 22 and 24 in source/app.d:

import inochi2d; // Error: can only import from a module, not from package inochi2d.inochi2d
....
import il18n; // Error: can only import from a module, not from package il18n.il18n

The root problem is that there are no files whose modules is inochi2d or il18n. No inochi2d.d or il18n.d in the folder containing app.d, nor inochi2d.d or il18n.d folders containing package.d.

I've opened up the project by local folder. Is there any steps I've missed out?


I've switch to vs code. Apparantly, it's undocumented, but binding to C.


I've cross-referred with creator.viewport.vertex's void incViewportVertexConfirmBar(). Looks like igButton(...) generates a button in the process while checking whether it's pressed.

@mechPenSketch
Copy link
Author

After looking into discord, I've learnt that the mesh nodes don't really need to be merged when they could be brought under a Composition Node as its children. They would still be separated under atlas, though.

@r888800009
Copy link
Contributor

I was wondering why not just merge the layers in the first place?

If you just want to keep the layers, you may be able to write a script in the drawing software to merge the layers then export.

When you want to update, you can skip merging in the previous process. Instead, merge the PSD into the current work, which will add the layer as a new node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Triage PR/Issue needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants