X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIBase.hxx;h=70e7c97184c834ab0ebbea4ad8349cbf52661647;hb=d70e26d87b5294315ca6d67b8c11fabe51abbc4b;hp=80a93c206b11d74a23510e1c53c29ffa9b9ab5c5;hpb=10866851de802979af4a5857aa795d0b4a90b0c5;p=flightgear.git diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 80a93c206..70e7c9718 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -21,28 +21,32 @@ #define _FG_AIBASE_HXX #include -#include #include -#include #include +#include #include #include #include +#include #include #include - #include
using std::string; -using std::list; -class SGMaterial; +namespace simgear { +class BVHMaterial; +} class FGAIManager; class FGAIFlightPlan; +class FGFX; +class FGNasalModelDataProxy; +class FGAIModelData; // defined below + class FGAIBase : public SGReferenced { @@ -50,9 +54,9 @@ public: enum object_type { otNull = 0, otAircraft, otShip, otCarrier, otBallistic, otRocket, otStorm, otThermal, otStatic, otWingman, otGroundVehicle, otEscort, otMultiplayer, - MAX_OBJECTS }; // Needs to be last!!! + MAX_OBJECTS }; // Needs to be last!!! - FGAIBase(object_type ot); + FGAIBase(object_type ot, bool enableHot); virtual ~FGAIBase(); virtual void readFromScenario(SGPropertyNode* scFileNode); @@ -64,6 +68,7 @@ public: virtual void unbind(); virtual void reinit() {} + void updateLOD(); void setManager(FGAIManager* mgr, SGPropertyNode* p); void setPath( const char* model ); void setSMPath( const string& p ); @@ -111,10 +116,9 @@ public: SGVec3d getCartPos() const; bool getGroundElevationM(const SGGeod& pos, double& elev, - const SGMaterial** material) const; + const simgear::BVHMaterial** material) const; double _elevation_m; - const SGMaterial* _material; double _getCartPosX() const; double _getCartPosY() const; @@ -133,14 +137,20 @@ public: string _path; string _callsign; string _submodel; - string _name; + std::string _name; string _parent; - SGGeod userpos; - - protected: - + /** + * Tied-properties helper, record nodes which are tied for easy un-tie-ing + */ + template + void tie(const char* aRelPath, const SGRawValue& aRawValue) + { + _tiedProperties.Tie(props->getNode(aRelPath, true), aRawValue); + } + + simgear::TiedPropertyList _tiedProperties; SGPropertyNode_ptr _selected_ac; SGPropertyNode_ptr props; SGPropertyNode_ptr trigger_node; @@ -148,10 +158,10 @@ protected: FGAIManager* manager; // these describe the model's actual state - SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters - double hdg; // True heading in degrees - double roll; // degrees, left is negative - double pitch; // degrees, nose-down is negative + SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters + double hdg; // True heading in degrees + double roll; // degrees, left is negative + double pitch; // degrees, nose-down is negative double speed; // knots true airspeed double altitude_ft; // feet above sea level double vs; // vertical speed, feet per minute @@ -183,16 +193,16 @@ protected: double x_shift; // value used by radar display instrument double y_shift; // value used by radar display instrument double rotation; // value used by radar display instrument - double ht_diff; // value used by radar display instrument + double ht_diff; // value used by radar display instrument - string model_path; //Path to the 3D model - osg::ref_ptr model; //The 3D model object + string model_path; //Path to the 3D model SGModelPlacement aip; bool delete_me; bool invisible; bool no_roll; bool serviceable; + bool _installed; int _subID; double life; @@ -215,12 +225,20 @@ protected: void CalculateMach(); double UpdateRadar(FGAIManager* manager); + void removeModel(); + void removeSoundFx(); + static int _newAIModelID(); private: int _refID; object_type _otype; bool _initialized; + osg::ref_ptr _model; //The 3D model LOD object + + osg::ref_ptr _modeldata; + + SGSharedPtr _fx; public: object_type getType(); @@ -234,7 +252,6 @@ public: void _setLongitude( double longitude ); void _setLatitude ( double latitude ); void _setSubID( int s ); - void _setUserPos(); double _getAltitudeAGL(SGGeod inpos, double start); @@ -299,10 +316,9 @@ public: inline double _getRange() { return range; }; inline double _getBearing() { return bearing; }; - virtual osg::Node* load3DModel(const string &path, - SGPropertyNode *prop_root); - static bool _isNight(); + + string & getCallSign(); }; inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) { @@ -363,6 +379,10 @@ inline void FGAIBase::setLatitude ( double latitude ) { inline void FGAIBase::setCallSign(const string& s) { _callsign = s; } +inline string& FGAIBase::getCallSign() { + return _callsign; +} + inline void FGAIBase::setXoffset(double x) { _x_offset = x; } @@ -432,4 +452,28 @@ inline void FGAIBase::setMaxSpeed(double m) { _max_speed = m; } -#endif // _FG_AIBASE_HXX + +class FGAIModelData : public simgear::SGModelData { +public: + FGAIModelData(SGPropertyNode *root = 0); + ~FGAIModelData(); + + /** osg callback, thread-safe */ + void modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *n); + + /** init hook to be called after model is loaded. + * Not thread-safe. Call from main thread only. */ + void init(void) { _initialized = true; } + + bool needInitilization(void) { return _ready && !_initialized;} + bool isInitialized(void) { return _initialized;} + inline std::string& get_sound_path() { return _fxpath;} + +private: + FGNasalModelDataProxy *_nasal; + std::string _fxpath; + bool _ready; + bool _initialized; +}; + +#endif // _FG_AIBASE_HXX