Skip to content

Commit

Permalink
Meshgroup adaptation for creator. (#194)
Browse files Browse the repository at this point in the history
* mesh recalculation: Cleanup algorithm to use matrix-based transformation.

* meshgroup: Added MeshGroup (WIP)

* node: Using "reparent" method to insert node into some parent node.

* Added code to apply all deformation transfer from mesh group to its children on export to INP.

* Added configuration UI for MeshGroup.
  • Loading branch information
seagetch authored Mar 3, 2023
1 parent 757eb65 commit 49bcd84
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
3 changes: 1 addition & 2 deletions source/creator/actions/node.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public:

// Set relative position
if (new_) {
sn.setRelativeTo(new_);
sn.insertInto(new_, pOffset);
sn.reparent(new_, pOffset);
} else sn.parent = null;
}
incActivePuppet().rescanNodes();
Expand Down
3 changes: 3 additions & 0 deletions source/creator/io/inpexport.d
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void incExportINP(Puppet origin, Atlas[] atlasses, string file) {
}
editable.parameters = params;

// Apply all deformation of mesh groups to its children.
editable.applyDeformToChildren();

// Discard invalid lanes
foreach(ref Animation animation; editable.getAnimations()) {
animation.finalize(editable);
Expand Down
23 changes: 23 additions & 0 deletions source/creator/panels/inspector.d
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ protected:
if (SimplePhysics part = cast(SimplePhysics)node) {
incInspectorModelSimplePhysics(part);
}

// Node MeshGroup Section
if (MeshGroup group = cast(MeshGroup)node) {
incInspectorModelMeshGroup(group);
}
}

break;
Expand Down Expand Up @@ -1125,6 +1130,24 @@ void incInspectorModelSimplePhysics(SimplePhysics node) {
incEndCategory();
}


void incInspectorModelMeshGroup(MeshGroup node) {
if (incBeginCategory(__("MeshGroup"))) {


igSpacing();

bool dynamic = node.dynamic;
if (igCheckbox(__("Use post-processing mode (slower)"), &dynamic)) {
node.switchMode(dynamic);
}

// Padding
igSpacing();
}
incEndCategory();
}

//
// MODEL MODE ARMED
//
Expand Down
4 changes: 4 additions & 0 deletions source/creator/panels/nodes.d
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ protected:
igSameLine(0, 2);
if (igMenuItem(__("Camera"), "", false, true)) incAddChildWithHistory(new ExCamera(n), n);

incText(incTypeIdToIcon("MeshGroup"));
igSameLine(0, 2);
if (igMenuItem(__("MeshGroup"), "", false, true)) incAddChildWithHistory(new MeshGroup(n), n);

igEndMenu();
}

Expand Down
1 change: 1 addition & 0 deletions source/creator/utils/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ string incTypeIdToIcon(string typeId) {
case "Mask": return "\ue14e";
case "SimplePhysics": return "\ue922";
case "Camera": return "";
case "MeshGroup": return "";
default: return "\ue97a";
}
}
9 changes: 8 additions & 1 deletion source/creator/viewport/vertex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,16 @@ void incViewportVertexDraw(Camera camera) {
if (targets.length > 0) {
foreach (target; targets) {
if (Part part = cast(Part)target) {

// Draw albedo texture at 0, 0
inDrawTextureAtPosition(part.textures[0], vec2(0, 0));
} else if (MeshGroup mgroup = cast(MeshGroup)target) {
Transform transform = mgroup.globalTransform;
transform.translation.x *= -1;
transform.translation.y *= -1;
transform.update();
mgroup.setOneTimeTransform(&transform);
mgroup.draw();
mgroup.setOneTimeTransform(null);
}
}
}
Expand Down

0 comments on commit 49bcd84

Please sign in to comment.