scenery: Only add trasnform matrices on successful loaded models.
This commit is contained in:
parent
a2b75e0d7a
commit
0d9b247da1
@ -130,17 +130,6 @@ void TileEntry::prep_ssg_node(float vis) {
|
|||||||
_node->setRange( 0, 0, vis + bounding_radius );
|
_node->setRange( 0, 0, vis + bounding_radius );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileEntry::obj_load(const string& path, osg::Group *geometry, bool is_base,
|
|
||||||
const osgDB::Options* options)
|
|
||||||
{
|
|
||||||
osg::Node* node = osgDB::readNodeFile(path, options);
|
|
||||||
if (node)
|
|
||||||
geometry->addChild(node);
|
|
||||||
|
|
||||||
return node != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OBJECT,
|
OBJECT,
|
||||||
OBJECT_SHARED,
|
OBJECT_SHARED,
|
||||||
@ -305,8 +294,10 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
|
|
||||||
if (found_tile_base) {
|
if (found_tile_base) {
|
||||||
// load tile if found ...
|
// load tile if found ...
|
||||||
obj_load( object_base.str(), new_tile, true, opt.get());
|
osg::ref_ptr<osg::Node> node;
|
||||||
|
node = osgDB::readRefNodeFile(object_base.str(), opt.get());
|
||||||
|
if (node.valid())
|
||||||
|
new_tile->addChild(node);
|
||||||
} else {
|
} else {
|
||||||
// ... or generate an ocean tile on the fly
|
// ... or generate an ocean tile on the fly
|
||||||
SG_LOG(SG_TERRAIN, SG_INFO, " Generating ocean tile");
|
SG_LOG(SG_TERRAIN, SG_INFO, " Generating ocean tile");
|
||||||
@ -328,7 +319,10 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
if (obj->type == OBJECT) {
|
if (obj->type == OBJECT) {
|
||||||
SGPath custom_path = obj->path;
|
SGPath custom_path = obj->path;
|
||||||
custom_path.append( obj->name );
|
custom_path.append( obj->name );
|
||||||
obj_load( custom_path.str(), new_tile, false, opt.get());
|
osg::ref_ptr<osg::Node> node;
|
||||||
|
node = osgDB::readRefNodeFile(custom_path.str(), opt.get());
|
||||||
|
if (node.valid())
|
||||||
|
new_tile->addChild(node);
|
||||||
|
|
||||||
} else if (obj->type == OBJECT_SHARED || obj->type == OBJECT_STATIC) {
|
} else if (obj->type == OBJECT_SHARED || obj->type == OBJECT_STATIC) {
|
||||||
// object loading is deferred to main render thread,
|
// object loading is deferred to main render thread,
|
||||||
@ -341,6 +335,14 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
}
|
}
|
||||||
custom_path.append( obj->name );
|
custom_path.append( obj->name );
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Node> model;
|
||||||
|
if(_modelLoader)
|
||||||
|
model = _modelLoader->loadTileModel(custom_path.str(),
|
||||||
|
obj->type == OBJECT_SHARED);
|
||||||
|
else
|
||||||
|
model = osgDB::readRefNodeFile(custom_path.str(), opt.get());
|
||||||
|
|
||||||
|
if (model.valid()) {
|
||||||
osg::Matrix obj_pos;
|
osg::Matrix obj_pos;
|
||||||
WorldCoordinate( obj_pos, obj->lat, obj->lon, obj->elev, obj->hdg );
|
WorldCoordinate( obj_pos, obj->lat, obj->lon, obj->elev, obj->hdg );
|
||||||
|
|
||||||
@ -351,24 +353,13 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
// wire as much of the scene graph together as we can
|
// wire as much of the scene graph together as we can
|
||||||
new_tile->addChild( obj_trans );
|
new_tile->addChild( obj_trans );
|
||||||
|
|
||||||
osg::Node* model = 0;
|
obj_trans->addChild(model.get());
|
||||||
if(_modelLoader)
|
}
|
||||||
model = _modelLoader->loadTileModel(custom_path.str(),
|
|
||||||
obj->type == OBJECT_SHARED);
|
|
||||||
if (model)
|
|
||||||
obj_trans->addChild(model);
|
|
||||||
} else if (obj->type == OBJECT_SIGN || obj->type == OBJECT_RUNWAY_SIGN) {
|
} else if (obj->type == OBJECT_SIGN || obj->type == OBJECT_RUNWAY_SIGN) {
|
||||||
// load the object itself
|
// load the object itself
|
||||||
SGPath custom_path = obj->path;
|
SGPath custom_path = obj->path;
|
||||||
custom_path.append( obj->name );
|
custom_path.append( obj->name );
|
||||||
|
|
||||||
osg::Matrix obj_pos;
|
|
||||||
WorldCoordinate( obj_pos, obj->lat, obj->lon, obj->elev, obj->hdg );
|
|
||||||
|
|
||||||
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
|
||||||
obj_trans->setDataVariance(osg::Object::STATIC);
|
|
||||||
obj_trans->setMatrix( obj_pos );
|
|
||||||
|
|
||||||
osg::Node *custom_obj = 0;
|
osg::Node *custom_obj = 0;
|
||||||
if (obj->type == OBJECT_SIGN)
|
if (obj->type == OBJECT_SIGN)
|
||||||
custom_obj = SGMakeSign(opt->getMaterialLib(), custom_path.str(), obj->name);
|
custom_obj = SGMakeSign(opt->getMaterialLib(), custom_path.str(), obj->name);
|
||||||
@ -377,10 +368,17 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
|
|
||||||
// wire the pieces together
|
// wire the pieces together
|
||||||
if ( custom_obj != NULL ) {
|
if ( custom_obj != NULL ) {
|
||||||
obj_trans -> addChild( custom_obj );
|
osg::Matrix obj_pos;
|
||||||
}
|
WorldCoordinate( obj_pos, obj->lat, obj->lon, obj->elev, obj->hdg );
|
||||||
new_tile->addChild( obj_trans );
|
|
||||||
|
|
||||||
|
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
||||||
|
obj_trans->setDataVariance(osg::Object::STATIC);
|
||||||
|
obj_trans->setMatrix( obj_pos );
|
||||||
|
|
||||||
|
obj_trans->addChild( custom_obj );
|
||||||
|
|
||||||
|
new_tile->addChild( obj_trans );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,6 @@ private:
|
|||||||
// osgDB::DatabasePager.
|
// osgDB::DatabasePager.
|
||||||
osg::ref_ptr<osg::Referenced> _databaseRequest;
|
osg::ref_ptr<osg::Referenced> _databaseRequest;
|
||||||
|
|
||||||
static bool obj_load( const std::string& path,
|
|
||||||
osg::Group* geometry,
|
|
||||||
bool is_base,
|
|
||||||
const osgDB::Options* options);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This value is used by the tile scheduler/loader to load tiles
|
* This value is used by the tile scheduler/loader to load tiles
|
||||||
* in a useful sequence. The priority is set to reflect the tiles
|
* in a useful sequence. The priority is set to reflect the tiles
|
||||||
|
Loading…
Reference in New Issue
Block a user