Package com.flansmod.common.vector

Examples of com.flansmod.common.vector.Vector3f


            if(worldObj.isRemote)
            {
                 if(part.onFire)
              {
                //Pick a random position within the bounding box and spawn a flame there
                Vector3f pos = axes.findLocalVectorGlobally(new Vector3f(part.box.x + rand.nextFloat() * part.box.w, part.box.y + rand.nextFloat() * part.box.h, part.box.z + rand.nextFloat() * part.box.d));
                worldObj.spawnParticle("flame", posX + pos.x, posY + pos.y, posZ + pos.z, 0, 0, 0);
              }
                 if(part.health > 0 && part.health < part.maxHealth / 2)
              {
                //Pick a random position within the bounding box and spawn a flame there
                Vector3f pos = axes.findLocalVectorGlobally(new Vector3f(part.box.x + rand.nextFloat() * part.box.w, part.box.y + rand.nextFloat() * part.box.h, part.box.z + rand.nextFloat() * part.box.d));
                worldObj.spawnParticle(part.health < part.maxHealth / 4 ? "largesmoke" : "smoke", posX + pos.x, posY + pos.y, posZ + pos.z, 0, 0, 0);
              }
            }
            //Server side fire handling
            if(part.onFire)
            {
              //Rain can put out fire
              if(worldObj.isRaining() && rand.nextInt(40) == 0)
                part.onFire = false;
              //Also water blocks
              //Get the centre point of the part
              Vector3f pos = axes.findLocalVectorGlobally(new Vector3f(part.box.x + part.box.w / 2F, part.box.y + part.box.h / 2F, part.box.z + part.box.d / 2F));
              if(worldObj.getBlock(MathHelper.floor_double(posX + pos.x), MathHelper.floor_double(posY + pos.y), MathHelper.floor_double(posZ + pos.z)).getMaterial() == Material.water)
              {
                part.onFire = false;
              }
            }
            else
            {
              Vector3f pos = axes.findLocalVectorGlobally(new Vector3f(part.box.x / 16F + part.box.w / 32F, part.box.y / 16F + part.box.h / 32F, part.box.z / 16F + part.box.d / 32F));
              if(worldObj.getBlock(MathHelper.floor_double(posX + pos.x), MathHelper.floor_double(posY + pos.y), MathHelper.floor_double(posZ + pos.z)).getMaterial() == Material.lava)
              {
                part.onFire = true;
              }
            }
View Full Code Here


    double speed = getSpeedXYZ();
    for(DriveablePosition p : getDriveableType().collisionPoints)
    {
      if(driveableData.parts.get(p.part).dead)
        continue;
      Vector3f lastRelPos = prevAxes.findLocalVectorGlobally(p.position);
      Vec3 lastPos = Vec3.createVectorHelper(prevPosX + lastRelPos.x, prevPosY + lastRelPos.y, prevPosZ + lastRelPos.z);
     
      Vector3f currentRelPos = axes.findLocalVectorGlobally(p.position);
      Vec3 currentPos = Vec3.createVectorHelper(posX + currentRelPos.x, posY + currentRelPos.y, posZ + currentRelPos.z);
     
      if(FlansMod.DEBUG && worldObj.isRemote)
      {
        worldObj.spawnEntityInWorld(new EntityDebugVector(worldObj, new Vector3f(lastPos), Vector3f.sub(currentRelPos, lastRelPos, null), 10, 1F, 0F, 0F));
      }
     
      MovingObjectPosition hit = worldObj.rayTraceBlocks(lastPos, currentPos, crashInWater);
      if(hit != null && hit.typeOfHit == MovingObjectType.BLOCK)
      {
View Full Code Here

  }

  /** Takes a vector (such as the origin of a seat / gun) and translates it from local coordinates to global coordinates */
  public Vector3f rotate(double x, double y, double z)
  { 
    return rotate(new Vector3f((float)x, (float)y, (float)z));
  }
View Full Code Here

  public ArrayList<BulletHit> attackFromBullet(Vector3f origin, Vector3f motion)
  {
    //Make an array to contain the hits
    ArrayList<BulletHit> hits = new ArrayList<BulletHit>();
    //Get the position of the bullet origin, relative to the centre of the plane, and then rotate the vectors onto local co-ordinates
    Vector3f relativePosVector = Vector3f.sub(origin, new Vector3f((float)posX, (float)posY, (float)posZ), null);
    Vector3f rotatedPosVector = axes.findGlobalVectorLocally(relativePosVector);
    Vector3f rotatedMotVector = axes.findGlobalVectorLocally(motion);
    //Check each part
    for(DriveablePart part : getDriveableData().parts.values())
    {
      //Ray trace the bullet
      DriveableHit hit = part.rayTrace(this, rotatedPosVector, rotatedMotVector);
View Full Code Here

 
  /** A simple raytracer for the driveable. Called by tools */
  public DriveablePart raytraceParts(Vector3f origin, Vector3f motion)
  {
    //Get the position of the bullet origin, relative to the centre of the plane, and then rotate the vectors onto local co-ordinates
    Vector3f relativePosVector = Vector3f.sub(origin, new Vector3f((float)posX, (float)posY, (float)posZ), null);
    Vector3f rotatedPosVector = axes.findGlobalVectorLocally(relativePosVector);
    Vector3f rotatedMotVector = axes.findGlobalVectorLocally(motion);
    //Check each part
    for(DriveablePart part : getDriveableData().parts.values())
    {
      //Ray trace the bullet
      if(part.rayTrace(this, rotatedPosVector, rotatedMotVector) != null)
View Full Code Here

   
    //Drop items
    DriveableType type = getDriveableType();
    if(!worldObj.isRemote)
    {
      Vector3f pos = new Vector3f(0, 0, 0);
         
      //Get the midpoint of the part
      if(part.box != null)
          pos = axes.findLocalVectorGlobally(new Vector3f(part.box.x / 16F + part.box.w / 32F, part.box.y / 16F + part.box.h / 32F, part.box.z / 16F + part.box.d / 32F));
         
      ArrayList<ItemStack> drops = type.getItemsRequired(part, getDriveableData().engine);
        if(drops != null)
      {
        //Drop each itemstack
View Full Code Here

    return rotationRoll;
  }
 
  public Vector3f getXAxis()
  {
    return new Vector3f(rotationMatrix.m00, rotationMatrix.m10, rotationMatrix.m20);
  }
View Full Code Here

    return new Vector3f(rotationMatrix.m00, rotationMatrix.m10, rotationMatrix.m20);
  }
 
  public Vector3f getYAxis()
  {
    return new Vector3f(rotationMatrix.m01, rotationMatrix.m11, rotationMatrix.m21);
  }
View Full Code Here

    return new Vector3f(rotationMatrix.m01, rotationMatrix.m11, rotationMatrix.m21);
  }
 
  public Vector3f getZAxis()
  {
    return new Vector3f(-rotationMatrix.m02, -rotationMatrix.m12, -rotationMatrix.m22);
  }
View Full Code Here

  }
 
  //Rotate globally by some angle about the yaw axis
  public RotatedAxes rotateGlobalYaw(float rotateBy)
  {
    rotationMatrix.rotate(rotateBy * 3.14159265F / 180F, new Vector3f(0F, 1F, 0F));
    convertMatrixToAngles();
    return this;
  }
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.