use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class LightningBolt method renderBolt.
private void renderBolt(Tessellator tessellator, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass) {
AMVector3 playervec = new AMVector3(sinyaw * -cospitch, -cossinpitch / cosyaw, cosyaw * cospitch);
float boltage = this.main.particleAge >= 0 ? this.main.particleAge / this.main.particleMaxAge : 0.0F;
float mainalpha = 1.0F;
if (pass == 0)
mainalpha = (1.0F - boltage) * 0.9F;
else if (pass == 1)
mainalpha = 1.0F - boltage * 0.6F;
else
mainalpha = 1.0F - boltage * 0.3F;
int renderlength = (int) ((this.main.particleAge + partialframe + (int) (this.main.length * 3.0F)) / (int) (this.main.length * 3.0F) * this.main.numsegments0);
for (Iterator iterator = this.main.segments.iterator(); iterator.hasNext(); ) {
LightningBoltCommon.Segment rendersegment = (LightningBoltCommon.Segment) iterator.next();
if (rendersegment.segmentno <= renderlength) {
float width = 0.03F * (getRelativeViewVector(rendersegment.startpoint.point).length() / 10.0F + 1.0F) * (1.0F + rendersegment.light) * 0.5F;
if (width > 0.05F)
width = 0.05F;
if (pass == 1)
width += 0.025f;
else if (pass == 1)
width += 0.05f;
AMVector3 diff1 = AMVector3.crossProduct(playervec, rendersegment.prevdiff).scale(width / rendersegment.sinprev);
AMVector3 diff2 = AMVector3.crossProduct(playervec, rendersegment.nextdiff).scale(width / rendersegment.sinnext);
AMVector3 startvec = rendersegment.startpoint.point;
AMVector3 endvec = rendersegment.endpoint.point;
float rx1 = (float) (startvec.x - interpPosX);
float ry1 = (float) (startvec.y - interpPosY);
float rz1 = (float) (startvec.z - interpPosZ);
float rx2 = (float) (endvec.x - interpPosX);
float ry2 = (float) (endvec.y - interpPosY);
float rz2 = (float) (endvec.z - interpPosZ);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, mainalpha * rendersegment.light);
tessellator.addVertexWithUV(rx2 - diff2.x, ry2 - diff2.y, rz2 - diff2.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx1 - diff1.x, ry1 - diff1.y, rz1 - diff1.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx1 + diff1.x, ry1 + diff1.y, rz1 + diff1.z, 0.5D, 1.0D);
tessellator.addVertexWithUV(rx2 + diff2.x, ry2 + diff2.y, rz2 + diff2.z, 0.5D, 1.0D);
if (rendersegment.next == null) {
AMVector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().scale(width));
float rx3 = (float) (roundend.x - interpPosX);
float ry3 = (float) (roundend.y - interpPosY);
float rz3 = (float) (roundend.z - interpPosZ);
tessellator.addVertexWithUV(rx3 - diff2.x, ry3 - diff2.y, rz3 - diff2.z, 0.0D, 0.0D);
tessellator.addVertexWithUV(rx2 - diff2.x, ry2 - diff2.y, rz2 - diff2.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx2 + diff2.x, ry2 + diff2.y, rz2 + diff2.z, 0.5D, 1.0D);
tessellator.addVertexWithUV(rx3 + diff2.x, ry3 + diff2.y, rz3 + diff2.z, 0.0D, 1.0D);
}
if (rendersegment.prev == null) {
AMVector3 roundend = rendersegment.startpoint.point.copy().sub(rendersegment.diff.copy().normalize().scale(width));
float rx3 = (float) (roundend.x - interpPosX);
float ry3 = (float) (roundend.y - interpPosY);
float rz3 = (float) (roundend.z - interpPosZ);
tessellator.addVertexWithUV(rx1 - diff1.x, ry1 - diff1.y, rz1 - diff1.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx3 - diff1.x, ry3 - diff1.y, rz3 - diff1.z, 0.0D, 0.0D);
tessellator.addVertexWithUV(rx3 + diff1.x, ry3 + diff1.y, rz3 + diff1.z, 0.0D, 1.0D);
tessellator.addVertexWithUV(rx1 + diff1.x, ry1 + diff1.y, rz1 + diff1.z, 0.5D, 1.0D);
}
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class LightningBoltCommon method fractal.
public void fractal(int splits, float amount, float splitchance, float splitlength, float splitangle) {
if (this.finalized)
return;
ArrayList oldsegments = this.segments;
this.segments = new ArrayList();
Segment prev = null;
for (Iterator iterator = oldsegments.iterator(); iterator.hasNext(); ) {
Segment segment = (Segment) iterator.next();
prev = segment.prev;
AMVector3 subsegment = segment.diff.copy().scale(1.0F / splits);
BoltPoint[] newpoints = new BoltPoint[splits + 1];
AMVector3 startpoint = segment.startpoint.point;
newpoints[0] = segment.startpoint;
newpoints[splits] = segment.endpoint;
for (int i = 1; i < splits; i++) {
AMVector3 randoff = AMVector3.getPerpendicular(segment.diff).rotate(this.rand.nextFloat() * 360.0F, segment.diff);
randoff.scale((this.rand.nextFloat() - 0.5F) * amount);
AMVector3 basepoint = startpoint.copy().add(subsegment.copy().scale(i));
newpoints[i] = new BoltPoint(basepoint, randoff);
}
for (int i = 0; i < splits; i++) {
Segment next = new Segment(newpoints[i], newpoints[(i + 1)], segment.light, segment.segmentno * splits + i, segment.splitno);
next.prev = prev;
if (prev != null)
prev.next = next;
if ((i != 0) && (this.rand.nextFloat() < splitchance)) {
AMVector3 splitrot = AMVector3.xCrossProduct(next.diff).rotate(this.rand.nextFloat() * 360.0F, next.diff);
AMVector3 diff = next.diff.copy().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).scale(splitlength);
this.numsplits += 1;
this.splitparents.put(Integer.valueOf(this.numsplits), Integer.valueOf(next.splitno));
Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[(i + 1)].basepoint, newpoints[(i + 1)].offsetvec.copy().add(diff)), segment.light / 2.0F, next.segmentno, this.numsplits);
split.prev = prev;
this.segments.add(split);
}
prev = next;
this.segments.add(next);
}
if (segment.next != null) {
segment.next.prev = prev;
}
}
this.numsegments0 *= splits;
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class ClientTickHandler method spawnPowerPathVisuals.
private void spawnPowerPathVisuals() {
if (Minecraft.getMinecraft().thePlayer.getCurrentArmor(3) != null && (Minecraft.getMinecraft().thePlayer.getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(Minecraft.getMinecraft().thePlayer.getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
if (arcSpawnCounter++ >= arcSpawnFrequency) {
arcSpawnCounter = 0;
AMVector3 playerPos = new AMVector3(Minecraft.getMinecraft().thePlayer);
HashMap<PowerTypes, ArrayList<LinkedList<AMVector3>>> paths = AMCore.proxy.getPowerPathVisuals();
if (paths != null) {
for (PowerTypes type : paths.keySet()) {
String texture = type == PowerTypes.LIGHT ? "textures/blocks/oreblockbluetopaz.png" : type == PowerTypes.NEUTRAL ? "textures/blocks/oreblockvinteum.png" : type == PowerTypes.DARK ? "textures/blocks/oreblocksunstone.png" : "textures/blocks/oreblocksunstone.png";
ArrayList<LinkedList<AMVector3>> pathList = paths.get(type);
for (LinkedList<AMVector3> individualPath : pathList) {
for (int i = 0; i < individualPath.size() - 1; ++i) {
AMVector3 start = individualPath.get(i + 1);
AMVector3 end = individualPath.get(i);
if (start.distanceSqTo(playerPos) > 2500 || end.distanceSqTo(playerPos) > 2500) {
continue;
}
TileEntity teStart = Minecraft.getMinecraft().theWorld.getTileEntity((int) start.x, (int) start.y, (int) start.z);
TileEntity teEnd = Minecraft.getMinecraft().theWorld.getTileEntity((int) end.x, (int) end.y, (int) end.z);
if (teEnd == null || !(teEnd instanceof IPowerNode))
break;
double startX = start.x + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(0) : 0.5f);
double startY = start.y + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(1) : 0.5f);
double startZ = start.z + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(2) : 0.5f);
double endX = end.x + ((IPowerNode) teEnd).particleOffset(0);
double endY = end.y + ((IPowerNode) teEnd).particleOffset(1);
double endZ = end.z + ((IPowerNode) teEnd).particleOffset(2);
AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(Minecraft.getMinecraft().theWorld, texture, startX, startY, startZ, endX, endY, endZ);
if (arc != null) {
arcs.add(arc);
}
}
}
}
}
}
} else {
Iterator<AMLineArc> it = arcs.iterator();
while (it.hasNext()) {
AMLineArc arc = it.next();
if (arc == null || arc.isDead)
it.remove();
else
arc.setDead();
}
arcSpawnCounter = arcSpawnFrequency;
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class ClientProxy method drawPowerOnBlockHighlight.
@Override
public void drawPowerOnBlockHighlight(EntityPlayer player, MovingObjectPosition target, float partialTicks) {
if (AMCore.proxy.getLocalPlayer().getCurrentArmor(3) != null && (AMCore.proxy.getLocalPlayer().getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(AMCore.proxy.getLocalPlayer().getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
TileEntity te = player.worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ);
if (te != null && te instanceof IPowerNode) {
AMCore.proxy.setTrackedLocation(new AMVector3(target.blockX, target.blockY, target.blockZ));
} else {
AMCore.proxy.setTrackedLocation(AMVector3.zero());
}
if (AMCore.proxy.hasTrackedLocationSynced()) {
PowerNodeEntry data = AMCore.proxy.getTrackedData();
Block block = player.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
float yOff = 0.5f;
if (data != null) {
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
for (PowerTypes type : ((IPowerNode) te).getValidPowerTypes()) {
float pwr = data.getPower(type);
float pct = pwr / ((IPowerNode) te).getCapacity() * 100;
RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), target.blockX - (player.prevPosX - (player.prevPosX - player.posX) * partialTicks) + 0.5f, target.blockY + yOff - (player.prevPosY - (player.prevPosY - player.posY) * partialTicks) + block.getBlockBoundsMaxY() * 0.8f, target.blockZ - (player.prevPosZ - (player.prevPosZ - player.posZ) * partialTicks) + 0.5f, 0xFFFFFF);
yOff += 0.12f;
}
GL11.glPopAttrib();
}
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class PowerNodeRegistry method LoadChunkFromNBT.
public void LoadChunkFromNBT(ChunkCoordIntPair chunk, NBTTagCompound compound) {
if (!compound.hasKey("AM2PowerData"))
//nothing was saved in this chunk for the power system
return;
NBTTagList powerNodeTagList = compound.getTagList("AM2PowerData", Constants.NBT.TAG_COMPOUND);
HashMap<AMVector3, PowerNodeEntry> chunkPowerData = new HashMap<AMVector3, PowerNodeEntry>();
for (int i = 0; i < powerNodeTagList.tagCount(); ++i) {
NBTTagCompound nodeCompound = (NBTTagCompound) powerNodeTagList.getCompoundTagAt(i);
AMVector3 nodeLocation = new AMVector3(nodeCompound.getInteger("xCoord"), nodeCompound.getInteger("yCoord"), nodeCompound.getInteger("zCoord"));
PowerNodeEntry pnd = new PowerNodeEntry();
pnd.readFromNBT(nodeCompound.getCompoundTag("nodeData"));
chunkPowerData.put(nodeLocation, pnd);
}
LogHelper.trace("Loaded %d power node entries", chunkPowerData.size());
powerNodes.put(chunk, chunkPowerData);
}
Aggregations