I'm currently trying to figure out if it is feasible to get the actual scenegraph root relative to where this is called from.
For testing purposes, I would suggest to edit canvas_mgr.cxx ($FG_SRC/Canvas) and change the scenegraph there to use the AI/MP branch instead:
- Code: Select all
//----------------------------------------------------------------------------
void CanvasMgr::init()
{
_gui_camera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
assert(_gui_camera.valid());
sc::Canvas::addPlacementFactory
(
"object",
boost::bind
(
&FGODGauge::set_aircraft_texture,
_1,
boost::bind(&sc::Canvas::getTexture, _2),
boost::bind(&sc::Canvas::getCullCallback, _2),
_2
)
);
sc::Canvas::addPlacementFactory("scenery-object", &addSceneObjectPlacement);
simgear::canvas::CanvasMgr::init();
}
Once/if that works, I would suggest to look at the scenery placement and use that as a template for a new AI/MP placement; if I am not mistaken, we can then use basically the same heuristics to traverse the /ai branch (AIManager) and get a handle to the correct 3D model, because $FG_SRC/AIModel/AIBase.cxx also supports the same FGNasalModelData hooks:
- Code: Select all
//------------------------------------------------------------------------------
static sc::Placements addSceneObjectPlacement( SGPropertyNode* placement,
sc::CanvasPtr canvas )
{
int module_id = placement->getIntValue("module-id", -1);
if( module_id < 0 )
return sc::Placements();
FGNasalModelData* model_data =
FGNasalModelData::getByModuleId( static_cast<unsigned int>(module_id) );
if( !model_data )
return sc::Placements();
if( !model_data->getNode() )
return sc::Placements();
return FGODGauge::set_texture
(
model_data->getNode(),
placement,
canvas->getTexture(),
canvas->getCullCallback(),
canvas
);
}