Ship you = shipsID.get(UID); int dis = 300; Vector3f X = new Vector3f(camera.x(), camera.y(), camera.z()); float x = (float) (Math.cos(Math.toRadians(camera.yaw()))*Math.cos(Math.toRadians(camera.pitch()))); float y = (float) (Math.sin(Math.toRadians(camera.yaw()))*Math.cos(Math.toRadians(camera.pitch()))); float z = (float) Math.sin(Math.toRadians(camera.pitch())); Vector3f V = new Vector3f(x, y, z); for (Tree tree : trees){ Vector3f Y = new Vector3f(tree.location.x, tree.location.y, tree.location.z); Vector3f YMinusX = Y.negate(X);//new Vector3f(Y.x - X.x, Y.y - X.y, Y.z - X.z); float dot = Vector3f.dot(YMinusX, V); if (dot > 0){ tree.render(); } }
static boolean getNormal(Point3f p1, Point3f p2, Point3f p3, Vector3f normal) { Vector3f v1 = new Vector3f(); Vector3f v2 = new Vector3f(); // Must compute normal v1.sub(p2, p1); v2.sub(p2, p3); normal.cross(v1, v2); normal.negate(); float length = normal.length(); if (length > 0) { length = 1 / length; normal.x *= length; normal.y *= length; normal.z *= length; return true; } return false; }
n1.negate(); } else { if (!flip_side_orient) { n1.negate(); } else { if (!flip_side_orient) { n2.negate(); } else { if (!flip_side_orient) { n3.negate(); } else { if (!flip_side_orient) { n4.negate(); nn1.negate(); } else { if (!flip_side_orient) { nn3.negate(); } else { if (!flip_side_orient) { n1.negate(); } else {
Vector3f cap0Normal = new Vector3f(axis1) ; Vector3f cap1Normal = new Vector3f(axis1) ; cap0Normal.negate() ;