Guest User

Untitled

a guest
Jan 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1.  void calculateNormal(GL gl, double height, String windPart) {
  2.         Vector3D vertA;  
  3.         Vector3D vertB;  
  4.         Vector3D vertC;
  5.         Vector3D normal;
  6.         Point2D p1 = (Point2D)(pts2d.get(0));
  7.         Point2D p2 = (Point2D)(pts2d.get(1));
  8.         if (windPart.equals("bot")) {
  9.             vertA = new Vector3D(p1.x, extra[0], p1.y);
  10.             vertB = new Vector3D(p2.x, extra[0], p2.y);
  11.             vertC =  new Vector3D(p2.x, extra[0] + height *1/3, p2.y);
  12.         }else{
  13.             vertA = new Vector3D(p1.x, extra[1] - height *1/3, p1.y);
  14.             vertB = new Vector3D(p2.x, extra[1] - height *1/3, p2.y);
  15.             vertC =  new Vector3D(p2.x, extra[1], p2.y);
  16.         }
  17.         vertB = vertB.subtract(vertA);
  18.         vertC = vertC.subtract(vertA);
  19.         normal = vertB.cross(vertC);
  20.         normal.normalize();
  21.         gl.glNormal3d(normal.x, normal.y, normal.z);
  22.     }
Add Comment
Please, Sign In to add comment