double circle_x[PLANET_VERTICES], circle_y[PLANET_VERTICES], circle_z[PLANET_VERTICES];
double crescent_x[PLANET_VERTICES], crescent_y[PLANET_VERTICES], crescent_z[PLANET_VERTICES];
double x[PLANET_VERTICES], y[PLANET_VERTICES], z[PLANET_VERTICES];
- double size, angle, fabs_angle, crescent;
+ double dist, size, angle, fabs_angle, crescent;
double _sin, _cos;
int i;
int rc;
rotate_coordinate(roll, pitch, yaw, &sun_x, &sun_y, &sun_z);
rotate_coordinate(roll, pitch, yaw, &loc_x, &loc_y, &loc_z);
+ /* distance to planet */
+ dist = sqrt(loc_x * loc_x + loc_y * loc_y + loc_z * loc_z);
+
/* calculate direction of the sun */
angle_sun_h = atan2(sun_x, sun_z);
angle_loc_h = atan2(loc_x, loc_z);
}
}
for (i = 0; i < PLANET_VERTICES; i++) {
- x[i] = loc_x + circle_x[i];
- y[i] = loc_y + circle_y[i];
- z[i] = loc_z + circle_z[i];
+ x[i] = (loc_x + circle_x[i]) / dist * 1000000.0;
+ y[i] = (loc_y + circle_y[i]) / dist * 1000000.0;
+ z[i] = (loc_z + circle_z[i]) / dist * 1000000.0;
}
opengl_render_polygon_and_line(x, y, z, PLANET_VERTICES); /* no culling, its a planet! */
if (angle > M_PI / 2.0 || (angle < 0.0 && angle > -M_PI / 2.0)) {
/* to the right */
for (i = 0; i < PLANET_VERTICES / 2 + 1; i++) {
- x[i] = loc_x + circle_x[i];
- y[i] = loc_y + circle_y[i];
- z[i] = loc_z + circle_z[i];
+ x[i] = (loc_x + circle_x[i]) / dist * 1000000.0;
+ y[i] = (loc_y + circle_y[i]) / dist * 1000000.0;
+ z[i] = (loc_z + circle_z[i]) / dist * 1000000.0;
}
_sin = sin((1.0 - angle / (M_PI / 2)) * (M_PI / 2.0));
for (; i < PLANET_VERTICES; i++) {
- x[i] = loc_x + crescent_x[i];
- y[i] = loc_y + crescent_y[i];
- z[i] = loc_z + crescent_z[i];
+ x[i] = (loc_x + crescent_x[i]) / dist * 1000000.0;
+ y[i] = (loc_y + crescent_y[i]) / dist * 1000000.0;
+ z[i] = (loc_z + crescent_z[i]) / dist * 1000000.0;
}
} else {
/* to the left */
for (i = 0; i < PLANET_VERTICES / 2 + 1; i++) {
- x[i] = loc_x + crescent_x[i];
- y[i] = loc_y + crescent_y[i];
- z[i] = loc_z + crescent_z[i];
+ x[i] = (loc_x + crescent_x[i]) / dist * 1000000.0;
+ y[i] = (loc_y + crescent_y[i]) / dist * 1000000.0;
+ z[i] = (loc_z + crescent_z[i]) / dist * 1000000.0;
}
for (; i < PLANET_VERTICES; i++) {
- x[i] = loc_x + circle_x[i];
- y[i] = loc_y + circle_y[i];
- z[i] = loc_z + circle_z[i];
+ x[i] = (loc_x + circle_x[i]) / dist * 1000000.0;
+ y[i] = (loc_y + circle_y[i]) / dist * 1000000.0;
+ z[i] = (loc_z + circle_z[i]) / dist * 1000000.0;
}
}
opengl_render_polygon_and_line(x, y, z, PLANET_VERTICES); /* no culling, its a planet! */