# include <strings.h>
#endif
+#include <plib/sg.h>
+
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/fgstream.hxx>
#include <Objects/materialmgr.hxx>
-// #include <gpc/gpc.h>
-
#include "genapt.hxx"
FG_USING_STD(string);
{
GLint display_list;
Point3D cart, cart_trans, tex;
- MAT3vec normal;
- double dist, max_dist, temp;
+ sgVec3 normal;
+ double dist, max_dist;
int center_num, i;
fgFRAGMENT fragment;
<< 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);
+ sgSetVec3( normal, average.x(), average.y(), average.z() );
+ sgNormalizeVec3( normal );
display_list = xglGenLists(1);
xglNewList(display_list, GL_COMPILE);
tex = calc_tex_coords( t->nodes[t->ncount-1], t->center );
xglTexCoord2f(tex.x(), tex.y());
- xglNormal3dv(normal);
+ xglNormal3fv(normal);
xglVertex3d(t->nodes[t->ncount-1][0],
t->nodes[t->ncount-1][1],
t->nodes[t->ncount-1][2]);
libCockpit_a_SOURCES = \
cockpit.cxx cockpit.hxx \
- hud.cxx hud.hxx \
+ hud.cxx hud.hxx hud_opts.hxx \
hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \
hud_labl.cxx hud_ladr.cxx \
hud_lat.cxx hud_lon.cxx \
hud_scal.cxx hud_tbi.cxx \
panel.cxx panel.hxx
-INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
\ No newline at end of file
+INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <deque> // STL double ended queue
#include <simgear/constants.h>
-#include <simgear/math/mat3.h>
#include <fg_typedefs.h>
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <GUI/gui.h>
+#include "hud_opts.hxx"
+
FG_USING_STD(deque);
FG_USING_STD(vector);
FG_USING_NAMESPACE(std);
+// some of Norman's crazy optimizations. :-)
+
#ifndef WIN32
typedef struct {
int x, y;
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
--- /dev/null
+// hud_opts.hxx -- hud optimization tools
+//
+// Probably written by Norman Vine, started sometime in 1998 or 1999.
+//
+// Copyright (C) 1999 FlightGear Project
+//
+// 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$
+
+
+#ifndef _HUD_OPTS_HXX
+#define _HUD_OPTS_HXX
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
+
+#if defined(i386)
+#define USE_X86_ASM
+#endif
+
+#if defined(USE_X86_ASM)
+static __inline__ int FloatToInt(float f)
+{
+ int r;
+ __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
+ return r;
+}
+#elif defined(__MSC__) && defined(__WIN32__)
+static __inline int FloatToInt(float f)
+{
+ int r;
+ _asm {
+ fld f
+ fistp r
+ }
+ return r;
+}
+#else
+#define FloatToInt(F) ((int) ((F) < 0.0f ? (F)-0.5f : (F)+0.5f))
+#endif
+
+
+#endif // _HUD_OPTS_H
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h> // for VERSION
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/misc/fgpath.hxx>
+// This should be ported to plib/sg before you try to compile it. If
+// you do the port please send it to me. :-)
+
#include <Math/mat3.h>
#include <Include/fg_constants.h>
#include <simgear/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/fg_random.h>
-#include <simgear/mat3.h>
#include <simgear/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/fg_random.h>
-#include <simgear/mat3.h>
#include <simgear/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <simgear/constants.h>
-#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <Scenery/tileentry.hxx>
Point3D& result) const
{
FGTileEntry *t;
- MAT3vec v1, v2, n, center;
- double p1[3], p2[3], p3[3];
+ sgVec3 v1, v2, n, center;
+ sgVec3 p1, p2, p3;
+ sgVec3 temp;
double x, y, z; // temporary holding spot for result
double a, b, c, d;
double x0, y0, z0, x1, y1, z1, a1, b1, c1;
// printf(".");
// get face vertex coordinates
- center[0] = t->center.x();
- center[1] = t->center.y();
- center[2] = t->center.z();
+ sgSetVec3( center, t->center.x(), t->center.y(), t->center.z() );
- MAT3_ADD_VEC(p1, t->nodes[(*current).n1], center);
- MAT3_ADD_VEC(p2, t->nodes[(*current).n2], center);
- MAT3_ADD_VEC(p3, t->nodes[(*current).n3], center);
+ sgSetVec3( temp, t->nodes[(*current).n1].x(),
+ t->nodes[(*current).n1].y(), t->nodes[(*current).n1].z() );
+ sgAddVec3( p1, temp, center );
+
+ sgSetVec3( temp, t->nodes[(*current).n2].x(),
+ t->nodes[(*current).n2].y(), t->nodes[(*current).n2].z() );
+ sgAddVec3( p2, temp, center );
+
+ sgSetVec3( temp, t->nodes[(*current).n3].x(),
+ t->nodes[(*current).n3].y(), t->nodes[(*current).n3].z() );
+ sgAddVec3( p3, temp, center );
// printf("point 1 = %.2f %.2f %.2f\n", p1[0], p1[1], p1[2]);
// printf("point 2 = %.2f %.2f %.2f\n", p2[0], p2[1], p2[2]);
// printf("point 3 = %.2f %.2f %.2f\n", p3[0], p3[1], p3[2]);
// calculate two edge vectors, and the face normal
- MAT3_SUB_VEC(v1, p2, p1);
- MAT3_SUB_VEC(v2, p3, p1);
- MAT3cross_product(n, v1, v2);
+ sgSubVec3( v1, p2, p1 );
+ sgSubVec3( v2, p3, p1 );
+ sgVectorProductVec3( n, v1, v2 );
// calculate the plane coefficients for the plane defined by
// this face. If n is the normal vector, n = (a, b, c) and p1
// all dimensions are really small so lets call it close
// enough and return a successful match
result = Point3D(x, y, z);
- return(1);
+ return 1;
}
// check if intersection point is on the same side of p1 <-> p2 as p3
// printf( "intersection point = %.2f %.2f %.2f\n", x, y, z);
result = Point3D(x, y, z);
- return(1);
+ return 1;
}
// printf("\n");
- return(0);
+ return 0;
}
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/math/point3d.hxx>
// given three points defining a triangle, calculate the normal
static void calc_normal(Point3D p1, Point3D p2,
- Point3D p3, double normal[3])
+ Point3D p3, sgVec3 normal)
{
- double v1[3], v2[3];
- double temp;
+ sgVec3 v1, v2;
v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2];
v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2];
- MAT3cross_product(normal, v1, v2);
- MAT3_NORMALIZE_VEC(normal,temp);
+ sgVectorProductVec3( normal, v1, v2 );
+ sgNormalizeVec3( normal );
// fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n",
// normal[0], normal[1], normal[2]);
// material
FGMaterial m = fragment.material_ptr->get_m();
double tex_width = m.get_xsize();
- double tex_height = m.get_ysize();
+ // double tex_height = m.get_ysize();
// set ssgState
state = fragment.material_ptr->get_state();
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
fgFRAGMENT fragment;
Point3D pp;
- double approx_normal[3] /*, normal[3], scale = 0.0 */;
+ sgVec3 approx_normal;
+ // double normal[3], scale = 0.0;
// double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
// GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
// GLint display_list = 0;
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>
// Calculate shortest distance from point to line
static double point_line_dist_squared( const Point3D& tc, const Point3D& vp,
- MAT3vec d )
+ sgVec3 d )
{
- MAT3vec p, p0;
+ sgVec3 p, p0;
- p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
- p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
+ sgSetVec3( p, tc.x(), tc.y(), tc.z() );
+ sgSetVec3( p0, vp.x(), vp.y(), vp.z() );
- return fgPointLineSquared(p, p0, d);
+ return sgPointLineDistSquared(p, p0, d);
}
Point3D abs_view_pos = current_view.get_abs_view_pos();
Point3D earth_center(0.0);
Point3D result;
- MAT3vec local_up;
+ sgVec3 local_up;
double dist, lat_geod, alt, sea_level_r;
int index;
- local_up[0] = abs_view_pos.x();
- local_up[1] = abs_view_pos.y();
- local_up[2] = abs_view_pos.z();
+ sgSetVec3( local_up, abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z() );
// Find current translation offset
// fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
fgFRAGMENT *frag_ptr;
Point3D earth_center(0.0);
Point3D result;
- MAT3vec local_up;
+ sgVec3 local_up;
double dist, lat_geod, alt, sea_level_r;
int index;
static int
inrange( const double radius, const Point3D& center, const Point3D& vp,
- const MAT3vec up)
+ const sgVec3 up)
{
- MAT3vec u, u1, v;
+ sgVec3 u, u1, v;
// double tmp;
// u = p - p0
// calculate the projection, u1, of u along d.
// u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d;
- MAT3_SCALE_VEC(u1, up,
- (MAT3_DOT_PRODUCT(u, up) / MAT3_DOT_PRODUCT(up, up)) );
+ sgScaleVec3( u1, up,
+ (sgScalarProductVec3(u, up) / sgScalarProductVec3(up, up)) );
// v = u - u1 = vector from closest point on line, p1, to the
// original point, p.
- MAT3_SUB_VEC(v, u, u1);
+ sgSubVec3( v, u, u1 );
- return( FG_SQUARE(radius) >= MAT3_DOT_PRODUCT(v, v));
+ return( FG_SQUARE(radius) >= sgScalarProductVec3(v, v));
}
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/interpolater.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/fgpath.hxx>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>