Package logisticspipes.utils

Examples of logisticspipes.utils.MathVector


 
  private int[] getCursor(IHeadUpDisplayRendererProvider renderer) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.thePlayer;
   
    MathVector playerView = MathVector.getFromAngles((270 - player.rotationYaw) / 360 * -2 * Math.PI, (player.rotationPitch) / 360 * -2 * Math.PI);
    MathVector playerPos = new MathVector();
    playerPos.X = player.posX;
    playerPos.Y = player.posY;
    playerPos.Z = player.posZ;

    MathVector panelPos = new MathVector();
    panelPos.X = renderer.getX() + 0.5;
    panelPos.Y = renderer.getY() + 0.5;
    panelPos.Z = renderer.getZ() + 0.5;
   
    MathVector panelView = new MathVector();
    panelView.X = playerPos.X - panelPos.X;
    panelView.Y = playerPos.Y - panelPos.Y;
    panelView.Z = playerPos.Z - panelPos.Z;

    panelPos.add(panelView, 0.44D);

    double d = panelPos.X * panelView.X + panelPos.Y * panelView.Y + panelPos.Z * panelView.Z;
    double c = panelView.X * playerPos.X + panelView.Y * playerPos.Y + panelView.Z * playerPos.Z;
    double b = panelView.X * playerView.X + panelView.Y * playerView.Y + panelView.Z * playerView.Z;
    double a = (d - c) / b;
   
    MathVector viewPos = new MathVector();
    viewPos.X = playerPos.X + a * playerView.X - panelPos.X;
    viewPos.Y = playerPos.Y + a * playerView.Y - panelPos.Y;
    viewPos.Z = playerPos.Z + a * playerView.Z - panelPos.Z;
   
    MathVector panelScalVector1 = new MathVector();
   
    if(panelView.Y == 0) {
      panelScalVector1.X = 0;
      panelScalVector1.Y = 1;
      panelScalVector1.Z = 0;
    } else {
      panelScalVector1 = panelView.getOrtogonal(-panelView.X, null, -panelView.Z).makeVectorLength(1.0D);
    }
   
    MathVector panelScalVector2 = new MathVector();
   
    if(panelView.Z == 0) {
      panelScalVector2.X = 0;
      panelScalVector2.Y = 0;
      panelScalVector2.Z = 1;
    } else {
      panelScalVector2 = panelView.getOrtogonal(1.0D, 0.0D, null).makeVectorLength(1.0D);
    }
   
    if(panelScalVector1.Y == 0) {
      return new int[]{};
    }
   
    double cursorY = -viewPos.Y / panelScalVector1.Y;
   
    MathVector restViewPos = viewPos.clone();
    restViewPos.X += cursorY*panelScalVector1.X;
    restViewPos.Y = 0;
    restViewPos.Z += cursorY*panelScalVector1.Z;
   
    double cursorX;
View Full Code Here

TOP

Related Classes of logisticspipes.utils.MathVector

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.