Advertisement
Corosus

hue

Dec 3rd, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.89 KB | None | 0 0
  1. public void rotateLockAround(Entity parEnt, Vec3 center) {
  2.        
  3.         //progress was made..... but theres more to do
  4.         // you need to recalculate the next axis based off of the result from the previous one!
  5.        
  6.         //do yaw, then from that yaw, do pitch
  7.        
  8.         //lets try using rules: looking forward where X+, behind you X-, left Z-, right Z+
  9.        
  10.         float calcsPerformed = 3;
  11.         double radius = 10D;//worldObj.getWorldTime() % 200 / 20D;//(0D + ((double)(parEnt.entityId % 15) * 4D)) / calcsPerformed;
  12.         float rotateRate = 15;
  13.        
  14.         float rotateTimeX = (worldObj.getWorldTime() % 360) * rotateRate;
  15.         float rotateTimeY = (worldObj.getWorldTime() % 360) * rotateRate / 2F;
  16.         float rotateTimeZ = (worldObj.getWorldTime() % 360) * rotateRate / 3F;
  17.         float rotateID = parEnt.entityId % 100 * 10F;
  18.         float yaw = 15+rotateID+rotateTimeX;
  19.         float pitch = 45+rotateTimeY;/*rotateTime * rotateRate*/;//rotateTime * rotateRate;//((worldObj.getWorldTime() % 360) * rotateRate);
  20.         float roll = 15+rotateTimeZ;//rotateTime - 180;//((worldObj.getWorldTime() % 360) * rotateRate);
  21.        
  22.         //yaw += parEnt.entityId % 100 * 10F;
  23.         //pitch += parEnt.entityId % 100 * 3.6F;
  24.         //roll += parEnt.entityId % 100 * 3.6F;
  25.        
  26.         /*yaw /= calcsPerformed;
  27.         pitch /= calcsPerformed;
  28.         roll /= calcsPerformed;*/
  29.        
  30.        
  31.         //Vec3 relPos = Vec3.createVectorHelper(center.xCoord, center.yCoord, center.zCoord);
  32.         double newX = center.xCoord;
  33.         double newY = center.yCoord;
  34.         double newZ = center.zCoord;
  35.        
  36.         Vec3 relPos = Vec3.createVectorHelper(newX, 0, newZ);
  37.         relPos.rotateAroundY(yaw * 0.01745329F);
  38.        
  39.         newX = relPos.xCoord / relPos.lengthVector(); //for some reason only normalizing here APPEARS to produce acceptable results, i suspect innacuracies though.... why only this axis?
  40.         newZ = relPos.zCoord / relPos.lengthVector();
  41.         newY /= relPos.lengthVector();
  42.        
  43.         relPos = Vec3.createVectorHelper(0, newY, newZ);
  44.         relPos.rotateAroundX(roll * 0.01745329F);
  45.        
  46.         newY = relPos.yCoord;
  47.         newZ = relPos.zCoord;
  48.        
  49.         relPos = Vec3.createVectorHelper(newX, newY, 0);
  50.         relPos.rotateAroundZ(pitch * 0.01745329F);
  51.        
  52.         newX = relPos.xCoord;
  53.         newY = relPos.yCoord;
  54.         //newZ /= relPos.lengthVector();
  55.        
  56.         //Vec3 relPosX = Vec3.createVectorHelper(0, center.yCoord, center.zCoord);
  57.         //Vec3 relPosZ = Vec3.createVectorHelper(center.xCoord, center.yCoord, 0);
  58.        
  59.         //relPosX.rotateAroundY(yaw * 0.01745329F);
  60.         //relPosZ.rotateAroundY(yaw * 0.01745329F);
  61.        
  62.        
  63.        
  64.         //relPosX.rotateAroundX(roll * 0.01745329F); //untested accurate
  65.         //relPosZ.rotateAroundZ(pitch * 0.01745329F); //untested accurate
  66.        
  67.        
  68.        
  69.         /*double finalXAbs = relPosX.xCoord / relPosX.lengthVector() * radius + relPosZ.xCoord / relPosZ.lengthVector() * radius + relPosY.xCoord / relPosY.lengthVector() * radius;
  70.         double finalYAbs = relPosX.yCoord / relPosX.lengthVector() * radius + relPosZ.yCoord / relPosZ.lengthVector() * radius + relPosY.yCoord / relPosY.lengthVector() * radius;
  71.         double finalZAbs = relPosX.zCoord / relPosX.lengthVector() * radius + relPosZ.zCoord / relPosZ.lengthVector() * radius + relPosY.zCoord / relPosY.lengthVector() * radius;*/
  72.        
  73.         /*double finalXAbs = (relPosX.xCoord / relPosX.lengthVector() + relPosZ.xCoord / relPosZ.lengthVector() + relPosY.xCoord / relPosY.lengthVector()) * radius;
  74.         double finalYAbs = (relPosX.yCoord / relPosX.lengthVector() + relPosZ.yCoord / relPosZ.lengthVector() + relPosY.yCoord / relPosY.lengthVector()) * radius;
  75.         double finalZAbs = (relPosX.zCoord / relPosX.lengthVector() + relPosZ.zCoord / relPosZ.lengthVector() + relPosY.zCoord / relPosY.lengthVector()) * radius;*/
  76.        
  77.         /*double finalXAbs = (relPosX.xCoord / relPosX.lengthVector() - relPosZ.xCoord / relPosZ.lengthVector() - relPosY.xCoord / relPosY.lengthVector()) * radius;
  78.         double finalYAbs = (relPosX.yCoord / relPosX.lengthVector() - relPosZ.yCoord / relPosZ.lengthVector() - relPosY.yCoord / relPosY.lengthVector()) * radius;
  79.         double finalZAbs = (relPosX.zCoord / relPosX.lengthVector() - relPosZ.zCoord / relPosZ.lengthVector() - relPosY.zCoord / relPosY.lengthVector()) * radius;*/
  80.        
  81.         //Vec3 distVec = Vec3.createVectorHelper(center.xCoord - newX, center.yCoord - newY, center.zCoord - newZ);
  82.         //Vec3 distVec = Vec3.createVectorHelper(newX - center.xCoord, newY - center.yCoord, newZ - center.zCoord);
  83.        
  84.         double finalXAbs = newX * radius;
  85.         double finalYAbs = newY * radius;
  86.         double finalZAbs = newZ * radius;
  87.        
  88.         parEnt.setPosition(center.xCoord + finalXAbs, center.yCoord + finalYAbs, center.zCoord + finalZAbs);
  89.        
  90.         //System.out.println("pos: " + finalXAbs + " - " + finalYAbs + " - " + finalZAbs);
  91.        
  92.         parEnt.motionX = 0;
  93.         parEnt.motionY = 0;
  94.         parEnt.motionZ = 0;
  95.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement