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

You can now specify a pivot point for bending. #41

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions 1.17-update.md

This file was deleted.

10 changes: 0 additions & 10 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"

modCompileOnly("maven.modrinth:3dskinlayers:1.5.2-1.19.3-fabric") //TODO
}

sourceSets {
main {
java {
//exclude "io/github/kosmx/bendylib/compat/tr7zw"
}
}
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ class Data{
public int u, v;
public boolean mirror = false;
public int textureWidth, textureHeight; //That will be int
public int pivot;
//public float bendX, bendY, bendZ;

public Data(){}

public Data(int u, int v, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float extraX, float extraY, float extraZ, boolean mirror, float textureWidth, float textureHeight){
public Data(int u, int v, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float extraX, float extraY, float extraZ, boolean mirror, float textureWidth, float textureHeight, int pivot) {
this.u = u;
this.v = v;
this.x = x;
Expand All @@ -36,10 +37,14 @@ public Data(int u, int v, float x, float y, float z, float sizeX, float sizeY, f
this.extraY = extraY;
this.extraZ = extraZ;
this.mirror = mirror;
this.pivot = pivot;
//Casting
this.textureWidth = (int) textureWidth;
this.textureHeight = (int) textureHeight;
}

public Data(int u, int v, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float extraX, float extraY, float extraZ, boolean mirror, float textureWidth, float textureHeight) {
this(u, v, x, y, z, sizeX, sizeY, sizeZ, extraX, extraY, extraZ, mirror, textureWidth, textureHeight, -1);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,28 @@ public BendableCuboid build(Data data, BuildableBendable builder){
int p = data.v;
int q = (int) (data.v + data.sizeZ);
int r = (int) (data.v + data.sizeZ + data.sizeY);
createAndAddQuads(planes, positions, new Vector3f[]{vertex6, vertex5, vertex2}, k, p, l, q, data.textureWidth, data.textureHeight, data.mirror, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex3, vertex4, vertex7}, l, q, m, p, data.textureWidth, data.textureHeight, data.mirror, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex1, vertex5, vertex4}, j, q, k, r, data.textureWidth, data.textureHeight, data.mirror, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex2, vertex1, vertex3}, k, q, l, r, data.textureWidth, data.textureHeight, data.mirror, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex6, vertex2, vertex7}, l, q, n, r, data.textureWidth, data.textureHeight, data.mirror, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex5, vertex6, vertex8}, n, q, o, r, data.textureWidth, data.textureHeight, data.mirror, data);

createAndAddQuads(planes, positions, new Vector3f[]{vertex6, vertex5, vertex2}, k, p, l, q, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex3, vertex4, vertex7}, l, q, m, p, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex1, vertex5, vertex4}, j, q, k, r, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex2, vertex1, vertex3}, k, q, l, r, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex6, vertex2, vertex7}, l, q, n, r, data);
createAndAddQuads(planes, positions, new Vector3f[]{vertex5, vertex6, vertex8}, n, q, o, r, data);

Vector3f pivot = new Vector3f(0, 0, 0);
if (data.pivot >= 0) {
float size = direction.step().mul(maxX - minX, maxY - minY, maxZ - minZ).length();
if (data.pivot <= size) {
pivot = direction.step().mul(size - (data.pivot * 2));
vertex7 = vertex7.sub(pivot);
}
}
boolean bl = direction == Direction.UP || direction == Direction.SOUTH || direction == Direction.EAST;
Plane aPlane = new Plane(direction.step(), vertex7);
Plane bPlane = new Plane(direction.step(), vertex1);
boolean bl = direction == Direction.UP || direction == Direction.SOUTH || direction == Direction.EAST;
float fullSize = - direction.step().dot(vertex1) + direction.step().dot(vertex7);
float bendX = ((float) data.sizeX + data.x + data.x)/2;
float bendY = ((float) data.sizeY + data.y + data.y)/2;
float bendZ = ((float) data.sizeZ + data.z + data.z)/2;
float bendX = (data.sizeX + data.x + data.x - pivot.x())/2;
float bendY = (data.sizeY + data.y + data.y - pivot.y())/2;
float bendZ = (data.sizeZ + data.z + data.z - pivot.z())/2;
return builder.build(planes.toArray(new Quad[0]), positions.values().toArray(new RememberingPos[0]), minX, minY, minZ, maxX, maxY, maxZ, bendX, bendY, bendZ, direction, bl ? aPlane : bPlane, bl ? bPlane : aPlane, fullSize);
}

Expand All @@ -196,7 +204,7 @@ public BendableCuboid build(Data data) {
}

//edge[2] can be calculated from edge 0, 1, 3...
private void createAndAddQuads(Collection<Quad> quads, HashMap<Vector3f, RememberingPos> positions, Vector3f[] edges, int u1, int v1, int u2, int v2, float squishU, float squishV, boolean flip, Data data){
private void createAndAddQuads(Collection<Quad> quads, HashMap<Vector3f, RememberingPos> positions, Vector3f[] edges, int u1, int v1, int u2, int v2, Data data){
int du = u2 < u1 ? 1 : -1;
int dv = v1 < v2 ? 1 : -1;
for(int localU = u2; localU != u1; localU += du){
Expand Down
2 changes: 0 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ dependencies {
modLocalRuntime "com.terraformersmc:modmenu:9.0.0"
// modLocalRuntime "maven.modrinth:skinswapper:3.12"

modCompileOnly modLocalRuntime("maven.modrinth:3dskinlayers:1.5.2-1.19.3-fabric")

//modLocalRuntime "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}"
// modLocalRuntime "dev.kosmx.player-anim:player-animation-lib-fabric:0.4.0-test1"
//modLocalRuntime "maven.modrinth:emotecraft:2.2.5-MC1.19.2-fabric"
Expand Down
18 changes: 1 addition & 17 deletions fabric/src/main/java/io/github/kosmx/bendylib/fabric/Init.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
package io.github.kosmx.bendylib.fabric;

import io.github.kosmx.bendylib.compat.tr7zw.TDSkinCompat;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Init implements ClientModInitializer {
public static Logger LOGGER = LoggerFactory.getLogger("bendy-lib");

@Override
public void onInitializeClient() {
if (FabricLoader.getInstance().isModLoaded("skinlayers")) {
LOGGER.info("Initializing 3D Skin Layers compatibility");

try {
TDSkinCompat.init();
} catch(NoClassDefFoundError|ClassNotFoundException e) {
LOGGER.error("Failed to initialize 3D Skin Layers compatibility");
}
}
}
public void onInitializeClient() {}
}
2 changes: 0 additions & 2 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ dependencies {

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }

//modCompileOnly modLocalRuntime("maven.modrinth:3dskinlayers:1.5.2-1.19.3-forge")
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
package io.github.kosmx.bendylib.neoforge;

import io.github.kosmx.bendylib.compat.tr7zw.TDSkinCompat;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Mod(value = "bendylib", dist = Dist.CLIENT)
public class ForgeModInterface {
public static Logger LOGGER = LoggerFactory.getLogger("bendy-lib");

public ForgeModInterface() {
if (ModList.get().isLoaded("skinlayers3d")) {
LOGGER.info("Initializing 3D Skin Layers compatibility");

try {
TDSkinCompat.init();
} catch(NoClassDefFoundError|ClassNotFoundException e) {
LOGGER.error("Failed to initialize 3D Skin Layers compatibility");
}
}
}
public ForgeModInterface() {}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx4G

mod_version=5.0
mod_version=5.1
maven_group=io.github.kosmx.bendy-lib
archives_base_name=bendy-lib

Expand Down
Loading