Search in sources :

Example 1 with Quaternion

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);
    }
}
Also used : Quaternion(ValkyrienWarfareBase.Math.Quaternion) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 2 with Quaternion

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);
}
Also used : Quaternion(ValkyrienWarfareBase.Math.Quaternion) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 3 with Quaternion

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);
    }
}
Also used : Quaternion(ValkyrienWarfareBase.Math.Quaternion) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 4 with Quaternion

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?");
//}
}
Also used : CoordTransformObject(ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject) Quaternion(ValkyrienWarfareBase.Math.Quaternion)

Example 5 with Quaternion

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();
    }
}
Also used : CoordTransformObject(ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject) Quaternion(ValkyrienWarfareBase.Math.Quaternion)

Aggregations

Quaternion (ValkyrienWarfareBase.Math.Quaternion)7 Vector (ValkyrienWarfareBase.API.Vector)5 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)4 CoordTransformObject (ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject)2 RenderManagerOverride (ValkyrienWarfareCombat.Render.RenderManagerOverride)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 EnumSkyBlock (net.minecraft.world.EnumSkyBlock)1