use of com.enderio.core.common.vecmath.Vector3d 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.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class GliderUpgrade method onPlayerTick.
@Override
public void onPlayerTick(@Nonnull ItemStack stack, @Nonnull IDarkSteelItem item, @Nonnull EntityPlayer player) {
if (!DarkSteelController.isGlideActive(player)) {
return;
}
if (!player.onGround && player.motionY < 0 && !player.isSneaking() && !player.isInWater()) {
double horizontalSpeed = Config.darkSteelGliderHorizontalSpeed;
double verticalSpeed = Config.darkSteelGliderVerticalSpeed;
if (player.isSprinting()) {
verticalSpeed = Config.darkSteelGliderVerticalSpeedSprinting;
}
Vector3d look = Util.getLookVecEio(player);
Vector3d side = new Vector3d();
side.cross(new Vector3d(0, 1, 0), look);
Vector3d playerPos = new Vector3d(player.prevPosX, player.prevPosY, player.prevPosZ);
Vector3d b = new Vector3d(playerPos);
b.y += 1;
Vector3d c = new Vector3d(playerPos);
c.add(side);
Vector4d plane = new Vector4d();
VecmathUtil.computePlaneEquation(playerPos, b, c, plane);
double dist = Math.abs(VecmathUtil.distanceFromPointToPlane(plane, new Vector3d(player.posX, player.posY, player.posZ)));
double minDist = 0.15;
if (dist < minDist) {
double dropRate = (minDist * 10) - (dist * 10);
verticalSpeed = verticalSpeed + (verticalSpeed * dropRate * 8);
horizontalSpeed -= (0.02 * dropRate);
}
double x = Math.cos(Math.toRadians(player.rotationYawHead + 90)) * horizontalSpeed;
double z = Math.sin(Math.toRadians(player.rotationYawHead + 90)) * horizontalSpeed;
player.motionX += x;
player.motionZ += z;
player.motionY = verticalSpeed;
player.fallDistance = 0f;
}
}
use of com.enderio.core.common.vecmath.Vector3d 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.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class LiquidConduitRenderer method setVerticesForTransmission.
@Override
protected void setVerticesForTransmission(BoundingBox bound, EnumFacing id) {
float yScale = getRatioForConnection(id);
float scale = 0.7f;
float xs = id.getFrontOffsetX() == 0 ? scale : 1;
float ys = id.getFrontOffsetY() == 0 ? Math.min(yScale, scale) : yScale;
float zs = id.getFrontOffsetZ() == 0 ? scale : 1;
double sizeY = bound.sizeY();
bound = bound.scale(xs, ys, zs);
double transY = (bound.sizeY() - sizeY) / 2;
Vector3d translation = new Vector3d(0, transY + 0.025, 0);
setupVertices(bound.translate(translation));
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class PowerConduitRenderer method addConduitQuads.
@Override
protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IConduit conduit, @Nonnull TextureAtlasSprite tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
if (IPowerConduit.COLOR_CONTROLLER_ID.equals(component.data)) {
IPowerConduit pc = (IPowerConduit) conduit;
ConnectionMode conMode = pc.getConnectionMode(component.dir);
if (conduit.containsExternalConnection(component.dir) && pc.getExtractionRedstoneMode(component.dir) != RedstoneControlMode.IGNORE && conMode != ConnectionMode.DISABLED) {
int cInt = ((IPowerConduit) conduit).getExtractionSignalColor(component.dir).getColor();
Vector4f col = ColorUtil.toFloat4(cInt);
BoundingBox bound = component.bound;
if (conMode != ConnectionMode.IN_OUT && conMode != ConnectionMode.NOT_SET) {
Vector3d trans = ForgeDirectionOffsets.offsetScaled(component.dir, -0.12);
bound = bound.translate(trans);
}
addQuadsForSection(bound, tex, component.dir, quads, col);
}
return;
}
super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads);
if (component.dir == null) {
return;
}
IPowerConduit pc = (IPowerConduit) conduit;
ConnectionMode mode = pc.getConnectionMode(component.dir);
if (mode != ConnectionMode.INPUT && mode != ConnectionMode.OUTPUT) {
return;
}
if (mode == ConnectionMode.INPUT) {
tex = pc.getTextureForInputMode();
} else {
tex = pc.getTextureForOutputMode();
}
Offset offset = bundle.getOffset(IPowerConduit.class, component.dir);
ConnectionModeGeometry.addModeConnectorQuads(component.dir, offset, tex, null, quads);
}
Aggregations