-// location.hxx -- class for determining model location in the flightgear world.
+// location.cxx -- class for determining model location in the flightgear world.
//
-// Written by Jim Wilson, David Megginson, started April 2002.
-// overhaul started October 2000.
+// Written by Jim Wilson, David Megginson, started April 2002.
+// Based largely on code by Curtis Olson and Norman Vine.
//
-// This file is in the Public Domain, and comes with no warranty.
-
+// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
#include <simgear/compiler.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/math/vector.hxx>
#include <Scenery/scenery.hxx>
-#include <simgear/math/vector.hxx>
-/*
#include "globals.hxx"
-*/
#include "location.hxx"
_alt_ft(0),
_roll_deg(0),
_pitch_deg(0),
- _heading_deg(0)
+ _heading_deg(0),
+ _cur_elev_m(0),
+ _tile_center(0)
{
sgdZeroVec3(_absolute_view_pos);
+ sgZeroVec3(_relative_view_pos);
+ sgZeroVec3(_zero_elev_view_pos);
+ sgMakeRotMat4( UP, 0.0, 0.0, 0.0 );
+ sgMakeRotMat4( TRANS, 0.0, 0.0, 0.0 );
}
Point3D p = Point3D(lon_deg * SG_DEGREES_TO_RADIANS,
lat_geoc_rad,
sea_level_radius_m);
- Point3D tmp = sgPolarToCart3d(p) - scenery.get_next_center();
+ Point3D tmp = sgPolarToCart3d(p) - _tile_center;
sgSetVec3(_zero_elev_view_pos, tmp[0], tmp[1], tmp[2]);
// Calculate the absolute view position
// Calculate the relative view position
// from the scenery center.
// aka Relative View Position
+
+ // FIXME: view position should ONLY be calculated in the viewer...
+ // Anything else should calculate their own positions relative to the
+ // viewer's tile_center.
sgdVec3 scenery_center;
sgdSetVec3(scenery_center,
- scenery.get_next_center().x(),
- scenery.get_next_center().y(),
- scenery.get_next_center().z());
+ globals->get_scenery()->get_center().x(),
+ globals->get_scenery()->get_center().y(),
+ globals->get_scenery()->get_center().z());
sgdVec3 view_pos;
sgdSubVec3(view_pos, _absolute_view_pos, scenery_center);
sgSetVec3(_relative_view_pos, view_pos);
FGLocation::update (int dt)
{
}
-
-
-