Compare commits

...

21 Commits

Author SHA1 Message Date
curt
9a2ee54389 Final 0.3.7 changes. 2004-10-12 14:35:42 +00:00
ehofman
ab69c03698 Fix a typo. 2004-10-11 07:56:08 +00:00
ehofman
fab1f4e7a0 Frederic: Ignore display lists when using the blend animation. 2004-10-11 07:37:42 +00:00
ehofman
41eed484c1 Adding the panel was a step too far for Linux, causing a segfault. 2004-10-10 19:38:46 +00:00
ehofman
7d18f9bdde Remove a phantom makeDList call (probably an old one from my code. 2004-10-10 19:16:25 +00:00
ehofman
3a48c3de7a Check for the plib version when using display lists, just to be sure. 2004-10-10 19:05:25 +00:00
ehofman
d769a9936b Frederic: Include FGPanelNode in the display list generation process. 2004-10-10 18:43:11 +00:00
ehofman
1697cb3b1a Frederic: Use display lists for 3d models also. 2004-10-10 17:49:27 +00:00
ehofman
62aa32a417 Reverse the declaration order. jpgRenderFrame (formerly known as trRenderFrame) is now declared as a NULL function pointer and assignment of the proper function is now done in FlightGear (jpgRenderFrame=FGRenderer::update). 2004-10-06 09:57:31 +00:00
ehofman
a0d0852838 David Luff:
The one-liner removes a lot of re-definition warnings on Cygwin.
2004-09-30 09:43:11 +00:00
ehofman
2f479cae69 Small update for future use. 2004-09-19 09:08:12 +00:00
curt
4820d57fa8 Expose the size() method for locked and blocking thread queues. 2004-09-15 15:28:58 +00:00
curt
04e3b0b3c1 Fix another case where the direction vector is not initialized which can
lead to openal "inrange" assertions, crashing FlightGear.
2004-09-15 15:28:14 +00:00
curt
a7f78b9f68 direction vector needs to be initialized, otherwise garbage data could cause
openal to generate an assertion, aborting the top level app.
2004-09-10 20:44:42 +00:00
curt
f3d8eb4665 Tweaks for 0.3.7-pre1 2004-09-10 18:16:06 +00:00
curt
090f79b951 Add support for parsing an xml stream from an in memory buffer, rather than
just from a specified file name.
2004-09-10 15:57:52 +00:00
ehofman
88c0dbf661 Add support for audio orientation: direction and cone definition. This currently only works for internal view and tower view because those set the listener position correctly. 2004-09-08 11:15:57 +00:00
ehofman
9e3822ceaf Remove a left over of ancient times. 2004-08-19 12:18:20 +00:00
ehofman
007b0a8fe6 this simple patch will enable the direct use of Point3D::get_n() instead of making duplications to call sgCartToGeod 2004-08-17 08:31:51 +00:00
ehofman
7f0ebf8871 this simple patch will prevent to have fog in Clear cload layers. 2004-08-17 08:28:35 +00:00
ehofman
5414e94a1a change the log level of the initialization of OpenAL. This prevent a console popup for no reason on Windows. 2004-08-15 09:24:12 +00:00
25 changed files with 227 additions and 36 deletions

View File

@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.3.6
PROJECT_NUMBER = 0.3.7
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@@ -10,7 +10,7 @@ EXTRA_DIST = \
SUBDIRS = src-libs simgear
dist-hook:
(cd $(top_srcdir); $(HOME)/projects/FlightGear-0.9/admin/am2dsp.pl)
(cd $(top_srcdir); $(HOME)/Projects/FlightGear-0.9/admin/am2dsp.pl)
#
# Rule to build RPM distribution package

11
NEWS
View File

@@ -1,3 +1,14 @@
New in 0.3.7
* October 12, 2004
* Add support for parsing xml from an in memory buffer, not just a file.
* Don't reduce visibility for a "clear" cloud layer.
* Add support for audio orientation (direction and cone) for internal
view and tower view.
* Add support for drawing from display lists rather than in immediate mode.
This provides a big performance improvement on many systems.
New in 0.3.6
* July 29, 2004

View File

@@ -10,7 +10,7 @@ dnl Require at least automake 2.52
AC_PREREQ(2.52)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.3.6)
AM_INIT_AUTOMAKE(SimGear, 0.3.7)
dnl Specify KAI C++ compiler and flags.
dnl Borrowed with slight modification from blitz distribution.
@@ -417,6 +417,7 @@ AC_CONFIG_FILES([ \
simgear/props/Makefile \
simgear/route/Makefile \
simgear/scene/Makefile \
simgear/scene/fgsg/Makefile \
simgear/scene/material/Makefile \
simgear/scene/model/Makefile \
simgear/scene/sky/Makefile \

View File

@@ -108,7 +108,7 @@ static double seaLevelRadius(double r, double z)
// starts making very poor guesses as to latitude. As altitude
// approaches infinity, it should be guessing with geocentric
// coordinates, not "local geodetic up" ones.
void sgCartToGeod(double* xyz, double* lat, double* lon, double* alt)
void sgCartToGeod(const double* xyz, double* lat, double* lon, double* alt)
{
// The error is expressed as a radian angle, and we want accuracy
// to 1 part in 2^50 (an IEEE double has between 51 and 52

View File

@@ -42,7 +42,7 @@ void sgGeodToGeoc(double lat_geod, double alt,
* @param lon (out) Longitude, in radians
* @param alt (out) Altitude, in meters above the WGS84 ellipsoid
*/
void sgCartToGeod(double* xyz, double* lat, double* lon, double* alt);
void sgCartToGeod(const double* xyz, double* lat, double* lon, double* alt);
/**
* Convert a cartesian point to a geodetic lat/lon/altitude.

View File

@@ -1,3 +0,0 @@
.deps
Makefile
Makefile.in

View File

@@ -561,7 +561,7 @@ public:
* Property value types.
*/
enum Type {
NONE,
NONE = 0,
ALIAS,
BOOL,
INT,

View File

@@ -322,6 +322,23 @@ readProperties (const string &file, SGPropertyNode * start_node)
}
/**
* Read properties from an in-memory buffer.
*
* @param buf A character buffer containing the xml data.
* @param size The size/length of the buffer in bytes
* @param start_node The root node for reading properties.
* @return true if the read succeeded, false otherwise.
*/
void readProperties (const char *buf, const int size,
SGPropertyNode * start_node)
{
PropsVisitor visitor(start_node, "");
readXML(buf, size, visitor);
if (visitor.hasException())
throw visitor.getException();
}
////////////////////////////////////////////////////////////////////////
// Property list writer.

View File

@@ -41,6 +41,13 @@ void readProperties (istream &input, SGPropertyNode * start_node,
void readProperties (const string &file, SGPropertyNode * start_node);
/**
* Read properties from an in-memory buffer.
*/
void readProperties (const char *buf, const int size,
SGPropertyNode * start_node);
/**
* Write properties to an XML output stream.
*/

View File

@@ -1,6 +1,6 @@
includedir = @includedir@/scene
SUBDIRS = material model sky tgdb
SUBDIRS = fgsg material model sky tgdb
# lib_LIBRARIES = libsgscene.a

View File

@@ -12,6 +12,7 @@
#include <string.h> // for strcmp()
#include <vector>
#include <set>
#include <plib/sg.h>
#include <plib/ssg.h>
@@ -26,6 +27,7 @@
#include "model.hxx"
SG_USING_STD(vector);
SG_USING_STD(set);
@@ -122,8 +124,10 @@ sgMakeAnimation( ssgBranch * model,
vector<SGPropertyNode_ptr> &name_nodes,
SGPropertyNode *prop_root,
SGPropertyNode_ptr node,
double sim_time_sec )
double sim_time_sec,
set<ssgBranch *> &ignore_branches )
{
bool ignore = false;
SGAnimation * animation = 0;
const char * type = node->getStringValue("type", "none");
if (!strcmp("none", type)) {
@@ -152,6 +156,7 @@ sgMakeAnimation( ssgBranch * model,
animation = new SGTexMultipleAnimation(prop_root, node);
} else if (!strcmp("blend", type)) {
animation = new SGBlendAnimation(prop_root, node);
ignore = true;
} else if (!strcmp("alpha-test", type)) {
animation = new SGAlphaTestAnimation(node);
} else if (!strcmp("flash", type)) {
@@ -204,10 +209,26 @@ sgMakeAnimation( ssgBranch * model,
branch->setUserData(animation);
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
branch->setTravCallback(SSG_CALLBACK_POSTTRAV, restore_callback);
if ( ignore ) {
ignore_branches.insert( branch );
}
}
}
static void makeDList( ssgBranch *b, const set<ssgBranch *> &ignore )
{
int nb = b->getNumKids();
for (int i = 0; i<nb; i++) {
ssgEntity *e = b->getKid(i);
if (e->isAKindOf(ssgTypeLeaf())) {
((ssgLeaf*)e)->makeDList();
} else if (e->isAKindOf(ssgTypeBranch()) && ignore.find((ssgBranch *)e) == ignore.end()) {
makeDList( (ssgBranch*)e, ignore );
}
}
}
////////////////////////////////////////////////////////////////////////
@@ -257,7 +278,6 @@ sgLoad3DModel( const string &fg_root, const string &path,
if (model == 0)
throw sg_exception("Failed to load 3D model");
}
// Set up the alignment node
ssgTransform * alignmainmodel = new ssgTransform;
if ( load_panel == 0 )
@@ -275,18 +295,6 @@ sgLoad3DModel( const string &fg_root, const string &path,
unsigned int i;
if ( load_panel ) {
// Load panels
vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
for (i = 0; i < panel_nodes.size(); i++) {
SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
ssgEntity * panel = load_panel(panel_nodes[i]);
if (panel_nodes[i]->hasValue("name"))
panel->setName((char *)panel_nodes[i]->getStringValue("name"));
model->addKid(panel);
}
}
// Load sub-models
vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
for (i = 0; i < model_nodes.size(); i++) {
@@ -310,13 +318,32 @@ sgLoad3DModel( const string &fg_root, const string &path,
}
// Load animations
set<ssgBranch *> ignore_branches;
vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
for (i = 0; i < animation_nodes.size(); i++) {
const char * name = animation_nodes[i]->getStringValue("name", 0);
vector<SGPropertyNode_ptr> name_nodes =
animation_nodes[i]->getChildren("object-name");
sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
sim_time_sec);
sim_time_sec, ignore_branches);
}
#if PLIB_VERSION > 183
if ( model != 0 ) {
makeDList( model, ignore_branches );
}
#endif
if ( load_panel ) {
// Load panels
vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
for (i = 0; i < panel_nodes.size(); i++) {
SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
ssgEntity * panel = load_panel(panel_nodes[i]);
if (panel_nodes[i]->hasValue("name"))
panel->setName((char *)panel_nodes[i]->getStringValue("name"));
model->addKid(panel);
}
}
return alignmainmodel;

View File

@@ -11,8 +11,10 @@
#endif
#include <vector>
#include <set>
SG_USING_STD(vector);
SG_USING_STD(set);
#include <plib/sg.h>
#include <plib/ssg.h>
@@ -63,7 +65,8 @@ sgMakeAnimation( ssgBranch * model,
vector<SGPropertyNode_ptr> &name_nodes,
SGPropertyNode *prop_root,
SGPropertyNode_ptr node,
double sim_time_sec );
double sim_time_sec,
set<ssgBranch *> &ignore_branches );
/**
* Set the filter state on models

View File

@@ -266,7 +266,10 @@ void SGSky::modify_vis( float alt, float time_factor ) {
double ratio = 1.0;
if ( alt < asl - transition ) {
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
// clear layer
ratio = 1.0;
} else if ( alt < asl - transition ) {
// below cloud layer
ratio = 1.0;
} else if ( alt < asl ) {

View File

@@ -177,7 +177,6 @@ bool sgGenTile( const string& path, SGBucket b,
new ssgVtxTable ( GL_TRIANGLE_FAN, vl, nl, tl, cl );
leaf->setState( state );
geometry->addKid( leaf );
return true;
@@ -448,7 +447,6 @@ bool sgBinObjLoad( const string& path, const bool is_base,
nodes, normals, texcoords,
tris_v[ind], tris_n[ind], tris_tc[ind],
is_base, ground_lights );
if ( use_random_objects ) {
SGMaterial *mat = matlib->find( tri_materials[ind] );
if ( mat == NULL ) {
@@ -467,7 +465,6 @@ bool sgBinObjLoad( const string& path, const bool is_base,
nodes, normals, texcoords,
strips_v[ind], strips_n[ind], strips_tc[ind],
is_base, ground_lights );
if ( use_random_objects ) {
SGMaterial *mat = matlib->find( strip_materials[ind] );
if ( mat == NULL ) {

View File

@@ -24,7 +24,7 @@
#ifndef __SG_EXTENSIONS_HXX
#define __SG_EXTENSIONS_HXX 1
#if defined(__CYGWIN__) /* && !defined(USING_X) */
#if defined(__CYGWIN__) && !defined(WIN32) /* && !defined(USING_X) */
#define WIN32
#endif

View File

@@ -57,8 +57,7 @@ typedef struct {
typedef my_destination_mgr * my_dest_ptr;
/* Where should this go <simgear/screen/tr.h> ?? */
extern void trRenderFrame( void );
void (*jpgRenderFrame)(void) = NULL;
trJpgFactory::trJpgFactory() {
imageWidth = imageHeight = 0;
@@ -233,7 +232,7 @@ int trJpgFactory::compress()
int trJpgFactory::render()
{
if( !tr ) {
if( !tr || !jpgRenderFrame ) {
printf("!! NO tr !!\n trJpgFactory::render()\n");
return 0;
}
@@ -253,7 +252,7 @@ int trJpgFactory::render()
// printf("\ttrBeginTile(tr)\n");
trBeginTile(tr);
trRenderFrame();
jpgRenderFrame();
trEndTile(tr);
/* just to be safe */

View File

@@ -36,6 +36,9 @@ extern "C" {
#include <simgear/screen/tr.h>
extern void (*jpgRenderFrame)(void);
/* should look at how VNC does this */
class trJpgFactory {
private:

View File

@@ -83,6 +83,8 @@ SGSoundSample::SGSoundSample( const char *path, const char *file,
source_pos[0] = 0.0; source_pos[1] = 0.0; source_pos[2] = 0.0;
offset_pos[0] = 0.0; offset_pos[1] = 0.0; offset_pos[2] = 0.0;
source_vel[0] = 0.0; source_vel[1] = 0.0; source_vel[2] = 0.0;
direction[0] = 0.0; direction[1] = 0.0; direction[2] = 0.0;
inner = outer = 360.0; outergain = 0.0;
// clear errors from elsewhere?
alGetError();
@@ -128,6 +130,10 @@ SGSoundSample::SGSoundSample( const char *path, const char *file,
alSourcef( source, AL_PITCH, pitch );
alSourcef( source, AL_GAIN, volume );
alSourcefv( source, AL_POSITION, source_pos );
alSourcefv( source, AL_DIRECTION, direction );
alSourcef( source, AL_CONE_INNER_ANGLE, inner );
alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
alSourcef( source, AL_CONE_OUTER_GAIN, outergain);
alSourcefv( source, AL_VELOCITY, source_vel );
alSourcei( source, AL_LOOPING, loop );
@@ -154,6 +160,8 @@ SGSoundSample::SGSoundSample( unsigned char *_data, int len, int _freq,
source_pos[0] = 0.0; source_pos[1] = 0.0; source_pos[2] = 0.0;
offset_pos[0] = 0.0; offset_pos[1] = 0.0; offset_pos[2] = 0.0;
source_vel[0] = 0.0; source_vel[1] = 0.0; source_vel[2] = 0.0;
direction[0] = 0.0; direction[1] = 0.0; direction[2] = 0.0;
inner = outer = 360.0; outergain = 0.0;
// clear errors from elsewhere?
alGetError();
@@ -192,6 +200,10 @@ SGSoundSample::SGSoundSample( unsigned char *_data, int len, int _freq,
alSourcef( source, AL_PITCH, pitch );
alSourcef( source, AL_GAIN, volume );
alSourcefv( source, AL_POSITION, source_pos );
alSourcefv( source, AL_DIRECTION, direction );
alSourcef( source, AL_CONE_INNER_ANGLE, inner );
alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
alSourcefv( source, AL_VELOCITY, source_vel );
alSourcei( source, AL_LOOPING, loop );

View File

@@ -74,6 +74,10 @@ private:
// A constant offset to be applied to the final source_pos
ALfloat offset_pos[3];
// The orientation of the sound (direction and cut-off angles)
ALfloat direction[3];
ALfloat inner, outer, outergain;
// Velocity of the source sound.
ALfloat source_vel[3];
@@ -237,6 +241,23 @@ public:
alSourcefv( source, AL_POSITION, final_pos );
}
/**
* Set the orientation of the sound source, both for direction
* and audio cut-off angles.
*/
inline void set_orientation( ALfloat *dir, ALfloat inner_angle=360.0,
ALfloat outer_angle=360.0,
ALfloat outer_gain=0.0)
{
inner = inner_angle;
outer = outer_angle;
outergain = outer_gain;
alSourcefv( source, AL_DIRECTION, dir);
alSourcef( source, AL_CONE_INNER_ANGLE, inner );
alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
}
/**
* Set velocity of sound source (uses same coordinate system as opengl)
*/

View File

@@ -61,7 +61,7 @@ inline int (isnan)(double r) { return isnan(r); }
// constructor
SGSoundMgr::SGSoundMgr() {
SG_LOG( SG_GENERAL, SG_ALERT, "Initializing OpenAL sound manager" );
SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
// initialize OpenAL
alutInit( 0, NULL );

View File

@@ -247,6 +247,25 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr,
offset_pos[2] = pos->getDoubleValue("z", 0.0);
}
//
// Orientation
//
sgVec3 dir;
float inner, outer, outer_gain;
sgSetVec3( dir, 0.0, 0.0, 0.0 );
inner = outer = 360.0;
outer_gain = 0.0;
pos = node->getChild("orientation");
if ( pos != NULL ) {
dir[0] = pos->getDoubleValue("x", 0.0);
dir[1] = pos->getDoubleValue("y", 0.0);
dir[2] = pos->getDoubleValue("z", 0.0);
inner = pos->getDoubleValue("inner-angle", 360.0);
outer = pos->getDoubleValue("outer-angle", 360.0);
outer_gain = pos->getDoubleValue("outer-gain", 0.0);
}
//
// Initialize the sample
//
@@ -260,6 +279,7 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr,
}
_sample->set_offset_pos( offset_pos );
_sample->set_orientation(dir, inner, outer, outer_gain);
_sample->set_volume(v);
_sample->set_reference_dist( reference_dist );
_sample->set_max_dist( max_dist );

View File

@@ -61,6 +61,13 @@ public:
*/
virtual T pop() = 0;
/**
* Query the size of the queue
*
* @return size_t size of queue.
*/
virtual size_t size() = 0;
protected:
/**
*
@@ -136,6 +143,17 @@ public:
this->fifo.pop();
return item;
}
/**
* Query the size of the queue
*
* @return size_t size of queue.
*/
virtual size_t size() {
SGGuard<SGLOCK> g(mutex);
return this->fifo.size();
}
private:
/**
@@ -222,6 +240,16 @@ public:
return item;
}
/**
* Query the size of the queue
*
* @return size_t size of queue.
*/
virtual size_t size() {
SGGuard<SGMutex> g(mutex);
return this->fifo.size();
}
private:
/**

View File

@@ -274,4 +274,27 @@ readXML (const string &path, XMLVisitor &visitor)
input.close();
}
void
readXML (const char *buf, const int size, XMLVisitor &visitor)
{
XML_Parser parser = XML_ParserCreate(0);
XML_SetUserData(parser, &visitor);
XML_SetElementHandler(parser, start_element, end_element);
XML_SetCharacterDataHandler(parser, character_data);
XML_SetProcessingInstructionHandler(parser, processing_instruction);
visitor.startXML();
if (!XML_Parse(parser, buf, size, false)) {
XML_ParserFree(parser);
throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)),
sg_location("In-memory XML buffer",
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser)),
"SimGear XML Parser");
}
XML_ParserFree(parser);
}
// end of easyxml.cxx

View File

@@ -401,5 +401,27 @@ extern void readXML (istream &input, XMLVisitor &visitor,
extern void readXML (const string &path, XMLVisitor &visitor);
/**
* @relates XMLVisitor
* Read an XML document.
*
* This function reads an XML document from the buffer provided,
* and invokes the callback methods in the visitor object to pass the
* parsing events back to the application. When this function
* returns, the parser will have reported all of the data in the XML
* document to the application through the visitor callback methods,
* and XML processing will be complete.
*
* @param buf The xml data buffer.
* @param size The size of the data buffer in bytes
* @param visitor An object that contains callbacks for XML parsing
* events.
* @exception Throws sg_io_exception or sg_xml_exception if there
* is a problem reading the file.
* @see XMLVisitor
*/
extern void readXML (const char *buf, const int size, XMLVisitor &visitor);
#endif // __EASYXML_HXX