#endif
#include <Debug/fg_debug.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Math/fg_geodesy.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Misc/fgstream.hxx>
#include <Objects/material.hxx>
#include "genapt.hxx"
-typedef vector < fgPoint3d > container;
+typedef vector < Point3D > container;
typedef container::iterator iterator;
typedef container::const_iterator const_iterator;
-// Calculate distance between to fgPoint3d's
-static double calc_dist(const fgPoint3d& p1, const fgPoint3d& p2) {
+/*
+// Calculate distance between to Point3D's
+static double calc_dist(const Point3D& p1, const Point3D& p2) {
double x, y, z;
- x = p1.x - p2.x;
- y = p1.y - p2.y;
- z = p1.z - p2.z;
+ x = p1.x() - p2.x();
+ y = p1.y() - p2.y();
+ z = p1.z() - p2.z();
return sqrt(x*x + y*y + z*z);
}
+*/
-// convert a geodetic point lon(degrees), lat(degrees), elev(meter) to a
-// cartesian point
-static fgPoint3d geod_to_cart(fgPoint3d geod) {
- fgPoint3d cart;
- fgPoint3d geoc;
- double sl_radius;
+// convert a geodetic point lon(radians), lat(radians), elev(meter) to
+// a cartesian point
+static Point3D geod_to_cart(const Point3D& geod) {
+ Point3D cp;
+ Point3D pp;
+ double gc_lon, gc_lat, sl_radius;
- // printf("A geodetic point is (%.2f, %.2f, %.2f)\n", geod[0],
- // geod[1], geod[2]);
+ // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
+ // geod[0], geod[1], geod[2]);
- geoc.lon = geod.lon*DEG_TO_RAD;
- fgGeodToGeoc(geod.lat*DEG_TO_RAD, geod.radius, &sl_radius, &geoc.lat);
+ gc_lon = geod.lon();
+ fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
// printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
- // gc_lat, sl_radius+geod[2]); */
+ // gc_lat, sl_radius+geod[2]);
- geoc.radius = sl_radius + geod.radius;
- cart = fgPolarToCart3d(geoc);
+ pp.setvals(gc_lon, gc_lat, sl_radius + geod.radius());
+ cp = fgPolarToCart3d(pp);
// printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z);
- return cart;
+ return(cp);
}
-
#define FG_APT_BASE_TEX_CONSTANT 2000.0
#ifdef OLD_TEX_COORDS
// Calculate texture coordinates for a given point.
-static fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) {
- fgPoint3d cp;
- fgPoint3d pp;
+static Point3D calc_tex_coords(double *node, const Point3D& ref) {
+ Point3D cp;
+ Point3D pp;
- cp.x = node[0] + ref->x;
- cp.y = node[1] + ref->y;
- cp.z = node[2] + ref->z;
+ cp.setvals( node[0] + ref.x(), node[1] + ref.y(), node[2] + ref.z() );
pp = fgCartToPolar3d(cp);
- pp.lon = fmod(FG_APT_BASE_TEX_CONSTANT * pp.lon, 10.0);
- pp.lat = fmod(FG_APT_BASE_TEX_CONSTANT * pp.lat, 10.0);
+ pp.setx( fmod(FG_APT_BASE_TEX_CONSTANT * pp.x(), 10.0) );
+ pp.sety( fmod(FG_APT_BASE_TEX_CONSTANT * pp.y(), 10.0) );
- if ( pp.lon < 0.0 ) {
- pp.lon += 10.0;
+ if ( pp.x() < 0.0 ) {
+ pp.setx( pp.x() + 10.0 );
}
- if ( pp.lat < 0.0 ) {
- pp.lat += 10.0;
+ if ( pp.y() < 0.0 ) {
+ pp.sety( pp.y() + 10.0 );
}
return(pp);
// generate the actual base area for the airport
static void
-gen_base( const fgPoint3d& average, const container& perimeter, fgTILE *t)
+gen_base( const Point3D& average, const container& perimeter, fgTILE *t)
{
GLint display_list;
- fgPoint3d cart, cart_trans, tex;
+ Point3D cart, cart_trans, tex;
MAT3vec normal;
double dist, max_dist, temp;
int center_num, i;
}
printf(" tile center = %.2f %.2f %.2f\n",
- t->center.x, t->center.y, t->center.z);
+ t->center.x(), t->center.y(), t->center.z() );
printf(" airport center = %.2f %.2f %.2f\n",
- average.x, average.y, average.z);
- fragment.center.x = average.x;
- fragment.center.y = average.y;
- fragment.center.z = average.z;
-
- normal[0] = average.x;
- normal[1] = average.y;
- normal[2] = average.z;
+ average.x(), average.y(), average.z());
+ fragment.center = average;
+
+ normal[0] = average.x();
+ normal[1] = average.y();
+ normal[2] = average.z();
MAT3_NORMALIZE_VEC(normal, temp);
display_list = xglGenLists(1);
xglBegin(GL_TRIANGLE_FAN);
// first point center of fan
- cart_trans.x = average.x - t->center.x;
- cart_trans.y = average.y - t->center.y;
- cart_trans.z = average.z - t->center.z;
- t->nodes[t->ncount][0] = cart_trans.x;
- t->nodes[t->ncount][1] = cart_trans.y;
- t->nodes[t->ncount][2] = cart_trans.z;
+ cart_trans = average - t->center;
+ t->nodes[t->ncount][0] = cart_trans.x();
+ t->nodes[t->ncount][1] = cart_trans.y();
+ t->nodes[t->ncount][2] = cart_trans.z();
center_num = t->ncount;
t->ncount++;
- tex = calc_tex_coords( t->nodes[t->ncount-1], &(t->center) );
- xglTexCoord2f(tex.x, tex.y);
+ tex = calc_tex_coords( t->nodes[t->ncount-1], t->center );
+ xglTexCoord2f(tex.x(), tex.y());
xglNormal3dv(normal);
xglVertex3dv(t->nodes[t->ncount-1]);
// first point on perimeter
- iterator current = perimeter.begin();
+ const_iterator current = perimeter.begin();
cart = geod_to_cart( *current );
- cart_trans.x = cart.x - t->center.x;
- cart_trans.y = cart.y - t->center.y;
- cart_trans.z = cart.z - t->center.z;
- t->nodes[t->ncount][0] = cart_trans.x;
- t->nodes[t->ncount][1] = cart_trans.y;
- t->nodes[t->ncount][2] = cart_trans.z;
+ cart_trans = cart - t->center;
+ t->nodes[t->ncount][0] = cart_trans.x();
+ t->nodes[t->ncount][1] = cart_trans.y();
+ t->nodes[t->ncount][2] = cart_trans.z();
t->ncount++;
i = 1;
- tex = calc_tex_coords( t->nodes[i], &(t->center) );
- dist = calc_dist(average, cart);
+ tex = calc_tex_coords( t->nodes[i], t->center );
+ dist = distance3D(average, cart);
if ( dist > max_dist ) {
max_dist = dist;
}
- xglTexCoord2f(tex.x, tex.y);
+ xglTexCoord2f(tex.x(), tex.y());
xglVertex3dv(t->nodes[i]);
++current;
++i;
const_iterator last = perimeter.end();
for ( ; current != last; ++current ) {
cart = geod_to_cart( *current );
- cart_trans.x = cart.x - t->center.x;
- cart_trans.y = cart.y - t->center.y;
- cart_trans.z = cart.z - t->center.z;
- t->nodes[t->ncount][0] = cart_trans.x;
- t->nodes[t->ncount][1] = cart_trans.y;
- t->nodes[t->ncount][2] = cart_trans.z;
+ cart_trans = cart - t->center;
+ t->nodes[t->ncount][0] = cart_trans.x();
+ t->nodes[t->ncount][1] = cart_trans.y();
+ t->nodes[t->ncount][2] = cart_trans.z();
t->ncount++;
fragment.add_face(center_num, i - 1, i);
- tex = calc_tex_coords( t->nodes[i], &(t->center) );
- dist = calc_dist(average, cart);
+ tex = calc_tex_coords( t->nodes[i], t->center );
+ dist = distance3D(average, cart);
if ( dist > max_dist ) {
max_dist = dist;
}
- xglTexCoord2f(tex.x, tex.y);
+ xglTexCoord2f(tex.x(), tex.y());
xglVertex3dv(t->nodes[i]);
i++;
}
// last point (first point in perimeter list)
current = perimeter.begin();
cart = geod_to_cart( *current );
- cart_trans.x = cart.x - t->center.x;
- cart_trans.y = cart.y - t->center.y;
- cart_trans.z = cart.z - t->center.z;
+ cart_trans = cart - t->center;
fragment.add_face(center_num, i - 1, 1);
- tex = calc_tex_coords( t->nodes[1], &(t->center) );
- xglTexCoord2f(tex.x, tex.y);
+ tex = calc_tex_coords( t->nodes[1], t->center );
+ xglTexCoord2f(tex.x(), tex.y());
xglVertex3dv(t->nodes[1]);
xglEnd();
// face list (this indexes into the master tile vertex list)
container perimeter;
- fgPoint3d p, average;
+ Point3D p, average;
+ double avex = 0.0, avey = 0.0, avez = 0.0;
int size;
// gpc_vertex p_2d, list_2d[MAX_PERIMETER];
in.stream() >> apt_id;
apt_name = "";
i = 1;
- average.lon = average.lat = average.radius = 0.0;
+ avex = avey = avez = 0.0;
perimeter.erase( perimeter.begin(), perimeter.end() );
// skip to end of line.
while ( in.get(c) && c != '\n' ) {
// out of the base terrain. The points are given in
// counter clockwise order and are specified in lon/lat
// degrees.
- in.stream() >> p.lon >> p.lat >> p.radius;
- average.x += tile->nodes[i][0];
- average.y += tile->nodes[i][1];
- average.z += tile->nodes[i][2];
+ in.stream() >> p;
+ avex += tile->nodes[i][0];
+ avey += tile->nodes[i][1];
+ avez += tile->nodes[i][2];
perimeter.push_back(p);
++i;
} else if ( token == "r" ) {
// we have just finished reading and airport record.
// process the info
size = perimeter.size();
- average.x = average.x / (double)size + tile->center.x;
- average.y = average.y / (double)size + tile->center.y;
- average.z = average.z / (double)size + tile->center.z;
+ average.setvals( avex / (double)size + tile->center.x(),
+ avey / (double)size + tile->center.y(),
+ avez / (double)size + tile->center.z() );
gen_base(average, perimeter, tile);
}
// $Log$
+// Revision 1.4 1998/10/16 00:51:46 curt
+// Converted to Point3D class.
+//
// Revision 1.3 1998/09/21 20:55:00 curt
// Used the cartesian form of the airport area coordinates to determine the
// center.
xglPushMatrix();
/* Translate to view position */
- xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
+ xglTranslatef( v->cur_zero_elev.x(),
+ v->cur_zero_elev.y(),
+ v->cur_zero_elev.z() );
/* printf(" Translated to %.2f %.2f %.2f\n",
v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); */
/* $Log$
-/* Revision 1.10 1998/08/29 13:07:16 curt
-/* Rewrite of event manager thanks to Bernie Bright.
+/* Revision 1.11 1998/10/16 00:52:19 curt
+/* Converted to Point3D class.
/*
+ * Revision 1.10 1998/08/29 13:07:16 curt
+ * Rewrite of event manager thanks to Bernie Bright.
+ *
* Revision 1.9 1998/08/22 01:18:59 curt
* Minor tweaks to avoid using unitialized memory.
*
#include <Aircraft/aircraft.h>
#include <Debug/fg_debug.h>
#include <Include/fg_constants.h>
-#include <Include/fg_types.h>
#include <Misc/fgstream.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
// Initialize the Star Management Subsystem
int fgStarsInit( void ) {
- fgPoint3d starlist[FG_MAX_STARS];
+ Point3D starlist[FG_MAX_STARS];
// struct CelestialCoord pltPos;
double right_ascension, declination, magnitude;
double min_magnitude[FG_STAR_LEVELS];
{
in.eat_comments();
string name;
- char c = 0;
getline( in.stream(), name, ',' );
- in.stream() >> starlist[starcount].x >> c;
- in.stream() >> starlist[starcount].y >> c;
- // in.stream() >> starlist[starcount].x; in.get(c);
- // in.stream() >> starlist[starcount].y; in.get(c);
- in.stream() >> starlist[starcount].z;
+ in.stream() >> starlist[starcount];
++starcount;
}
count = 0;
for ( j = 0; j < starcount; j++ ) {
- magnitude = starlist[j].z;
+ magnitude = starlist[j].z();
// printf("magnitude = %.2f\n", magnitude);
if ( magnitude < min_magnitude[i] ) {
- right_ascension = starlist[j].x;
- declination = starlist[j].y;
+ right_ascension = starlist[j].x();
+ declination = starlist[j].y();
count++;
// $Log$
+// Revision 1.18 1998/10/16 00:52:20 curt
+// Converted to Point3D class.
+//
// Revision 1.17 1998/09/24 15:36:19 curt
// Converted to c++ style comments.
//
// setup transformation for drawing astronomical objects
xglPushMatrix();
// Translate to view position
- xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
+ xglTranslatef( v->view_pos.x(), v->view_pos.y(), v->view_pos.z() );
// Rotate based on gst (sidereal time)
// note: constant should be 15.041085, Curt thought it was 15
angle = t->gst * 15.041085;
// $Log$
+// Revision 1.57 1998/10/16 00:54:00 curt
+// Converted to Point3D class.
+//
// Revision 1.56 1998/10/02 12:46:47 curt
// Added an "auto throttle"
//
#include <Joystick/joystick.h>
#include <Math/fg_geodesy.h>
#include <Math/fg_random.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
// convert a geodetic point lon(radians), lat(radians), elev(meter) to
// a cartesian point
-fgPoint3d geod_to_cart(double geod[3]) {
- fgPoint3d cp;
- fgPoint3d pp;
+static Point3D geod_to_cart(double geod[3]) {
+ Point3D cp;
+ Point3D pp;
double gc_lon, gc_lat, sl_radius;
// printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
// printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
// gc_lat, sl_radius+geod[2]);
- pp.lon = gc_lon;
- pp.lat = gc_lat;
- pp.radius = sl_radius + geod[2];
+ pp.setvals( gc_lon, gc_lat, sl_radius + geod[2] );
cp = fgPolarToCart3d(pp);
// printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z);
fgTIME *t;
fgVIEW *v;
double geod_pos[3];
- fgPoint3d abs_view_pos;
+ Point3D abs_view_pos;
l = &cur_light_params;
t = &cur_time_params;
// Calculate ground elevation at starting point
scenery.cur_elev =
- fgTileMgrCurElev( FG_Longitude, FG_Latitude, &abs_view_pos );
+ fgTileMgrCurElev( FG_Longitude, FG_Latitude, abs_view_pos );
FG_Runway_altitude = scenery.cur_elev * METER_TO_FEET;
// Reset our altitude if we are below ground
// $Log$
+// Revision 1.41 1998/10/16 00:54:01 curt
+// Converted to Point3D class.
+//
// Revision 1.40 1998/10/02 12:46:49 curt
// Added an "auto throttle"
//
#include <Debug/fg_debug.h>
#include <Include/fg_constants.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Math/vector.hxx>
#include <Scenery/scenery.hxx>
xglLoadIdentity();
// set up our view volume (default)
- LookAt(view_pos.x, view_pos.y, view_pos.z,
- view_pos.x + view_forward[0],
- view_pos.y + view_forward[1],
- view_pos.z + view_forward[2],
+ LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
+ view_pos.x() + view_forward[0],
+ view_pos.y() + view_forward[1],
+ view_pos.z() + view_forward[2],
view_up[0], view_up[1], view_up[2]);
// look almost straight up (testing and eclipse watching)
- /* LookAt(view_pos.x, view_pos.y, view_pos.z,
- view_pos.x + view_up[0] + .001,
- view_pos.y + view_up[1] + .001,
- view_pos.z + view_up[2] + .001,
+ /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
+ view_pos.x() + view_up[0] + .001,
+ view_pos.y() + view_up[1] + .001,
+ view_pos.z() + view_up[2] + .001,
view_up[0], view_up[1], view_up[2]); */
// lock view horizontally towards sun (testing)
- /* LookAt(view_pos.x, view_pos.y, view_pos.z,
- view_pos.x + surface_to_sun[0],
- view_pos.y + surface_to_sun[1],
- view_pos.z + surface_to_sun[2],
+ /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
+ view_pos.x() + surface_to_sun[0],
+ view_pos.y() + surface_to_sun[1],
+ view_pos.z() + surface_to_sun[2],
view_up[0], view_up[1], view_up[2]); */
// lock view horizontally towards south (testing)
- /* LookAt(view_pos.x, view_pos.y, view_pos.z,
- view_pos.x + surface_south[0],
- view_pos.y + surface_south[1],
- view_pos.z + surface_south[2],
+ /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
+ view_pos.x() + surface_south[0],
+ view_pos.y() + surface_south[1],
+ view_pos.z() + surface_south[2],
view_up[0], view_up[1], view_up[2]); */
// set the sun position
// Update the view parameters
void fgVIEW::UpdateViewMath( fgFLIGHT *f ) {
- fgPoint3d p;
+ Point3D p;
MAT3vec vec, forward, v0, minus_z;
MAT3mat R, TMP, UP, LOCAL, VIEW;
double ntmp;
update_fov = false;
}
- scenery.center.x = scenery.next_center.x;
- scenery.center.y = scenery.next_center.y;
- scenery.center.z = scenery.next_center.z;
+ scenery.center = scenery.next_center;
// printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
// scenery.center.y, scenery.center.z);
// calculate the cartesion coords of the current lat/lon/0 elev
- p.lon = FG_Longitude;
- p.lat = FG_Lat_geocentric;
- p.radius = FG_Sea_level_radius * FEET_TO_METER;
+ p.setvals(
+ FG_Longitude,
+ FG_Lat_geocentric,
+ FG_Sea_level_radius * FEET_TO_METER );
- cur_zero_elev = fgPolarToCart3d(p);
-
- cur_zero_elev.x -= scenery.center.x;
- cur_zero_elev.y -= scenery.center.y;
- cur_zero_elev.z -= scenery.center.z;
+ cur_zero_elev = fgPolarToCart3d(p) - scenery.center;
// calculate view position in current FG view coordinate system
// p.lon & p.lat are already defined earlier, p.radius was set to
// the sea level radius, so now we add in our altitude.
if ( FG_Altitude * FEET_TO_METER >
(scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
- p.radius += FG_Altitude * FEET_TO_METER;
+ p.setz( p.radius() + FG_Altitude * FEET_TO_METER );
} else {
- p.radius += scenery.cur_elev + 0.5 * METER_TO_FEET;
+ p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
}
abs_view_pos = fgPolarToCart3d(p);
-
- view_pos.x = abs_view_pos.x - scenery.center.x;
- view_pos.y = abs_view_pos.y - scenery.center.y;
- view_pos.z = abs_view_pos.z - scenery.center.z;
+ view_pos = abs_view_pos - scenery.center;
fgPrintf( FG_VIEW, FG_DEBUG, "Absolute view pos = %.4f, %.4f, %.4f\n",
- abs_view_pos.x, abs_view_pos.y, abs_view_pos.z);
+ abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z());
fgPrintf( FG_VIEW, FG_DEBUG, "Relative view pos = %.4f, %.4f, %.4f\n",
- view_pos.x, view_pos.y, view_pos.z);
+ view_pos.x(), view_pos.y(), view_pos.z());
// Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
// from FG_T_local_to_body[3][3]
MAT3mult_vec(view_forward, forward, TMP);
// make a vector to the current view position
- MAT3_SET_VEC(v0, view_pos.x, view_pos.y, view_pos.z);
+ MAT3_SET_VEC(v0, view_pos.x(), view_pos.y(), view_pos.z());
// Given a vector pointing straight down (-Z), map into onto the
// local plane representing "horizontal". This should give us the
// MAT3print(AIRCRAFT, stdout);
// View position in scenery centered coordinates
- MAT3_SET_HVEC(vec, view_pos.x, view_pos.y, view_pos.z, 1.0);
+ MAT3_SET_HVEC(vec, view_pos.x(), view_pos.y(), view_pos.z(), 1.0);
MAT3translate(T_view, vec);
// printf("\nTranslation matrix\n");
// MAT3print(T_view, stdout);
// Olson curt@me.umn.edu and Norman Vine nhv@yahoo.com with 'gentle
// guidance' from Steve Baker sbaker@link.com
int
-fgVIEW::SphereClip( const fgPoint3d *cp,
- const double radius )
+fgVIEW::SphereClip( const Point3D& cp, const double radius )
{
double x1, y1;
// $Log$
+// Revision 1.22 1998/10/16 00:54:03 curt
+// Converted to Point3D class.
+//
// Revision 1.21 1998/09/17 18:35:33 curt
// Added F8 to toggle fog and F9 to toggle texturing.
//
#endif
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Flight/flight.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Time/fg_time.hxx>
#include <Time/light.hxx>
int tris_rendered;
// absolute view position
- fgPoint3d abs_view_pos;
+ Point3D abs_view_pos;
// view position translated to scenery.center
- fgPoint3d view_pos;
+ Point3D view_pos;
// cartesion coordinates of current lon/lat if at sea level
// translated to scenery.center*/
- fgPoint3d cur_zero_elev;
+ Point3D cur_zero_elev;
// vector in cartesian coordinates from current position to the
// postion on the earth's surface the sun is directly over
// $Log$
+// Revision 1.14 1998/10/16 00:54:04 curt
+// Converted to Point3D class.
+//
// Revision 1.13 1998/09/08 15:04:36 curt
// Optimizations by Norman Vine.
//
#include <Include/fg_constants.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Scenery/tile.hxx>
#include "fragment.hxx"
// intersection found, 0 otherwise. If it intesects, result is the
// point of intersection
-int fgFRAGMENT::intersect( const fgPoint3d *end0,
- const fgPoint3d *end1,
+int fgFRAGMENT::intersect( const Point3D& end0,
+ const Point3D& end1,
int side_flag,
- fgPoint3d *result) const
+ Point3D& result) const
{
fgTILE *t;
MAT3vec v1, v2, n, center;
// printf(".");
// get face vertex coordinates
- center[0] = t->center.x;
- center[1] = t->center.y;
- center[2] = t->center.z;
+ center[0] = t->center.x();
+ center[1] = t->center.y();
+ center[2] = t->center.z();
MAT3_ADD_VEC(p1, t->nodes[(*current).n1], center);
MAT3_ADD_VEC(p2, t->nodes[(*current).n2], center);
// printf("p3(d) = %.2f\n", a * p3[0] + b * p3[1] + c * p3[2]);
// calculate the line coefficients for the specified line
- x0 = end0->x; x1 = end1->x;
- y0 = end0->y; y1 = end1->y;
- z0 = end0->z; z1 = end1->z;
+ x0 = end0.x(); x1 = end1.x();
+ y0 = end0.y(); y1 = end1.y();
+ z0 = end0.z(); z1 = end1.z();
if ( fabs(x1 - x0) > FG_EPSILON ) {
a1 = 1.0 / (x1 - x0);
// everything is too close together to tell the difference
// so the current intersection point should work as good
// as any
- result->x = x;
- result->y = y;
- result->z = z;
+ result.setvals(x, y, z);
return(1);
}
side1 = FG_SIGN (t1 - t2);
} else {
// all dimensions are really small so lets call it close
// enough and return a successful match
- result->x = x;
- result->y = y;
- result->z = z;
+ result.setvals(x, y, z);
return(1);
}
}
// printf( "intersection point = %.2f %.2f %.2f\n", x, y, z);
- result->x = x;
- result->y = y;
- result->z = z;
+ result.setvals(x, y, z);
return(1);
}
}
// $Log$
+// Revision 1.5 1998/10/16 00:54:37 curt
+// Converted to Point3D class.
+//
// Revision 1.4 1998/09/15 01:35:03 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
#include <vector>
#include <Bucket/bucketutils.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include "Include/fg_constants.h"
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#ifdef NEEDNAMESPACESTD
using namespace std;
public:
// culling data for this object fragment (fine grain culling)
- fgPoint3d center;
+ Point3D center;
double bounding_radius;
// variable offset data for this object fragment for this frame
// to see that end points are on opposite sides of face. Returns
// 1 if it intersection found, 0 otherwise. If it intesects,
// result is the point of intersection
- int intersect( const fgPoint3d *end0,
- const fgPoint3d *end1,
+ int intersect( const Point3D& end0,
+ const Point3D& end1,
int side_flag,
- fgPoint3d *result) const;
+ Point3D& result) const;
// Constructors
fgFRAGMENT () { /*faces.reserve(512);*/}
inline bool
operator == ( const fgFRAGMENT & lhs, const fgFRAGMENT & rhs ) {
- return (( lhs.center.x - rhs.center.x ) < FG_EPSILON &&
- ( lhs.center.y - rhs.center.y ) < FG_EPSILON &&
- ( lhs.center.z - rhs.center.z ) < FG_EPSILON );
+ return lhs.center == rhs.center;
}
// $Log$
+// Revision 1.6 1998/10/16 00:54:38 curt
+// Converted to Point3D class.
+//
// Revision 1.5 1998/09/15 01:35:04 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
#include <Main/options.hxx>
#include <Math/mat3.h>
#include <Math/fg_random.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Misc/stopwatch.hxx>
#include <Misc/fgstream.hxx>
// Calculate texture coordinates for a given point.
-fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) {
- fgPoint3d cp;
- fgPoint3d pp;
+Point3D calc_tex_coords(double *node, const Point3D& ref) {
+ Point3D cp;
+ Point3D pp;
- cp.x = node[0] + ref->x;
- cp.y = node[1] + ref->y;
- cp.z = node[2] + ref->z;
+ cp.setvals( node[0] + ref.x(),
+ node[1] + ref.y(),
+ node[2] + ref.z() );
pp = fgCartToPolar3d(cp);
- pp.lon = fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.lon, 25.0);
- pp.lat = fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.lat, 25.0);
+ pp.setx( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.x(), 25.0) );
+ pp.sety( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.y(), 25.0) );
- if ( pp.lon < 0.0 ) {
- pp.lon += 25.0;
+ if ( pp.x() < 0.0 ) {
+ pp.setx( pp.x() + 25.0 );
}
- if ( pp.lat < 0.0 ) {
- pp.lat += 25.0;
+ if ( pp.y() < 0.0 ) {
+ pp.sety( pp.y() + 25.0 );
}
return(pp);
// Load a .obj file and build the GL fragment list
int fgObjLoad( const string& path, fgTILE *t) {
fgFRAGMENT fragment;
- fgPoint3d pp;
+ Point3D pp;
double approx_normal[3], normal[3], scale;
// double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
// GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
int in_fragment, in_faces, vncount, n1, n2, n3, n4;
int last1, last2, odd;
double (*nodes)[3];
- fgPoint3d *center;
+ Point3D center;
// printf("loading %s\n", path.c_str() );
vncount = 1;
t->bounding_radius = 0.0;
nodes = t->nodes;
- center = &t->center;
+ center = t->center;
StopWatch stopwatch;
stopwatch.start();
if ( token == "gbs" )
{
// reference point (center offset)
- in.stream() >> t->center.x
- >> t->center.y
- >> t->center.z
- >> t->bounding_radius;
+ in.stream() >> t->center >> t->bounding_radius;
}
else if ( token == "bs" )
{
// reference point (center offset)
+ /*
in.stream() >> fragment.center.x
>> fragment.center.y
>> fragment.center.z
- >> fragment.bounding_radius;
+ */
+ in.stream() >> fragment.center;
+ in.stream() >> fragment.bounding_radius;
}
else if ( token == "vn" )
{
MAT3_SCALE_VEC(normal, normals[n1], scale);
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n1][0],t->nodes[n1][1],t->nodes[n1][2]);
xglVertex3dv(nodes[n1]);
MAT3_SCALE_VEC(normal, normals[n2], scale);
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
//xglVertex3d(t->nodes[n2][0],t->nodes[n2][1],t->nodes[n2][2]);
xglVertex3dv(nodes[n2]);
MAT3_SCALE_VEC(normal, normals[n3], scale);
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n3][0],t->nodes[n3][1],t->nodes[n3][2]);
xglVertex3dv(nodes[n3]);
} else {
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n1][0],t->nodes[n1][1],t->nodes[n1][2]);
xglVertex3dv(nodes[n1]);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n2][0],t->nodes[n2][1],t->nodes[n2][2]);
xglVertex3dv(nodes[n2]);
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n3][0],t->nodes[n3][1],t->nodes[n3][2]);
xglVertex3dv(nodes[n3]);
}
}
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n4], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n4][0],t->nodes[n4][1],t->nodes[n4][2]);
xglVertex3dv(nodes[n4]);
// xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
xglNormal3dv(normals[n1]);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n1][0], t->nodes[n1][1], t->nodes[n1][2]);
xglVertex3dv(nodes[n1]);
// xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);
xglNormal3dv(normals[n2]);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n2][0], t->nodes[n2][1], t->nodes[n2][2]);
xglVertex3dv(nodes[n2]);
// xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]);
xglNormal3dv(normals[n3]);
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n3][0], t->nodes[n3][1], t->nodes[n3][2]);
xglVertex3dv(nodes[n3]);
// printf("some normals, texcoords, and vertices (tris)\n");
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n1][0], t->nodes[n1][1], t->nodes[n1][2]);
xglVertex3dv(nodes[n1]);
// printf("a normal, texcoord, and vertex (4th)\n");
xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon, pp.lat);
+ xglTexCoord2f(pp.lon(), pp.lat());
// xglVertex3d(t->nodes[n2][0],t->nodes[n2][1],t->nodes[n2][2]);
xglVertex3dv(nodes[n2]);
// printf("a normal, texcoord, and vertex (4th)\n");
// $Log$
+// Revision 1.5 1998/10/16 00:54:39 curt
+// Converted to Point3D class.
+//
// Revision 1.4 1998/09/15 01:35:07 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
#include <string>
-#include <Include/fg_types.h>
-
#include <Scenery/tile.hxx>
// $Log$
+// Revision 1.3 1998/10/16 00:54:41 curt
+// Converted to Point3D class.
+//
// Revision 1.2 1998/09/01 19:03:10 curt
// Changes contributed by Bernie Bright <bbright@c031.aone.net.au>
// - The new classes in libmisc.tgz define a stream interface into zlib.
#endif
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
+#include <Math/point3d.hxx>
/* Define a structure containing global scenery parameters */
struct fgSCENERY {
/* center of current scenery chunk */
- fgPoint3d center;
+ Point3D center;
/* next center of current scenery chunk */
- fgPoint3d next_center;
+ Point3D next_center;
/* angle of sun relative to current local horizontal */
double sun_angle;
/* $Log$
-/* Revision 1.4 1998/07/12 03:18:28 curt
-/* Added ground collision detection. This involved:
-/* - saving the entire vertex list for each tile with the tile records.
-/* - saving the face list for each fragment with the fragment records.
-/* - code to intersect the current vertical line with the proper face in
-/* an efficient manner as possible.
-/* Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
+/* Revision 1.5 1998/10/16 00:55:44 curt
+/* Converted to Point3D class.
/*
+ * Revision 1.4 1998/07/12 03:18:28 curt
+ * Added ground collision detection. This involved:
+ * - saving the entire vertex list for each tile with the tile records.
+ * - saving the face list for each fragment with the fragment records.
+ * - code to intersect the current vertical line with the proper face in
+ * an efficient manner as possible.
+ * Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
+ *
* Revision 1.3 1998/07/08 14:47:22 curt
* Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
* polare3d.h renamed to polar3d.hxx
#include <Include/fg_constants.h>
-#include <Include/fg_types.h>
#include <Math/mat3.h>
#include "tile.hxx"
// intersection found, 0 otherwise. If it intesects, result is the
// point of intersection
-int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag,
- fgPoint3d *result)
+int fgFRAGMENT::intersect( const Point3D& end0, Point3D& end1, int side_flag,
+ Point3D& result)
{
fgTILE *t;
fgFACE face;
// printf("p3(d) = %.2f\n", a * p3[0] + b * p3[1] + c * p3[2]);
// calculate the line coefficients for the specified line
- x0 = end0->x; x1 = end1->x;
- y0 = end0->y; y1 = end1->y;
- z0 = end0->z; z1 = end1->z;
+ x0 = end0.x(); x1 = end1.x();
+ y0 = end0.y(); y1 = end1.y();
+ z0 = end0.z(); z1 = end1.z();
if ( fabs(x1 - x0) > FG_EPSILON ) {
a1 = 1.0 / (x1 - x0);
// $Log$
+// Revision 1.12 1998/10/16 00:55:45 curt
+// Converted to Point3D class.
+//
// Revision 1.11 1998/09/02 14:37:08 curt
// Use erase() instead of while ( size() ) pop_front();
//
#include <list> // STL list
#include <Bucket/bucketutils.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Objects/fragment.hxx>
#ifdef NEEDNAMESPACESTD
int ncount;
// culling data for whole tile (course grain culling)
- fgPoint3d center;
+ Point3D center;
double bounding_radius;
- fgPoint3d offset;
+ Point3D offset;
GLdouble model_view[16];
// this tile's official location in the world
// Calculate this tile's offset
void
- fgTILE::SetOffset( fgPoint3d *off)
+ fgTILE::SetOffset( const Point3D& off)
{
- offset.x = center.x - off->x;
- offset.y = center.y - off->y;
- offset.z = center.z - off->z;
+ offset = center - off;
}
#endif
// This is equivalent to doing a glTranslatef(x, y, z);
- model_view[12] += (model_view[0]*offset.x + model_view[4]*offset.y +
- model_view[8]*offset.z);
- model_view[13] += (model_view[1]*offset.x + model_view[5]*offset.y +
- model_view[9]*offset.z);
- model_view[14] += (model_view[2]*offset.x + model_view[6]*offset.y +
- model_view[10]*offset.z);
+ model_view[12] += (model_view[0]*offset.x() + model_view[4]*offset.y() +
+ model_view[8]*offset.z());
+ model_view[13] += (model_view[1]*offset.x() + model_view[5]*offset.y() +
+ model_view[9]*offset.z());
+ model_view[14] += (model_view[2]*offset.x() + model_view[6]*offset.y() +
+ model_view[10]*offset.z() );
// m[15] += (m[3]*x + m[7]*y + m[11]*z);
// m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
// so m[15] is unchanged
// $Log$
+// Revision 1.20 1998/10/16 00:55:46 curt
+// Converted to Point3D class.
+//
// Revision 1.19 1998/09/17 18:36:17 curt
// Tweaks and optimizations by Norman Vine.
//
fgTILECACHE::next_avail( void )
{
fgVIEW *v;
+ Point3D delta;
int i;
- float dx, dy, dz, max, med, min, tmp;
+ float max, med, min, tmp;
float dist, max_dist;
int max_index;
// calculate approximate distance from view point
fgPrintf( FG_TERRAIN, FG_DEBUG,
"DIST Abs view pos = %.4f, %.4f, %.4f\n",
- v->abs_view_pos.x, v->abs_view_pos.y, v->abs_view_pos.z );
+ v->abs_view_pos.x(), v->abs_view_pos.y(),
+ v->abs_view_pos.z() );
fgPrintf( FG_TERRAIN, FG_DEBUG,
" ref point = %.4f, %.4f, %.4f\n",
- tile_cache[i].center.x, tile_cache[i].center.y,
- tile_cache[i].center.z);
+ tile_cache[i].center.x(), tile_cache[i].center.y(),
+ tile_cache[i].center.z());
- dx = fabs(tile_cache[i].center.x - v->abs_view_pos.x);
- dy = fabs(tile_cache[i].center.y - v->abs_view_pos.y);
- dz = fabs(tile_cache[i].center.z - v->abs_view_pos.z);
+ delta = tile_cache[i].center - v->abs_view_pos;
- max = dx; med = dy; min = dz;
+ max = delta.x(); med = delta.y(); min = delta.z();
if ( max < med ) {
tmp = max; max = med; med = tmp;
}
// $Log$
+// Revision 1.17 1998/10/16 00:55:48 curt
+// Converted to Point3D class.
+//
// Revision 1.16 1998/09/14 12:45:23 curt
// minor tweaks.
//
#include <XGL/xgl.h>
#include <Bucket/bucketutils.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
+#include <Math/point3d.hxx>
#include "tile.hxx"
// $Log$
+// Revision 1.12 1998/10/16 00:55:49 curt
+// Converted to Point3D class.
+//
// Revision 1.11 1998/09/14 12:45:25 curt
// minor tweaks.
//
#include <Bucket/bucketutils.h>
#include <Debug/fg_debug.h>
#include <Include/fg_constants.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Main/options.hxx>
#include <Main/views.hxx>
#include <Math/fg_geodesy.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Math/vector.hxx>
#include <Objects/material.hxx>
// Calculate shortest distance from point to line
-static double point_line_dist_squared( fgPoint3d *tc, fgPoint3d *vp,
+static double point_line_dist_squared( const Point3D& tc, const Point3D& vp,
MAT3vec d )
{
MAT3vec p, p0;
double dist;
- p[0] = tc->x; p[1] = tc->y; p[2] = tc->z;
- p0[0] = vp->x; p0[1] = vp->y; p0[2] = vp->z;
+ p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
+ p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
dist = fgPointLineSquared(p, p0, d);
// Calculate if point/radius is inside view frustum
-static int viewable( fgPoint3d *cp, double radius ) {
+static int viewable( const Point3D& cp, double radius ) {
int viewable = 1; // start by assuming it's viewable
double x1, y1;
double *mat;
double x, y, z;
- x = cp->x;
- y = cp->y;
- z = cp->z;
+ x = cp.x();
+ y = cp.y();
+ z = cp.z();
mat = (double *)(current_view.WORLD_TO_EYE);
// the compiler should inline this for us
static int
-inrange( const double radius, const fgPoint3d *center, const fgPoint3d *vp,
+inrange( const double radius, const Point3D& center, const Point3D& vp,
const MAT3vec up)
{
MAT3vec u, u1, v;
// double tmp;
// u = p - p0
- u[0] = center->x - vp->x;
- u[1] = center->y - vp->y;
- u[2] = center->z - vp->z;
+ u[0] = center.x() - vp.x();
+ u[1] = center.y() - vp.y();
+ u[2] = center.z() - vp.z();
// calculate the projection, u1, of u along d.
// u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d;
// render the scene, but we'd also like to be able to do this
// explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result in meters.
-double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos ) {
+double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
fgTILECACHE *c;
fgTILE *t;
// fgVIEW *v;
fgFRAGMENT *frag_ptr;
fgBUCKET p;
- fgPoint3d earth_center, result;
- fgPoint3d pp;
+ Point3D earth_center, result;
+ Point3D pp;
MAT3vec local_up;
list < fgFRAGMENT > :: iterator current;
list < fgFRAGMENT > :: iterator last;
c = &global_tile_cache;
// v = ¤t_view;
- local_up[0] = abs_view_pos->x;
- local_up[1] = abs_view_pos->y;
- local_up[2] = abs_view_pos->z;
+ local_up[0] = abs_view_pos.x();
+ local_up[1] = abs_view_pos.y();
+ local_up[2] = abs_view_pos.z();
// Find current translation offset
fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
index = c->exists(&p);
t = c->get_tile(index);
- scenery.next_center.x = t->center.x;
- scenery.next_center.y = t->center.y;
- scenery.next_center.z = t->center.z;
+ scenery.next_center = t->center;
- earth_center.x = 0.0;
- earth_center.y = 0.0;
- earth_center.z = 0.0;
+ earth_center.setvals(0.0, 0.0, 0.0);
fgPrintf( FG_TERRAIN, FG_DEBUG,
"Pos = (%.2f, %.2f) Current bucket = %d %d %d %d Index = %ld\n",
point_line_dist_squared(&(t->offset), &(v->view_pos),
v->local_up), t->bounding_radius); */
- dist = point_line_dist_squared( &(t->center), abs_view_pos,
- local_up );
+ dist = point_line_dist_squared( t->center, abs_view_pos, local_up );
if ( dist < FG_SQUARE(t->bounding_radius) ) {
// traverse fragment list for tile
&abs_view_pos), local_up),
frag_ptr->bounding_radius); */
- dist = point_line_dist_squared( &(frag_ptr->center),
- abs_view_pos, local_up);
+ dist = point_line_dist_squared( frag_ptr->center,
+ abs_view_pos,
+ local_up);
if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
if ( frag_ptr->intersect( abs_view_pos,
- &earth_center, 0, &result ) ) {
+ earth_center, 0, result ) ) {
// compute geocentric coordinates of tile center
pp = fgCartToPolar3d(result);
// convert to geodetic coordinates
- fgGeocToGeod(pp.lat, pp.radius, &lat_geod,
+ fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod,
&alt, &sea_level_r);
// printf("alt = %.2f\n", alt);
// exit since we found an intersection
double x, y, z;
// calculate tile offset
- x = (t->offset.x = t->center.x - scenery.center.x);
- y = (t->offset.y = t->center.y - scenery.center.y);
- z = (t->offset.z = t->center.z - scenery.center.z);
+ t->offset = t->center - scenery.center;
+
+ x = t->offset.x();
+ y = t->offset.y();
+ z = t->offset.z();
m = t->model_view;
fgTILECACHE *c;
fgTILE *t;
fgVIEW *v;
- fgPoint3d frag_offset;
+ Point3D frag_offset;
fgFRAGMENT *frag_ptr;
fgMATERIAL *mtl_ptr;
list < fgFRAGMENT > :: iterator current;
tile_diameter = current_options.get_tile_diameter();
scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude,
- &(v->abs_view_pos) );
+ v->abs_view_pos );
// initialize the transient per-material fragment lists
material_mgr.init_transient_material_lists();
t = c->get_tile(index);
// calculate tile offset
- t->SetOffset( &(scenery.center) );
+ t->SetOffset( scenery.center );
// Course (tile based) culling
- if ( viewable(&(t->offset), t->bounding_radius) ) {
+ if ( viewable(t->offset, t->bounding_radius) ) {
// at least a portion of this tile could be viewable
// Calculate the model_view transformation matrix for this tile
if ( frag_ptr->display_list >= 0 ) {
// Fine (fragment based) culling
- frag_offset.x = frag_ptr->center.x - scenery.center.x;
- frag_offset.y = frag_ptr->center.y - scenery.center.y;
- frag_offset.z = frag_ptr->center.z - scenery.center.z;
+ frag_offset = frag_ptr->center - scenery.center;
- if ( viewable(&frag_offset, frag_ptr->bounding_radius*2) ) {
+ if ( viewable(frag_offset, frag_ptr->bounding_radius*2) ) {
// add to transient per-material property fragment list
// frag_ptr->tile_offset.x = t->offset.x;
// frag_ptr->tile_offset.y = t->offset.y;
// $Log$
+// Revision 1.39 1998/10/16 00:55:50 curt
+// Converted to Point3D class.
+//
// Revision 1.38 1998/09/17 18:36:18 curt
// Tweaks and optimizations by Norman Vine.
//
// render the scene, but we'd also like to be able to do this
// explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result in meters.
-double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos );
+double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos );
// Render the local tiles --- hack, hack, hack
// $Log$
+// Revision 1.5 1998/10/16 00:55:52 curt
+// Converted to Point3D class.
+//
// Revision 1.4 1998/09/09 20:58:11 curt
// Tweaks to loop constructs with STL usage.
//
#include "Include/fg_stl_config.h"
-#ifdef _FG_NEED_AUTO_PTR
+#ifdef FG_NEED_AUTO_PTR
# include "Include/auto_ptr.hxx"
#else
# include <memory>
// $Log$
+// Revision 1.12 1998/10/16 00:56:08 curt
+// Converted to Point3D class.
+//
// Revision 1.11 1998/09/15 02:09:30 curt
// Include/fg_callback.hxx
// Moved code inline to stop g++ 2.7 from complaining.
#include <GL/glut.h>
#include <time.h>
-#include <Include/fg_types.h>
#include <Flight/flight.h>
// $Log$
+// Revision 1.7 1998/10/16 00:56:09 curt
+// Converted to Point3D class.
+//
// Revision 1.6 1998/07/27 18:42:22 curt
// Added a pause option.
//
#include <GL/glut.h>
#include <XGL/xgl.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
#include <Math/interpolater.hxx>
+#include <Math/point3d.hxx>
// Define a structure containing the global lighting parameters
double sun_lon, sun_gc_lat;
// in cartesian coordiantes
- fgPoint3d fg_sunpos;
+ Point3D fg_sunpos;
// (in view coordinates)
GLfloat sun_vec[4];
// $Log$
+// Revision 1.8 1998/10/16 00:56:10 curt
+// Converted to Point3D class.
+//
// Revision 1.7 1998/08/29 13:11:33 curt
// Bernie Bright writes:
// I've created some new classes to enable pointers-to-functions and
#include <Main/views.hxx>
#include <Math/fg_geodesy.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
#include <Math/vector.hxx>
#include <Scenery/scenery.hxx>
fgTIME *t;
fgVIEW *v;
MAT3vec nup, nsun, v0;
- fgPoint3d p;
+ Point3D p, rel_sunpos;
double dot, east_dot;
double sun_gd_lat, sl_radius;
double ntmp;
fgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &l->sun_gc_lat);
- p.lon = l->sun_lon;
- p.lat = l->sun_gc_lat;
- p.radius = sl_radius;
+ p.setvals( l->sun_lon, l->sun_gc_lat, sl_radius );
l->fg_sunpos = fgPolarToCart3d(p);
printf( " t->cur_time = %ld\n", t->cur_time);
sun_gd_lat, l->sun_gc_lat);
// I think this will work better for generating the sun light vector
- l->sun_vec[0] = l->fg_sunpos.x;
- l->sun_vec[1] = l->fg_sunpos.y;
- l->sun_vec[2] = l->fg_sunpos.z;
+ l->sun_vec[0] = l->fg_sunpos.x();
+ l->sun_vec[1] = l->fg_sunpos.y();
+ l->sun_vec[2] = l->fg_sunpos.z();
MAT3_NORMALIZE_VEC(l->sun_vec, ntmp);
MAT3_SCALE_VEC(l->sun_vec_inv, l->sun_vec, -1.0);
// calculate the sun's relative angle to local up
MAT3_COPY_VEC(nup, v->local_up);
- nsun[0] = l->fg_sunpos.x;
- nsun[1] = l->fg_sunpos.y;
- nsun[2] = l->fg_sunpos.z;
+ nsun[0] = l->fg_sunpos.x();
+ nsun[1] = l->fg_sunpos.y();
+ nsun[2] = l->fg_sunpos.z();
MAT3_NORMALIZE_VEC(nup, ntmp);
MAT3_NORMALIZE_VEC(nsun, ntmp);
// l->sun_angle);
// calculate vector to sun's position on the earth's surface
- v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
- v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
- v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
+ rel_sunpos = l->fg_sunpos - (v->view_pos + scenery.center);
+ v->to_sun[0] = rel_sunpos.x();
+ v->to_sun[1] = rel_sunpos.y();
+ v->to_sun[2] = rel_sunpos.z();
// printf( "Vector to sun = %.2f %.2f %.2f\n",
// v->to_sun[0], v->to_sun[1], v->to_sun[2]);
// make a vector to the current view position
- MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
+ MAT3_SET_VEC(v0, v->view_pos.x(), v->view_pos.y(), v->view_pos.z());
// Given a vector from the view position to the point on the
// earth's surface the sun is directly over, map into onto the
// $Log$
+// Revision 1.13 1998/10/16 00:56:12 curt
+// Converted to Point3D class.
+//
// Revision 1.12 1998/09/15 04:27:50 curt
// Changes for new astro code.
//
#include <time.h>
-#include <Include/fg_types.h>
-
/* update the cur_time_params structure with the current sun position */
void fgUpdateSunPos( void );