Package com.flansmod.common.guns.raytracing

Examples of com.flansmod.common.guns.raytracing.DriveableHit


     
      for(BulletHit bulletHit : hits)
      {
        if(bulletHit instanceof DriveableHit)
        {
          DriveableHit driveableHit = (DriveableHit)bulletHit;
          penetratingPower = driveableHit.driveable.bulletHit(this, driveableHit, penetratingPower);
          if(FlansMod.DEBUG)
            worldObj.spawnEntityInWorld(new EntityDebugDot(worldObj, new Vector3f(posX + motionX * driveableHit.intersectTime, posY + motionY * driveableHit.intersectTime, posZ + motionZ * driveableHit.intersectTime), 1000, 0F, 0F, 1F));

        }
View Full Code Here


      {
        float intersectTime = (box.x - origin.x) / motion.x;
        float intersectY = origin.y + motion.y * intersectTime;
        float intersectZ = origin.z + motion.z * intersectTime;
        if(intersectY >= box.y && intersectY <= box.y + box.h && intersectZ >= box.z && intersectZ <= box.z + box.d)
          return new DriveableHit(driveable, type, intersectTime);
      }
      else if(origin.x > box.x + box.w) //Check face x = o.x + d.x
      {
        float intersectTime = (box.x + box.w - origin.x) / motion.x;
        float intersectY = origin.y + motion.y * intersectTime;
        float intersectZ = origin.z + motion.z * intersectTime;
        if(intersectY >= box.y && intersectY <= box.y + box.h && intersectZ >= box.z && intersectZ <= box.z + box.d)
          return new DriveableHit(driveable, type, intersectTime);
      }
    }
   
    //Z - axis and faces z = box.z and z = box.z + box.d
    if(motion.z != 0F)
    {
      if(origin.z < box.z) //Check face z = box.z
      {
        float intersectTime = (box.z - origin.z) / motion.z;
        float intersectX = origin.x + motion.x * intersectTime;
        float intersectY = origin.y + motion.y * intersectTime;
        if(intersectX >= box.x && intersectX <= box.x + box.w && intersectY >= box.y && intersectY <= box.y + box.h)
          return new DriveableHit(driveable, type, intersectTime);
      }
      else if(origin.z > box.z + box.d) //Check face z = box.z + box.d
      {
        float intersectTime = (box.z + box.d - origin.z) / motion.z;
        float intersectX = origin.x + motion.x * intersectTime;
        float intersectY = origin.y + motion.y * intersectTime;
        if(intersectX >= box.x && intersectX <= box.x + box.w && intersectY >= box.y && intersectY <= box.y + box.h)
          return new DriveableHit(driveable, type, intersectTime);
      }
    }
   
    //Y - axis and faces y = box.y and y = box.y + box.h
    if(motion.y != 0F)
    {
      if(origin.y < box.y) //Check face y = o.y
      {
        float intersectTime = (box.y - origin.y) / motion.y;
        float intersectX = origin.x + motion.x * intersectTime;
        float intersectZ = origin.z + motion.z * intersectTime;
        if(intersectX >= box.x && intersectX <= box.x + box.w && intersectZ >= box.z && intersectZ <= box.z + box.d)
          return new DriveableHit(driveable, type, intersectTime);
      }
      else if(origin.y > box.y + box.h) //Check face x = box.y + box.h
      {
        float intersectTime = (box.y + box.h - origin.y) / motion.y;
        float intersectX = origin.x + motion.x * intersectTime;
        float intersectZ = origin.z + motion.z * intersectTime;
        if(intersectX >= box.x && intersectX <= box.x + box.w && intersectZ >= box.z && intersectZ <= box.z + box.d)
          return new DriveableHit(driveable, type, intersectTime);
      }
    }

    return null;
  }
View Full Code Here

    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);
      if(hit != null)
        hits.add(hit);
    }
    return hits;
  }
View Full Code Here

TOP

Related Classes of com.flansmod.common.guns.raytracing.DriveableHit

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.