-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,592 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
common/src/lib/java/dev/engine_room/flywheel/lib/internal/FlwLibLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
package dev.engine_room.flywheel.lib.internal; | ||
|
||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
|
||
import dev.engine_room.flywheel.api.internal.DependencyInjection; | ||
import dev.engine_room.flywheel.lib.transform.PoseTransformStack; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
|
||
public interface FlwLibLink { | ||
FlwLibLink INSTANCE = DependencyInjection.load(FlwLibLink.class, "dev.engine_room.flywheel.impl.FlwLibLinkImpl"); | ||
|
||
Logger getLogger(); | ||
|
||
PoseTransformStack getPoseTransformStackOf(PoseStack stack); | ||
|
||
Map<String, ModelPart> getModelPartChildren(ModelPart part); | ||
|
||
void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
common/src/lib/java/dev/engine_room/flywheel/lib/model/RetexturedMesh.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.engine_room.flywheel.lib.model; | ||
|
||
import org.joml.Vector4fc; | ||
|
||
import dev.engine_room.flywheel.api.model.IndexSequence; | ||
import dev.engine_room.flywheel.api.model.Mesh; | ||
import dev.engine_room.flywheel.api.vertex.MutableVertexList; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
|
||
public record RetexturedMesh(Mesh mesh, TextureAtlasSprite sprite) implements Mesh { | ||
@Override | ||
public int vertexCount() { | ||
return mesh.vertexCount(); | ||
} | ||
|
||
@Override | ||
public void write(MutableVertexList vertexList) { | ||
mesh.write(new RetexturingVertexList(vertexList, sprite)); | ||
} | ||
|
||
@Override | ||
public IndexSequence indexSequence() { | ||
return mesh.indexSequence(); | ||
} | ||
|
||
@Override | ||
public int indexCount() { | ||
return mesh.indexCount(); | ||
} | ||
|
||
@Override | ||
public Vector4fc boundingSphere() { | ||
return mesh.boundingSphere(); | ||
} | ||
|
||
@Override | ||
public void delete() { | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
common/src/lib/java/dev/engine_room/flywheel/lib/model/RetexturingVertexList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.engine_room.flywheel.lib.model; | ||
|
||
import dev.engine_room.flywheel.api.vertex.MutableVertexList; | ||
import dev.engine_room.flywheel.lib.vertex.WrappedVertexList; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
|
||
/** | ||
* A wrapper so that differently textured models from the same mesh tree can share the same backing memory | ||
*/ | ||
public class RetexturingVertexList extends WrappedVertexList { | ||
private final TextureAtlasSprite sprite; | ||
|
||
public RetexturingVertexList(MutableVertexList delegate, TextureAtlasSprite sprite) { | ||
super(delegate); | ||
|
||
this.sprite = sprite; | ||
} | ||
|
||
@Override | ||
public void u(int index, float u) { | ||
super.u(index, sprite.getU(u * 16)); | ||
} | ||
|
||
@Override | ||
public void v(int index, float v) { | ||
super.v(index, sprite.getV(v * 16)); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
common/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ItemModelBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dev.engine_room.flywheel.lib.model.baked; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
|
||
import dev.engine_room.flywheel.api.material.Material; | ||
import dev.engine_room.flywheel.lib.internal.FlwLibXplat; | ||
import dev.engine_room.flywheel.lib.model.SimpleModel; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.world.item.ItemDisplayContext; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
@ApiStatus.NonExtendable | ||
public abstract class ItemModelBuilder { | ||
final ItemStack itemStack; | ||
final BakedModel model; | ||
@Nullable | ||
PoseStack poseStack; | ||
@Nullable | ||
ItemDisplayContext displayContext; | ||
boolean leftHand; | ||
@Nullable | ||
BiFunction<RenderType, Boolean, Material> materialFunc; | ||
|
||
ItemModelBuilder(ItemStack itemStack, BakedModel model) { | ||
this.itemStack = itemStack; | ||
this.model = model; | ||
} | ||
|
||
public static ItemModelBuilder create(ItemStack stack, BakedModel model) { | ||
return FlwLibXplat.INSTANCE.createItemModelBuilder(stack, model); | ||
} | ||
|
||
public ItemModelBuilder poseStack(PoseStack poseStack) { | ||
this.poseStack = poseStack; | ||
return this; | ||
} | ||
|
||
public ItemModelBuilder displayContext(ItemDisplayContext displayContext) { | ||
this.displayContext = displayContext; | ||
return this; | ||
} | ||
|
||
public ItemModelBuilder leftHand(boolean leftHand) { | ||
this.leftHand = leftHand; | ||
return this; | ||
} | ||
|
||
public ItemModelBuilder materialFunc(BiFunction<RenderType, Boolean, Material> materialFunc) { | ||
this.materialFunc = materialFunc; | ||
return this; | ||
} | ||
|
||
public abstract SimpleModel build(); | ||
} |
Oops, something went wrong.