use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class NetworkRenderer method renderNetworks.
public static void renderNetworks(World world, float partialTicks) {
List<TileEntityBeamOutput> nodes = new ArrayList<TileEntityBeamOutput>();
for (Object o : new ArrayList<TileEntity>(world.loadedTileEntityList)) {
if (o instanceof TileEntityBeamOutput) {
nodes.add((TileEntityBeamOutput) o);
}
}
if (nodes.isEmpty()) {
return;
}
Tessellator tess = Tessellator.getInstance();
EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
GL11.glDisable(GL11.GL_TEXTURE_2D);
for (TileEntityBeamOutput tileEntity : nodes) {
if (tileEntity.getTarget() == null) {
continue;
}
GL11.glPushMatrix();
Vector3 outputPoint = tileEntity.getOutputPoint(true);
Vector3 targetInputPoint = tileEntity.getTarget().getInputPoint();
Vector3 direction = Vector3.subtract(outputPoint, targetInputPoint);
float directionLength = (float) direction.getMagnitude();
float posX = (float) (tileEntity.getPos().getX() - interpPosX);
float posY = (float) (tileEntity.getPos().getY() - interpPosY);
float posZ = (float) (tileEntity.getPos().getZ() - interpPosZ);
GL11.glTranslatef(posX, posY, posZ);
GL11.glTranslatef(outputPoint.floatX() - tileEntity.getPos().getX(), outputPoint.floatY() - tileEntity.getPos().getY(), outputPoint.floatZ() - tileEntity.getPos().getZ());
GL11.glRotatef(tileEntity.yaw + 180, 0, 1, 0);
GL11.glRotatef(-tileEntity.pitch, 1, 0, 0);
GL11.glRotatef(tileEntity.ticks * 10, 0, 0, 1);
tess.getWorldRenderer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
for (EnumFacing dir : EnumFacing.VALUES) {
tess.getWorldRenderer().pos(dir.getFrontOffsetX() / 40.0F, dir.getFrontOffsetY() / 40.0F, dir.getFrontOffsetZ() / 40.0F).color(tileEntity.getColor().floatX(), tileEntity.getColor().floatY(), tileEntity.getColor().floatZ(), 1.0F).endVertex();
tess.getWorldRenderer().pos(dir.getFrontOffsetX() / 40.0F, dir.getFrontOffsetY() / 40.0F, directionLength + dir.getFrontOffsetZ() / 40.0F).color(tileEntity.getColor().floatX(), tileEntity.getColor().floatY(), tileEntity.getColor().floatZ(), 1.0F).endVertex();
}
tess.draw();
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(1, 1, 1, 1);
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class ColorUtil method interpolateInArray.
private static Vector3 interpolateInArray(Vector3[] array, int i, double mu) {
Vector3 point0 = array[i + 1];
Vector3 point1 = array[i];
Vector3 point2 = array[i - 1];
Vector3 point3 = array[i - 2];
double x = cubicInterpolate(point0.x, point1.x, point2.x, point3.x, mu);
double y = cubicInterpolate(point0.y, point1.y, point2.y, point3.y, mu);
double z = cubicInterpolate(point0.z, point1.z, point2.z, point3.z, mu);
return new Vector3(x, y, z);
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class TileEntityBeamReceiver method getOutputPoint.
@Override
public Vector3 getOutputPoint(boolean offset) {
Vector3 headVec = new Vector3(this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5);
if (this.facing != null) {
headVec.x += this.facing.getFrontOffsetX() * 0.1F;
headVec.y += this.facing.getFrontOffsetY() * 0.1F;
headVec.z += this.facing.getFrontOffsetZ() * 0.1F;
}
return headVec;
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class EntityTier2Rocket method spawnParticles.
protected void spawnParticles(boolean launched) {
if (!this.isDead) {
double sinPitch = Math.sin(this.rotationPitch / Constants.RADIANS_TO_DEGREES_D);
double x1 = 2.9 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
double z1 = 2.9 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
double y1 = 2.9 * Math.cos((this.rotationPitch - 180) / Constants.RADIANS_TO_DEGREES_D);
if (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() && this.targetVec != null) {
double modifier = this.posY - this.targetVec.getY();
modifier = Math.min(Math.max(modifier, 80.0), 200.0);
x1 *= modifier / 100.0D;
y1 *= modifier / 100.0D;
z1 *= modifier / 100.0D;
}
final double y = this.prevPosY + (this.posY - this.prevPosY) + y1 - this.motionY + (!this.getLaunched() ? 1.2D : 0D);
;
final double x2 = this.posX + x1 - this.motionX;
final double z2 = this.posZ + z1 - this.motionZ;
final double x3 = x2 + x1 / 2D;
final double y3 = y + y1 / 2D;
final double z3 = z2 + z1 / 2D;
Vector3 motionVec = new Vector3(x1, y1, z1);
if (this.ticksExisted % 2 == 0 && !this.getLaunched())
return;
String flame = this.getLaunched() ? "launchFlameLaunched" : "launchFlameIdle";
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4, y, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4, y, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2 + 0.4D), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2 - 0.4D), motionVec, new Object[] { riddenByEntity });
// Larger flameball for T2 - positioned behind the smaller one
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 + 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 + 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 + 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 + 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 - 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 - 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 - 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 - 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 + 0.7 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 + 0.7 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + this.rand.nextDouble() / 10, y3, z3 + 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2 - 0.8, y, z2), motionVec, new Object[] {});
GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2 + 0.8, y, z2), motionVec, new Object[] {});
GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2, y, z2 - 0.8), motionVec, new Object[] {});
GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2, y, z2 + 0.8), motionVec, new Object[] {});
}
}
Aggregations