use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class TileKillerJoe method getHooverBounds.
@Nonnull
private AxisAlignedBB getHooverBounds() {
if (hooverBounds == NULL_AABB) {
double killerJoeHooverXpHeight = KillerJoeConfig.killerJoeHooverXpHeight.get();
double killerJoeHooverXpLength = KillerJoeConfig.killerJoeHooverXpLength.get();
double killerJoeHooverXpWidth = KillerJoeConfig.killerJoeHooverXpWidth.get();
BoundingBox bb = new BoundingBox(getLocation());
Vector3d min = bb.getMin();
Vector3d max = bb.getMax();
max.y += killerJoeHooverXpHeight;
min.y -= killerJoeHooverXpHeight;
EnumFacing facingDir = facing;
if (ForgeDirectionOffsets.isPositiveOffset(facingDir)) {
max.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
min.add(ForgeDirectionOffsets.forDir(facingDir));
} else {
min.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
max.add(ForgeDirectionOffsets.forDir(facingDir));
}
if (facingDir.getFrontOffsetX() == 0) {
min.x -= killerJoeHooverXpWidth * 2;
max.x += killerJoeHooverXpWidth * 2;
} else {
min.z -= killerJoeHooverXpWidth * 2;
max.z += killerJoeHooverXpWidth * 2;
}
hooverBounds = new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
}
return hooverBounds;
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class ConduitGeometryUtil method createConduitBounds.
@Nonnull
private BoundingBox createConduitBounds(Class<? extends IConduit> type, EnumFacing dir, boolean isStub, @Nonnull Offset offset) {
BoundingBox bb = CORE_BOUNDS;
Vector3d min = bb.getMin();
Vector3d max = bb.getMax();
if (dir != null) {
switch(dir) {
case WEST:
min.x = isStub ? Math.max(0, bb.minX - STUB_WIDTH) : 0;
max.x = bb.minX;
break;
case EAST:
min.x = bb.maxX;
max.x = isStub ? Math.min(1, bb.maxX + STUB_WIDTH) : 1;
break;
case DOWN:
min.y = isStub ? Math.max(0, bb.minY - STUB_HEIGHT) : 0;
max.y = bb.minY;
break;
case UP:
max.y = isStub ? Math.min(1, bb.maxY + STUB_HEIGHT) : 1;
min.y = bb.maxY;
break;
case NORTH:
min.z = isStub ? Math.max(0.0F, bb.minZ - STUB_WIDTH) : 0;
max.z = bb.minZ;
break;
case SOUTH:
max.z = isStub ? Math.min(1F, bb.maxZ + STUB_WIDTH) : 1;
min.z = bb.maxZ;
break;
default:
break;
}
}
Vector3d trans = getTranslation(dir, offset);
min.add(trans);
max.add(trans);
bb = new BoundingBox(VecmathUtil.clamp(min, 0, 1), VecmathUtil.clamp(max, 0, 1));
return bb;
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class ConduitGeometryUtil method getBoundingBox.
@Nonnull
public BoundingBox getBoundingBox(Class<? extends IConduit> type, EnumFacing dir, boolean isStub, Offset offset) {
GeometryKey key = new GeometryKey(dir, isStub, offset, type);
BoundingBox result = boundsCache.get(key);
if (result == null) {
result = createConduitBounds(type, key);
boundsCache.put(key, result);
}
return result;
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class LiquidConduitRenderer method computeFluidOutlineToCache.
public static List<CachableRenderStatement> computeFluidOutlineToCache(CollidableComponent component, Fluid fluid, double scaleFactor, float outlineWidth) {
Map<Fluid, List<CachableRenderStatement>> cache0 = cache.get(component);
if (cache0 == null) {
cache0 = new HashMap<Fluid, List<CachableRenderStatement>>();
cache.put(component, cache0);
}
List<CachableRenderStatement> data = cache0.get(fluid);
if (data != null) {
return data;
}
data = new ArrayList<CachableRenderStatement>();
cache0.put(fluid, data);
TextureAtlasSprite texture = RenderUtil.getStillTexture(fluid);
if (texture == null) {
return data;
}
int color = fluid.getColor();
Vector4f colorv = new Vector4f((color >> 16 & 0xFF) / 255d, (color >> 8 & 0xFF) / 255d, (color & 0xFF) / 255d, 1);
BoundingBox bbb;
double width = outlineWidth;
scaleFactor = scaleFactor - 0.05;
double xScale = Math.abs(component.dir.getFrontOffsetX()) == 1 ? width : scaleFactor;
double yScale = Math.abs(component.dir.getFrontOffsetY()) == 1 ? width : scaleFactor;
double zScale = Math.abs(component.dir.getFrontOffsetZ()) == 1 ? width : scaleFactor;
double offSize = (0.5 - width) / 2 - width / 2;
double xOff = component.dir.getFrontOffsetX() * offSize;
double yOff = component.dir.getFrontOffsetY() * offSize;
double zOff = component.dir.getFrontOffsetZ() * offSize;
bbb = component.bound.scale(xScale, yScale, zScale);
bbb = bbb.translate(new Vector3d(xOff, yOff, zOff));
for (EnumFacing face : EnumFacing.VALUES) {
if (face != component.dir && face != component.dir.getOpposite()) {
List<Vertex> corners = bbb.getCornersWithUvForFace(face, texture.getMinU(), texture.getMaxU(), texture.getMinV(), texture.getMaxV());
for (Vertex corner : corners) {
data.add(new CachableRenderStatement.AddVertexWithUV(corner.x(), corner.y(), corner.z(), corner.uv.x, corner.uv.y, colorv));
}
}
}
return data;
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class PowerConduit method createCollidables.
@Override
@Nonnull
public Collection<CollidableComponent> createCollidables(@Nonnull CacheKey key) {
Collection<CollidableComponent> baseCollidables = super.createCollidables(key);
if (key.dir == null) {
return baseCollidables;
}
BoundingBox bb = ConduitGeometryUtil.instance.createBoundsForConnectionController(key.dir, key.offset);
CollidableComponent cc = new CollidableComponent(IPowerConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
result.addAll(baseCollidables);
result.add(cc);
return result;
}
Aggregations