mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-25 14:44:22 +00:00
Added support for Qubicle Model files.
This commit is contained in:
1 parent
477b77e7e1
commit
7450370d99
7 files changed
+1006
-13
No files matched your search
@@ -35,6 +35,11 @@ public class BlockCoord implements Comparable<BlockCoord>
|
||||
{
|
||||
}
|
||||
|
||||
public static BlockCoord fromAxes(int[] ia)
|
||||
{
|
||||
return new BlockCoord(ia[2], ia[0], ia[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -146,6 +151,36 @@ public class BlockCoord implements Comparable<BlockCoord>
|
||||
{
|
||||
return offset(side, -amount);
|
||||
}
|
||||
|
||||
public int getSide(int side) {
|
||||
switch(side) {
|
||||
case 0:
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
case 3:
|
||||
return z;
|
||||
case 4:
|
||||
case 5:
|
||||
return x;
|
||||
}
|
||||
throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
|
||||
public BlockCoord setSide(int s, int v)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
case 0:
|
||||
case 1: y = v; break;
|
||||
case 2:
|
||||
case 3: z = v; break;
|
||||
case 4:
|
||||
case 5: x = v; break;
|
||||
default: throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public static final BlockCoord[] sideOffsets = new BlockCoord[]{
|
||||
new BlockCoord( 0,-1, 0),
|
||||
|
||||
@@ -69,7 +69,36 @@ public class CuboidCoord implements Iterable<BlockCoord>
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getSide(int s)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
case 0: return min.y;
|
||||
case 1: return max.y;
|
||||
case 2: return min.z;
|
||||
case 3: return max.z;
|
||||
case 4: return min.x;
|
||||
case 5: return max.x;
|
||||
}
|
||||
throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
|
||||
public CuboidCoord setSide(int s, int v)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
case 0: min.y = v; break;
|
||||
case 1: max.y = v; break;
|
||||
case 2: min.z = v; break;
|
||||
case 3: max.z = v; break;
|
||||
case 4: min.x = v; break;
|
||||
case 5: max.x = v; break;
|
||||
default: throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getVolume()
|
||||
{
|
||||
return (max.x-min.x+1)*(max.y-min.y+1)*(max.z-min.z+1);
|
||||
@@ -108,9 +137,14 @@ public class CuboidCoord implements Iterable<BlockCoord>
|
||||
return new CuboidCoord(min.copy(), max.copy());
|
||||
}
|
||||
|
||||
public Cuboid6 bounds()
|
||||
{
|
||||
return new Cuboid6(min.x, min.y, min.z, max.x+1, max.y+1, max.z+1);
|
||||
}
|
||||
|
||||
public AxisAlignedBB toAABB()
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x+1, max.y+1, max.z+1);
|
||||
return bounds().toAABB();
|
||||
}
|
||||
|
||||
public void set(BlockCoord min, BlockCoord max)
|
||||
|
||||
@@ -18,6 +18,22 @@ public class Rectangle4i
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public int x1() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y1() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int x2() {
|
||||
return x+w-1;
|
||||
}
|
||||
|
||||
public int y2() {
|
||||
return y+h-1;
|
||||
}
|
||||
|
||||
public Rectangle4i offset(int dx, int dy)
|
||||
{
|
||||
@@ -25,13 +41,39 @@ public class Rectangle4i
|
||||
y+=dy;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public Rectangle4i with(int px, int py)
|
||||
{
|
||||
if(x > px) x = px;
|
||||
if(y > py) y = py;
|
||||
if(x + w <= px) w = px-x+1;
|
||||
if(y + h <= py) h = py-y+1;
|
||||
return include(px, py);
|
||||
}
|
||||
|
||||
public Rectangle4i include(int px, int py) {
|
||||
if(px < x) expand(px-x, 0);
|
||||
if(px >= x+w) expand(px-x-w+1, 0);
|
||||
if(py < y) expand(0, py-y);
|
||||
if(py >= y+h) expand(0, py-y-h+1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Rectangle4i include(Rectangle4i r) {
|
||||
include(r.x, r.y);
|
||||
return include(r.x2(), r.y2());
|
||||
}
|
||||
|
||||
public Rectangle4i expand(int px, int py) {
|
||||
if(px > 0)
|
||||
w+=px;
|
||||
else {
|
||||
x+=px;
|
||||
w-=px;
|
||||
}
|
||||
if(py > 0)
|
||||
h+=py;
|
||||
else {
|
||||
y+=py;
|
||||
h-=py;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -42,7 +84,13 @@ public class Rectangle4i
|
||||
|
||||
public boolean intersects(Rectangle4i r)
|
||||
{
|
||||
return x <= r.x+r.w && r.x <= x+w &&
|
||||
y <= r.y+r.h && r.y <= y+h;
|
||||
return r.x+r.w > x &&
|
||||
r.x < x+w &&
|
||||
r.y+r.h > y &&
|
||||
r.y < y+h;
|
||||
}
|
||||
|
||||
public int area() {
|
||||
return w * h;
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,11 @@ public class Vector3
|
||||
z = vec.z;
|
||||
}
|
||||
|
||||
public Vector3(double[] da)
|
||||
{
|
||||
this(da[0], da[1], da[2]);
|
||||
}
|
||||
|
||||
public Vector3(Vec3 vec)
|
||||
{
|
||||
x = vec.xCoord;
|
||||
@@ -84,6 +89,11 @@ public class Vector3
|
||||
return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5);
|
||||
}
|
||||
|
||||
public static Vector3 fromAxes(double[] da)
|
||||
{
|
||||
return new Vector3(da[2], da[0], da[1]);
|
||||
}
|
||||
|
||||
public Vector3 set(double d, double d1, double d2)
|
||||
{
|
||||
x = d;
|
||||
@@ -100,6 +110,36 @@ public class Vector3
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSide(int side) {
|
||||
switch(side) {
|
||||
case 0:
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
case 3:
|
||||
return z;
|
||||
case 4:
|
||||
case 5:
|
||||
return x;
|
||||
}
|
||||
throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
|
||||
public Vector3 setSide(int s, double v)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
case 0:
|
||||
case 1: y = v; break;
|
||||
case 2:
|
||||
case 3: z = v; break;
|
||||
case 4:
|
||||
case 5: x = v; break;
|
||||
default: throw new IndexOutOfBoundsException("Switch Falloff");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public double dotProduct(Vector3 vec)
|
||||
{
|
||||
double d = vec.x * x + vec.y * y + vec.z * z;
|
||||
|
||||
Reference in new issue
Block a user