Harald JOHNSEN:
I have corrected a few bugs with the owner draw gauge, weather radar code and heat-haze effect. - od_gauge.cxx : corrected a rendering bug where the generated texture was only visible from a certain angle or distance ; corrected the search of textures inside the aircraft scene graph ; - wxRadar.cxx : the echo of clouds was lost when the pilot was not looking in the plane direction ;
This commit is contained in:
parent
ae928dde80
commit
0a59a4d4bc
3 changed files with 50 additions and 13 deletions
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// Written by Harald JOHNSEN, started May 2005.
|
// Written by Harald JOHNSEN, started May 2005.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
|
// Copyright (C) 2005 Harald JOHNSEN
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program 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 General Public License as
|
||||||
|
@ -130,11 +130,15 @@ void FGODGauge::Clear(void) {
|
||||||
|
|
||||||
void FGODGauge::endCapture(GLuint texID) {
|
void FGODGauge::endCapture(GLuint texID) {
|
||||||
glBindTexture(GL_TEXTURE_2D, texID);
|
glBindTexture(GL_TEXTURE_2D, texID);
|
||||||
|
// don't use mimaps if we don't update them
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureWH, textureWH);
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureWH, textureWH);
|
||||||
if(rtAvailable)
|
if(rtAvailable)
|
||||||
rt->EndCapture();
|
rt->EndCapture();
|
||||||
else
|
else
|
||||||
set3D();
|
set3D();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGODGauge::setSize(int viewSize) {
|
void FGODGauge::setSize(int viewSize) {
|
||||||
|
@ -149,19 +153,39 @@ bool FGODGauge::serviceable(void) {
|
||||||
/**
|
/**
|
||||||
* Locate a texture SSG node in a branch.
|
* Locate a texture SSG node in a branch.
|
||||||
*/
|
*/
|
||||||
static ssgTexture *
|
static const char *strip_path(const char *name) {
|
||||||
|
/* Remove all leading path information. */
|
||||||
|
const char* seps = "\\/" ;
|
||||||
|
const char* fn = & name [ strlen ( name ) - 1 ] ;
|
||||||
|
for ( ; fn != name && strchr(seps,*fn) == NULL ; fn-- )
|
||||||
|
/* Search back for a seperator */ ;
|
||||||
|
if ( strchr(seps,*fn) != NULL )
|
||||||
|
fn++ ;
|
||||||
|
return fn ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssgSimpleState *
|
||||||
find_texture_node (ssgEntity * node, const char * name)
|
find_texture_node (ssgEntity * node, const char * name)
|
||||||
{
|
{
|
||||||
if( node->isA( ssgTypeTexture() ) ) {
|
if( node->isAKindOf( ssgTypeLeaf() ) ) {
|
||||||
ssgTexture *tex = (ssgTexture *) node;
|
ssgLeaf *leaf = (ssgLeaf *) node;
|
||||||
char * texture_name = tex->getFilename();
|
ssgSimpleState *state = (ssgSimpleState *) leaf->getState();
|
||||||
if (texture_name != 0 && !strcmp(name, texture_name))
|
if( state ) {
|
||||||
return tex;
|
ssgTexture *tex = state->getTexture();
|
||||||
|
if( tex ) {
|
||||||
|
const char * texture_name = tex->getFilename();
|
||||||
|
if (texture_name) {
|
||||||
|
texture_name = strip_path( texture_name );
|
||||||
|
if ( !strcmp(name, texture_name) )
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (node->isAKindOf(ssgTypeBranch())) {
|
else {
|
||||||
int nKids = node->getNumKids();
|
int nKids = node->getNumKids();
|
||||||
for (int i = 0; i < nKids; i++) {
|
for (int i = 0; i < nKids; i++) {
|
||||||
ssgTexture * result =
|
ssgSimpleState * result =
|
||||||
find_texture_node(((ssgBranch*)node)->getKid(i), name);
|
find_texture_node(((ssgBranch*)node)->getKid(i), name);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return result;
|
return result;
|
||||||
|
@ -172,9 +196,10 @@ find_texture_node (ssgEntity * node, const char * name)
|
||||||
|
|
||||||
void FGODGauge::set_texture(const char * name, GLuint new_texture) {
|
void FGODGauge::set_texture(const char * name, GLuint new_texture) {
|
||||||
ssgEntity * root = globals->get_scenery()->get_aircraft_branch();
|
ssgEntity * root = globals->get_scenery()->get_aircraft_branch();
|
||||||
ssgTexture * node = find_texture_node( root, name );
|
name = strip_path( name );
|
||||||
|
ssgSimpleState * node = find_texture_node( root, name );
|
||||||
if( node )
|
if( node )
|
||||||
node->setHandle( new_texture );
|
node->setTexture( new_texture );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGODGauge::set2D() {
|
void FGODGauge::set2D() {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// Written by Harald JOHNSEN, started May 2005.
|
// Written by Harald JOHNSEN, started May 2005.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
|
// Copyright (C) 2005 Harald JOHNSEN
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program 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 General Public License as
|
||||||
|
@ -134,8 +134,18 @@ wxRadarBg::update (double delta_time_sec)
|
||||||
odg->set_texture( odgauge_name, resultTexture->getHandle());
|
odg->set_texture( odgauge_name, resultTexture->getHandle());
|
||||||
last_switchKnob = switchKnob;
|
last_switchKnob = switchKnob;
|
||||||
}
|
}
|
||||||
|
FGViewer *current__view = globals->get_current_view();
|
||||||
|
if( current__view->getInternal() &&
|
||||||
|
(current__view->getHeadingOffset_deg() <= 15.0 || current__view->getHeadingOffset_deg() >= 345.0) &&
|
||||||
|
(current__view->getPitchOffset_deg() <= 15.0 || current__view->getPitchOffset_deg() >= 350.0) ) {
|
||||||
|
|
||||||
|
// we don't update the radar echo if the pilot looks around
|
||||||
|
// this is a copy
|
||||||
|
radarEchoBuffer = *sgEnviro.get_radar_echo();
|
||||||
|
}
|
||||||
odg->beginCapture(256);
|
odg->beginCapture(256);
|
||||||
odg->Clear();
|
odg->Clear();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -172,7 +182,7 @@ wxRadarBg::update (double delta_time_sec)
|
||||||
const float rot_x = cos ( view_heading );
|
const float rot_x = cos ( view_heading );
|
||||||
const float rot_y = sin ( view_heading );
|
const float rot_y = sin ( view_heading );
|
||||||
|
|
||||||
list_of_SGWxRadarEcho *radarEcho = sgEnviro.get_radar_echo();
|
list_of_SGWxRadarEcho *radarEcho = &radarEchoBuffer;
|
||||||
list_of_SGWxRadarEcho::iterator iradarEcho;
|
list_of_SGWxRadarEcho::iterator iradarEcho;
|
||||||
const float LWClevel[] = { 0.1f, 0.5f, 2.1f };
|
const float LWClevel[] = { 0.1f, 0.5f, 2.1f };
|
||||||
const float symbolSize = 1.0f / 8.0f ;
|
const float symbolSize = 1.0f / 8.0f ;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
#include <simgear/environment/visual_enviro.hxx>
|
||||||
|
|
||||||
class ssgTexture;
|
class ssgTexture;
|
||||||
class FGODGauge;
|
class FGODGauge;
|
||||||
|
@ -53,6 +54,7 @@ private:
|
||||||
string last_switchKnob;
|
string last_switchKnob;
|
||||||
bool sim_init_done;
|
bool sim_init_done;
|
||||||
FGODGauge *odg;
|
FGODGauge *odg;
|
||||||
|
list_of_SGWxRadarEcho radarEchoBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _INST_WXRADAR_HXX
|
#endif // _INST_WXRADAR_HXX
|
||||||
|
|
Loading…
Add table
Reference in a new issue