Skip to content

Commit

Permalink
feat: evangelion
Browse files Browse the repository at this point in the history
  • Loading branch information
HamaIndustries committed Nov 3, 2024
1 parent 840ebdf commit 47e91b9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,12 @@ private void addSegment(BBModelTree segment, PoseStack matrices) {
String cname = nextNode.node.name();
matrices.pushPose();
{
matrices.mulPose(new Quaternionf().rotationZYX((float) segment.node.rotation().z() * Mth.DEG_TO_RAD, (float) segment.node.rotation().y() * Mth.DEG_TO_RAD, (float) segment.node.rotation().x() * Mth.DEG_TO_RAD).invert());
matrices.translate(-segment.node.origin().x, -segment.node.origin().y, -segment.node.origin().z);
segmentQuads.add(ModelBaker.bake(segment, n -> !n.node.name().equals(cname), matrices));
segmentQuads.add(ModelBaker.bakeNoTransform(new ArrayList<>(), segment, matrices, n -> !n.node.name().equals(cname)));
addSegment(nextNode, matrices);
}
matrices.popPose();
addSegment(nextNode, matrices);
} else {
matrices.pushPose();
{
matrices.mulPose(new Quaternionf().rotationZYX((float) segment.node.rotation().z() * Mth.DEG_TO_RAD, (float) segment.node.rotation().y() * Mth.DEG_TO_RAD, (float) segment.node.rotation().x() * Mth.DEG_TO_RAD).invert());
matrices.translate(-segment.node.origin().x, -segment.node.origin().y, -segment.node.origin().z);
segmentQuads.add(ModelBaker.bake(segment, n -> true, matrices));
}
matrices.popPose();
segmentQuads.add(ModelBaker.bakeNoTransform(new ArrayList<>(), segment, matrices, n -> true));
}
}

Expand All @@ -90,10 +82,9 @@ public void render(MechaEntity mecha, PoseStack matrices, MultiBufferSource buff
yaw = Mth.PI - yaw;
float calcPitch = interpretPitch(bone, yaw, parentYaw);

matrices.mulPose(new Quaternionf().rotateZYX(0, yaw, calcPitch + Mth.PI));
var seg = segmentNodes.get(i).origin();
matrices.mulPose(new Quaternionf().rotateZYX(0, yaw, calcPitch + Mth.PI));
matrices.translate(-seg.x, -seg.y, -seg.z);

PartRenderer.renderQuads(quadArrays.get(i), texture, matrices.last(), bufferSource, color, packedLight, packedOverlay);
}
matrices.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public static List<Quad> bake(BBModelTree tree, Predicate<BBModelTree> filter, P
return bake(new ArrayList<>(), tree, poseStack, filter);
}

public static List<Quad> bakeNoTransform(List<Quad> quads, BBModelTree tree, PoseStack poseStack, Predicate<BBModelTree> filter) {
if (!filter.test(tree)) return quads;

for (Element element : tree.elements()) addElement(quads, poseStack, element);
for (BBModelTree child : tree.children()) bake(quads, child, poseStack, filter);

return quads;
}

private static List<Quad> bake(List<Quad> quads, BBModelTree tree, PoseStack poseStack, Predicate<BBModelTree> filter) {
if (!filter.test(tree)) return quads;
Vector3fc origin = tree.node.origin().toVector3f();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ChassisPart extends AbstractMechaPart {
public final List<Vec3> debugStepTargets = new ArrayList<>();
protected final DirectionState direction = new DirectionState(Math.PI);
protected final ChassisSchematic schematic;
protected final double followTolerance = 4; // temp: related to model diameter
protected final double followTolerance = 20; // temp: related to model diameter
protected final double moveSpeed;
protected List<ChassisLeg> legs;
protected Vec3 movement = Vec3.ZERO;
Expand Down Expand Up @@ -151,7 +151,7 @@ public void serverTick() {
} else {
// otherwise we are facing it, so we ask our legs to move us towards it.
// temp: set from model data
float stepOffsetDistance = 0.5f;
float stepOffsetDistance = 10f;
legMap.setMapOffset(new Vec3(0, 0, stepOffsetDistance));
legMap.setMapRotation(0);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public void serverTick() {
// move to centroid
if (prevPos == Vec3.ZERO) prevPos = core.position();
var curPos = IKUtil.f2m(skeleton.getChain(0).getBone(0).getEndLocation());
float ticksPerBlock = 30;
float ticksPerBlock = 2;
var delta = desiredPos.subtract(curPos);
Vec3f tgt = IKUtil.m2f(curPos.add(delta.normalize().scale(1 / ticksPerBlock)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void tick() {
*/
if (!ArmisticeDebugValues.ikSolving) return;

float ticksPerBlock = 15;
float ticksPerBlock = 1;
Vec3 mapTarget = chassis.legMap().legTarget(legIndex);
Vec3 tip = tipPos();
float mapDelta = (float) mapTarget.distanceTo(tip);
Expand All @@ -175,7 +175,7 @@ public void tick() {
ticksToStep--;
float stepPercent = (totalTicksToStep - ticksToStep) / totalTicksToStep;
tickTarget = prevStepTarget.add(finalStepTarget.subtract(prevStepTarget).scale(stepPercent))
.add(0, GeometryUtil.easedCurve(stepPercent), 0);
.add(0, GeometryUtil.easedCurve(stepPercent) * 5, 0);

} else { //final tick
ticksToStep = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LegMap {
protected final Vec3 centroidOffset;
protected Vec3 mapOffset = Vec3.ZERO;
protected float mapYaw = 0;
protected double stepTolerance = 0.5;
protected double stepTolerance = 3;
protected double[] directionWeights;

public LegMap(MechaModelData data, ChassisPart chassis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public record OutlinerNode(
List<Either<OutlinerNode, String>> children,
Map<String, Double> parameters
) {
public static final float BASE_SCALE_FACTOR = 1f / 16;
public static final float BASE_SCALE_FACTOR = 1f / 4;

public static final Codec<OutlinerNode> CODEC =
Codec.recursive(
Expand Down

0 comments on commit 47e91b9

Please sign in to comment.