-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#133] Finished intensity calculation. Removed intensity and added of…
…fset as parameter.
- Loading branch information
1 parent
2f7bc01
commit d2c0260
Showing
6 changed files
with
130 additions
and
36 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
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
64 changes: 64 additions & 0 deletions
64
src/main/java/net/landofrails/landofsignals/utils/VecUtil.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,64 @@ | ||
package net.landofrails.landofsignals.utils; | ||
|
||
import cam72cam.mod.math.Vec3d; | ||
import cam72cam.mod.util.FastMath; | ||
import util.Matrix4; | ||
|
||
public class VecUtil { | ||
private VecUtil() { | ||
// Disable construction since java does not have static classes | ||
} | ||
|
||
public static Vec3d fromYaw(double distance, float yaw) { | ||
return new Vec3d(Math.sin(Math.toRadians(yaw)) * distance, 0, Math.cos(Math.toRadians(yaw)) * distance); | ||
} | ||
public static float toYaw(Vec3d delta) { | ||
float yaw = (float) Math.toDegrees(FastMath.atan2(delta.x, delta.z)); | ||
return (yaw + 360f) % 360f; | ||
} | ||
public static Vec3d rotateYaw(Vec3d pos, float rotationYaw) { | ||
if (rotationYaw - 90 == 0) { | ||
return pos; | ||
} | ||
//return new Matrix4().rotate(Math.toRadians(rotationYaw-90), 0, 1, 0).apply(pos); | ||
double cos = Math.cos(Math.toRadians(rotationYaw - 90)); | ||
double sin = Math.sin(Math.toRadians(rotationYaw - 90)); | ||
return new Vec3d( | ||
cos * pos.x + sin * pos.z, | ||
pos.y, | ||
-sin * pos.x + cos * pos.z | ||
); | ||
} | ||
public static Vec3d rotatePitch(Vec3d pos, float rotationPitch) { | ||
if (Math.abs(rotationPitch) < 0.01) { | ||
return pos; | ||
} | ||
// TODO optimize me! | ||
return new Matrix4().rotate(Math.toRadians(rotationPitch), 0, 0, 1).apply(pos); | ||
} | ||
|
||
public static Vec3d fromWrongYaw(double distance, float yaw) { | ||
return new Vec3d(-Math.sin(Math.toRadians(yaw)) * distance, 0, Math.cos(Math.toRadians(yaw)) * distance); | ||
} | ||
|
||
public static float toWrongYaw(Vec3d delta) { | ||
float yaw = (float) Math.toDegrees(FastMath.atan2(-delta.x, delta.z)); | ||
return (yaw + 360f) % 360f; | ||
} | ||
public static float toPitch(Vec3d delta) { | ||
float yaw = (float) Math.toDegrees(FastMath.atan2(Math.sqrt(delta.z * delta.z + delta.x * delta.x), delta.y)); | ||
return (yaw + 360f) % 360f; | ||
} | ||
|
||
public static Vec3d rotateWrongYaw(Vec3d pos, float rotationYaw) { | ||
return fromWrongYaw(pos.x, rotationYaw).add(fromWrongYaw(pos.z, rotationYaw + 90).add(0, pos.y, 0)); | ||
} | ||
|
||
public static Vec3d fromWrongYawPitch(float distance, float rotationYaw, float rotationPitch) { | ||
return fromWrongYaw(distance, rotationYaw).add(0, Math.tan(Math.toRadians(rotationPitch)) * distance, 0); | ||
} | ||
|
||
public static Vec3d between(Vec3d front, Vec3d rear) { | ||
return new Vec3d((front.x + rear.x) / 2, (front.y + rear.y) / 2, (front.z + rear.z) / 2); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../resources/assets/landofsignals/models/block/landofsignals/light_flare/lightflare.bbmodel
Large diffs are not rendered by default.
Oops, something went wrong.
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