Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void rotateLockAround(Entity parEnt, Vec3 center) {
- //progress was made..... but theres more to do
- // you need to recalculate the next axis based off of the result from the previous one!
- //do yaw, then from that yaw, do pitch
- //lets try using rules: looking forward where X+, behind you X-, left Z-, right Z+
- float calcsPerformed = 3;
- double radius = 10D;//worldObj.getWorldTime() % 200 / 20D;//(0D + ((double)(parEnt.entityId % 15) * 4D)) / calcsPerformed;
- float rotateRate = 15;
- float rotateTimeX = (worldObj.getWorldTime() % 360) * rotateRate;
- float rotateTimeY = (worldObj.getWorldTime() % 360) * rotateRate / 2F;
- float rotateTimeZ = (worldObj.getWorldTime() % 360) * rotateRate / 3F;
- float rotateID = parEnt.entityId % 100 * 10F;
- float yaw = 15+rotateID+rotateTimeX;
- float pitch = 45+rotateTimeY;/*rotateTime * rotateRate*/;//rotateTime * rotateRate;//((worldObj.getWorldTime() % 360) * rotateRate);
- float roll = 15+rotateTimeZ;//rotateTime - 180;//((worldObj.getWorldTime() % 360) * rotateRate);
- //yaw += parEnt.entityId % 100 * 10F;
- //pitch += parEnt.entityId % 100 * 3.6F;
- //roll += parEnt.entityId % 100 * 3.6F;
- /*yaw /= calcsPerformed;
- pitch /= calcsPerformed;
- roll /= calcsPerformed;*/
- //Vec3 relPos = Vec3.createVectorHelper(center.xCoord, center.yCoord, center.zCoord);
- double newX = center.xCoord;
- double newY = center.yCoord;
- double newZ = center.zCoord;
- Vec3 relPos = Vec3.createVectorHelper(newX, 0, newZ);
- relPos.rotateAroundY(yaw * 0.01745329F);
- newX = relPos.xCoord / relPos.lengthVector(); //for some reason only normalizing here APPEARS to produce acceptable results, i suspect innacuracies though.... why only this axis?
- newZ = relPos.zCoord / relPos.lengthVector();
- newY /= relPos.lengthVector();
- relPos = Vec3.createVectorHelper(0, newY, newZ);
- relPos.rotateAroundX(roll * 0.01745329F);
- newY = relPos.yCoord;
- newZ = relPos.zCoord;
- relPos = Vec3.createVectorHelper(newX, newY, 0);
- relPos.rotateAroundZ(pitch * 0.01745329F);
- newX = relPos.xCoord;
- newY = relPos.yCoord;
- //newZ /= relPos.lengthVector();
- //Vec3 relPosX = Vec3.createVectorHelper(0, center.yCoord, center.zCoord);
- //Vec3 relPosZ = Vec3.createVectorHelper(center.xCoord, center.yCoord, 0);
- //relPosX.rotateAroundY(yaw * 0.01745329F);
- //relPosZ.rotateAroundY(yaw * 0.01745329F);
- //relPosX.rotateAroundX(roll * 0.01745329F); //untested accurate
- //relPosZ.rotateAroundZ(pitch * 0.01745329F); //untested accurate
- /*double finalXAbs = relPosX.xCoord / relPosX.lengthVector() * radius + relPosZ.xCoord / relPosZ.lengthVector() * radius + relPosY.xCoord / relPosY.lengthVector() * radius;
- double finalYAbs = relPosX.yCoord / relPosX.lengthVector() * radius + relPosZ.yCoord / relPosZ.lengthVector() * radius + relPosY.yCoord / relPosY.lengthVector() * radius;
- double finalZAbs = relPosX.zCoord / relPosX.lengthVector() * radius + relPosZ.zCoord / relPosZ.lengthVector() * radius + relPosY.zCoord / relPosY.lengthVector() * radius;*/
- /*double finalXAbs = (relPosX.xCoord / relPosX.lengthVector() + relPosZ.xCoord / relPosZ.lengthVector() + relPosY.xCoord / relPosY.lengthVector()) * radius;
- double finalYAbs = (relPosX.yCoord / relPosX.lengthVector() + relPosZ.yCoord / relPosZ.lengthVector() + relPosY.yCoord / relPosY.lengthVector()) * radius;
- double finalZAbs = (relPosX.zCoord / relPosX.lengthVector() + relPosZ.zCoord / relPosZ.lengthVector() + relPosY.zCoord / relPosY.lengthVector()) * radius;*/
- /*double finalXAbs = (relPosX.xCoord / relPosX.lengthVector() - relPosZ.xCoord / relPosZ.lengthVector() - relPosY.xCoord / relPosY.lengthVector()) * radius;
- double finalYAbs = (relPosX.yCoord / relPosX.lengthVector() - relPosZ.yCoord / relPosZ.lengthVector() - relPosY.yCoord / relPosY.lengthVector()) * radius;
- double finalZAbs = (relPosX.zCoord / relPosX.lengthVector() - relPosZ.zCoord / relPosZ.lengthVector() - relPosY.zCoord / relPosY.lengthVector()) * radius;*/
- //Vec3 distVec = Vec3.createVectorHelper(center.xCoord - newX, center.yCoord - newY, center.zCoord - newZ);
- //Vec3 distVec = Vec3.createVectorHelper(newX - center.xCoord, newY - center.yCoord, newZ - center.zCoord);
- double finalXAbs = newX * radius;
- double finalYAbs = newY * radius;
- double finalZAbs = newZ * radius;
- parEnt.setPosition(center.xCoord + finalXAbs, center.yCoord + finalYAbs, center.zCoord + finalZAbs);
- //System.out.println("pos: " + finalXAbs + " - " + finalYAbs + " - " + finalZAbs);
- parEnt.motionX = 0;
- parEnt.motionY = 0;
- parEnt.motionZ = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement