List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getY
public double getY()
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D ceil(Vector3D vec) { return new Vector3D(FastMath.ceil(vec.getX()), FastMath.ceil(vec.getY()), FastMath.ceil(vec.getZ())); }
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D floor(Vector3D vec) { return new Vector3D(FastMath.floor(vec.getX()), FastMath.floor(vec.getY()), FastMath.floor(vec.getZ())); }
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D abs(Vector3D vec) { return new Vector3D(FastMath.abs(vec.getX()), FastMath.abs(vec.getY()), FastMath.abs(vec.getZ())); }
From source file:nova.core.util.RayTracer.java
/** * Calculates intersection with the given ray between a certain distance * interval.// w ww . ja v a 2 s . c om * <p> * Ray-box intersection is using IEEE numerical properties to ensure the * test is both robust and efficient, as described in: * <br> * <code>Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley: "An * Efficient and Robust Ray-Box Intersection Algorithm" Journal of graphics * tools, 10(1):49-54, 2005</code> * @param cuboid The cuboid to trace * @param minDist The minimum distance * @param maxDist The maximum distance * @return intersection point on the bounding box (only the first is * returned) or null if no intersection */ public Optional<Vector3D> rayTrace(Cuboid cuboid, double minDist, double maxDist) { Vector3D bbox; double tMin; double tMax; bbox = ray.signDirX ? cuboid.max : cuboid.min; tMin = (bbox.getX() - ray.origin.getX()) * ray.invDir.getX(); bbox = ray.signDirX ? cuboid.min : cuboid.max; tMax = (bbox.getX() - ray.origin.getX()) * ray.invDir.getX(); //Y bbox = ray.signDirY ? cuboid.max : cuboid.min; double tyMin = (bbox.getY() - ray.origin.getY()) * ray.invDir.getY(); bbox = ray.signDirY ? cuboid.min : cuboid.max; double tyMax = (bbox.getY() - ray.origin.getY()) * ray.invDir.getY(); //Check with the current tMin and tMax to see if the clipping is out of bounds if ((tMin > tyMax) || (tyMin > tMax)) { return Optional.empty(); } //Reset tMin and tMax if (tyMin > tMin) { tMin = tyMin; } if (tyMax < tMax) { tMax = tyMax; } bbox = ray.signDirZ ? cuboid.max : cuboid.min; double tzMin = (bbox.getZ() - ray.origin.getZ()) * ray.invDir.getZ(); bbox = ray.signDirZ ? cuboid.min : cuboid.max; double tzMax = (bbox.getZ() - ray.origin.getZ()) * ray.invDir.getZ(); //Check with the current tMin and tMax to see if the clipping is out of bounds if ((tMin > tzMax) || (tzMin > tMax)) { return Optional.empty(); } //Reset tMin and tMax if (tzMin > tMin) { tMin = tzMin; } if (tzMax < tMax) { tMax = tzMax; } if ((tMin < maxDist) && (tMax > minDist)) { return Optional.of(ray.origin.add(ray.dir.scalarMultiply(tMin))); } return Optional.empty(); }
From source file:nova.core.wrapper.mc.forge.v17.launcher.ClientProxy.java
@Override public Entity spawnParticle(net.minecraft.world.World world, Entity entity) { //Backward entity particle unwrapper if (entity instanceof BWEntityFX) { EntityFX entityFX = ((BWEntityFX) entity).createEntityFX(); Vector3D position = entity.position(); entityFX.posX = position.getX(); entityFX.posY = position.getY(); entityFX.posZ = position.getZ(); FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX); return Game.natives().toNova(entityFX); } else {//from w ww . j a v a2 s .c om FWEntityFX bwEntityFX = new FWEntityFX(world, entity); FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX); return bwEntityFX.wrapped; } }
From source file:nova.core.wrapper.mc.forge.v17.network.netty.MCNetworkManager.java
public void sendToAllAround(PacketAbstract message, World world, Vector3D point, double range) { sendToAllAround(message, world, point.getX(), point.getY(), point.getZ(), range); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java
public Block getBlockInstance(net.minecraft.world.IBlockAccess access, Vector3D position) { /**//from w w w. ja va2 s . c o m * If this block has a TileEntity, forward the method into the Stateful * block. Otherwise, create a new instance of the block and forward the * methods over. */ if (hasTileEntity(0)) { FWTile tileWrapper = (FWTile) access.getTileEntity((int) position.getX(), (int) position.getY(), (int) position.getZ()); if (tileWrapper != null && tileWrapper.getBlock() != null) { return tileWrapper.getBlock(); } System.out.println("Error: Block in TileWrapper is null."); } return getBlockInstance((nova.core.world.World) Game.natives().toNova(access), position); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java
@Override public void markStaticRender(Vector3D position) { world().markBlockForUpdate((int) position.getX(), (int) position.getY(), (int) position.getZ()); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java
@Override public void markChange(Vector3D position) { world().notifyBlockChange((int) position.getX(), (int) position.getY(), (int) position.getZ(), access.getBlock((int) position.getX(), (int) position.getY(), (int) position.getZ())); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java
@Override public Optional<Block> getBlock(Vector3D position) { net.minecraft.block.Block mcBlock = access.getBlock((int) position.getX(), (int) position.getY(), (int) position.getZ()); if (mcBlock == null || mcBlock == Blocks.air) { Block airBlock = Game.blocks().getAirBlock().build(); airBlock.components.add(new MCBlockTransform(airBlock, this, position)); return Optional.of(airBlock); } else if (mcBlock instanceof FWBlock) { return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position)); } else {// ww w . j a v a2 s. c om return Optional.of(new BWBlock(mcBlock, this, position)); } }