use of ValkyrienWarfareBase.API.Vector in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysObjectRenderManager method inverseTransform.
// TODO: Program me
public void inverseTransform(double partialTicks) {
PhysicsWrapperEntity entity = parent.wrapper;
Vector centerOfRotation = entity.wrapping.centerCoord;
curPartialTick = partialTicks;
double moddedX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
double moddedY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
double moddedZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
double p0 = Minecraft.getMinecraft().thePlayer.lastTickPosX + (Minecraft.getMinecraft().thePlayer.posX - Minecraft.getMinecraft().thePlayer.lastTickPosX) * (double) partialTicks;
double p1 = Minecraft.getMinecraft().thePlayer.lastTickPosY + (Minecraft.getMinecraft().thePlayer.posY - Minecraft.getMinecraft().thePlayer.lastTickPosY) * (double) partialTicks;
double p2 = Minecraft.getMinecraft().thePlayer.lastTickPosZ + (Minecraft.getMinecraft().thePlayer.posZ - Minecraft.getMinecraft().thePlayer.lastTickPosZ) * (double) partialTicks;
Quaternion smoothRotation = getSmoothRotationQuat(partialTicks);
double[] radians = smoothRotation.toRadians();
double moddedPitch = Math.toDegrees(radians[0]);
double moddedYaw = Math.toDegrees(radians[1]);
double moddedRoll = Math.toDegrees(radians[2]);
if (offsetPos != null) {
double offsetX = offsetPos.getX() - centerOfRotation.X;
double offsetY = offsetPos.getY() - centerOfRotation.Y;
double offsetZ = offsetPos.getZ() - centerOfRotation.Z;
GL11.glTranslated(-offsetX, -offsetY, -offsetZ);
GL11.glRotated(-moddedRoll, 0, 0, 1D);
GL11.glRotated(-moddedYaw, 0, 1D, 0);
GL11.glRotated(-moddedPitch, 1D, 0, 0);
GlStateManager.translate(p0 - moddedX, p1 - moddedY, p2 - moddedZ);
// transformBuffer = BufferUtils.createFloatBuffer(16);
}
}
use of ValkyrienWarfareBase.API.Vector in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysObjectRenderManager method getSmoothRotationQuat.
public Quaternion getSmoothRotationQuat(double partialTick) {
PhysicsWrapperEntity entity = parent.wrapper;
double[] oldRotation = RotationMatrices.getDoubleIdentity();
oldRotation = RotationMatrices.rotateAndTranslate(oldRotation, entity.prevPitch, entity.prevYaw, entity.prevRoll, new Vector());
Quaternion oneTickBefore = Quaternion.QuaternionFromMatrix(oldRotation);
double[] newRotation = RotationMatrices.getDoubleIdentity();
newRotation = RotationMatrices.rotateAndTranslate(newRotation, entity.pitch, entity.yaw, entity.roll, new Vector());
Quaternion nextQuat = Quaternion.QuaternionFromMatrix(newRotation);
return Quaternion.getBetweenQuat(oneTickBefore, nextQuat, partialTick);
}
use of ValkyrienWarfareBase.API.Vector in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysObjectRenderManager method updateTranslation.
public void updateTranslation(double partialTicks) {
PhysicsWrapperEntity entity = parent.wrapper;
Vector centerOfRotation = entity.wrapping.centerCoord;
curPartialTick = partialTicks;
double moddedX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
double moddedY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
double moddedZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
double p0 = Minecraft.getMinecraft().thePlayer.lastTickPosX + (Minecraft.getMinecraft().thePlayer.posX - Minecraft.getMinecraft().thePlayer.lastTickPosX) * (double) partialTicks;
double p1 = Minecraft.getMinecraft().thePlayer.lastTickPosY + (Minecraft.getMinecraft().thePlayer.posY - Minecraft.getMinecraft().thePlayer.lastTickPosY) * (double) partialTicks;
double p2 = Minecraft.getMinecraft().thePlayer.lastTickPosZ + (Minecraft.getMinecraft().thePlayer.posZ - Minecraft.getMinecraft().thePlayer.lastTickPosZ) * (double) partialTicks;
Quaternion smoothRotation = getSmoothRotationQuat(partialTicks);
double[] radians = smoothRotation.toRadians();
double moddedPitch = Math.toDegrees(radians[0]);
double moddedYaw = Math.toDegrees(radians[1]);
double moddedRoll = Math.toDegrees(radians[2]);
parent.coordTransform.updateRenderMatrices(moddedX, moddedY, moddedZ, moddedPitch, moddedYaw, moddedRoll);
if (offsetPos != null) {
double offsetX = offsetPos.getX() - centerOfRotation.X;
double offsetY = offsetPos.getY() - centerOfRotation.Y;
double offsetZ = offsetPos.getZ() - centerOfRotation.Z;
GlStateManager.translate(-p0 + moddedX, -p1 + moddedY, -p2 + moddedZ);
GL11.glRotated(moddedPitch, 1D, 0, 0);
GL11.glRotated(moddedYaw, 0, 1D, 0);
GL11.glRotated(moddedRoll, 0, 0, 1D);
GL11.glTranslated(offsetX, offsetY, offsetZ);
// transformBuffer = BufferUtils.createFloatBuffer(16);
}
}
use of ValkyrienWarfareBase.API.Vector in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ValkyrienWarfareMod method loadConfig.
public void loadConfig() {
File file = new File(ValkyrienWarfareMod.getWorkingFolder(), "/valkyrienwarfaresettings.dat");
if (!file.exists()) {
tag = new DataTag(file);
tag.setBoolean("doGravity", true);
tag.setBoolean("doPhysicsBlocks", true);
tag.setBoolean("doBalloons", true);
tag.setBoolean("doAirshipRotation", true);
tag.setBoolean("doAirshipMovement", true);
tag.setBoolean("doSplitting", false);
tag.setInteger("maxShipSize", 15000);
tag.setDouble("gravityVecX", 0);
tag.setDouble("gravityVecY", -9.8);
tag.setDouble("gravityVecZ", 0);
tag.setInteger("physicsIterations", 10);
tag.setDouble("physicsSpeed", 0.05);
tag.setBoolean("doEtheriumLifting", true);
tag.save();
} else {
tag = new DataTag(file);
}
PhysicsSettings.doGravity = tag.getBoolean("doGravity", true);
PhysicsSettings.doPhysicsBlocks = tag.getBoolean("doPhysicsBlocks", true);
PhysicsSettings.doBalloons = tag.getBoolean("doBalloons", true);
PhysicsSettings.doAirshipRotation = tag.getBoolean("doAirshipRotation", true);
PhysicsSettings.doAirshipMovement = tag.getBoolean("doAirshipMovement", true);
ValkyrienWarfareMod.doSplitting = tag.getBoolean("doSplitting", false);
ValkyrienWarfareMod.maxShipSize = tag.getInteger("maxShipSize", 15000);
ValkyrienWarfareMod.physIter = tag.getInteger("physicsIterations", 8);
ValkyrienWarfareMod.physSpeed = tag.getDouble("physicsSpeed", 0.05);
ValkyrienWarfareMod.gravity = new Vector(tag.getDouble("gravityVecX", 0.0), tag.getDouble("gravityVecY", -9.8), tag.getDouble("gravityVecZ", 0.0));
PhysicsSettings.doEtheriumLifting = tag.getBoolean("doEtheriumLifting", true);
//save the tag in case new fields are added, this way they are saved right away
tag.save();
}
use of ValkyrienWarfareBase.API.Vector in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CoordTransformObject method updateParentAABB.
// TODO: FinishME
public void updateParentAABB() {
double mnX = 0, mnY = 0, mnZ = 0, mxX = 0, mxY = 0, mxZ = 0;
Vector currentLocation = new Vector();
mnX = mxX = parent.wrapper.posX;
mnY = mxY = parent.wrapper.posY;
mnZ = mxZ = parent.wrapper.posZ;
for (BlockPos pos : parent.blockPositions) {
currentLocation.X = pos.getX() + .5D;
currentLocation.Y = pos.getY() + .5D;
currentLocation.Z = pos.getZ() + .5D;
fromLocalToGlobal(currentLocation);
if (currentLocation.X < mnX) {
mnX = currentLocation.X;
}
if (currentLocation.X > mxX) {
mxX = currentLocation.X;
}
if (currentLocation.Y < mnY) {
mnY = currentLocation.Y;
}
if (currentLocation.Y > mxY) {
mxY = currentLocation.Y;
}
if (currentLocation.Z < mnZ) {
mnZ = currentLocation.Z;
}
if (currentLocation.Z > mxZ) {
mxZ = currentLocation.Z;
}
}
AxisAlignedBB enclosingBB = new AxisAlignedBB(mnX, mnY, mnZ, mxX, mxY, mxZ).expand(.6D, .6D, .6D);
parent.collisionBB = enclosingBB;
}
Aggregations