use of ValkyrienWarfareBase.Math.Quaternion 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.Math.Quaternion 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.Math.Quaternion 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.Math.Quaternion in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsCalculations method applyAngularVelocity.
public void applyAngularVelocity() {
CoordTransformObject coordTrans = parent.coordTransform;
double[] rotationChange = RotationMatrices.getRotationMatrix(angularVelocity.X, angularVelocity.Y, angularVelocity.Z, angularVelocity.length() * physTickSpeed);
Quaternion faggot = Quaternion.QuaternionFromMatrix(RotationMatrices.getMatrixProduct(rotationChange, coordTrans.lToWRotation));
double[] radians = faggot.toRadians();
//if (!(Double.isNaN(radians[0]) || Double.isNaN(radians[1]) || Double.isNaN(radians[2]))) {
wrapperEnt.pitch = Double.isNaN(radians[0]) ? 0.0f : (float) Math.toDegrees(radians[0]);
wrapperEnt.yaw = Double.isNaN(radians[1]) ? 0.0f : (float) Math.toDegrees(radians[1]);
wrapperEnt.roll = Double.isNaN(radians[2]) ? 0.0f : (float) Math.toDegrees(radians[2]);
coordTrans.updateAllTransforms();
//} else {
//wrapperEnt.isDead=true;
//wrapperEnt.wrapping.doPhysics = false;
// linearMomentum = new Vector();
// angularVelocity = new Vector();
//System.out.println(angularVelocity);
//System.out.println("Rotational Error?");
//}
}
use of ValkyrienWarfareBase.Math.Quaternion in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsCalculationsOrbital method applyAngularVelocity.
@Override
public void applyAngularVelocity() {
if (!isOrbitalPhased) {
super.applyAngularVelocity();
} else {
CoordTransformObject coordTrans = parent.coordTransform;
double[] rotationChange = RotationMatrices.getRotationMatrix(setAngularVel.X, setAngularVel.Y, setAngularVel.Z, angularVelocity.length() * physTickSpeed);
Quaternion faggot = Quaternion.QuaternionFromMatrix(RotationMatrices.getMatrixProduct(rotationChange, coordTrans.lToWRotation));
double[] radians = faggot.toRadians();
wrapperEnt.pitch = Double.isNaN(radians[0]) ? 0.0f : (float) Math.toDegrees(radians[0]);
wrapperEnt.yaw = Double.isNaN(radians[1]) ? 0.0f : (float) Math.toDegrees(radians[1]);
wrapperEnt.roll = Double.isNaN(radians[2]) ? 0.0f : (float) Math.toDegrees(radians[2]);
coordTrans.updateAllTransforms();
}
}
Aggregations