Lots of (mostly) doxygen fixes/cleanup.
This commit is contained in:
parent
942181c8ae
commit
3bcd0bafd5
25
Doxyfile
25
Doxyfile
@ -744,30 +744,7 @@ WARN_LOGFILE =
|
|||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = DoxygenMain.cxx \
|
INPUT = DoxygenMain.cxx \
|
||||||
simgear/bucket \
|
simgear
|
||||||
simgear/canvas \
|
|
||||||
simgear/compiler.h \
|
|
||||||
simgear/constants.h \
|
|
||||||
simgear/debug \
|
|
||||||
simgear/environment \
|
|
||||||
simgear/ephemeris \
|
|
||||||
simgear/io \
|
|
||||||
simgear/magvar \
|
|
||||||
simgear/math \
|
|
||||||
simgear/misc \
|
|
||||||
simgear/nasal \
|
|
||||||
simgear/props \
|
|
||||||
simgear/route \
|
|
||||||
simgear/scene \
|
|
||||||
simgear/screen \
|
|
||||||
simgear/serial \
|
|
||||||
simgear/structure \
|
|
||||||
simgear/sg_inlines.h \
|
|
||||||
simgear/sg_traits.hxx \
|
|
||||||
simgear/sound \
|
|
||||||
simgear/threads \
|
|
||||||
simgear/timing \
|
|
||||||
simgear/xml
|
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
|
@ -127,21 +127,22 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a bucket given a specific location.
|
* Construct a bucket given a specific location.
|
||||||
* @param dlon longitude specified in degrees
|
*
|
||||||
* @param dlat latitude specified in degrees
|
* @param geod Geodetic location
|
||||||
*/
|
*/
|
||||||
SGBucket(const SGGeod& geod);
|
SGBucket(const SGGeod& geod);
|
||||||
|
|
||||||
/** Construct a bucket given a unique bucket index number.
|
/** Construct a bucket given a unique bucket index number.
|
||||||
|
*
|
||||||
* @param bindex unique bucket index
|
* @param bindex unique bucket index
|
||||||
*/
|
*/
|
||||||
SGBucket(const long int bindex);
|
SGBucket(const long int bindex);
|
||||||
|
|
||||||
#ifndef NO_DEPRECATED_API
|
#ifndef NO_DEPRECATED_API
|
||||||
/**
|
/**
|
||||||
* Reset a bucket to represent a new lat and lon
|
* Reset a bucket to represent a new location.
|
||||||
* @param dlon longitude specified in degrees
|
*
|
||||||
* @param dlat latitude specified in degrees
|
* @param geod New geodetic location
|
||||||
*/
|
*/
|
||||||
void set_bucket(const SGGeod& geod);
|
void set_bucket(const SGGeod& geod);
|
||||||
|
|
||||||
|
@ -228,12 +228,12 @@ namespace canvas
|
|||||||
ElementWeakPtr _focus_element;
|
ElementWeakPtr _focus_element;
|
||||||
|
|
||||||
CullCallbackPtr _cull_callback;
|
CullCallbackPtr _cull_callback;
|
||||||
bool _render_always; //<! Used to disable automatic lazy rendering (culling)
|
bool _render_always; //!< Used to disable automatic lazy rendering (culling)
|
||||||
|
|
||||||
std::vector<SGPropertyNode*> _dirty_placements;
|
std::vector<SGPropertyNode*> _dirty_placements;
|
||||||
std::vector<Placements> _placements;
|
std::vector<Placements> _placements;
|
||||||
std::set<CanvasWeakPtr> _parent_canvases, //<! Canvases showing this canvas
|
std::set<CanvasWeakPtr> _parent_canvases, //!< Canvases showing this canvas
|
||||||
_child_canvases; //<! Canvases displayed within
|
_child_canvases; //!< Canvases displayed within
|
||||||
// this canvas
|
// this canvas
|
||||||
|
|
||||||
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
|
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
|
||||||
|
@ -279,9 +279,10 @@ namespace canvas
|
|||||||
/**
|
/**
|
||||||
* Register a function for setting a style specified by the given property
|
* Register a function for setting a style specified by the given property
|
||||||
*
|
*
|
||||||
* @param name Property name
|
* @param name Property name
|
||||||
* @param type Interpolation type
|
* @param type Interpolation type
|
||||||
* @param setter Setter function
|
* @param setter Setter function
|
||||||
|
* @param inheritable If this style propagates to child elements
|
||||||
*
|
*
|
||||||
* @tparam T1 Type of value used to retrieve value from property
|
* @tparam T1 Type of value used to retrieve value from property
|
||||||
* node
|
* node
|
||||||
|
@ -41,6 +41,7 @@ namespace canvas
|
|||||||
*
|
*
|
||||||
* @param type_str Event type name (if name does not exist yet it will
|
* @param type_str Event type name (if name does not exist yet it will
|
||||||
* be registered as new event type)
|
* be registered as new event type)
|
||||||
|
* @param bubbles If this event should take part in the bubbling phase
|
||||||
* @param data Optional user data stored in event
|
* @param data Optional user data stored in event
|
||||||
*/
|
*/
|
||||||
CustomEvent( std::string const& type_str,
|
CustomEvent( std::string const& type_str,
|
||||||
@ -50,6 +51,7 @@ namespace canvas
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param type_id Event type id
|
* @param type_id Event type id
|
||||||
|
* @param bubbles If this event should take part in the bubbling phase
|
||||||
* @param data Optional user data stored in event
|
* @param data Optional user data stored in event
|
||||||
*/
|
*/
|
||||||
CustomEvent( int type_id,
|
CustomEvent( int type_id,
|
||||||
@ -66,10 +68,16 @@ namespace canvas
|
|||||||
*/
|
*/
|
||||||
StringMap const& getDetail() const { return detail; }
|
StringMap const& getDetail() const { return detail; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this event supports bubbling.
|
||||||
|
*
|
||||||
|
* @see #bubbles
|
||||||
|
* @see CustomEvent()
|
||||||
|
*/
|
||||||
virtual bool canBubble() const { return bubbles; }
|
virtual bool canBubble() const { return bubbles; }
|
||||||
|
|
||||||
StringMap detail; //<! user data map
|
StringMap detail; //!< User data map
|
||||||
bool bubbles;
|
bool bubbles; //!< Whether the event supports bubbling
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace canvas
|
} // namespace canvas
|
||||||
|
@ -61,14 +61,14 @@ namespace canvas
|
|||||||
bool isModifier() const;
|
bool isModifier() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t _key, //<! Key identifier for this event
|
uint32_t _key, //!< Key identifier for this event
|
||||||
_unmodified_key; //<! Virtual key identifier without any
|
_unmodified_key; //!< Virtual key identifier without any
|
||||||
// modifiers applied
|
// modifiers applied
|
||||||
bool _repeat; //<! If key has been depressed long enough to
|
bool _repeat; //!< If key has been depressed long enough to
|
||||||
// generate key repetition
|
// generate key repetition
|
||||||
|
|
||||||
mutable std::string _name; //<! Printable representation/name
|
mutable std::string _name; //!< Printable representation/name
|
||||||
mutable uint8_t _location; //<! Location of the key on the keyboard
|
mutable uint8_t _location; //!< Location of the key on the keyboard
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,13 +61,13 @@ namespace canvas
|
|||||||
|
|
||||||
int getCurrentClickCount() const { return click_count; }
|
int getCurrentClickCount() const { return click_count; }
|
||||||
|
|
||||||
osg::Vec2f screen_pos, //<! Position in screen coordinates
|
osg::Vec2f screen_pos, //!< Position in screen coordinates
|
||||||
client_pos, //<! Position in window/canvas coordinates
|
client_pos, //!< Position in window/canvas coordinates
|
||||||
local_pos, //<! Position in local/element coordinates
|
local_pos, //!< Position in local/element coordinates
|
||||||
delta;
|
delta;
|
||||||
int button, //<! Button for this event
|
int button, //!< Button for this event
|
||||||
buttons, //<! Current button state
|
buttons, //!< Current button state
|
||||||
click_count; //<! Current click count
|
click_count; //!< Current click count
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace canvas
|
} // namespace canvas
|
||||||
|
@ -99,9 +99,9 @@ namespace canvas
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef const int& (SGVec2i::*CoordGetter)() const;
|
typedef const int& (SGVec2i::*CoordGetter)() const;
|
||||||
CoordGetter _get_layout_coord, //<! getter for coordinate in layout
|
CoordGetter _get_layout_coord, //!< getter for coordinate in layout
|
||||||
// direction
|
// direction
|
||||||
_get_fixed_coord; //<! getter for coordinate in secondary
|
_get_fixed_coord; //!< getter for coordinate in secondary
|
||||||
// (fixed) direction
|
// (fixed) direction
|
||||||
|
|
||||||
int _padding;
|
int _padding;
|
||||||
|
@ -81,13 +81,13 @@ namespace canvas
|
|||||||
int size_hint,
|
int size_hint,
|
||||||
min_size,
|
min_size,
|
||||||
max_size,
|
max_size,
|
||||||
padding_orig, //<! original padding as specified by the user
|
padding_orig, //!< original padding as specified by the user
|
||||||
padding, //<! padding before element (layouted)
|
padding, //!< padding before element (layouted)
|
||||||
size, //<! layouted size
|
size, //!< layouted size
|
||||||
stretch; //<! stretch factor
|
stretch; //!< stretch factor
|
||||||
bool visible : 1,
|
bool visible : 1,
|
||||||
has_hfw : 1, //<! height for width
|
has_hfw : 1, //!< height for width
|
||||||
done : 1; //<! layouting done
|
done : 1; //!< layouting done
|
||||||
|
|
||||||
/** Clear values (reset to default/empty state) */
|
/** Clear values (reset to default/empty state) */
|
||||||
void reset();
|
void reset();
|
||||||
@ -110,12 +110,12 @@ namespace canvas
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int _num_not_done, //<! number of children not layouted yet
|
int _num_not_done, //!< number of children not layouted yet
|
||||||
_sum_stretch, //<! sum of stretch factors of all not yet layouted
|
_sum_stretch, //!< sum of stretch factors of all not yet layouted
|
||||||
// children
|
// children
|
||||||
_space_stretch,//<! space currently assigned to all not yet layouted
|
_space_stretch,//!< space currently assigned to all not yet layouted
|
||||||
// stretchable children
|
// stretchable children
|
||||||
_space_left; //<! remaining space not used by any child yet
|
_space_left; //!< remaining space not used by any child yet
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,9 +44,8 @@
|
|||||||
|
|
||||||
#include "sg_file.hxx"
|
#include "sg_file.hxx"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
SGFile::SGFile(const string &file, int repeat_)
|
SGFile::SGFile(const std::string &file, int repeat_)
|
||||||
: file_name(file), fp(-1), eof_flag(true), repeat(repeat_), iteration(0)
|
: file_name(file), fp(-1), eof_flag(true), repeat(repeat_), iteration(0)
|
||||||
{
|
{
|
||||||
set_type( sgFileType );
|
set_type( sgFileType );
|
||||||
|
@ -1,37 +1,31 @@
|
|||||||
/** \file sg_file.hxx
|
///@file
|
||||||
* File I/O routines.
|
/// File I/O routines.
|
||||||
*/
|
//
|
||||||
|
|
||||||
// Written by Curtis Olson, started November 1999.
|
// Written by Curtis Olson, started November 1999.
|
||||||
//
|
//
|
||||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SG_FILE_HXX
|
#ifndef _SG_FILE_HXX
|
||||||
#define _SG_FILE_HXX
|
#define _SG_FILE_HXX
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "iochannel.hxx"
|
#include "iochannel.hxx"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A file I/O class based on SGIOChannel.
|
* A file I/O class based on SGIOChannel.
|
||||||
@ -91,7 +85,4 @@ public:
|
|||||||
virtual bool eof() const { return eof_flag; };
|
virtual bool eof() const { return eof_flag; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // _SG_FILE_HXX
|
#endif // _SG_FILE_HXX
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
#include "interpolater.hxx"
|
#include "interpolater.hxx"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
// Constructor -- starts with an empty table.
|
// Constructor -- starts with an empty table.
|
||||||
SGInterpTable::SGInterpTable()
|
SGInterpTable::SGInterpTable()
|
||||||
{
|
{
|
||||||
@ -55,7 +53,7 @@ SGInterpTable::SGInterpTable(const SGPropertyNode* interpolation)
|
|||||||
|
|
||||||
// Constructor -- loads the interpolation table from the specified
|
// Constructor -- loads the interpolation table from the specified
|
||||||
// file
|
// file
|
||||||
SGInterpTable::SGInterpTable( const string& file )
|
SGInterpTable::SGInterpTable( const std::string& file )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_MATH, SG_INFO, "Initializing Interpolator for " << file );
|
SG_LOG( SG_MATH, SG_INFO, "Initializing Interpolator for " << file );
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "sgstream.hxx"
|
#include "sgstream.hxx"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using std::istream;
|
using std::istream;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ sg_gzifstream::sg_gzifstream()
|
|||||||
//
|
//
|
||||||
// Open a possibly gzipped file for reading.
|
// Open a possibly gzipped file for reading.
|
||||||
//
|
//
|
||||||
sg_gzifstream::sg_gzifstream( const string& name, ios_openmode io_mode )
|
sg_gzifstream::sg_gzifstream( const std::string& name, ios_openmode io_mode )
|
||||||
: istream(&gzbuf)
|
: istream(&gzbuf)
|
||||||
{
|
{
|
||||||
this->open( name, io_mode );
|
this->open( name, io_mode );
|
||||||
@ -65,12 +64,12 @@ sg_gzifstream::sg_gzifstream( int fd, ios_openmode io_mode )
|
|||||||
// then append ".gz" and try again.
|
// then append ".gz" and try again.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
sg_gzifstream::open( const string& name, ios_openmode io_mode )
|
sg_gzifstream::open( const std::string& name, ios_openmode io_mode )
|
||||||
{
|
{
|
||||||
gzbuf.open( name.c_str(), io_mode );
|
gzbuf.open( name.c_str(), io_mode );
|
||||||
if ( ! gzbuf.is_open() )
|
if ( ! gzbuf.is_open() )
|
||||||
{
|
{
|
||||||
string s = name;
|
std::string s = name;
|
||||||
if ( s.substr( s.length() - 3, 3 ) == ".gz" )
|
if ( s.substr( s.length() - 3, 3 ) == ".gz" )
|
||||||
{
|
{
|
||||||
// remove ".gz" suffix
|
// remove ".gz" suffix
|
||||||
@ -160,7 +159,7 @@ sg_gzofstream::sg_gzofstream()
|
|||||||
//
|
//
|
||||||
// Open a file for gzipped writing.
|
// Open a file for gzipped writing.
|
||||||
//
|
//
|
||||||
sg_gzofstream::sg_gzofstream( const string& name, ios_openmode io_mode )
|
sg_gzofstream::sg_gzofstream( const std::string& name, ios_openmode io_mode )
|
||||||
: ostream(&gzbuf)
|
: ostream(&gzbuf)
|
||||||
{
|
{
|
||||||
this->open( name, io_mode );
|
this->open( name, io_mode );
|
||||||
@ -181,7 +180,7 @@ sg_gzofstream::sg_gzofstream( int fd, ios_openmode io_mode )
|
|||||||
// Open a file for gzipped writing.
|
// Open a file for gzipped writing.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
sg_gzofstream::open( const string& name, ios_openmode io_mode )
|
sg_gzofstream::open( const std::string& name, ios_openmode io_mode )
|
||||||
{
|
{
|
||||||
gzbuf.open( name.c_str(), io_mode );
|
gzbuf.open( name.c_str(), io_mode );
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,6 @@ namespace nasal
|
|||||||
*
|
*
|
||||||
* @tparam Sig Function signature
|
* @tparam Sig Function signature
|
||||||
* @param name Member name
|
* @param name Member name
|
||||||
* @param key Member key
|
|
||||||
*/
|
*/
|
||||||
template<class Sig, class Key>
|
template<class Sig, class Key>
|
||||||
typename boost::enable_if< boost::is_function<Sig>,
|
typename boost::enable_if< boost::is_function<Sig>,
|
||||||
|
@ -47,7 +47,7 @@ namespace nasal
|
|||||||
*
|
*
|
||||||
* @param str Existing Nasal String
|
* @param str Existing Nasal String
|
||||||
*/
|
*/
|
||||||
String(naRef string);
|
String(naRef str);
|
||||||
|
|
||||||
const char* c_str() const;
|
const char* c_str() const;
|
||||||
const char* begin() const;
|
const char* begin() const;
|
||||||
|
@ -161,7 +161,7 @@ struct naFunc {
|
|||||||
struct naCCode {
|
struct naCCode {
|
||||||
GC_HEADER;
|
GC_HEADER;
|
||||||
union {
|
union {
|
||||||
naCFunction fptr; //<! pointer to simple callback function. Invalid if
|
naCFunction fptr; //!< pointer to simple callback function. Invalid if
|
||||||
// fptru is not NULL.
|
// fptru is not NULL.
|
||||||
struct {
|
struct {
|
||||||
void* user_data;
|
void* user_data;
|
||||||
|
@ -39,8 +39,8 @@ namespace simgear
|
|||||||
/**
|
/**
|
||||||
* Remove the property listener of the element.
|
* Remove the property listener of the element.
|
||||||
*
|
*
|
||||||
* You will need to call the appropriate methods (#childAdded,
|
* You will need to call the appropriate methods (childAdded(),
|
||||||
* #childRemoved, #valueChanged) yourself to ensure the element still
|
* childRemoved(), valueChanged()) yourself to ensure the element still
|
||||||
* receives the needed events.
|
* receives the needed events.
|
||||||
*/
|
*/
|
||||||
void removeListener();
|
void removeListener();
|
||||||
|
@ -52,7 +52,6 @@ using std::cerr;
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
using std::find;
|
using std::find;
|
||||||
using std::sort;
|
using std::sort;
|
||||||
using std::string;
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
@ -104,7 +103,7 @@ parse_name (const SGPropertyNode *node, const Range &path)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i != max && *i != '/')
|
if (i != max && *i != '/')
|
||||||
throw string("illegal character after . or ..");
|
throw std::string("illegal character after . or ..");
|
||||||
} else if (isalpha(*i) || *i == '_') {
|
} else if (isalpha(*i) || *i == '_') {
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
@ -117,7 +116,7 @@ parse_name (const SGPropertyNode *node, const Range &path)
|
|||||||
} else if (*i == '[' || *i == '/') {
|
} else if (*i == '[' || *i == '/') {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
string err = "'";
|
std::string err = "'";
|
||||||
err.push_back(*i);
|
err.push_back(*i);
|
||||||
err.append("' found in propertyname after '"+node->getNameString()+"'");
|
err.append("' found in propertyname after '"+node->getNameString()+"'");
|
||||||
err.append("\nname may contain only ._- and alphanumeric characters");
|
err.append("\nname may contain only ._- and alphanumeric characters");
|
||||||
@ -129,7 +128,7 @@ parse_name (const SGPropertyNode *node, const Range &path)
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
if (path.begin() == i) {
|
if (path.begin() == i) {
|
||||||
string err = "'";
|
std::string err = "'";
|
||||||
err.push_back(*i);
|
err.push_back(*i);
|
||||||
err.append("' found in propertyname after '"+node->getNameString()+"'");
|
err.append("' found in propertyname after '"+node->getNameString()+"'");
|
||||||
err.append("\nname must begin with alpha or '_'");
|
err.append("\nname must begin with alpha or '_'");
|
||||||
@ -140,7 +139,7 @@ parse_name (const SGPropertyNode *node, const Range &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate the name of a single node
|
// Validate the name of a single node
|
||||||
inline bool validateName(const string& name)
|
inline bool validateName(const std::string& name)
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
@ -287,7 +286,7 @@ find_node_aux(SGPropertyNode * current, SplitItr& itr, bool create,
|
|||||||
if (equals(name, "..")) {
|
if (equals(name, "..")) {
|
||||||
SGPropertyNode * parent = current->getParent();
|
SGPropertyNode * parent = current->getParent();
|
||||||
if (parent == 0)
|
if (parent == 0)
|
||||||
throw string("attempt to move past root with '..'");
|
throw std::string("attempt to move past root with '..'");
|
||||||
return find_node_aux(parent, ++itr, create, last_index);
|
return find_node_aux(parent, ++itr, create, last_index);
|
||||||
}
|
}
|
||||||
int index = -1;
|
int index = -1;
|
||||||
@ -320,10 +319,10 @@ find_node_aux(SGPropertyNode * current, SplitItr& itr, bool create,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == token.end() || *i != ']')
|
if (i == token.end() || *i != ']')
|
||||||
throw string("unterminated index (looking for ']')");
|
throw std::string("unterminated index (looking for ']')");
|
||||||
} else {
|
} else {
|
||||||
throw string("illegal characters in token: ")
|
throw std::string("illegal characters in token: ")
|
||||||
+ string(name.begin(), name.end());
|
+ std::string(name.begin(), name.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -733,12 +732,12 @@ SGPropertyNode::SGPropertyNode (Itr begin, Itr end,
|
|||||||
_local_val.string_val = 0;
|
_local_val.string_val = 0;
|
||||||
_value.val = 0;
|
_value.val = 0;
|
||||||
if (!validateName(_name))
|
if (!validateName(_name))
|
||||||
throw string("plain name expected instead of '") + _name + '\'';
|
throw std::string("plain name expected instead of '") + _name + '\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode::SGPropertyNode (const string& name,
|
SGPropertyNode::SGPropertyNode( const std::string& name,
|
||||||
int index,
|
int index,
|
||||||
SGPropertyNode * parent)
|
SGPropertyNode * parent)
|
||||||
: _index(index),
|
: _index(index),
|
||||||
_name(name),
|
_name(name),
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
@ -750,7 +749,7 @@ SGPropertyNode::SGPropertyNode (const string& name,
|
|||||||
_local_val.string_val = 0;
|
_local_val.string_val = 0;
|
||||||
_value.val = 0;
|
_value.val = 0;
|
||||||
if (!validateName(name))
|
if (!validateName(name))
|
||||||
throw string("plain name expected instead of '") + _name + '\'';
|
throw std::string("plain name expected instead of '") + _name + '\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -956,7 +955,7 @@ SGPropertyNode::getChild (const char * name, int index, bool create)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode *
|
SGPropertyNode *
|
||||||
SGPropertyNode::getChild (const string& name, int index, bool create)
|
SGPropertyNode::getChild (const std::string& name, int index, bool create)
|
||||||
{
|
{
|
||||||
SGPropertyNode* node = getExistingChild(name.begin(), name.end(), index);
|
SGPropertyNode* node = getExistingChild(name.begin(), name.end(), index);
|
||||||
if (node) {
|
if (node) {
|
||||||
@ -1072,10 +1071,10 @@ SGPropertyNode::removeAllChildren()
|
|||||||
_children.clear();
|
_children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
std::string
|
||||||
SGPropertyNode::getDisplayName (bool simplify) const
|
SGPropertyNode::getDisplayName (bool simplify) const
|
||||||
{
|
{
|
||||||
string display_name = _name;
|
std::string display_name = _name;
|
||||||
if (_index != 0 || !simplify) {
|
if (_index != 0 || !simplify) {
|
||||||
stringstream sstr;
|
stringstream sstr;
|
||||||
sstr << '[' << _index << ']';
|
sstr << '[' << _index << ']';
|
||||||
@ -1084,14 +1083,14 @@ SGPropertyNode::getDisplayName (bool simplify) const
|
|||||||
return display_name;
|
return display_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
std::string
|
||||||
SGPropertyNode::getPath (bool simplify) const
|
SGPropertyNode::getPath (bool simplify) const
|
||||||
{
|
{
|
||||||
typedef std::vector<SGConstPropertyNode_ptr> PList;
|
typedef std::vector<SGConstPropertyNode_ptr> PList;
|
||||||
PList pathList;
|
PList pathList;
|
||||||
for (const SGPropertyNode* node = this; node->_parent; node = node->_parent)
|
for (const SGPropertyNode* node = this; node->_parent; node = node->_parent)
|
||||||
pathList.push_back(node);
|
pathList.push_back(node);
|
||||||
string result;
|
std::string result;
|
||||||
for (PList::reverse_iterator itr = pathList.rbegin(),
|
for (PList::reverse_iterator itr = pathList.rbegin(),
|
||||||
rend = pathList.rend();
|
rend = pathList.rend();
|
||||||
itr != rend;
|
itr != rend;
|
||||||
@ -1672,7 +1671,7 @@ bool SGPropertyNode::interpolate( const std::string& type,
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool SGPropertyNode::interpolate( const std::string& type,
|
bool SGPropertyNode::interpolate( const std::string& type,
|
||||||
const PropertyList& values,
|
const simgear::PropertyList& values,
|
||||||
const double_list& deltas,
|
const double_list& deltas,
|
||||||
const std::string& easing )
|
const std::string& easing )
|
||||||
{
|
{
|
||||||
@ -1810,7 +1809,7 @@ SGPropertyNode::untie ()
|
|||||||
}
|
}
|
||||||
case props::STRING:
|
case props::STRING:
|
||||||
case props::UNSPECIFIED: {
|
case props::UNSPECIFIED: {
|
||||||
string val = getStringValue();
|
std::string val = getStringValue();
|
||||||
clearValue();
|
clearValue();
|
||||||
_type = props::STRING;
|
_type = props::STRING;
|
||||||
_local_val.string_val = copy_string(val.c_str());
|
_local_val.string_val = copy_string(val.c_str());
|
||||||
|
@ -252,15 +252,14 @@ class SGRawBase<T, 0> : public SGRawExtended
|
|||||||
/**
|
/**
|
||||||
* Abstract base class for a raw value.
|
* Abstract base class for a raw value.
|
||||||
*
|
*
|
||||||
* <p>The property manager is implemented in two layers. The {@link
|
* The property manager is implemented in two layers. The SGPropertyNode is the
|
||||||
* SGPropertyNode} is the highest and most abstract layer,
|
* highest and most abstract layer, representing an LValue/RValue pair: it
|
||||||
* representing an LValue/RValue pair: it records the position of the
|
* records the position of the property in the property tree and contains
|
||||||
* property in the property tree and contains facilities for
|
* facilities for navigation to other nodes. It is guaranteed to be persistent:
|
||||||
* navigation to other nodes. It is guaranteed to be persistent: the
|
* the SGPropertyNode will not change during a session, even if the property is
|
||||||
* {@link SGPropertyNode} will not change during a session, even if
|
* bound and unbound multiple times.
|
||||||
* the property is bound and unbound multiple times.</p>
|
|
||||||
*
|
*
|
||||||
* <p>When the property value is not managed internally in the
|
* When the property value is not managed internally in the
|
||||||
* SGPropertyNode, the SGPropertyNode will contain a reference to an
|
* SGPropertyNode, the SGPropertyNode will contain a reference to an
|
||||||
* SGRawValue (this class), which provides an abstract way to get,
|
* SGRawValue (this class), which provides an abstract way to get,
|
||||||
* set, and clone the underlying value. The SGRawValue may change
|
* set, and clone the underlying value. The SGRawValue may change
|
||||||
@ -268,13 +267,12 @@ class SGRawBase<T, 0> : public SGRawExtended
|
|||||||
* unbound to various data source, but the abstract SGPropertyNode
|
* unbound to various data source, but the abstract SGPropertyNode
|
||||||
* layer insulates the application from those changes.
|
* layer insulates the application from those changes.
|
||||||
*
|
*
|
||||||
* <p>The SGPropertyNode class always keeps a *copy* of a raw value,
|
* The SGPropertyNode class always keeps a *copy* of a raw value, not the
|
||||||
* not the original one passed to it; if you override a derived class
|
* original one passed to it; if you override a derived class but do not replace
|
||||||
* but do not replace the {@link #clone} method, strange things will
|
* the {@link SGRaw::clone clone()} method, strange things will happen.
|
||||||
* happen.</p>
|
|
||||||
*
|
*
|
||||||
* <p>All derived SGRawValue classes must implement {@link #getValue},
|
* All derived SGRawValue classes must implement getValue(), setValue(), and
|
||||||
* {@link #setValue}, and {@link #clone} for the appropriate type.</p>
|
* {@link SGRaw::clone clone()} for the appropriate type.
|
||||||
*
|
*
|
||||||
* @see SGPropertyNode
|
* @see SGPropertyNode
|
||||||
* @see SGRawValuePointer
|
* @see SGRawValuePointer
|
||||||
@ -696,9 +694,15 @@ class SGPropertyChangeListener
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~SGPropertyChangeListener ();
|
virtual ~SGPropertyChangeListener ();
|
||||||
virtual void valueChanged (SGPropertyNode * node);
|
|
||||||
virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
|
/// Called if value of \a node has changed.
|
||||||
virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
|
virtual void valueChanged(SGPropertyNode * node);
|
||||||
|
|
||||||
|
/// Called if \a child has been added to the given \a parent.
|
||||||
|
virtual void childAdded(SGPropertyNode * parent, SGPropertyNode * child);
|
||||||
|
|
||||||
|
/// Called if \a child has been removed from its \a parent.
|
||||||
|
virtual void childRemoved(SGPropertyNode * parent, SGPropertyNode * child);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class SGPropertyNode;
|
friend class SGPropertyNode;
|
||||||
@ -1289,7 +1293,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param type Type of interpolation ("numeric", "color", etc.)
|
* @param type Type of interpolation ("numeric", "color", etc.)
|
||||||
* @param values Nodes containing intermediate and target values
|
* @param values Nodes containing intermediate and target values
|
||||||
* @param duration Durations for each interpolation step (in seconds)
|
* @param deltas Durations for each interpolation step (in seconds)
|
||||||
* @param easing Easing function (http://easings.net/)
|
* @param easing Easing function (http://easings.net/)
|
||||||
*/
|
*/
|
||||||
bool interpolate( const std::string& type,
|
bool interpolate( const std::string& type,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/** \file
|
||||||
* \file propsfwwd.hxx
|
*
|
||||||
* Forward declarations for properties (and related structures)
|
* Forward declarations for properties (and related structures)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -9,10 +9,10 @@
|
|||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
class SGPropertyNode;
|
class SGPropertyNode;
|
||||||
|
|
||||||
typedef SGSharedPtr<SGPropertyNode> SGPropertyNode_ptr;
|
typedef SGSharedPtr<SGPropertyNode> SGPropertyNode_ptr;
|
||||||
typedef SGSharedPtr<const SGPropertyNode> SGConstPropertyNode_ptr;
|
typedef SGSharedPtr<const SGPropertyNode> SGConstPropertyNode_ptr;
|
||||||
|
|
||||||
class SGCondition;
|
class SGCondition;
|
||||||
|
|
||||||
#endif // of SG_PROPS_FWD_HXX
|
#endif // of SG_PROPS_FWD_HXX
|
||||||
|
@ -295,9 +295,9 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
|
|||||||
const char* name);
|
const char* name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a node mentioned in a <use> clause from the global property
|
* Get the name of a node mentioned in a \<use\> clause from the global property
|
||||||
* tree.
|
* tree.
|
||||||
* @return empty if prop doesn't contain a <use> clause; otherwise the
|
* @return empty if prop doesn't contain a \<use\> clause; otherwise the
|
||||||
* mentioned node name.
|
* mentioned node name.
|
||||||
*/
|
*/
|
||||||
std::string getGlobalProperty(const SGPropertyNode* prop,
|
std::string getGlobalProperty(const SGPropertyNode* prop,
|
||||||
@ -597,9 +597,9 @@ inline void setDynamicVariance(osg::Object* obj)
|
|||||||
/**
|
/**
|
||||||
* Initialize the value and the possible updating of an effect
|
* Initialize the value and the possible updating of an effect
|
||||||
* attribute. If the value is specified directly, set it. Otherwise,
|
* attribute. If the value is specified directly, set it. Otherwise,
|
||||||
* use the <use> tag to look at the parameters. Again, if there is a
|
* use the \<use\> tag to look at the parameters. Again, if there is a
|
||||||
* value there set it directly. Otherwise, the parameter contains its
|
* value there set it directly. Otherwise, the parameter contains its
|
||||||
* own <use> tag referring to a property in the global property tree;
|
* own \<use\> tag referring to a property in the global property tree;
|
||||||
* install a change listener that will set the attribute when the
|
* install a change listener that will set the attribute when the
|
||||||
* property changes.
|
* property changes.
|
||||||
*
|
*
|
||||||
@ -641,12 +641,12 @@ initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
|||||||
* The parameter may be updated at runtime.
|
* The parameter may be updated at runtime.
|
||||||
*
|
*
|
||||||
* If the value is specified directly, set it. Otherwise, use the
|
* If the value is specified directly, set it. Otherwise, use the
|
||||||
* <use> tag to look at the parameters. Again, if there is a value
|
* \<use\> tag to look at the parameters. Again, if there is a value
|
||||||
* there set it directly. Otherwise, the parameter contains one or several
|
* there set it directly. Otherwise, the parameter contains one or several
|
||||||
* <use> tags. If there is one tag, it is a property that is the root
|
* \<use\> tags. If there is one tag, it is a property that is the root
|
||||||
* for the values needed to update the parameter; nameIter holds the
|
* for the values needed to update the parameter; nameIter holds the
|
||||||
* names of the properties relative to the root. If there are several
|
* names of the properties relative to the root. If there are several
|
||||||
* <use> tags, they each hold the name of the property holding the
|
* \<use\> tags, they each hold the name of the property holding the
|
||||||
* value for the corresponding vector member.
|
* value for the corresponding vector member.
|
||||||
*
|
*
|
||||||
* Install a change listener that will set the attribute when the
|
* Install a change listener that will set the attribute when the
|
||||||
|
@ -68,10 +68,8 @@
|
|||||||
#include "Pass.hxx"
|
#include "Pass.hxx"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
|
||||||
using namespace simgear;
|
using namespace simgear;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Constructors and destructor.
|
// Constructors and destructor.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@ -82,8 +80,10 @@ SGMaterial::_internal_state::_internal_state(Effect *e, bool l,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
|
SGMaterial::_internal_state::_internal_state( Effect *e,
|
||||||
const SGReaderWriterOptions* o)
|
const std::string &t,
|
||||||
|
bool l,
|
||||||
|
const SGReaderWriterOptions* o )
|
||||||
: effect(e), effect_realized(l), options(o)
|
: effect(e), effect_realized(l), options(o)
|
||||||
{
|
{
|
||||||
texture_paths.push_back(std::make_pair(t,0));
|
texture_paths.push_back(std::make_pair(t,0));
|
||||||
@ -132,7 +132,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
std::vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
|
std::vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
|
||||||
for (unsigned int i = 0; i < textures.size(); i++)
|
for (unsigned int i = 0; i < textures.size(); i++)
|
||||||
{
|
{
|
||||||
string tname = textures[i]->getStringValue();
|
std::string tname = textures[i]->getStringValue();
|
||||||
|
|
||||||
if (tname.empty()) {
|
if (tname.empty()) {
|
||||||
tname = "unknown.rgb";
|
tname = "unknown.rgb";
|
||||||
@ -140,7 +140,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
|
|
||||||
SGPath tpath("Textures.high");
|
SGPath tpath("Textures.high");
|
||||||
tpath.append(tname);
|
tpath.append(tname);
|
||||||
string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
|
std::string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
|
||||||
if (fullTexPath.empty()) {
|
if (fullTexPath.empty()) {
|
||||||
tpath.set("Textures");
|
tpath.set("Textures");
|
||||||
tpath.append(tname);
|
tpath.append(tname);
|
||||||
@ -170,14 +170,14 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
std::vector<SGPropertyNode_ptr> textures = texturesets[i]->getChildren("texture");
|
std::vector<SGPropertyNode_ptr> textures = texturesets[i]->getChildren("texture");
|
||||||
for (unsigned int j = 0; j < textures.size(); j++)
|
for (unsigned int j = 0; j < textures.size(); j++)
|
||||||
{
|
{
|
||||||
string tname = textures[j]->getStringValue();
|
std::string tname = textures[j]->getStringValue();
|
||||||
if (tname.empty()) {
|
if (tname.empty()) {
|
||||||
tname = "unknown.rgb";
|
tname = "unknown.rgb";
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPath tpath("Textures.high");
|
SGPath tpath("Textures.high");
|
||||||
tpath.append(tname);
|
tpath.append(tname);
|
||||||
string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
|
std::string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
|
||||||
if (fullTexPath.empty()) {
|
if (fullTexPath.empty()) {
|
||||||
tpath.set("Textures");
|
tpath.set("Textures");
|
||||||
tpath.append(tname);
|
tpath.append(tname);
|
||||||
@ -215,12 +215,13 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
std::vector<SGPropertyNode_ptr> masks = props->getChildren("object-mask");
|
std::vector<SGPropertyNode_ptr> masks = props->getChildren("object-mask");
|
||||||
for (unsigned int i = 0; i < masks.size(); i++)
|
for (unsigned int i = 0; i < masks.size(); i++)
|
||||||
{
|
{
|
||||||
string omname = masks[i]->getStringValue();
|
std::string omname = masks[i]->getStringValue();
|
||||||
|
|
||||||
if (! omname.empty()) {
|
if (! omname.empty()) {
|
||||||
SGPath ompath("Textures.high");
|
SGPath ompath("Textures.high");
|
||||||
ompath.append(omname);
|
ompath.append(omname);
|
||||||
string fullMaskPath = SGModelLib::findDataFile(ompath.str(), options);
|
std::string fullMaskPath =
|
||||||
|
SGModelLib::findDataFile(ompath.str(), options);
|
||||||
|
|
||||||
if (fullMaskPath.empty()) {
|
if (fullMaskPath.empty()) {
|
||||||
ompath.set("Textures");
|
ompath.set("Textures");
|
||||||
@ -279,7 +280,8 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
building_coverage = props->getDoubleValue("building-coverage", 0.0);
|
building_coverage = props->getDoubleValue("building-coverage", 0.0);
|
||||||
building_spacing = props->getDoubleValue("building-spacing-m", 5.0);
|
building_spacing = props->getDoubleValue("building-spacing-m", 5.0);
|
||||||
|
|
||||||
string bt = props->getStringValue("building-texture", "Textures/buildings.png");
|
std::string bt = props->getStringValue( "building-texture",
|
||||||
|
"Textures/buildings.png" );
|
||||||
building_texture = SGModelLib::findDataFile(bt, options);
|
building_texture = SGModelLib::findDataFile(bt, options);
|
||||||
|
|
||||||
if (building_texture.empty()) {
|
if (building_texture.empty()) {
|
||||||
@ -340,7 +342,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
const SGPropertyNode* treeTexNode = props->getChild("tree-texture");
|
const SGPropertyNode* treeTexNode = props->getChild("tree-texture");
|
||||||
|
|
||||||
if (treeTexNode) {
|
if (treeTexNode) {
|
||||||
string treeTexPath = props->getStringValue("tree-texture");
|
std::string treeTexPath = props->getStringValue("tree-texture");
|
||||||
|
|
||||||
if (! treeTexPath.empty()) {
|
if (! treeTexPath.empty()) {
|
||||||
SGPath treePath("Textures.high");
|
SGPath treePath("Textures.high");
|
||||||
@ -540,9 +542,9 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SGMaterialGlyph* SGMaterial::get_glyph (const string& name) const
|
SGMaterialGlyph* SGMaterial::get_glyph (const std::string& name) const
|
||||||
{
|
{
|
||||||
map<string, SGSharedPtr<SGMaterialGlyph> >::const_iterator it;
|
map<std::string, SGSharedPtr<SGMaterialGlyph> >::const_iterator it;
|
||||||
it = glyphs.find(name);
|
it = glyphs.find(name);
|
||||||
if (it == glyphs.end())
|
if (it == glyphs.end())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -32,7 +32,7 @@ ConditionNode::ConditionNode()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ConditionNode::ConditionNode(const ConditionNode& rhs, const CopyOp& op)
|
ConditionNode::ConditionNode(const ConditionNode& rhs, const osg::CopyOp& op)
|
||||||
: Group(rhs, op), _condition(rhs._condition)
|
: Group(rhs, op), _condition(rhs._condition)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ TextureUpdateVisitor::TextureUpdateVisitor(const osgDB::FilePathList& pathList)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureUpdateVisitor::apply(Node& node)
|
void TextureUpdateVisitor::apply(osg::Node& node)
|
||||||
{
|
{
|
||||||
StateSet* stateSet = cloneStateSet(node.getStateSet());
|
StateSet* stateSet = cloneStateSet(node.getStateSet());
|
||||||
if (stateSet)
|
if (stateSet)
|
||||||
|
@ -500,8 +500,12 @@ bool SGCloudLayer::repaint( const SGVec3f& fog_color ) {
|
|||||||
// lat specifies a rotation about the new Y axis
|
// lat specifies a rotation about the new Y axis
|
||||||
// spin specifies a rotation about the new Z axis (and orients the
|
// spin specifies a rotation about the new Z axis (and orients the
|
||||||
// sunrise/set effects
|
// sunrise/set effects
|
||||||
bool SGCloudLayer::reposition( const SGVec3f& p, const SGVec3f& up, double lon, double lat,
|
bool SGCloudLayer::reposition( const SGVec3f& p,
|
||||||
double alt, double dt )
|
const SGVec3f& up,
|
||||||
|
double lon,
|
||||||
|
double lat,
|
||||||
|
double alt,
|
||||||
|
double dt )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR)
|
if (getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR)
|
||||||
|
@ -214,13 +214,13 @@ public:
|
|||||||
* orientation.
|
* orientation.
|
||||||
* @param p position vector
|
* @param p position vector
|
||||||
* @param up the local up vector
|
* @param up the local up vector
|
||||||
* @param lon specifies a rotation about the Z axis
|
* @param lon TODO
|
||||||
* @param lat specifies a rotation about the new Y axis
|
* @param lat TODO
|
||||||
* @param spin specifies a rotation about the new Z axis
|
* @param alt TODO
|
||||||
* (and orients the sunrise/set effects)
|
|
||||||
* @param dt the time elapsed since the last call
|
* @param dt the time elapsed since the last call
|
||||||
*/
|
*/
|
||||||
bool reposition( const SGVec3f& p, const SGVec3f& up,
|
bool reposition( const SGVec3f& p,
|
||||||
|
const SGVec3f& up,
|
||||||
double lon, double lat, double alt,
|
double lon, double lat, double alt,
|
||||||
double dt = 0.0 );
|
double dt = 0.0 );
|
||||||
|
|
||||||
|
@ -79,9 +79,12 @@ SGSky::~SGSky( void )
|
|||||||
|
|
||||||
// initialize the sky and connect the components to the scene graph at
|
// initialize the sky and connect the components to the scene graph at
|
||||||
// the provided branch
|
// the provided branch
|
||||||
void SGSky::build( double h_radius_m, double v_radius_m,
|
void SGSky::build( double h_radius_m,
|
||||||
double sun_size, double moon_size,
|
double v_radius_m,
|
||||||
const SGEphemeris& eph, SGPropertyNode *property_tree_node,
|
double sun_size,
|
||||||
|
double moon_size,
|
||||||
|
const SGEphemeris& eph,
|
||||||
|
SGPropertyNode *property_tree_node,
|
||||||
simgear::SGReaderWriterOptions* options )
|
simgear::SGReaderWriterOptions* options )
|
||||||
{
|
{
|
||||||
dome = new SGSkyDome;
|
dome = new SGSkyDome;
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
#define _SG_SKY_HXX
|
#define _SG_SKY_HXX
|
||||||
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# error This library requires C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
@ -57,29 +53,36 @@ namespace simgear {
|
|||||||
class SGReaderWriterOptions;
|
class SGReaderWriterOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
struct SGSkyState
|
||||||
SGVec3d pos;
|
{
|
||||||
SGGeod pos_geod;
|
SGVec3d pos; //!< View position in world Cartesian coordinates.
|
||||||
SGQuatd ori;
|
SGGeod pos_geod;
|
||||||
double spin;
|
SGQuatd ori;
|
||||||
double gst;
|
double spin; //!< An offset angle for orienting the sky effects with the
|
||||||
double sun_dist;
|
// sun position so sunset and sunrise effects look correct.
|
||||||
double moon_dist;
|
double gst; //!< GMT side real time.
|
||||||
double sun_angle;
|
double sun_dist; //!< the sun's distance from the current view point
|
||||||
} SGSkyState;
|
// (to keep it inside your view volume).
|
||||||
|
double moon_dist;//!< The moon's distance from the current view point.
|
||||||
|
double sun_angle;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct SGSkyColor
|
||||||
SGVec3f sky_color;
|
{
|
||||||
SGVec3f adj_sky_color;
|
SGVec3f sky_color;
|
||||||
SGVec3f fog_color;
|
SGVec3f adj_sky_color;
|
||||||
SGVec3f cloud_color;
|
SGVec3f fog_color;
|
||||||
double sun_angle, moon_angle;
|
SGVec3f cloud_color;
|
||||||
} SGSkyColor;
|
double sun_angle,
|
||||||
|
moon_angle;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* \anchor SGSky-details
|
||||||
|
*
|
||||||
* A class to model a realistic (time/date/position) based sky.
|
* A class to model a realistic (time/date/position) based sky.
|
||||||
*
|
*
|
||||||
* Introduction
|
* Introduction
|
||||||
*
|
*
|
||||||
* The SGSky class models a blended sky dome, a haloed sun, a textured
|
* The SGSky class models a blended sky dome, a haloed sun, a textured
|
||||||
* moon with phase that properly matches the date, stars and planets,
|
* moon with phase that properly matches the date, stars and planets,
|
||||||
@ -164,10 +167,10 @@ typedef struct {
|
|||||||
|
|
||||||
* A typical application might do the following:
|
* A typical application might do the following:
|
||||||
|
|
||||||
* <li> thesky->preDraw( my_altitude );
|
* \li thesky->preDraw( my_altitude );
|
||||||
* <li> thesky->drawUpperClouds();
|
* \li thesky->drawUpperClouds();
|
||||||
* <li> ssgCullAndDraw ( myscene ) ;
|
* \li ssgCullAndDraw ( myscene ) ;
|
||||||
* <li> thesky->drawLowerClouds();
|
* \li thesky->drawLowerClouds();
|
||||||
|
|
||||||
* The current altitude in meters is passed to the preDraw() method
|
* The current altitude in meters is passed to the preDraw() method
|
||||||
* so the clouds layers can be rendered correction from most distant
|
* so the clouds layers can be rendered correction from most distant
|
||||||
@ -261,84 +264,54 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the sky and connect the components to the scene
|
* Initialize the sky and connect the components to the scene
|
||||||
* graph at the provided branch. See discussion in detailed class
|
* graph at the provided branch.
|
||||||
* description.
|
*
|
||||||
* @param h_radius_m horizontal radius of sky dome
|
* @note See discussion in \ref SGSky-details "detailed class description".
|
||||||
* @param v_radius_m vertical radius of sky dome
|
*
|
||||||
* @param sun_size size of sun
|
* @param h_radius_m Horizontal radius of sky dome
|
||||||
* @param moon_size size of moon
|
* @param v_radius_m Vertical radius of sky dome
|
||||||
* @param nplanets number of planets
|
* @param sun_size Size of sun
|
||||||
* @param planet_data an array of planet right ascensions, declinations,
|
* @param moon_size Size of moon
|
||||||
* and magnitudes
|
* @param eph Current positions of planets and stars
|
||||||
* @param nstars number of stars
|
* @param node Property node connecting sun with environment
|
||||||
* @param star_data an array of star right ascensions, declinations,
|
* @param options
|
||||||
* and magnitudes
|
|
||||||
*/
|
*/
|
||||||
void build( double h_radius_m, double v_radius_m,
|
void build( double h_radius_m,
|
||||||
double sun_size, double moon_size,
|
double v_radius_m,
|
||||||
const SGEphemeris& eph, SGPropertyNode *property_tree_node,
|
double sun_size,
|
||||||
simgear::SGReaderWriterOptions* options);
|
double moon_size,
|
||||||
|
const SGEphemeris& eph,
|
||||||
|
SGPropertyNode *node,
|
||||||
|
simgear::SGReaderWriterOptions* options );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repaint the sky components based on current value of sun_angle,
|
* Repaint the sky components based on current sun angle, and sky and fog
|
||||||
* sky, and fog colors. You can also specify new star and planet
|
* colors.
|
||||||
* data so that we can optionally change the magnitude of these
|
|
||||||
* (for day/night transitions.) See discussion in detailed
|
|
||||||
* class description.
|
|
||||||
*
|
*
|
||||||
* Sun and moon angles are specified in degrees relative to local up
|
* @note See discussion in \ref SGSky-details "detailed class description".
|
||||||
* <li> 0 degrees = high noon
|
*
|
||||||
* <li> 90 degrees = sun rise/set
|
* @param sky_color The base sky color (for the top of the dome)
|
||||||
* <li> 180 degrees = darkest midnight
|
* @param eph Current positions of planets and stars
|
||||||
* @param sky_color the base sky color (for the top of the dome)
|
|
||||||
* @param fog_color the fog color (for the horizon)
|
|
||||||
* @param sun_angle the sun angle with the horizon (for sunrise/sunset
|
|
||||||
* effects)
|
|
||||||
* @param moon_angle the moon angle (so we can make it more yellow
|
|
||||||
* at the horizon)
|
|
||||||
* @param nplanets number of planets
|
|
||||||
* @param planet_data an array of planet right ascensions, declinations,
|
|
||||||
* and magnitudes
|
|
||||||
* @param nstars number of stars
|
|
||||||
* @param star_data an array of star right ascensions, declinations,
|
|
||||||
* and magnitudes
|
|
||||||
*/
|
*/
|
||||||
bool repaint( const SGSkyColor &sc, const SGEphemeris& eph );
|
bool repaint( const SGSkyColor &sky_color,
|
||||||
|
const SGEphemeris& eph );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reposition the sky at the specified origin and orientation
|
* Reposition the sky at the specified origin and orientation.
|
||||||
|
*
|
||||||
|
* @note See discussion in \ref SGSky-details "detailed class description".
|
||||||
*
|
*
|
||||||
* lon specifies a rotation about the Z axis
|
|
||||||
* lat specifies a rotation about the new Y axis
|
|
||||||
* spin specifies a rotation about the new Z axis (this allows
|
|
||||||
* additional orientation for the sunrise/set effects and is used
|
|
||||||
* by the skydome and perhaps clouds. See discussion in detailed
|
|
||||||
* class description.
|
|
||||||
* @param view_pos specify your view position in world Cartesian
|
|
||||||
* coordinates
|
|
||||||
* @param zero_elev the zero elevation position in world Cartesian
|
|
||||||
* coordinates
|
|
||||||
* @param view_up the up vector in world Cartesian coordinates
|
|
||||||
* @param lon current longitude
|
|
||||||
* @param lat current latitude
|
|
||||||
* @param alt current altitude
|
|
||||||
* @param spin an offset angle for orienting the sky effects with the
|
|
||||||
* sun position so sunset and sunrise effects look correct.
|
|
||||||
* @param gst GMT side real time
|
|
||||||
* @param sun_ra the sun's current right ascension
|
|
||||||
* @param sun_dec the sun's current declination
|
|
||||||
* @param sun_dist the sun's distance from the current view point
|
|
||||||
* (to keep it inside your view volume.)
|
|
||||||
* @param moon_ra the moon's current right ascension
|
|
||||||
* @param moon_dec the moon's current declination
|
|
||||||
* @param moon_dist the moon's distance from the current view point.
|
|
||||||
*/
|
*/
|
||||||
bool reposition( const SGSkyState &st, const SGEphemeris& eph, double dt = 0.0 );
|
bool reposition( const SGSkyState& sky_state,
|
||||||
|
const SGEphemeris& eph,
|
||||||
|
double dt = 0.0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify the given visibility based on cloud layers, thickness,
|
* Modify the given visibility based on cloud layers, thickness,
|
||||||
* transition range, and simulated "puffs". See discussion in detailed
|
* transition range, and simulated "puffs".
|
||||||
* class description.
|
*
|
||||||
|
* @note See discussion in \ref SGSky-details "detailed class description".
|
||||||
|
*
|
||||||
* @param alt current altitude
|
* @param alt current altitude
|
||||||
* @param time_factor amount of time since modify_vis() last called so
|
* @param time_factor amount of time since modify_vis() last called so
|
||||||
* we can scale effect rates properly despite variable frame rates.
|
* we can scale effect rates properly despite variable frame rates.
|
||||||
@ -350,7 +323,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the texture path (optional, defaults to current directory)
|
* Specify the texture path (optional, defaults to current directory)
|
||||||
* @param path base path to texture locations
|
*
|
||||||
|
* @param path Base path to texture locations
|
||||||
*/
|
*/
|
||||||
void texture_path( const std::string& path );
|
void texture_path( const std::string& path );
|
||||||
|
|
||||||
@ -424,7 +398,8 @@ public:
|
|||||||
float get_3dCloudVisRange() const;
|
float get_3dCloudVisRange() const;
|
||||||
|
|
||||||
/** Set 3D cloud visibility range
|
/** Set 3D cloud visibility range
|
||||||
* @param density 3D cloud visibility range
|
*
|
||||||
|
* @param vis 3D cloud visibility range
|
||||||
*/
|
*/
|
||||||
void set_3dCloudVisRange(float vis);
|
void set_3dCloudVisRange(float vis);
|
||||||
|
|
||||||
@ -432,7 +407,8 @@ public:
|
|||||||
float get_3dCloudImpostorDistance() const;
|
float get_3dCloudImpostorDistance() const;
|
||||||
|
|
||||||
/** Set 3D cloud impostor distance
|
/** Set 3D cloud impostor distance
|
||||||
* @param density 3D cloud impostor distance
|
*
|
||||||
|
* @param vis 3D cloud impostor distance
|
||||||
*/
|
*/
|
||||||
void set_3dCloudImpostorDistance(float vis);
|
void set_3dCloudImpostorDistance(float vis);
|
||||||
|
|
||||||
@ -456,7 +432,8 @@ public:
|
|||||||
bool get_3dCloudUseImpostors() const;
|
bool get_3dCloudUseImpostors() const;
|
||||||
|
|
||||||
/** Set 3D cloud impostor usage
|
/** Set 3D cloud impostor usage
|
||||||
* @param wrap whether use impostors for 3D clouds
|
*
|
||||||
|
* @param imp whether use impostors for 3D clouds
|
||||||
*/
|
*/
|
||||||
void set_3dCloudUseImpostors(bool imp);
|
void set_3dCloudUseImpostors(bool imp);
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@ public:
|
|||||||
void calcApronPts(double tex_width);
|
void calcApronPts(double tex_width);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
void OceanMesh::calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient,
|
void OceanMesh::calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient,
|
||||||
double clon, double clat,
|
double clon, double clat,
|
||||||
@ -238,8 +237,6 @@ void OceanMesh::calcApronPts(double tex_width)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
// Enter the vertices of triangles that fill one row of the
|
// Enter the vertices of triangles that fill one row of the
|
||||||
// mesh. The vertices are entered in counter-clockwise order.
|
// mesh. The vertices are entered in counter-clockwise order.
|
||||||
void fillDrawElementsRow(int width, short row0Start, short row1Start,
|
void fillDrawElementsRow(int width, short row0Start, short row1Start,
|
||||||
|
@ -28,14 +28,18 @@ namespace simgear
|
|||||||
{
|
{
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
NodeAndDrawableVisitor::NodeAndDrawableVisitor(NodeVisitor::TraversalMode tm) :
|
NodeAndDrawableVisitor::NodeAndDrawableVisitor(
|
||||||
NodeVisitor(tm)
|
osg::NodeVisitor::TraversalMode tm
|
||||||
|
):
|
||||||
|
NodeVisitor(tm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeAndDrawableVisitor::NodeAndDrawableVisitor(NodeVisitor::VisitorType type,
|
NodeAndDrawableVisitor::NodeAndDrawableVisitor(
|
||||||
NodeVisitor::TraversalMode tm) :
|
osg::NodeVisitor::VisitorType type,
|
||||||
NodeVisitor(type, tm)
|
osg::NodeVisitor::TraversalMode tm
|
||||||
|
):
|
||||||
|
NodeVisitor(type, tm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,16 +47,16 @@ NodeAndDrawableVisitor::~NodeAndDrawableVisitor()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeAndDrawableVisitor::apply(Node& node)
|
void NodeAndDrawableVisitor::apply(osg::Node& node)
|
||||||
{
|
{
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeAndDrawableVisitor::apply(Drawable& Drawable)
|
void NodeAndDrawableVisitor::apply(osg::Drawable& Drawable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeAndDrawableVisitor::traverse(Node& node)
|
void NodeAndDrawableVisitor::traverse(osg::Node& node)
|
||||||
{
|
{
|
||||||
TraversalMode tm = getTraversalMode();
|
TraversalMode tm = getTraversalMode();
|
||||||
if (tm == TRAVERSE_NONE) {
|
if (tm == TRAVERSE_NONE) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
///@file Helper for OSG related debugging
|
///@file
|
||||||
|
/// Helper for OSG related debugging
|
||||||
//
|
//
|
||||||
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
|
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
|
||||||
//
|
//
|
||||||
|
@ -16,7 +16,7 @@ void SplicingVisitor::reset()
|
|||||||
NodeVisitor::reset();
|
NodeVisitor::reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList SplicingVisitor::traverse(Node& node)
|
NodeList SplicingVisitor::traverse(osg::Node& node)
|
||||||
{
|
{
|
||||||
NodeList result;
|
NodeList result;
|
||||||
_childStack.push_back(NodeList());
|
_childStack.push_back(NodeList());
|
||||||
@ -25,21 +25,22 @@ NodeList SplicingVisitor::traverse(Node& node)
|
|||||||
_childStack.pop_back();
|
_childStack.pop_back();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void SplicingVisitor::apply(Node& node)
|
void SplicingVisitor::apply(osg::Node& node)
|
||||||
{
|
{
|
||||||
NodeVisitor::traverse(node);
|
NodeVisitor::traverse(node);
|
||||||
pushNode(&node);
|
pushNode(&node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplicingVisitor::apply(Group& node)
|
void SplicingVisitor::apply(osg::Group& node)
|
||||||
{
|
{
|
||||||
if (pushNode(getNewNode(node)))
|
if (pushNode(getNewNode(node)))
|
||||||
return;
|
return;
|
||||||
pushResultNode(&node, &node, traverse(node));
|
pushResultNode(&node, &node, traverse(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* SplicingVisitor::pushResultNode(Group* node, Group* newNode,
|
osg::Group* SplicingVisitor::pushResultNode( osg::Group* node,
|
||||||
const NodeList& children)
|
osg::Group* newNode,
|
||||||
|
const osg::NodeList& children )
|
||||||
{
|
{
|
||||||
ref_ptr<Group> result;
|
ref_ptr<Group> result;
|
||||||
if (node == newNode) {
|
if (node == newNode) {
|
||||||
@ -56,21 +57,21 @@ Group* SplicingVisitor::pushResultNode(Group* node, Group* newNode,
|
|||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* SplicingVisitor::pushResultNode(Node* node, Node* newNode)
|
osg::Node* SplicingVisitor::pushResultNode(osg::Node* node, osg::Node* newNode)
|
||||||
{
|
{
|
||||||
_childStack.back().push_back(newNode);
|
_childStack.back().push_back(newNode);
|
||||||
recordNewNode(node, newNode);
|
recordNewNode(node, newNode);
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* SplicingVisitor::pushNode(Node* node)
|
osg::Node* SplicingVisitor::pushNode(osg::Node* node)
|
||||||
{
|
{
|
||||||
if (node)
|
if (node)
|
||||||
_childStack.back().push_back(node);
|
_childStack.back().push_back(node);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* SplicingVisitor::getResult()
|
osg::Node* SplicingVisitor::getResult()
|
||||||
{
|
{
|
||||||
NodeList& top = _childStack.at(0);
|
NodeList& top = _childStack.at(0);
|
||||||
if (top.empty()) {
|
if (top.empty()) {
|
||||||
@ -87,7 +88,7 @@ Node* SplicingVisitor::getResult()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* SplicingVisitor::getNewNode(osg::Node* node)
|
osg::Node* SplicingVisitor::getNewNode(osg::Node* node)
|
||||||
{
|
{
|
||||||
ref_ptr<Node> tmpPtr(node);
|
ref_ptr<Node> tmpPtr(node);
|
||||||
NodeMap::iterator itr;
|
NodeMap::iterator itr;
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
#include "soundmgr_openal_private.hxx"
|
#include "soundmgr_openal_private.hxx"
|
||||||
#include "sample_group.hxx"
|
#include "sample_group.hxx"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
#ifdef HAVE_STD_ISNAN
|
#ifdef HAVE_STD_ISNAN
|
||||||
using std::isnan;
|
using std::isnan;
|
||||||
#endif
|
#endif
|
||||||
@ -57,7 +55,8 @@ SGSampleGroup::SGSampleGroup () :
|
|||||||
_samples.clear();
|
_samples.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr, const string &refname ) :
|
SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr,
|
||||||
|
const std::string &refname ):
|
||||||
_smgr(smgr),
|
_smgr(smgr),
|
||||||
_refname(refname),
|
_refname(refname),
|
||||||
_active(false),
|
_active(false),
|
||||||
@ -227,8 +226,9 @@ void SGSampleGroup::update( double dt ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add a sound effect, return true if successful
|
// add a sound effect, return true if successful
|
||||||
bool SGSampleGroup::add( SGSharedPtr<SGSoundSample> sound, const string& refname ) {
|
bool SGSampleGroup::add( SGSharedPtr<SGSoundSample> sound,
|
||||||
|
const std::string& refname )
|
||||||
|
{
|
||||||
sample_map_iterator sample_it = _samples.find( refname );
|
sample_map_iterator sample_it = _samples.find( refname );
|
||||||
if ( sample_it != _samples.end() ) {
|
if ( sample_it != _samples.end() ) {
|
||||||
// sample name already exists
|
// sample name already exists
|
||||||
@ -241,7 +241,7 @@ bool SGSampleGroup::add( SGSharedPtr<SGSoundSample> sound, const string& refname
|
|||||||
|
|
||||||
|
|
||||||
// remove a sound effect, return true if successful
|
// remove a sound effect, return true if successful
|
||||||
bool SGSampleGroup::remove( const string &refname ) {
|
bool SGSampleGroup::remove( const std::string &refname ) {
|
||||||
|
|
||||||
sample_map_iterator sample_it = _samples.find( refname );
|
sample_map_iterator sample_it = _samples.find( refname );
|
||||||
if ( sample_it == _samples.end() ) {
|
if ( sample_it == _samples.end() ) {
|
||||||
@ -259,7 +259,7 @@ bool SGSampleGroup::remove( const string &refname ) {
|
|||||||
|
|
||||||
|
|
||||||
// return true of the specified sound exists in the sound manager system
|
// return true of the specified sound exists in the sound manager system
|
||||||
bool SGSampleGroup::exists( const string &refname ) {
|
bool SGSampleGroup::exists( const std::string &refname ) {
|
||||||
sample_map_iterator sample_it = _samples.find( refname );
|
sample_map_iterator sample_it = _samples.find( refname );
|
||||||
if ( sample_it == _samples.end() ) {
|
if ( sample_it == _samples.end() ) {
|
||||||
// sample was not found
|
// sample was not found
|
||||||
@ -272,7 +272,7 @@ bool SGSampleGroup::exists( const string &refname ) {
|
|||||||
|
|
||||||
// return a pointer to the SGSoundSample if the specified sound exists
|
// return a pointer to the SGSoundSample if the specified sound exists
|
||||||
// in the sound manager system, otherwise return NULL
|
// in the sound manager system, otherwise return NULL
|
||||||
SGSoundSample *SGSampleGroup::find( const string &refname ) {
|
SGSoundSample *SGSampleGroup::find( const std::string &refname ) {
|
||||||
sample_map_iterator sample_it = _samples.find( refname );
|
sample_map_iterator sample_it = _samples.find( refname );
|
||||||
if ( sample_it == _samples.end() ) {
|
if ( sample_it == _samples.end() ) {
|
||||||
// sample was not found
|
// sample was not found
|
||||||
@ -353,7 +353,9 @@ SGSampleGroup::resume ()
|
|||||||
|
|
||||||
|
|
||||||
// tell the scheduler to play the indexed sample in a continuous loop
|
// tell the scheduler to play the indexed sample in a continuous loop
|
||||||
bool SGSampleGroup::play( const string &refname, bool looping = false ) {
|
bool SGSampleGroup::play( const std::string &refname,
|
||||||
|
bool looping )
|
||||||
|
{
|
||||||
SGSoundSample *sample = find( refname );
|
SGSoundSample *sample = find( refname );
|
||||||
|
|
||||||
if ( sample == NULL ) {
|
if ( sample == NULL ) {
|
||||||
@ -366,7 +368,7 @@ bool SGSampleGroup::play( const string &refname, bool looping = false ) {
|
|||||||
|
|
||||||
|
|
||||||
// return true of the specified sound is currently being played
|
// return true of the specified sound is currently being played
|
||||||
bool SGSampleGroup::is_playing( const string& refname ) {
|
bool SGSampleGroup::is_playing( const std::string& refname ) {
|
||||||
SGSoundSample *sample = find( refname );
|
SGSoundSample *sample = find( refname );
|
||||||
|
|
||||||
if ( sample == NULL ) {
|
if ( sample == NULL ) {
|
||||||
@ -377,7 +379,7 @@ bool SGSampleGroup::is_playing( const string& refname ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// immediate stop playing the sound
|
// immediate stop playing the sound
|
||||||
bool SGSampleGroup::stop( const string& refname ) {
|
bool SGSampleGroup::stop( const std::string& refname ) {
|
||||||
SGSoundSample *sample = find( refname );
|
SGSoundSample *sample = find( refname );
|
||||||
|
|
||||||
if ( sample == NULL ) {
|
if ( sample == NULL ) {
|
||||||
@ -488,7 +490,7 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SGSampleGroup::testForError(void *p, string s)
|
bool SGSampleGroup::testForError(void *p, std::string s)
|
||||||
{
|
{
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
SG_LOG( SG_SOUND, SG_ALERT, "Error (sample group): " << s);
|
SG_LOG( SG_SOUND, SG_ALERT, "Error (sample group): " << s);
|
||||||
@ -497,7 +499,7 @@ bool SGSampleGroup::testForError(void *p, string s)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SGSampleGroup::testForALError(string s)
|
bool SGSampleGroup::testForALError(std::string s)
|
||||||
{
|
{
|
||||||
#ifdef SG_C
|
#ifdef SG_C
|
||||||
ALenum error = alGetError();
|
ALenum error = alGetError();
|
||||||
|
@ -1,30 +1,26 @@
|
|||||||
// sample_group.hxx -- Manage a group of samples relative to a base position
|
///@file
|
||||||
|
/// Manage a group of samples relative to a base position
|
||||||
|
///
|
||||||
|
/// Sample groups contain all sounds related to one specific object and
|
||||||
|
/// have to be added to the sound manager, otherwise they won't get processed.
|
||||||
//
|
//
|
||||||
// Written for the new SoundSystem by Erik Hofman, October 2009
|
// Written for the new SoundSystem by Erik Hofman, October 2009
|
||||||
//
|
//
|
||||||
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// License along with this library; if not, write to the Free Software
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file sample_group.hxx
|
|
||||||
* sample groups contain all sounds related to one specific object and
|
|
||||||
* have to be added to the sound manager, otherwise they won't get processed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SG_SAMPLE_GROUP_OPENAL_HXX
|
#ifndef _SG_SAMPLE_GROUP_OPENAL_HXX
|
||||||
#define _SG_SAMPLE_GROUP_OPENAL_HXX 1
|
#define _SG_SAMPLE_GROUP_OPENAL_HXX 1
|
||||||
@ -137,7 +133,7 @@ public:
|
|||||||
* @param looping Define if the sound should loop continuously
|
* @param looping Define if the sound should loop continuously
|
||||||
* @return true if the audio sample exsists and is scheduled for playing
|
* @return true if the audio sample exsists and is scheduled for playing
|
||||||
*/
|
*/
|
||||||
bool play( const std::string& refname, bool looping );
|
bool play( const std::string& refname, bool looping = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request to start playing the referred audio sample looping.
|
* Request to start playing the referred audio sample looping.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// sample_openal.hxx -- Audio sample encapsulation class
|
///@file
|
||||||
|
/// Provides an audio sample encapsulation class.
|
||||||
//
|
//
|
||||||
// Written by Curtis Olson, started April 2004.
|
// Written by Curtis Olson, started April 2004.
|
||||||
// Modified to match the new SoundSystem by Erik Hofman, October 2009
|
// Modified to match the new SoundSystem by Erik Hofman, October 2009
|
||||||
@ -6,26 +7,19 @@
|
|||||||
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||||
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// License along with this library; if not, write to the Free Software
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file audio sample.hxx
|
|
||||||
* Provides a audio sample encapsulation
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SG_SAMPLE_HXX
|
#ifndef _SG_SAMPLE_HXX
|
||||||
#define _SG_SAMPLE_HXX 1
|
#define _SG_SAMPLE_HXX 1
|
||||||
@ -45,7 +39,9 @@ class SGPath;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* manages everything we need to know for an individual audio sample
|
* Encapsulate and audio sample.
|
||||||
|
*
|
||||||
|
* Manages everything we need to know for an individual audio sample.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SGSoundSample : public SGReferenced {
|
class SGSoundSample : public SGReferenced {
|
||||||
@ -95,6 +91,7 @@ public:
|
|||||||
* Test if this audio sample configuration has changed since the last call.
|
* Test if this audio sample configuration has changed since the last call.
|
||||||
* Calling this function will reset the flag so calling it a second
|
* Calling this function will reset the flag so calling it a second
|
||||||
* time in a row will return false.
|
* time in a row will return false.
|
||||||
|
*
|
||||||
* @return Return true is the configuration has changed in the mean time.
|
* @return Return true is the configuration has changed in the mean time.
|
||||||
*/
|
*/
|
||||||
bool has_changed() {
|
bool has_changed() {
|
||||||
@ -105,6 +102,7 @@ public:
|
|||||||
* Test if static data of audio sample configuration has changed.
|
* Test if static data of audio sample configuration has changed.
|
||||||
* Calling this function will reset the flag so calling it a second
|
* Calling this function will reset the flag so calling it a second
|
||||||
* time in a row will return false.
|
* time in a row will return false.
|
||||||
|
*
|
||||||
* @return Return true is the static data has changed in the mean time.
|
* @return Return true is the static data has changed in the mean time.
|
||||||
*/
|
*/
|
||||||
bool has_static_data_changed() {
|
bool has_static_data_changed() {
|
||||||
@ -114,7 +112,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Schedule this audio sample for playing. Actual playing will only start
|
* Schedule this audio sample for playing. Actual playing will only start
|
||||||
* at the next call op SoundGroup::update()
|
* at the next call op SoundGroup::update()
|
||||||
* @param _loop Define whether this sound should be played in a loop.
|
*
|
||||||
|
* @param loop Whether this sound should be played in a loop.
|
||||||
*/
|
*/
|
||||||
void play( bool loop = false ) {
|
void play( bool loop = false ) {
|
||||||
_playing = true; _loop = loop; _changed = true; _static_changed = true;
|
_playing = true; _loop = loop; _changed = true; _static_changed = true;
|
||||||
@ -122,6 +121,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this audio sample is set to be continuous looping.
|
* Check if this audio sample is set to be continuous looping.
|
||||||
|
*
|
||||||
* @return Return true if this audio sample is set to looping.
|
* @return Return true if this audio sample is set to looping.
|
||||||
*/
|
*/
|
||||||
inline bool is_looping() { return _loop; }
|
inline bool is_looping() { return _loop; }
|
||||||
@ -405,7 +405,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Set the velocity vector (in meters per second) of this sound.
|
* Set the velocity vector (in meters per second) of this sound.
|
||||||
* This is in the local frame coordinate system; x=north, y=east, z=down
|
* This is in the local frame coordinate system; x=north, y=east, z=down
|
||||||
* @param Velocity vector
|
*
|
||||||
|
* @param vel Velocity vector
|
||||||
*/
|
*/
|
||||||
inline void set_velocity( const SGVec3f& vel ) {
|
inline void set_velocity( const SGVec3f& vel ) {
|
||||||
_velocity = vel; _changed = true;
|
_velocity = vel; _changed = true;
|
||||||
|
@ -1,37 +1,27 @@
|
|||||||
// queue.hxx -- Sample Queue encapsulation class
|
///@file
|
||||||
//
|
/// Provides a sample queue encapsulation
|
||||||
|
//
|
||||||
// based on sample.hxx
|
// based on sample.hxx
|
||||||
//
|
//
|
||||||
// Copyright (C) 2010 Erik Hofman <erik@ehofman.com>
|
// Copyright (C) 2010 Erik Hofman <erik@ehofman.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// License along with this library; if not, write to the Free Software
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file audio sample.hxx
|
|
||||||
* Provides a sample queue encapsulation
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SG_QUEUE_HXX
|
#ifndef _SG_QUEUE_HXX
|
||||||
#define _SG_QUEUE_HXX 1
|
#define _SG_QUEUE_HXX 1
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# error This library requires C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -68,20 +58,23 @@ public:
|
|||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue new data for this audio sample
|
* Queue new data for this audio sample.
|
||||||
* @param data Pointer to a memory block containg this audio sample data.
|
*
|
||||||
* @param len length of the sample buffer in bytes
|
* @param data Pointer to a memory block containg this audio sample data.
|
||||||
|
* @param len Length of the sample buffer in bytes.
|
||||||
*/
|
*/
|
||||||
void add( const void* smp_data, size_t len );
|
void add( const void* data, size_t len );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the source id of this source
|
* Set the source id of this source.
|
||||||
|
*
|
||||||
* @param sid OpenAL source-id
|
* @param sid OpenAL source-id
|
||||||
*/
|
*/
|
||||||
virtual void set_source(unsigned int sid);
|
virtual void set_source(unsigned int sid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the buffer-id of this audio sample may be passed to OpenAL.
|
* Test if the buffer-id of this audio sample may be passed to OpenAL.
|
||||||
|
*
|
||||||
* @return false for sample queue
|
* @return false for sample queue
|
||||||
*/
|
*/
|
||||||
inline bool is_valid_buffer() const { return false; }
|
inline bool is_valid_buffer() const { return false; }
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
@ -408,7 +407,7 @@ if (isNaN(_velocity.data())) printf("NaN in listener velocity\n");
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add a sample group, return true if successful
|
// add a sample group, return true if successful
|
||||||
bool SGSoundMgr::add( SGSampleGroup *sgrp, const string& refname )
|
bool SGSoundMgr::add( SGSampleGroup *sgrp, const std::string& refname )
|
||||||
{
|
{
|
||||||
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
||||||
if ( sample_grp_it != d->_sample_groups.end() ) {
|
if ( sample_grp_it != d->_sample_groups.end() ) {
|
||||||
@ -424,7 +423,7 @@ bool SGSoundMgr::add( SGSampleGroup *sgrp, const string& refname )
|
|||||||
|
|
||||||
|
|
||||||
// remove a sound effect, return true if successful
|
// remove a sound effect, return true if successful
|
||||||
bool SGSoundMgr::remove( const string &refname )
|
bool SGSoundMgr::remove( const std::string &refname )
|
||||||
{
|
{
|
||||||
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
||||||
if ( sample_grp_it == d->_sample_groups.end() ) {
|
if ( sample_grp_it == d->_sample_groups.end() ) {
|
||||||
@ -439,7 +438,7 @@ bool SGSoundMgr::remove( const string &refname )
|
|||||||
|
|
||||||
|
|
||||||
// return true of the specified sound exists in the sound manager system
|
// return true of the specified sound exists in the sound manager system
|
||||||
bool SGSoundMgr::exists( const string &refname ) {
|
bool SGSoundMgr::exists( const std::string &refname ) {
|
||||||
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
||||||
return ( sample_grp_it != d->_sample_groups.end() );
|
return ( sample_grp_it != d->_sample_groups.end() );
|
||||||
}
|
}
|
||||||
@ -447,7 +446,7 @@ bool SGSoundMgr::exists( const string &refname ) {
|
|||||||
|
|
||||||
// return a pointer to the SGSampleGroup if the specified sound exists
|
// return a pointer to the SGSampleGroup if the specified sound exists
|
||||||
// in the sound manager system, otherwise return NULL
|
// in the sound manager system, otherwise return NULL
|
||||||
SGSampleGroup *SGSoundMgr::find( const string &refname, bool create ) {
|
SGSampleGroup *SGSoundMgr::find( const std::string &refname, bool create ) {
|
||||||
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
sample_group_map_iterator sample_grp_it = d->_sample_groups.find( refname );
|
||||||
if ( sample_grp_it == d->_sample_groups.end() ) {
|
if ( sample_grp_it == d->_sample_groups.end() ) {
|
||||||
// sample group was not found.
|
// sample group was not found.
|
||||||
@ -524,7 +523,7 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
|
|||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
if ( !sample->is_valid_buffer() ) {
|
if ( !sample->is_valid_buffer() ) {
|
||||||
// sample was not yet loaded or removed again
|
// sample was not yet loaded or removed again
|
||||||
string sample_name = sample->get_sample_name();
|
std::string sample_name = sample->get_sample_name();
|
||||||
void *sample_data = NULL;
|
void *sample_data = NULL;
|
||||||
|
|
||||||
// see if the sample name is already cached
|
// see if the sample name is already cached
|
||||||
@ -588,7 +587,7 @@ void SGSoundMgr::release_buffer(SGSoundSample *sample)
|
|||||||
{
|
{
|
||||||
if ( !sample->is_queue() )
|
if ( !sample->is_queue() )
|
||||||
{
|
{
|
||||||
string sample_name = sample->get_sample_name();
|
std::string sample_name = sample->get_sample_name();
|
||||||
buffer_map_iterator buffer_it = d->_buffers.find( sample_name );
|
buffer_map_iterator buffer_it = d->_buffers.find( sample_name );
|
||||||
if ( buffer_it == d->_buffers.end() ) {
|
if ( buffer_it == d->_buffers.end() ) {
|
||||||
// buffer was not found
|
// buffer was not found
|
||||||
@ -608,8 +607,11 @@ void SGSoundMgr::release_buffer(SGSoundSample *sample)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SGSoundMgr::load(const string &samplepath, void **dbuf, int *fmt,
|
bool SGSoundMgr::load( const std::string &samplepath,
|
||||||
size_t *sz, int *frq )
|
void **dbuf,
|
||||||
|
int *fmt,
|
||||||
|
size_t *sz,
|
||||||
|
int *frq )
|
||||||
{
|
{
|
||||||
if ( !is_working() )
|
if ( !is_working() )
|
||||||
return false;
|
return false;
|
||||||
@ -668,7 +670,7 @@ vector<const char*> SGSoundMgr::get_available_devices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SGSoundMgr::testForError(void *p, string s)
|
bool SGSoundMgr::testForError(void *p, std::string s)
|
||||||
{
|
{
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
SG_LOG( SG_SOUND, SG_ALERT, "Error: " << s);
|
SG_LOG( SG_SOUND, SG_ALERT, "Error: " << s);
|
||||||
@ -678,7 +680,7 @@ bool SGSoundMgr::testForError(void *p, string s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SGSoundMgr::testForALError(string s)
|
bool SGSoundMgr::testForALError(std::string s)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
ALenum error = alGetError();
|
ALenum error = alGetError();
|
||||||
@ -691,7 +693,7 @@ bool SGSoundMgr::testForALError(string s)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SGSoundMgr::testForALCError(string s)
|
bool SGSoundMgr::testForALCError(std::string s)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
ALCenum error;
|
ALCenum error;
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
// soundmgr.hxx -- Sound effect management class
|
///@file
|
||||||
|
/// Sound effect management class
|
||||||
|
///
|
||||||
|
/// Provides a sound manager class to keep track of multiple sounds and manage
|
||||||
|
/// playing them with different effects and timings.
|
||||||
//
|
//
|
||||||
// Sound manager initially written by David Findlay
|
// Sound manager initially written by David Findlay
|
||||||
// <david_j_findlay@yahoo.com.au> 2001
|
// <david_j_findlay@yahoo.com.au> 2001
|
||||||
@ -9,28 +13,19 @@
|
|||||||
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
|
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||||
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// License along with this library; if not, write to the Free Software
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file soundmgr.hxx
|
|
||||||
* Provides a sound manager class to keep track of
|
|
||||||
* multiple sounds and manage playing them with different effects and
|
|
||||||
* timings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SG_SOUNDMGR_OPENAL_HXX
|
#ifndef _SG_SOUNDMGR_OPENAL_HXX
|
||||||
#define _SG_SOUNDMGR_OPENAL_HXX 1
|
#define _SG_SOUNDMGR_OPENAL_HXX 1
|
||||||
@ -114,13 +109,16 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a specified sample group in the sound manager
|
* Find a specified sample group in the sound manager
|
||||||
|
*
|
||||||
* @param refname Reference name of the sample group to find
|
* @param refname Reference name of the sample group to find
|
||||||
|
* @param create If the group should be create if it does not exist
|
||||||
* @return A pointer to the SGSampleGroup
|
* @return A pointer to the SGSampleGroup
|
||||||
*/
|
*/
|
||||||
SGSampleGroup *find( const std::string& refname, bool create = false );
|
SGSampleGroup *find( const std::string& refname, bool create = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Cartesian position of the sound manager.
|
* Set the Cartesian position of the sound manager.
|
||||||
|
*
|
||||||
* @param pos OpenAL listener position
|
* @param pos OpenAL listener position
|
||||||
*/
|
*/
|
||||||
void set_position( const SGVec3d& pos, const SGGeod& pos_geod );
|
void set_position( const SGVec3d& pos, const SGGeod& pos_geod );
|
||||||
@ -132,6 +130,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get the position of the sound manager.
|
* Get the position of the sound manager.
|
||||||
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right
|
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right
|
||||||
|
*
|
||||||
* @return OpenAL listener position
|
* @return OpenAL listener position
|
||||||
*/
|
*/
|
||||||
const SGVec3d& get_position() const;
|
const SGVec3d& get_position() const;
|
||||||
@ -139,7 +138,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Set the velocity vector (in meters per second) of the sound manager
|
* Set the velocity vector (in meters per second) of the sound manager
|
||||||
* This is the horizontal local frame; x=north, y=east, z=down
|
* This is the horizontal local frame; x=north, y=east, z=down
|
||||||
* @param Velocity vector
|
*
|
||||||
|
* @param vel Velocity vector
|
||||||
*/
|
*/
|
||||||
void set_velocity( const SGVec3d& vel ) {
|
void set_velocity( const SGVec3d& vel ) {
|
||||||
_velocity = vel; _changed = true;
|
_velocity = vel; _changed = true;
|
||||||
@ -148,18 +148,21 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get the velocity vector of the sound manager
|
* Get the velocity vector of the sound manager
|
||||||
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
||||||
|
*
|
||||||
* @return Velocity vector of the OpenAL listener
|
* @return Velocity vector of the OpenAL listener
|
||||||
*/
|
*/
|
||||||
inline SGVec3f get_velocity() { return toVec3f(_velocity); }
|
inline SGVec3f get_velocity() { return toVec3f(_velocity); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the orientation of the sound manager
|
* Set the orientation of the sound manager
|
||||||
|
*
|
||||||
* @param ori Quaternation containing the orientation information
|
* @param ori Quaternation containing the orientation information
|
||||||
*/
|
*/
|
||||||
void set_orientation( const SGQuatd& ori );
|
void set_orientation( const SGQuatd& ori );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the orientation of the sound manager
|
* Get the orientation of the sound manager
|
||||||
|
*
|
||||||
* @return Quaternation containing the orientation information
|
* @return Quaternation containing the orientation information
|
||||||
*/
|
*/
|
||||||
const SGQuatd& get_orientation() const;
|
const SGQuatd& get_orientation() const;
|
||||||
@ -167,6 +170,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get the direction vector of the sound manager
|
* Get the direction vector of the sound manager
|
||||||
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
||||||
|
*
|
||||||
* @return Look-at direction of the OpenAL listener
|
* @return Look-at direction of the OpenAL listener
|
||||||
*/
|
*/
|
||||||
SGVec3f get_direction() const;
|
SGVec3f get_direction() const;
|
||||||
@ -179,24 +183,28 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the master volume.
|
* Set the master volume.
|
||||||
|
*
|
||||||
* @param vol Volume (must be between 0.0 and 1.0)
|
* @param vol Volume (must be between 0.0 and 1.0)
|
||||||
*/
|
*/
|
||||||
void set_volume( float vol );
|
void set_volume( float vol );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the master volume.
|
* Get the master volume.
|
||||||
|
*
|
||||||
* @return Volume (must be between 0.0 and 1.0)
|
* @return Volume (must be between 0.0 and 1.0)
|
||||||
*/
|
*/
|
||||||
inline float get_volume() { return _volume; }
|
inline float get_volume() { return _volume; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a free OpenAL source-id
|
* Get a free OpenAL source-id
|
||||||
|
*
|
||||||
* @return NO_SOURCE if no source is available
|
* @return NO_SOURCE if no source is available
|
||||||
*/
|
*/
|
||||||
unsigned int request_source();
|
unsigned int request_source();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free an OpenAL source-id for future use
|
* Free an OpenAL source-id for future use
|
||||||
|
*
|
||||||
* @param source OpenAL source-id to free
|
* @param source OpenAL source-id to free
|
||||||
*/
|
*/
|
||||||
void release_source( unsigned int source );
|
void release_source( unsigned int source );
|
||||||
@ -204,6 +212,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get a free OpenAL buffer-id
|
* Get a free OpenAL buffer-id
|
||||||
* The buffer-id will be assigned to the sample by calling this function.
|
* The buffer-id will be assigned to the sample by calling this function.
|
||||||
|
*
|
||||||
* @param sample Pointer to an audio sample to assign the buffer-id to
|
* @param sample Pointer to an audio sample to assign the buffer-id to
|
||||||
* @return NO_BUFFER if loading of the buffer failed.
|
* @return NO_BUFFER if loading of the buffer failed.
|
||||||
*/
|
*/
|
||||||
@ -211,6 +220,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Free an OpenAL buffer-id for this sample
|
* Free an OpenAL buffer-id for this sample
|
||||||
|
*
|
||||||
* @param sample Pointer to an audio sample for which to free the buffer
|
* @param sample Pointer to an audio sample for which to free the buffer
|
||||||
*/
|
*/
|
||||||
void release_buffer( SGSoundSample *sample );
|
void release_buffer( SGSoundSample *sample );
|
||||||
@ -218,6 +228,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Test if the position of the sound manager has changed.
|
* Test if the position of the sound manager has changed.
|
||||||
* The value will be set to false upon the next call to update_late()
|
* The value will be set to false upon the next call to update_late()
|
||||||
|
*
|
||||||
* @return true if the position has changed
|
* @return true if the position has changed
|
||||||
*/
|
*/
|
||||||
inline bool has_changed() { return _changed; }
|
inline bool has_changed() { return _changed; }
|
||||||
@ -232,6 +243,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a sample file and return it's configuration and data.
|
* Load a sample file and return it's configuration and data.
|
||||||
|
*
|
||||||
* @param samplepath Path to the file to load
|
* @param samplepath Path to the file to load
|
||||||
* @param data Pointer to a variable that points to the allocated data
|
* @param data Pointer to a variable that points to the allocated data
|
||||||
* @param format Pointer to a vairable that gets the OpenAL format
|
* @param format Pointer to a vairable that gets the OpenAL format
|
||||||
@ -239,8 +251,11 @@ public:
|
|||||||
* @param freq Pointer to a vairable that gets the sample frequency in Herz
|
* @param freq Pointer to a vairable that gets the sample frequency in Herz
|
||||||
* @return true if succesful, false on error
|
* @return true if succesful, false on error
|
||||||
*/
|
*/
|
||||||
bool load(const std::string &samplepath, void **data, int *format,
|
bool load( const std::string &samplepath,
|
||||||
size_t *size, int *freq );
|
void **data,
|
||||||
|
int *format,
|
||||||
|
size_t *size,
|
||||||
|
int *freq );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of available playback devices.
|
* Get a list of available playback devices.
|
||||||
|
@ -88,9 +88,11 @@ SGXmlSound::~SGXmlSound()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
|
SGXmlSound::init( SGPropertyNode *root,
|
||||||
SGSampleGroup *sgrp, SGSampleGroup *avionics,
|
SGPropertyNode *node,
|
||||||
const SGPath& currentDir)
|
SGSampleGroup *sgrp,
|
||||||
|
SGSampleGroup *avionics,
|
||||||
|
const SGPath& path )
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -279,7 +281,7 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
|
|||||||
_sgrp = sgrp;
|
_sgrp = sgrp;
|
||||||
}
|
}
|
||||||
string soundFileStr = node->getStringValue("path", "");
|
string soundFileStr = node->getStringValue("path", "");
|
||||||
_sample = new SGSoundSample(soundFileStr.c_str(), currentDir);
|
_sample = new SGSoundSample(soundFileStr.c_str(), path);
|
||||||
if (!_sample->file_path().exists()) {
|
if (!_sample->file_path().exists()) {
|
||||||
throw sg_io_exception("XML sound: couldn't find file: '" + soundFileStr + "'");
|
throw sg_io_exception("XML sound: couldn't find file: '" + soundFileStr + "'");
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,26 @@
|
|||||||
// sound.hxx -- Sound class implementation
|
///@file
|
||||||
|
/// Sound class implementation
|
||||||
|
///
|
||||||
|
/// Provides a class to manage a single sound event including things like
|
||||||
|
/// looping, volume and pitch changes.
|
||||||
//
|
//
|
||||||
// Started by Erik Hofman, February 2002
|
// Started by Erik Hofman, February 2002
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 Erik Hofman - erik@ehofman.com
|
// Copyright (C) 2002 Erik Hofman - erik@ehofman.com
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU Library General Public
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
// License as published by the Free Software Foundation; either
|
||||||
// License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// Library General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU Library General Public
|
||||||
// along with this program; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file sound.hxx
|
|
||||||
* Provides a class to manage a single sound event including things
|
|
||||||
* like looping, volume and pitch changes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SG_SOUND_HXX
|
#ifndef _SG_SOUND_HXX
|
||||||
#define _SG_SOUND_HXX 1
|
#define _SG_SOUND_HXX 1
|
||||||
@ -71,6 +67,7 @@ public:
|
|||||||
* and a sound manager class has to be defined.
|
* and a sound manager class has to be defined.
|
||||||
*
|
*
|
||||||
* A sound configuration file would look like this:
|
* A sound configuration file would look like this:
|
||||||
|
* @code{xml}
|
||||||
* <fx>
|
* <fx>
|
||||||
* <event_name>
|
* <event_name>
|
||||||
* <name/> Define the name of the event. For reference only.
|
* <name/> Define the name of the event. For reference only.
|
||||||
@ -98,16 +95,20 @@ public:
|
|||||||
* <event_name>
|
* <event_name>
|
||||||
* </event_name>
|
* </event_name>
|
||||||
* </fx>
|
* </fx>
|
||||||
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param root The root node of the programs property tree.
|
* @param root The root node of the programs property tree.
|
||||||
* @param child A pointer to the location of the current event as defined
|
* @param child A pointer to the location of the current event as
|
||||||
* in the configuration file.
|
* defined in the configuration file.
|
||||||
* @param sgrp A pointer to a pre-initialized sample group class.
|
* @param sgrp A pointer to a pre-initialized sample group class.
|
||||||
* @param avionics A pointer to the pre-initialized avionics sample group.
|
* @param avionics A pointer to the pre-initialized avionics sample group.
|
||||||
* @param path The path where the audio files remain.
|
* @param path The path where the audio files remain.
|
||||||
*/
|
*/
|
||||||
virtual void init (SGPropertyNode *, SGPropertyNode *, SGSampleGroup *,
|
virtual void init( SGPropertyNode *root,
|
||||||
SGSampleGroup *, const SGPath& currentDir);
|
SGPropertyNode *child,
|
||||||
|
SGSampleGroup *sgrp,
|
||||||
|
SGSampleGroup *avionics,
|
||||||
|
const SGPath& path );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether an event has happened and if action has to be taken.
|
* Check whether an event has happened and if action has to be taken.
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Convenience constructor.
|
* Convenience constructor.
|
||||||
*
|
*
|
||||||
* @param node The binding will be built from this node.
|
* @param commandName TODO
|
||||||
*/
|
*/
|
||||||
SGBinding(const std::string& commandName);
|
SGBinding(const std::string& commandName);
|
||||||
|
|
||||||
@ -49,8 +49,10 @@ public:
|
|||||||
* Convenience constructor.
|
* Convenience constructor.
|
||||||
*
|
*
|
||||||
* @param node The binding will be built from this node.
|
* @param node The binding will be built from this node.
|
||||||
|
* @param root Property root used while building binding.
|
||||||
*/
|
*/
|
||||||
SGBinding (const SGPropertyNode * node, SGPropertyNode* root);
|
SGBinding( const SGPropertyNode *node,
|
||||||
|
SGPropertyNode *root );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +99,8 @@ public:
|
|||||||
* Read a binding from a property node.
|
* Read a binding from a property node.
|
||||||
*
|
*
|
||||||
* @param node The property node containing the binding.
|
* @param node The property node containing the binding.
|
||||||
|
* @param root The property root node used while building the binding from
|
||||||
|
* \a node.
|
||||||
*/
|
*/
|
||||||
void read (const SGPropertyNode * node, SGPropertyNode* root);
|
void read (const SGPropertyNode * node, SGPropertyNode* root);
|
||||||
|
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
/* -*-c++-*-
|
///@file
|
||||||
*
|
/// Pointer proxy doing reference counting.
|
||||||
* Copyright (C) 2005-2012 Mathias Froehlich
|
//
|
||||||
*
|
// Copyright (C) 2005-2012 Mathias Froehlich
|
||||||
* This program is free software; you can redistribute it and/or
|
//
|
||||||
* modify it under the terms of the GNU General Public License as
|
// This library is free software; you can redistribute it and/or
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
// modify it under the terms of the GNU Library General Public
|
||||||
* License, or (at your option) any later version.
|
// 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
|
// This library is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
*
|
// Library 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
|
// You should have received a copy of the GNU Library General Public
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// License along with this library; if not, write to the Free Software
|
||||||
*
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SGSharedPtr_HXX
|
#ifndef SGSharedPtr_HXX
|
||||||
#define SGSharedPtr_HXX
|
#define SGSharedPtr_HXX
|
||||||
@ -31,7 +30,7 @@ class SGWeakPtr;
|
|||||||
/// it is pointing to.
|
/// it is pointing to.
|
||||||
/// The SGSharedPtr class handles reference counting and possible
|
/// The SGSharedPtr class handles reference counting and possible
|
||||||
/// destruction if no nore references are in use automatically.
|
/// destruction if no nore references are in use automatically.
|
||||||
/// Classes derived from @SGReferenced can be handled with SGSharedPtr.
|
/// Classes derived from SGReferenced can be handled with SGSharedPtr.
|
||||||
/// Once you have a SGSharedPtr available you can use it just like
|
/// Once you have a SGSharedPtr available you can use it just like
|
||||||
/// a usual pointer with the exception that you don't need to delete it.
|
/// a usual pointer with the exception that you don't need to delete it.
|
||||||
/// Such a reference is initialized by zero if not initialized with a
|
/// Such a reference is initialized by zero if not initialized with a
|
||||||
|
@ -101,11 +101,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Register a new command with the manager.
|
* Register a new command with the manager.
|
||||||
*
|
*
|
||||||
* @param name The command name. Any existing command with
|
* @param name The command name. Any existing command with the same name
|
||||||
* the same name will silently be overwritten.
|
* will silently be overwritten.
|
||||||
* @param command A pointer to a one-arg function returning
|
* @param f A pointer to a one-arg function returning a bool result. The
|
||||||
* a bool result. The argument is always a const pointer to
|
* argument is always a const pointer to an SGPropertyNode
|
||||||
* an SGPropertyNode (which may contain multiple values).
|
* (which may contain multiple values).
|
||||||
*/
|
*/
|
||||||
void addCommand(const std::string& name, command_t f)
|
void addCommand(const std::string& name, command_t f)
|
||||||
{ addCommandObject(name, new FunctionCommand(f)); }
|
{ addCommandObject(name, new FunctionCommand(f)); }
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of sg_location class.
|
// Implementation of sg_location class.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@ -148,10 +146,10 @@ sg_throwable::getMessage () const
|
|||||||
return _message;
|
return _message;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string
|
const std::string
|
||||||
sg_throwable::getFormattedMessage () const
|
sg_throwable::getFormattedMessage () const
|
||||||
{
|
{
|
||||||
return string(getMessage());
|
return std::string(getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -204,7 +202,7 @@ sg_error::sg_error (const char* message, const char *origin)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_error::sg_error (const string& message, const string& origin)
|
sg_error::sg_error(const std::string& message, const std::string& origin)
|
||||||
: sg_throwable(message.c_str(), origin.c_str())
|
: sg_throwable(message.c_str(), origin.c_str())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -212,7 +210,7 @@ sg_error::sg_error (const string& message, const string& origin)
|
|||||||
sg_error::~sg_error () throw ()
|
sg_error::~sg_error () throw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of sg_exception class.
|
// Implementation of sg_exception class.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@ -227,7 +225,8 @@ sg_exception::sg_exception (const char* message, const char* origin)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_exception::sg_exception (const string& message, const string& origin)
|
sg_exception::sg_exception( const std::string& message,
|
||||||
|
const std::string& origin )
|
||||||
: sg_throwable(message.c_str(), origin.c_str())
|
: sg_throwable(message.c_str(), origin.c_str())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -235,7 +234,7 @@ sg_exception::sg_exception (const string& message, const string& origin)
|
|||||||
sg_exception::~sg_exception () throw ()
|
sg_exception::~sg_exception () throw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of sg_io_exception.
|
// Implementation of sg_io_exception.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@ -258,34 +257,36 @@ sg_io_exception::sg_io_exception (const char* message,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_io_exception::sg_io_exception (const string& message, const string& origin)
|
sg_io_exception::sg_io_exception( const std::string& message,
|
||||||
|
const std::string& origin )
|
||||||
: sg_exception(message, origin)
|
: sg_exception(message, origin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_io_exception::sg_io_exception (const string& message,
|
sg_io_exception::sg_io_exception( const std::string& message,
|
||||||
const sg_location &location,
|
const sg_location &location,
|
||||||
const string& origin)
|
const std::string& origin )
|
||||||
: sg_exception(message, origin),
|
: sg_exception(message, origin),
|
||||||
_location(location)
|
_location(location)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_io_exception::sg_io_exception (const string &message, const SGPath& origin)
|
sg_io_exception::sg_io_exception( const std::string &message,
|
||||||
|
const SGPath& origin )
|
||||||
: sg_exception(message, origin.str())
|
: sg_exception(message, origin.str())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_io_exception::~sg_io_exception () throw ()
|
sg_io_exception::~sg_io_exception () throw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const string
|
const std::string
|
||||||
sg_io_exception::getFormattedMessage () const
|
sg_io_exception::getFormattedMessage () const
|
||||||
{
|
{
|
||||||
string ret = getMessage();
|
std::string ret = getMessage();
|
||||||
string loc = getLocation().asString();
|
std::string loc = getLocation().asString();
|
||||||
if (loc.length()) {
|
if (loc.length()) {
|
||||||
ret += "\n at ";
|
ret += "\n at ";
|
||||||
ret += loc;
|
ret += loc;
|
||||||
@ -325,9 +326,9 @@ sg_format_exception::sg_format_exception (const char* message,
|
|||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_format_exception::sg_format_exception (const string& message,
|
sg_format_exception::sg_format_exception( const std::string& message,
|
||||||
const string& text,
|
const std::string& text,
|
||||||
const string& origin)
|
const std::string& origin )
|
||||||
: sg_exception(message, origin)
|
: sg_exception(message, origin)
|
||||||
{
|
{
|
||||||
setText(text.c_str());
|
setText(text.c_str());
|
||||||
@ -371,8 +372,8 @@ sg_range_exception::sg_range_exception (const char* message,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_range_exception::sg_range_exception(const string& message,
|
sg_range_exception::sg_range_exception(const std::string& message,
|
||||||
const string& origin)
|
const std::string& origin)
|
||||||
: sg_exception(message, origin)
|
: sg_exception(message, origin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -13,21 +13,18 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an SGGuard object and lock the passed lockable object.
|
* Create an SGGuard object and lock the passed lockable object.
|
||||||
* @param SGLOCK A lockable object.
|
* @param l A lockable object.
|
||||||
*/
|
*/
|
||||||
inline SGGuard( SGLOCK& l ) : lock(l) { lock.lock(); }
|
inline SGGuard( SGLOCK& l ) : lock(l) { lock.lock(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy this object and unlock the locakable object.
|
* Destroy this object and unlock the lockable object.
|
||||||
*/
|
*/
|
||||||
inline ~SGGuard() { lock.unlock(); }
|
inline ~SGGuard() { lock.unlock(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
SGLOCK& lock; //!< A lockable object
|
||||||
* A lockable object.
|
|
||||||
*/
|
|
||||||
SGLOCK& lock;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Disable copying.
|
// Disable copying.
|
||||||
|
@ -38,21 +38,21 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an item to the end of the queue.
|
* Add an item to the end of the queue.
|
||||||
*
|
*
|
||||||
* @param T object to add.
|
* @param item object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push( const T& item ) = 0;
|
virtual void push( const T& item ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View the item from the head of the queue.
|
* View the item from the head of the queue.
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() = 0;
|
virtual T front() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an item from the head of the queue.
|
* Get an item from the head of the queue.
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop() = 0;
|
virtual T pop() = 0;
|
||||||
|
|
||||||
@ -86,12 +86,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Destroy this object.
|
* Destroy this object.
|
||||||
*/
|
*/
|
||||||
~SGLockedQueue() {}
|
virtual ~SGLockedQueue() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this queue is empty (contains no elements).
|
* Returns whether this queue is empty (contains no elements).
|
||||||
*
|
*
|
||||||
* @return bool True if queue is empty, otherwisr false.
|
* @return True if queue is empty, otherwise false.
|
||||||
*/
|
*/
|
||||||
virtual bool empty() {
|
virtual bool empty() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an item to the end of the queue.
|
* Add an item to the end of the queue.
|
||||||
*
|
*
|
||||||
* @param T object to add.
|
* @param item object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push( const T& item ) {
|
virtual void push( const T& item ) {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* View the item from the head of the queue.
|
* View the item from the head of the queue.
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() {
|
virtual T front() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get an item from the head of the queue.
|
* Get an item from the head of the queue.
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop() {
|
virtual T pop() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Query the size of the queue
|
* Query the size of the queue
|
||||||
*
|
*
|
||||||
* @return size_t size of queue.
|
* @return Size of queue.
|
||||||
*/
|
*/
|
||||||
virtual size_t size() {
|
virtual size_t size() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -178,7 +178,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Destroy this queue.
|
* Destroy this queue.
|
||||||
*/
|
*/
|
||||||
~SGBlockingQueue() {}
|
virtual ~SGBlockingQueue() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -191,7 +191,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an item to the end of the queue.
|
* Add an item to the end of the queue.
|
||||||
*
|
*
|
||||||
* @param T object to add.
|
* @param item The object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push( const T& item ) {
|
virtual void push( const T& item ) {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -203,7 +203,7 @@ public:
|
|||||||
* View the item from the head of the queue.
|
* View the item from the head of the queue.
|
||||||
* Calling thread is not suspended
|
* Calling thread is not suspended
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() {
|
virtual T front() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -219,7 +219,7 @@ public:
|
|||||||
* Get an item from the head of the queue.
|
* Get an item from the head of the queue.
|
||||||
* If no items are available then the calling thread is suspended
|
* If no items are available then the calling thread is suspended
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop() {
|
virtual T pop() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -238,7 +238,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Query the size of the queue
|
* Query the size of the queue
|
||||||
*
|
*
|
||||||
* @return size_t size of queue.
|
* @return Size of queue.
|
||||||
*/
|
*/
|
||||||
virtual size_t size() {
|
virtual size_t size() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -280,7 +280,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Destroy this dequeue.
|
* Destroy this dequeue.
|
||||||
*/
|
*/
|
||||||
~SGBlockingDeque() {}
|
virtual ~SGBlockingDeque() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -301,7 +301,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an item to the front of the queue.
|
* Add an item to the front of the queue.
|
||||||
*
|
*
|
||||||
* @param T object to add.
|
* @param item The object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push_front( const T& item ) {
|
virtual void push_front( const T& item ) {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -312,7 +312,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an item to the back of the queue.
|
* Add an item to the back of the queue.
|
||||||
*
|
*
|
||||||
* @param T object to add.
|
* @param item The object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push_back( const T& item ) {
|
virtual void push_back( const T& item ) {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -324,7 +324,7 @@ public:
|
|||||||
* View the item from the head of the queue.
|
* View the item from the head of the queue.
|
||||||
* Calling thread is not suspended
|
* Calling thread is not suspended
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() {
|
virtual T front() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -340,7 +340,7 @@ public:
|
|||||||
* Get an item from the head of the queue.
|
* Get an item from the head of the queue.
|
||||||
* If no items are available then the calling thread is suspended
|
* If no items are available then the calling thread is suspended
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop_front() {
|
virtual T pop_front() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -360,7 +360,7 @@ public:
|
|||||||
* Get an item from the tail of the queue.
|
* Get an item from the tail of the queue.
|
||||||
* If no items are available then the calling thread is suspended
|
* If no items are available then the calling thread is suspended
|
||||||
*
|
*
|
||||||
* @return T next available object.
|
* @return The next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop_back() {
|
virtual T pop_back() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
@ -379,7 +379,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Query the size of the queue
|
* Query the size of the queue
|
||||||
*
|
*
|
||||||
* @return size_t size of queue.
|
* @return Size of queue.
|
||||||
*/
|
*/
|
||||||
virtual size_t size() {
|
virtual size_t size() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
SGGuard<SGMutex> g(mutex);
|
||||||
|
@ -146,16 +146,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Wait for this condition variable to be signaled.
|
* Wait for this condition variable to be signaled.
|
||||||
*
|
*
|
||||||
* @param SGMutex& reference to a locked mutex.
|
* @param mutex Reference to a locked mutex.
|
||||||
*/
|
*/
|
||||||
void wait(SGMutex&);
|
void wait(SGMutex& mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for this condition variable to be signaled for at most
|
* Wait for this condition variable to be signaled for at most \a 'msec'
|
||||||
* 'ms' milliseconds.
|
* milliseconds.
|
||||||
*
|
*
|
||||||
* @param mutex reference to a locked mutex.
|
* @param mutex Reference to a locked mutex.
|
||||||
* @param ms milliseconds to wait for a signal.
|
* @param msec Milliseconds to wait for a signal.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -116,13 +116,15 @@ public:
|
|||||||
* If you don't know your position when you call the SGTime
|
* If you don't know your position when you call the SGTime
|
||||||
* constructor, you can just use the first form (which assumes 0,
|
* constructor, you can just use the first form (which assumes 0,
|
||||||
* 0).
|
* 0).
|
||||||
* @param lon_rad current longitude (radians)
|
*
|
||||||
* @param lat_rad current latitude (radians)
|
* @param location Current geodetic location
|
||||||
* @param root root path point to data file location (timezone, etc.)
|
* @param root Root path point to data file location (timezone, etc.)
|
||||||
* @param init_time provide an initialization time, 0 means use
|
* @param init_time Provide an initialization time, 0 means use current
|
||||||
current clock time */
|
* clock time
|
||||||
SGTime( const SGGeod& location, const SGPath& root,
|
*/
|
||||||
time_t init_time );
|
SGTime( const SGGeod& location,
|
||||||
|
const SGPath& root,
|
||||||
|
time_t init_time );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance given a data file path.
|
* Create an instance given a data file path.
|
||||||
@ -140,12 +142,13 @@ public:
|
|||||||
* you to offset "sim" time relative to "real" time. The update()
|
* you to offset "sim" time relative to "real" time. The update()
|
||||||
* method is designed to be called by the host application before
|
* method is designed to be called by the host application before
|
||||||
* every frame.
|
* every frame.
|
||||||
* @param lon_rad current longitude (radians)
|
*
|
||||||
* @param lat_rad current latitude (radians)
|
* @param location Current geodetic location
|
||||||
* @param ct specify a unix time, otherwise specify 0 to use current
|
* @param ct Specify a unix time, otherwise specify 0 to use current
|
||||||
clock time
|
* clock time
|
||||||
* @param warp an optional time offset specified in seconds. This
|
* @param warp Optional time offset in seconds. This allows to advance
|
||||||
* allows us to advance or rewind "time" if we choose to. */
|
* or rewind "time".
|
||||||
|
*/
|
||||||
void update( const SGGeod& location, time_t ct, long int warp );
|
void update( const SGGeod& location, time_t ct, long int warp );
|
||||||
|
|
||||||
/** Deprecated method. To be removed after the next release... */
|
/** Deprecated method. To be removed after the next release... */
|
||||||
@ -158,9 +161,10 @@ public:
|
|||||||
* enough that your timezone may have changed as well. In the
|
* enough that your timezone may have changed as well. In the
|
||||||
* FlightGear project we call updateLocal() every few minutes from
|
* FlightGear project we call updateLocal() every few minutes from
|
||||||
* our periodic event manager.
|
* our periodic event manager.
|
||||||
* @param lon_rad current longitude (radians)
|
*
|
||||||
* @param lat_rad current latitude (radians)
|
* @param location Current geodetic location
|
||||||
* @param root base path containing time zone directory */
|
* @param root Bbase path containing time zone directory
|
||||||
|
*/
|
||||||
void updateLocal( const SGGeod& location, const std::string& root );
|
void updateLocal( const SGGeod& location, const std::string& root );
|
||||||
|
|
||||||
/** @return current system/unix time in seconds */
|
/** @return current system/unix time in seconds */
|
||||||
|
Loading…
Reference in New Issue
Block a user