Skip to content

Commit

Permalink
Add two missing expand exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
Desoroxxx committed Nov 10, 2024
1 parent da70ba9 commit 54c9477
Show file tree
Hide file tree
Showing 2 changed files with 218 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ tasks {
inputs.properties(expandProperties)

filesMatching("**/*.*") {
val exclusions = listOf(".png", ".obj", ".frag", ".ogg", "craftingmappings.json")
val exclusions = listOf(".png", "_at.cfg", ".refmap.json", ".obj", ".frag", ".ogg", "craftingmappings.json")
if (!exclusions.any { path.endsWith(it) })
expand(expandProperties)
}
Expand Down
217 changes: 217 additions & 0 deletions src/main/java/com/paneedah/mwc/rendering/Transform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
package com.paneedah.mwc.rendering;

import com.paneedah.weaponlib.RenderContext;
import com.paneedah.weaponlib.RenderableState;
import org.lwjgl.opengl.GL11;

import java.util.function.Consumer;
import java.util.function.Supplier;

public class Transform {

public static final Transform NULL = new Transform().withPosition(0, 0, 0).withRotation(0, 0, 0).withRotationPoint(0, 0, 0).withScale(1, 1, 1);

private double[] scale = new double[3];
private double[] rotation = new double[3];
private double[] position = new double[3];
private double[] rotationPoint = new double[3];

public Transform() {


}

public Transform withScale(double x, double y, double z) {
scale[0] = x;
scale[1] = y;
scale[2] = z;
return this;
}

public Transform withPosition(double x, double y, double z) {
position[0] = x;
position[1] = y;
position[2] = z;
return this;
}

/**
* When going from BB edit mode to the game, the X and Y rotations are inverted. This method will automatically do
* that for you.
*
* @param x
* @param y
* @param z
*
* @return
*/
public Transform withBBRotation(double x, double y, double z) {
rotation[0] = -x;
rotation[1] = -y;
rotation[2] = z;
return this;
}

public Transform withRotation(double x, double y, double z) {
rotation[0] = x;
rotation[1] = y;
rotation[2] = z;
return this;
}

public Transform addTransformConditional(Supplier<Boolean> condition, double x, double y, double z) {
if (!condition.get()) {

Check warning on line 63 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-unboxing

Auto-unboxing `condition.get()`
return this;
}
return addTransform(x, y, z);
}

public Transform addTransform(double x, double y, double z) {
position[0] += x;
position[1] += y;
position[2] += z;
return this;
}


public Transform withRotationPoint(double x, double y, double z) {
rotationPoint[0] = x;
rotationPoint[1] = y;
rotationPoint[2] = z;
return this;
}

/*
* Transforms
*/


public double getPositionX() {
return position[0];
}

public double getPositionY() {
return position[1];
}

public double getPositionZ() {
return position[2];
}

/*
* Rotations
*/

public double getRotationX() {
return rotation[0];
}

public double getRotationY() {
return rotation[1];
}

public double getRotationZ() {
return rotation[2];
}

/*
* Scale
*/

public double getScaleX() {
return scale[0];
}

public double getScaleY() {
return scale[1];
}

public double getScaleZ() {
return scale[2];
}

/*
* Rotation Point
*/

public double getRotationPointX() {
return rotationPoint[0];
}

public double getRotationPointY() {
return rotationPoint[1];
}

public double getRotationPointZ() {
return rotationPoint[2];
}


private double[] copyArray(double[] array) {
double[] newArray = new double[array.length];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
}

public void set(Transform t) {
this.position = copyArray(t.position);
this.rotation = copyArray(t.rotation);
this.rotationPoint = copyArray(t.rotationPoint);
this.scale = copyArray(t.scale);
}

public Transform copy() {
Transform nT = new Transform();
nT.position = copyArray(position);
nT.rotation = copyArray(rotation);
nT.rotationPoint = copyArray(rotationPoint);
nT.scale = copyArray(scale);
return nT;
}

/*
* Export to VMW
*/

public Consumer<RenderContext<RenderableState>> getAsPosition() {
return (renderContext) -> {
doGLDirect();
/*
GL11.glTranslated(getPositionX(), getPositionY(), getPositionZ());
GL11.glTranslated(getRotationPointX(), getRotationPointY(), getRotationPointZ());
GL11.glRotated(getRotationZ(), 0, 0, 1);
GL11.glRotated(getRotationY(), 0, 1, 0);
GL11.glRotated(getRotationX(), 1, 0, 0);
GL11.glTranslated(-getRotationPointX(), -getRotationPointY(), -getRotationPointZ());
GL11.glScaled(getScaleX(), getScaleY(), getScaleZ());
*/
};

}

public void doGLDirect() {
GL11.glTranslated(getPositionX(), getPositionY(), getPositionZ());
GL11.glTranslated(getRotationPointX(), getRotationPointY(), getRotationPointZ());
GL11.glRotated(getRotationZ(), 0, 0, 1);
GL11.glRotated(getRotationY(), 0, 1, 0);
GL11.glRotated(getRotationX(), 1, 0, 0);
GL11.glTranslated(-getRotationPointX(), -getRotationPointY(), -getRotationPointZ());
GL11.glScaled(getScaleX(), getScaleY(), getScaleZ());
}

public void printTransform() {


String result = "new Transform()" +
String.format("\n.withPosition(%ff, %ff, %ff)", getPositionX(), getPositionY(),

Check warning on line 206 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getPositionY()`

Check warning on line 206 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getPositionX()`
getPositionZ()) +

Check warning on line 207 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getPositionZ()`
String.format("\n.withRotation(%ff, %ff, %ff)", getRotationX(), getRotationY(),

Check warning on line 208 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationY()`

Check warning on line 208 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationX()`
getRotationZ()) +

Check warning on line 209 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationZ()`
String.format("\n.withRotationPoint(%ff, %ff, %ff)", getRotationPointX(), getRotationPointY(), getRotationPointZ()) +

Check warning on line 210 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationPointX()`

Check warning on line 210 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationPointZ()`

Check warning on line 210 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getRotationPointY()`
String.format("\n.withScale(%ff, %ff, %ff)", getScaleX(), getScaleY(), getScaleZ());

Check warning on line 211 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getScaleY()`

Check warning on line 211 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getScaleZ()`

Check warning on line 211 in src/main/java/com/paneedah/mwc/rendering/Transform.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `getScaleX()`

System.out.println("\n" + result);
}


}

0 comments on commit 54c9477

Please sign in to comment.