Package com.flansmod.common.vector

Examples of com.flansmod.common.vector.Vector3f


   
    pumpModel[0] = new ModelRendererTurbo(this, 8, 7, textureX, textureY);
    pumpModel[0].addBox(10F, 2.8F, -1F, 4, 1, 2);
   
    //Scope
    scopeAttachPoint = new Vector3f(3F / 16F, 5F / 16F, 0F);

    //Stock
    defaultStockModel = new ModelRendererTurbo[3];
   
    defaultStockModel[0] = new ModelRendererTurbo(this, 8, 10, textureX, textureY);
    defaultStockModel[0].addBox(-8F, 0F, -1F, 3, 3, 2);
   
    defaultStockModel[1] = new ModelRendererTurbo(this, 0, 12, textureX, textureY);
    defaultStockModel[1].addBox(-5F, 1F, -1F, 2, 2, 2);
   
    defaultStockModel[2] = new ModelRendererTurbo(this, 18, 12, textureX, textureY);
    defaultStockModel[2].addBox(-3F, 2F, -1F, 2, 2, 2);
   
    stockAttachPoint = new Vector3f(1F / 16F, 4F / 16F, 0F);
   
    //Barrel   
    barrelAttachPoint = new Vector3f(18F / 16F, 4F / 16F, 0F);
   
    //Grip
    gripAttachPoint = new Vector3f(12F / 16F, 3F / 16F, 0F);
   
    //Ammo
    ammoModel = new ModelRendererTurbo[1];
   
    ammoModel[0] = new ModelRendererTurbo(this, 22, 0, textureX, textureY);
View Full Code Here


    gunModel[1].addBox(-1F, -8F, -0.5F, 2, 6, 1);
   
    for(int i = 0; i < 2; i++)
      gunModel[i].setRotationPoint(0F, 8F, 0F);
   
    thirdPersonOffset = new Vector3f(0F, 0F, 0F);
  }
View Full Code Here

   
    for(int i = 0; i < 7; i++)
      heliMainRotorModels[1][i].setRotationPoint(128F, 0F, 0F);
   
    //The helicopter rotor origins for rendering. Better than the old propeller rotation point code
    heliMainRotorOrigins = new Vector3f[] { new Vector3f(-84F / 16F, 48F / 16F, 0F), new Vector3f(128F / 16F, 48F / 16F, 0F) };
       
    heliRotorSpeeds = new float[] { 1F, 1F };
   
    translateAll(0F, -15F, 0F);
   
View Full Code Here

            GL11.glTranslatef(0F, -0.03F * adsSwitch, 0F);
          }
         
          if(animations.meleeAnimationProgress > 0 && animations.meleeAnimationProgress < gunType.meleePath.size())
          {
            Vector3f meleePos = gunType.meleePath.get(animations.meleeAnimationProgress);
            Vector3f nextMeleePos = animations.meleeAnimationProgress + 1 < gunType.meleePath.size() ? gunType.meleePath.get(animations.meleeAnimationProgress + 1) : new Vector3f();
            GL11.glTranslatef(meleePos.x + (nextMeleePos.x - meleePos.x) * smoothing, meleePos.y + (nextMeleePos.y - meleePos.y) * smoothing, meleePos.z + (nextMeleePos.z - meleePos.z) * smoothing);
            Vector3f meleeAngles = gunType.meleePathAngles.get(animations.meleeAnimationProgress);
            Vector3f nextMeleeAngles = animations.meleeAnimationProgress + 1 < gunType.meleePathAngles.size() ? gunType.meleePathAngles.get(animations.meleeAnimationProgress + 1) : new Vector3f();
            GL11.glRotatef(meleeAngles.y + (nextMeleeAngles.y - meleeAngles.y) * smoothing, 0F, 1F, 0F);
            GL11.glRotatef(meleeAngles.z + (nextMeleeAngles.z - meleeAngles.z) * smoothing, 0F, 0F, 1F);
            GL11.glRotatef(meleeAngles.x + (nextMeleeAngles.x - meleeAngles.x) * smoothing, 1F, 0F, 0F);

          }
View Full Code Here

   
    gunModel[4] = new ModelRendererTurbo(this, 4, 11, textureX, textureY);
    gunModel[4].addBox(4F, -1F, -0.5F, 1, 4, 1);
   
    //Scope
    scopeAttachPoint = new Vector3f(1.5F / 16F, 5F / 16F, 0F);
   
    //Barrel   
    barrelAttachPoint = new Vector3f(18F / 16F, 4F / 16F, 0F);
   
    //Stock   
    stockAttachPoint = new Vector3f(-1F / 16F, 1F / 16F, 0F);
   
    //Ammo
    ammoModel = new ModelRendererTurbo[4];
   
    ammoModel[0] = new ModelRendererTurbo(this, 14, 12, textureX, textureY);
View Full Code Here

    breakActionModel[0].addBox(3F, 3F, -1.2F, 8, 1, 2.4F);
   
    breakActionModel[1] = new ModelRendererTurbo(this, 0, 9, textureX, textureY);
    breakActionModel[1].addBox(2F, 4F, -1F, 11, 1, 2);

    barrelBreakPoint = new Vector3f(3F / 16F, 3F / 16F, 0F);
   
    ammoModel = new ModelRendererTurbo[2];
   
    ammoModel[0] = new ModelRendererTurbo(this, 20, 0, textureX, textureY);
    ammoModel[0].addBox(1.9F, 4.1F, -0.9F, 3, 0.8F, 0.8F);
   
    ammoModel[1] = new ModelRendererTurbo(this, 20, 0, textureX, textureY);
    ammoModel[1].addBox(1.9F, 4.1F, 0.1F, 3, 0.8F, 0.8F);
   
    barrelAttachPoint = new Vector3f(7.5F / 16F, 4F / 16F, 0F);
   
    scopeAttachPoint = new Vector3f(3F / 16F, 5F / 16F, 0F);
    scopeIsOnSlide = true;
   
   
    gunSlideDistance = 0.25F;
    animationType = EnumAnimationType.BREAK_ACTION;
View Full Code Here

   
    gunModel[7] = new ModelRendererTurbo(this, 16, 5, textureX, textureY);
    gunModel[7].addBox(14F, 5F, -0.5F, 1, 1, 1);

    //Scope
    scopeAttachPoint = new Vector3f(4F / 16F, 5F / 16F, 0F);

    //Stock
    defaultStockModel = new ModelRendererTurbo[3];
   
    defaultStockModel[0] = new ModelRendererTurbo(this, 10, 13, textureX, textureY);
    defaultStockModel[0].addBox(-8F, 2F, -0.5F, 1, 2, 1);
   
    defaultStockModel[1] = new ModelRendererTurbo(this, 20, 6, textureX, textureY);
    defaultStockModel[1].addShapeBox(-7F, 2F, -0.5F, 5, 2, 1, 0F, /* 0 */ 0F, 0F, 0F, /* 1 */ 0F, -1F, 0F, /* 2 */ 0F, -1F, 0F, /* 3 */ 0F, 0F, 0F, /* 4 */ 0F, 0F, 0F, /* 5 */ 0F, 0F, 0F, /* 6 */ 0F, 0F, 0F, /* 7 */ 0F, 0F, 0F);

    defaultStockModel[2] = new ModelRendererTurbo(this, 20, 9, textureX, textureY);
    defaultStockModel[2].addShapeBox(-2F, 3F, -1F, 1, 2, 2, 0F, /* 0 */ 0F, 0F, -0.5F, /* 1 */ 0F, 0F, 0F, /* 2 */ 0F, 0F, 0F, /* 3 */ 0F, 0F, -0.5F, /* 4 */ 0F, -1F, -0.5F, /* 5 */ 0F, 0F, 0F, /* 6 */ 0F, 0F, 0F, /* 7 */ 0F, -1F, -0.5F);
   
    stockAttachPoint = new Vector3f(-4F / 16F, 3.5F / 16F, 0F);
   
    //Barrel   
    barrelAttachPoint = new Vector3f(18F / 16F, 3.75F / 16F, 0F);
   
    //Grip
   
    gripAttachPoint = new Vector3f(10F / 16F, 3F / 16F, 0F);
   
    //Ammo
    ammoModel = new ModelRendererTurbo[1];
   
    ammoModel[0] = new ModelRendererTurbo(this, 26, 9, textureX, textureY);
View Full Code Here

        secondaryFunction = EnumSecondaryFunction.CUSTOM_MELEE;
      else if(split[0].equals("MeleeTime"))
        meleeTime = Integer.parseInt(split[1]);
      else if(split[0].equals("AddNode"))
      {
        meleePath.add(new Vector3f(Float.parseFloat(split[1]) / 16F, Float.parseFloat(split[2]) / 16F, Float.parseFloat(split[3]) / 16F));
        meleePathAngles.add(new Vector3f(Float.parseFloat(split[4]), Float.parseFloat(split[5]), Float.parseFloat(split[6])));
      }
      else if(split[0].equals("MeleeDamagePoint") || split[0].equals("MeleeDamageOffset"))
      {
        meleeDamagePoints.add(new Vector3f(Float.parseFloat(split[1]) / 16F, Float.parseFloat(split[2]) / 16F, Float.parseFloat(split[3]) / 16F));
      }
     
      //Player modifiers
      else if(split[0].equals("MoveSpeedModifier") || split[0].equals("Slowness"))
        moveSpeedModifier = Float.parseFloat(split[1]);
      else if(split[0].equals("KnockbackReduction") || split[0].equals("KnockbackModifier"))
        knockbackModifier = Float.parseFloat(split[1]);
     
      //Attachment settings
      else if(split[0].equals("AllowAllAttachments"))
        allowAllAttachments = Boolean.parseBoolean(split[1].toLowerCase());
      else if(split[0].equals("AllowAttachments"))
      {
        for(int i = 1; i < split.length; i++)
        {
          allowedAttachments.add(AttachmentType.getAttachment(split[i]));
        }
      }
      else if(split[0].equals("AllowBarrelAttachments"))
        allowBarrelAttachments = Boolean.parseBoolean(split[1].toLowerCase());
      else if(split[0].equals("AllowScopeAttachments"))
        allowScopeAttachments = Boolean.parseBoolean(split[1].toLowerCase());
      else if(split[0].equals("AllowStockAttachments"))
        allowStockAttachments = Boolean.parseBoolean(split[1].toLowerCase());
      else if(split[0].equals("AllowGripAttachments"))
        allowGripAttachments = Boolean.parseBoolean(split[1].toLowerCase());
      else if(split[0].equals("NumGenericAttachmentSlots"))
        numGenericAttachmentSlots = Integer.parseInt(split[1]);
     
      //Paintjobs
      else if(split[0].toLowerCase().equals("paintjob"))
      {
        ItemStack[] dyeStacks = new ItemStack[(split.length - 3) / 2];
        for(int i = 0; i < (split.length - 3) / 2; i++)
          dyeStacks[i] = new ItemStack(Items.dye, Integer.parseInt(split[i * 2 + 4]), getDyeDamageValue(split[i * 2 + 3]));
        paintjobs.add(new Paintjob(split[1], split[2], dyeStacks));
      }
     
      //Shield settings
      else if(split[0].toLowerCase().equals("shield"))
      {
        shield = true;
        shieldDamageAbsorption = Float.parseFloat(split[1]);
        shieldOrigin = new Vector3f(Float.parseFloat(split[2]) / 16F, Float.parseFloat(split[3]) / 16F, Float.parseFloat(split[4]) / 16F);
        shieldDimensions = new Vector3f(Float.parseFloat(split[5]) / 16F, Float.parseFloat(split[6]) / 16F, Float.parseFloat(split[7]) / 16F);
      }
    }
    catch (Exception e)
    {
      System.out.println("Reading gun file failed.");
View Full Code Here

  }
 
  /** @return The centre (in global co-ordinates) */
  public Vector3f getCentre()
  {
    return new Vector3f(x + w / 2F, y + h / 2F, z + d / 2F);
  }
View Full Code Here

     
      //Got no propellers. Derp.
      if(numProps == 0)
        break;
     
      Vector3f up = axes.getYAxis();
     
      throttleScaled *= numPropsWorking / numProps * 2F;
           
      float upwardsForce = throttle * throttleScaled + (g - throttleScaled / 2F);
      if(throttle < 0.5F)
        upwardsForce = g * throttle * 2F;
     
      if(!isPartIntact(EnumDriveablePart.blades))
      {
        upwardsForce = 0F;
      }
     
      //Move up
      //Throttle - 0.5 means that the positive throttle scales from -0.5 to +0.5. Thus it accounts for gravity-ish
      motionX += upwardsForce * up.x * 0.5F;
      motionY += upwardsForce * up.y;
      motionZ += upwardsForce * up.z * 0.5F;
      //Apply gravity
      motionY -= g;
     
      //Apply wobble
      //motionX += rand.nextGaussian() * wobbleFactor;
      //motionY += rand.nextGaussian() * wobbleFactor;
      //motionZ += rand.nextGaussian() * wobbleFactor;
     
      //Apply drag
      motionX *= drag;
      motionY *= drag;
      motionZ *= drag;

      break;
     
    case PLANE :
      //Count the number of working propellers
      for(Propeller prop : type.propellers)
        if(isPartIntact(prop.planePart))
          numPropsWorking++;
      numProps = type.propellers.size();
     
      //Got no propellers. Derp.
      if(numProps == 0)
        break;
     
      //Apply forces
      Vector3f forwards = (Vector3f)axes.getXAxis().normalise();
     
      //Sanity limiter
      if(lastTickSpeed > 2F)
        lastTickSpeed = 2F;
     
      float newSpeed = lastTickSpeed + throttleScaled * 2F;
     
      //Calculate the amount to alter motion by
      float proportionOfMotionToCorrect = 2F * throttle - 0.5F;
      if(proportionOfMotionToCorrect < 0F)
        proportionOfMotionToCorrect = 0F;
      if(proportionOfMotionToCorrect > 0.5F)
        proportionOfMotionToCorrect = 0.5F;
     
      //Apply gravity
      g = 0.98F / 20F;
      motionY -= g;
     
      //Apply lift
      int numWingsIntact = 0;
      if(isPartIntact(EnumDriveablePart.rightWing)) numWingsIntact++;
      if(isPartIntact(EnumDriveablePart.leftWing)) numWingsIntact++;
     
      float amountOfLift = 2F * g * throttle * numWingsIntact / 2F;
      if(amountOfLift > g)
        amountOfLift = g;
     
      motionY += amountOfLift;
     
      //Cut out some motion for correction
      motionX *= 1F - proportionOfMotionToCorrect;
      motionY *= 1F - proportionOfMotionToCorrect;
      motionZ *= 1F - proportionOfMotionToCorrect;
     
      //Add the corrected motion
      motionX += proportionOfMotionToCorrect * newSpeed * forwards.x;
      motionY += proportionOfMotionToCorrect * newSpeed * forwards.y;
      motionZ += proportionOfMotionToCorrect * newSpeed * forwards.z;
     
      //Apply drag
      motionX *= drag;
      motionY *= drag;
      motionZ *= drag;
      break;
    default:
      break;
    }
       
    for(EntityWheel wheel : wheels)
    {
      if(wheel != null && worldObj != null)
      if(type.floatOnWater && worldObj.isAnyLiquid(wheel.boundingBox))
      {
        motionY += type.buoyancy;
      }
    }
   
    //Move the wheels first
    for(EntityWheel wheel : wheels)
    {
      if(wheel != null)
      {
        wheel.prevPosY = wheel.posY;
        wheel.moveEntity(motionX, motionY, motionZ);
      }
    }
   
    //Update wheels
    for(int i = 0; i < 2; i++)
    {
      Vector3f amountToMoveCar = new Vector3f(motionX / 2F, motionY / 2F, motionZ / 2F);
     
      for(EntityWheel wheel : wheels)
      {
        if(wheel == null)
          continue;
       
        //Hacky way of forcing the car to step up blocks
        onGround = true;
        wheel.onGround = true;
       
        //Update angles
        wheel.rotationYaw = axes.getYaw();
       
        //Pull wheels towards car
        Vector3f targetWheelPos = axes.findLocalVectorGlobally(getPlaneType().wheelPositions[wheel.ID].position);
        Vector3f currentWheelPos = new Vector3f(wheel.posX - posX, wheel.posY - posY, wheel.posZ - posZ);
       
        float targetWheelLength = targetWheelPos.length();
        float currentWheelLength = currentWheelPos.length();
       
        float dLength = targetWheelLength - currentWheelLength;
        float dAngle = Vector3f.angle(targetWheelPos, currentWheelPos);
       
        //if(dLength > 0.01F || dAngle > 1F)
        {
          //Now Lerp by wheelSpringStrength and work out the new positions   
          float newLength = currentWheelLength + dLength * type.wheelSpringStrength;
          Vector3f rotateAround = Vector3f.cross(targetWheelPos, currentWheelPos, null);
         
          Matrix4f mat = new Matrix4f();
          mat.m00 = currentWheelPos.x;
          mat.m10 = currentWheelPos.y;
          mat.m20 = currentWheelPos.z;
          mat.rotate(dAngle * type.wheelSpringStrength, rotateAround);
         
          axes.rotateGlobal(-dAngle * type.wheelSpringStrength, rotateAround);
                   
          Vector3f newWheelPos = new Vector3f(mat.m00, mat.m10, mat.m20);
          newWheelPos.normalise().scale(newLength);
         
          //The proportion of the spring adjustment that is applied to the wheel. 1 - this is applied to the plane
          float wheelProportion = 0.75F;
         
          //wheel.motionX = (newWheelPos.x - currentWheelPos.x) * wheelProportion;
          //wheel.motionY = (newWheelPos.y - currentWheelPos.y) * wheelProportion;
          //wheel.motionZ = (newWheelPos.z - currentWheelPos.z) * wheelProportion;
         
          Vector3f amountToMoveWheel = new Vector3f();
         
          amountToMoveWheel.x = (newWheelPos.x - currentWheelPos.x) * (1F - wheelProportion);
          amountToMoveWheel.y = (newWheelPos.y - currentWheelPos.y) * (1F - wheelProportion);
          amountToMoveWheel.z = (newWheelPos.z - currentWheelPos.z) * (1F - wheelProportion);   
         
View Full Code Here

TOP

Related Classes of com.flansmod.common.vector.Vector3f

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.