use of ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject 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.PhysicsManagement.CoordTransformObject 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();
}
}
use of ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityDraggable method tickAddedVelocity.
//TODO: Finishme
public void tickAddedVelocity() {
if (worldBelowFeet != null && !ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
CoordTransformObject coordTransform = worldBelowFeet.wrapping.coordTransform;
float rotYaw = draggableAsEntity.rotationYaw;
float rotPitch = draggableAsEntity.rotationPitch;
float prevYaw = draggableAsEntity.prevRotationYaw;
float prevPitch = draggableAsEntity.prevRotationPitch;
Vector oldPos = new Vector(draggableAsEntity);
RotationMatrices.applyTransform(coordTransform.prevwToLTransform, coordTransform.prevWToLRotation, draggableAsEntity);
RotationMatrices.applyTransform(coordTransform.lToWTransform, coordTransform.lToWRotation, draggableAsEntity);
Vector newPos = new Vector(draggableAsEntity);
//Move the entity back to its old position, the added velocity will be used afterwards
draggableAsEntity.setPosition(oldPos.X, oldPos.Y, oldPos.Z);
Vector addedVel = oldPos.getSubtraction(newPos);
velocityAddedToPlayer = addedVel;
draggableAsEntity.rotationYaw = rotYaw;
draggableAsEntity.rotationPitch = rotPitch;
draggableAsEntity.prevRotationYaw = prevYaw;
draggableAsEntity.prevRotationPitch = prevPitch;
Vector oldLookingPos = new Vector(draggableAsEntity.getLook(1.0F));
RotationMatrices.applyTransform(coordTransform.prevWToLRotation, oldLookingPos);
RotationMatrices.applyTransform(coordTransform.lToWRotation, oldLookingPos);
double newPitch = Math.asin(oldLookingPos.Y) * -180D / Math.PI;
double f4 = -Math.cos(-newPitch * 0.017453292D);
double radianYaw = Math.atan2((oldLookingPos.X / f4), (oldLookingPos.Z / f4));
radianYaw += Math.PI;
radianYaw *= -180D / Math.PI;
if (!(Double.isNaN(radianYaw) || Math.abs(newPitch) > 85)) {
double wrappedYaw = MathHelper.wrapDegrees(radianYaw);
double wrappedRotYaw = MathHelper.wrapDegrees(draggableAsEntity.rotationYaw);
double yawDif = wrappedYaw - wrappedRotYaw;
if (Math.abs(yawDif) > 180D) {
if (yawDif < 0) {
yawDif += 360D;
} else {
yawDif -= 360D;
}
}
yawDif %= 360D;
final double threshold = .1D;
if (Math.abs(yawDif) < threshold) {
yawDif = 0D;
}
yawDifVelocity = yawDif;
}
}
boolean onGroundOrig = draggableAsEntity.onGround;
if (!ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
float originalWalked = draggableAsEntity.distanceWalkedModified;
float originalWalkedOnStep = draggableAsEntity.distanceWalkedOnStepModified;
boolean originallySneaking = draggableAsEntity.isSneaking();
draggableAsEntity.setSneaking(false);
if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
MovementInput moveInput = playerSP.movementInput;
originallySneaking = moveInput.sneak;
moveInput.sneak = false;
}
draggableAsEntity.moveEntity(velocityAddedToPlayer.X, velocityAddedToPlayer.Y, velocityAddedToPlayer.Z);
if (!(draggableAsEntity instanceof EntityPlayer)) {
if (draggableAsEntity instanceof EntityArrow) {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw -= yawDifVelocity;
} else {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw += yawDifVelocity;
}
} else {
if (draggableAsEntity.worldObj.isRemote) {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw += yawDifVelocity;
}
}
//Do not add this movement as if the entity were walking it
draggableAsEntity.distanceWalkedModified = originalWalked;
draggableAsEntity.distanceWalkedOnStepModified = originalWalkedOnStep;
draggableAsEntity.setSneaking(originallySneaking);
if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
MovementInput moveInput = playerSP.movementInput;
moveInput.sneak = originallySneaking;
}
}
if (onGroundOrig) {
draggableAsEntity.onGround = onGroundOrig;
}
velocityAddedToPlayer.multiply(.99D);
yawDifVelocity *= .95D;
}
Aggregations