// bobject.hpp -- the base class for objects in a flightgear scenery tile // // Written by Frederic Bouvier, started February 2002. // // Copyright (C) 2002 Frederic Bouvier - fredb@users.sourceforge.net // // 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: bobject.hpp,v 1.22 2004/02/14 14:17:38 fredb2 Exp $ #ifndef _bobject_hpp_ #define _bobject_hpp_ #ifdef _MSC_VER #pragma warning( disable : 4786 ) #endif #include #include #include class FGSD_Tile; class FGSD_Image; class SGPath; class FGSD_BaseObject { public: struct Color { float red, green, blue; Color() : red(0), green(0), blue(0) {} Color(float r, float g, float b) : red(r), green(g), blue(b) {} friend Color operator * ( float f, const Color &c ) { return Color( f * c.red, f * c.green, f * c.blue ); } }; typedef std::map MaterialColorMap; // Don't change the order : NoType < ObjectBase < Object < ObjectStatic enum ObjectType { NoType, TriangleObject, BinaryObject, ObjectBase, Object, ObjectStatic, Curve, LevelCurve }; enum DrawType { Normal, Shadowed, SlopeGradient, AltGradient }; FGSD_BaseObject( FGSD_Tile *__tile, ObjectType __type ); virtual ~FGSD_BaseObject(); ObjectType type() const; FGSD_Tile *tile() const; bool isModified() const; void reparent( FGSD_Tile * ); bool isA( ObjectType __type ); virtual void draw( double alpha, bool lines, DrawType drawType, double minx, double maxx, double miny, double maxy, double zLevel ) = 0; virtual bool propertiesUnderMouse( double lon, double lat, double &height, std::string &material, std::string &airportID ) const = 0; virtual bool objectUnderMouse( double lon, double lat, double zLevel ) = 0; virtual bool visible( double minx, double maxx, double miny, double maxy ) const = 0; virtual bool visible( double lon, double lat ) const = 0; virtual std::string getName() const = 0; virtual void *convertTo( FGSD_BaseObject::ObjectType __type ) = 0; static double _factor; static MaterialColorMap _materialColorMap; static void loadRGBTexture( FGSD_Image &, const SGPath &, const char * ); protected: static SGPropertyNode _materials; static bool _materialInit; ObjectType _type; bool _modified; FGSD_Tile *_tile; }; inline FGSD_BaseObject::ObjectType FGSD_BaseObject::type() const { return _type; } inline FGSD_Tile *FGSD_BaseObject::tile() const { return _tile; } inline void FGSD_BaseObject::reparent( FGSD_Tile *__tile ) { _tile = __tile; } inline bool FGSD_BaseObject::isModified() const { return _modified; } inline bool FGSD_BaseObject::isA( ObjectType __type ) { return convertTo( __type ) != 0; } #endif