Package com.flansmod.common

Examples of com.flansmod.common.RotatedAxes


    pos = new Vector3f(p.posX, p.posY, p.posZ);
    if(FlansMod.proxy.isThePlayer(p))
      pos = new Vector3f(p.posX, p.posY - 1.6F, p.posZ);
    hitboxes = new ArrayList<PlayerHitbox>();
   
    RotatedAxes bodyAxes = new RotatedAxes(p.renderYawOffset, 0F, 0F);
    RotatedAxes headAxes = new RotatedAxes(p.rotationYawHead - p.renderYawOffset, 0F, -p.rotationPitch);
   
    hitboxes.add(new PlayerHitbox(player, bodyAxes, new Vector3f(0F, 0F, 0F), new Vector3f(-0.25F, 0F, -0.15F), new Vector3f(0.5F, 1.4F, 0.3F), EnumHitboxType.BODY));   
    hitboxes.add(new PlayerHitbox(player, bodyAxes.findLocalAxesGlobally(headAxes), new Vector3f(0.0F, 1.4F, 0F), new Vector3f(-0.25F, 0F, -0.25F), new Vector3f(0.5F, 0.5F, 0.5F), EnumHitboxType.HEAD));
   
    //Calculate rotation of arms using modified code from ModelBiped
    float yHead = (p.rotationYawHead - p.renderYawOffset) / (180F / (float)Math.PI);
        float xHead = p.rotationPitch / (180F / (float)Math.PI);
   
        float zRight = 0.0F;
        float zLeft = 0.0F;
        float yRight = -0.1F + yHead - ((float)Math.PI / 2F);
        float yLeft = 0.1F + yHead + 0.4F - ((float)Math.PI / 2F);
        float xRight = -((float)Math.PI / 2F) + xHead;
        float xLeft = -((float)Math.PI / 2F) + xHead;
       
        zRight += MathHelper.cos(p.ticksExisted * 0.09F) * 0.05F + 0.05F;
        zLeft -= MathHelper.cos(p.ticksExisted * 0.09F) * 0.05F + 0.05F;
        xRight += MathHelper.sin(p.ticksExisted * 0.067F) * 0.05F;
        xLeft -= MathHelper.sin(p.ticksExisted * 0.067F) * 0.05F;
           
    RotatedAxes leftArmAxes = (new RotatedAxes()).rotateGlobalPitchInRads(xLeft).rotateGlobalYawInRads((float)Math.PI + yLeft).rotateGlobalRollInRads(-zLeft);
    RotatedAxes rightArmAxes = (new RotatedAxes()).rotateGlobalPitchInRads(xRight).rotateGlobalYawInRads((float)Math.PI + yRight).rotateGlobalRollInRads(-zRight);
   
    float originZRight = MathHelper.sin(-p.renderYawOffset * 3.14159265F / 180F) * 5.0F / 16F;
    float originXRight = -MathHelper.cos(-p.renderYawOffset * 3.14159265F / 180F) * 5.0F / 16F;

    float originZLeft = -MathHelper.sin(-p.renderYawOffset * 3.14159265F / 180F) * 5.0F / 16F;
View Full Code Here


  public EntityMecha(World world)
  {
    super(world);
    setSize(2F, 3F);
    stepHeight = 3;
    legAxes = new RotatedAxes();
    inventory = new MechaInventory(this);
  }
View Full Code Here

  }
 
  public EntityMecha(World world, double x, double y, double z, MechaType type, DriveableData data, NBTTagCompound tags)
  {
    super(world, type, data);
    legAxes = new RotatedAxes();
    setSize(2F, 3F);
    stepHeight = 3;
    setPosition(x, y, z);
    initType(type, false);
    inventory = new MechaInventory(this, tags);
View Full Code Here

  private void shoot(ItemStack stack, GunType gunType, ItemStack bulletStack, boolean creative, boolean left)
  {
    MechaType mechaType = getMechaType();
    BulletType bulletType = ((ItemBullet)bulletStack.getItem()).type;
    RotatedAxes a = new RotatedAxes();
   
    Vector3f armVector = new Vector3f(mechaType.armLength, 0F, 0F);
    Vector3f gunVector = new Vector3f(mechaType.armLength + 1.2F * mechaType.heldItemScale, 0.5F * mechaType.heldItemScale, 0F);
    Vector3f armOrigin = left ?  mechaType.leftArmOrigin : mechaType.rightArmOrigin;
   
    a.rotateGlobalYaw(axes.getYaw());
    armOrigin = a.findLocalVectorGlobally(armOrigin);
   
    a.rotateLocalPitch(-seats[0].looking.getPitch());
    gunVector = a.findLocalVectorGlobally(gunVector);
    armVector = a.findLocalVectorGlobally(armVector);
   
    Vector3f bulletOrigin = Vector3f.add(armOrigin, gunVector, null);
   
    bulletOrigin  = Vector3f.add(new Vector3f(posX, posY, posZ), bulletOrigin, null);
       
View Full Code Here

   * Should not be called server side EVER */
  public EntitySeat(World world)
  {
    super(world);
    setSize(1F, 1F);
    prevLooking = new RotatedAxes();
    looking = new RotatedAxes();
  }
View Full Code Here

    //If on the client
    if(worldObj.isRemote)
    {
      if(driver && riddenByEntity == Minecraft.getMinecraft().thePlayer && FlansModClient.controlModeMouse && driveable.hasMouseControlMode())
      {
        looking = new RotatedAxes();
      }
      //DEBUG : Spawn particles along axes
     
      Vector3f xAxis = driveable.axes.findLocalAxesGlobally(looking).getXAxis();
      Vector3f yAxis = driveable.axes.findLocalAxesGlobally(looking).getYAxis();
View Full Code Here

    Vector3f localPosition = new Vector3f(seatInfo.x / 16F, seatInfo.y / 16F, seatInfo.z / 16F);
   
    //Rotate the offset vector by the turret yaw
    if(driveable != null && driveable.seats != null && driveable.seats[0] != null && driveable.seats[0].looking != null)
    {
      RotatedAxes yawOnlyLooking = new RotatedAxes(driveable.seats[0].looking.getYaw(), 0F, 0F);
      Vector3f rotatedOffset = yawOnlyLooking.findLocalVectorGlobally(seatInfo.rotatedOffset);
      Vector3f.add(localPosition, new Vector3f(rotatedOffset.x, 0F, rotatedOffset.z), localPosition);
    }
   
    //If this seat is connected to the turret, then its position vector on the driveable axes needs an extra rotation in it
    //if(driveable.rotateWithTurret(seatInfo) && driveable.seats[0] != null)
      //localPosition = driveable.seats[0].looking.findLocalVectorGlobally(localPosition);
    //Get the position of this seat globally, but positionally relative to the driveable
    Vector3f relativePosition = driveable.axes.findLocalVectorGlobally(localPosition);
    //Set the absol
    setPosition(driveable.posX + relativePosition.x, driveable.posY + relativePosition.y, driveable.posZ + relativePosition.z);
   
    if(riddenByEntity != null)
    {
        DriveableType type = driveable.getDriveableType();
      Vec3 yOffset = driveable.rotate(0, riddenByEntity.getYOffset(), 0).toVec3();
     
      playerPosX = posX + yOffset.xCoord;
      playerPosY = posY + yOffset.yCoord;
      playerPosZ = posZ + yOffset.zCoord;
     
      riddenByEntity.lastTickPosX = riddenByEntity.prevPosX = prevPlayerPosX;
      riddenByEntity.lastTickPosY = riddenByEntity.prevPosY = prevPlayerPosY;
      riddenByEntity.lastTickPosZ = riddenByEntity.prevPosZ = prevPlayerPosZ;
            riddenByEntity.setPosition(playerPosX, playerPosY, playerPosZ)
           
            //Calculate the local look axes globally
      RotatedAxes globalLookAxes = driveable.axes.findLocalAxesGlobally(looking);
      //Set the player's rotation based on this
      playerYaw = -90F + globalLookAxes.getYaw();
      playerPitch = globalLookAxes.getPitch();
     
      double dYaw = playerYaw - prevPlayerYaw;
      if(dYaw > 180)
        prevPlayerYaw += 360F;
      if(dYaw < -180)
        prevPlayerYaw -= 360F;
     
      if(riddenByEntity instanceof EntityPlayer)
      {
        riddenByEntity.prevRotationYaw = prevPlayerYaw;
        riddenByEntity.prevRotationPitch = prevPlayerPitch;
       
        riddenByEntity.rotationYaw = playerYaw;
        riddenByEntity.rotationPitch = playerPitch;
      }
     
      //If the entity is a player, roll its view accordingly
      if(worldObj.isRemote)
      {
        prevPlayerRoll = playerRoll;
        playerRoll = -globalLookAxes.getRoll();
      }   
    }
  }
View Full Code Here

            if(gun.isAmmo(bullet))
            {
              //Gun origin
              Vector3f gunOrigin = Vector3f.add(driveable.axes.findLocalVectorGlobally(seatInfo.gunOrigin), new Vector3f(driveable.posX, driveable.posY, driveable.posZ), null);
              //Calculate the look axes globally
              RotatedAxes globalLookAxes = driveable.axes.findLocalAxesGlobally(looking);
              Vector3f shootVec = driveable.axes.findLocalVectorGlobally(looking.getXAxis());
              //Calculate the origin of the bullets
              Vector3f yOffset = driveable.axes.findLocalVectorGlobally(new Vector3f(0F, (float)player.getMountedYOffset(), 0F));           
              //Spawn a new bullet item
              worldObj.spawnEntityInWorld(((ItemShootable)bulletItemStack.getItem()).getEntity(worldObj, Vector3f.add(yOffset, new Vector3f(gunOrigin.x, gunOrigin.y, gunOrigin.z), null), shootVec, (EntityLivingBase)riddenByEntity, gun.bulletSpread, gun.damage, gun.bulletSpeed, bulletItemStack.getItemDamage(), driveable.getDriveableType()));
View Full Code Here

        {
          Vector3f meleeDamagePoint = type.meleeDamagePoints.get(k);
          //Do a raytrace from the prev pos to the current pos and attack anything in the way
          Vector3f nextPos = type.meleePath.get((data.meleeProgress + 1) % type.meleePath.size());
          Vector3f nextAngles = type.meleePathAngles.get((data.meleeProgress + 1) % type.meleePathAngles.size());
          RotatedAxes nextAxes = new RotatedAxes().rotateGlobalRoll(-nextAngles.x).rotateGlobalPitch(-nextAngles.z).rotateGlobalYaw(-nextAngles.y);
         
          Vector3f nextPosInGunCoords = nextAxes.findLocalVectorGlobally(meleeDamagePoint);
          Vector3f.add(nextPos, nextPosInGunCoords, nextPosInGunCoords);
          Vector3f.add(new Vector3f(0F, 0F, 0F), nextPosInGunCoords, nextPosInGunCoords);
          Vector3f nextPosInPlayerCoords = new RotatedAxes(player.rotationYaw + 90F, player.rotationPitch, 0F).findLocalVectorGlobally(nextPosInGunCoords);
         
         
          if(!FlansMod.proxy.isThePlayer(player))
            nextPosInPlayerCoords.y += 1.6F;
         
          Vector3f nextPosInWorldCoords = new Vector3f(player.posX + nextPosInPlayerCoords.x, player.posY + nextPosInPlayerCoords.y, player.posZ + nextPosInPlayerCoords.z);
         
          Vector3f dPos = data.lastMeleePositions[k] == null ? new Vector3f() : Vector3f.sub(nextPosInWorldCoords, data.lastMeleePositions[k], null);
         
          if(player.worldObj.isRemote && FlansMod.DEBUG)
            player.worldObj.spawnEntityInWorld(new EntityDebugVector(player.worldObj, data.lastMeleePositions[k], dPos, 200, 1F, 0F, 0F));
         
          //Do the raytrace
          {
            //Create a list for all bullet hits
            ArrayList<BulletHit> hits = new ArrayList<BulletHit>();
                   
            //Iterate over all entities
            for(int j = 0; j < world.loadedEntityList.size(); j++)
            {
              Object obj = world.loadedEntityList.get(j);
              //Get players
              if(obj instanceof EntityPlayer)
              {
                EntityPlayer otherPlayer = (EntityPlayer)obj;
                PlayerData otherData = PlayerHandler.getPlayerData(otherPlayer);
                boolean shouldDoNormalHitDetect = false;
                if(otherPlayer == player)
                  continue;
                if(otherData != null)
                {
                  if(otherPlayer.isDead || otherData.team == Team.spectators)
                  {
                    continue;
                  }
                  int snapshotToTry = player instanceof EntityPlayerMP ? ((EntityPlayerMP)player).ping / 50 : 0;
                  if(snapshotToTry >= otherData.snapshots.length)
                    snapshotToTry = otherData.snapshots.length - 1;
                 
                  PlayerSnapshot snapshot = otherData.snapshots[snapshotToTry];
                  if(snapshot == null)
                    snapshot = otherData.snapshots[0];
                 
                  //DEBUG
                  //snapshot = new PlayerSnapshot(player);
                 
                  //Check one last time for a null snapshot. If this is the case, fall back to normal hit detection
                  if(snapshot == null)
                    shouldDoNormalHitDetect = true;
                  else
                  {
                    //Raytrace
                    ArrayList<BulletHit> playerHits = snapshot.raytrace(data.lastMeleePositions[k] == null ? nextPosInWorldCoords : data.lastMeleePositions[k], dPos);
                    hits.addAll(playerHits);
                  }
                }
               
                //If we couldn't get a snapshot, use normal entity hitbox calculations
                if(otherData == null || shouldDoNormalHitDetect)
                {
                  MovingObjectPosition mop = data.lastMeleePositions[k] == null ? player.boundingBox.calculateIntercept(nextPosInWorldCoords.toVec3(), Vec3.createVectorHelper(0F, 0F, 0F)) : player.boundingBox.calculateIntercept(data.lastMeleePositions[k].toVec3(), nextPosInWorldCoords.toVec3());
                  if(mop != null)
                  {
                    Vector3f hitPoint = new Vector3f(mop.hitVec.xCoord - data.lastMeleePositions[k].x, mop.hitVec.yCoord - data.lastMeleePositions[k].y, mop.hitVec.zCoord - data.lastMeleePositions[k].z);
                    float hitLambda = 1F;
                    if(dPos.x != 0F)
                      hitLambda = hitPoint.x / dPos.x;
                    else if(dPos.y != 0F)
                      hitLambda = hitPoint.y / dPos.y;
                    else if(dPos.z != 0F)
                      hitLambda = hitPoint.z / dPos.z;
                    if(hitLambda < 0)
                      hitLambda = -hitLambda;
                   
                    hits.add(new PlayerBulletHit(new PlayerHitbox(otherPlayer, new RotatedAxes(), new Vector3f(), new Vector3f(), new Vector3f(), EnumHitboxType.BODY), hitLambda));
                  }
                }
              }
              else
              {
View Full Code Here

            else if(motion.z != 0F)
              hitLambda = hitPoint.z / motion.z;
            if(hitLambda < 0)
              hitLambda = -hitLambda;
           
            hits.add(new PlayerBulletHit(new PlayerHitbox(player, new RotatedAxes(), new Vector3f(), new Vector3f(), new Vector3f(), EnumHitboxType.BODY), hitLambda));
          }
        }
      }
      else
      {
View Full Code Here

TOP

Related Classes of com.flansmod.common.RotatedAxes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.