Board index FlightGear Development Aircraft

Dual control for Boeing 777

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Re: Dual control for Boeing 777

Postby Hooray » Mon May 16, 2016 12:10 pm

Maybe I am simply missing something here, but I was referring to the texture visitor not being able to "identify" what 3D model/texture we're referring to to replace the static texture with a dynamic one (Canvas RTT/FBO) - for that, we need to have some kind of scheme in place to look up the correct model, because a model may be instantiated multiple times, depending on the surrounding AI/MP traffic.

The cmdarg() method might simply work, but it will still only work for Nasal embedded in model-xml files, i.e. would not work for accessing an AI/MP model from a different Nasal context, while is in contrast to how placements work otherwise. Anyway, we will see ...
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Dual control for Boeing 777

Postby Richard » Mon May 16, 2016 5:42 pm

bugman wrote in Mon May 16, 2016 10:25 am:I would simply suggest trying out the lastest FlightGear code (or unstable nightly release).


I'm testing against sources from around the 12th - which I think includes the scenegraph fixes.
Richard
 
Posts: 707
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Dual control for Boeing 777

Postby Richard » Mon May 16, 2016 7:58 pm

I think globals->get_scenery()->get_aircraft_branch() might be the cause of the problem.

I'm currently trying to figure out if it is feasible to get the actual scenegraph root relative to where this is called from.

Code: Select all
simgear::canvas::Placements
FGODGauge::set_aircraft_texture( SGPropertyNode* placement,
                                 osg::Texture2D* new_texture,
                                 osg::NodeCallback* cull_callback,
                                 const simgear::canvas::CanvasWeakPtr& canvas )
{
  return set_texture
  (
    globals->get_scenery()->get_aircraft_branch(),
     placement,
    new_texture,
    cull_callback,
    canvas
  );
}
Richard
 
Posts: 707
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Dual control for Boeing 777

Postby Hooray » Mon May 16, 2016 8:18 pm

glad to see that the pointers seem to have been at least somewhat helpful; I think, the set_aircraft_texture() API could bee overloaded to provide a "context" to match the calling context - OTOH, that is basically what the raw set_texture() API is doing by accepting an osg::Node.

If I were testing this, I'd just overload the set_aircraft_texture() method and provide a 2nd API that uses the model_* scene graph instead and see if that just works or not - that would at least tell us if this is a red herring or not.

disclaimer: I haven't actually tested any this, let alone rebuilt sg/fg, so it's just a wild guess that this is was going on
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Dual control for Boeing 777

Postby Hooray » Tue May 17, 2016 12:51 am

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
  );
}

Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Dual control for Boeing 777

Postby Richard » Thu May 19, 2016 5:14 am

Thanks to Tom's posting in the mailing list the solution to this is to change the placement for the backseater/co-pilot

in the model.xml I dynamically load the Nasal module and tell it to use _module_id as the placement. I'm using emesary to communicate the _module_id to the VSD - but this would probably work by just directly calling the appropriate function in the VSD module. I'm doing it like this so that the VSD can be initialized in the same way from both front and backseat.

Code: Select all
                print("Loading F-15 VSD from ",fn_vsd);
                io.load_nasal(fn_vsd, "f15vsd");
                emesary.GlobalTransmitter.NotifyAll(emesary.Notification.new("F15Model", _module_id));


In the VSD it uses a different method of placement (thanks Tom) that will use the scenery rather than the aircraft to locate the texture.

Code: Select all
        if (target_module_id != nil)
        {
            print("Backseat VSD ",target_module_id);
            dev_canvas.addPlacement({
                    "module-id": target_module_id,
                        type: "scenery-object",
                        "node": model_element
                        });
        }
        else
        {
            print("Front seat VSD");
            dev_canvas.addPlacement({
                    "node": model_element
                        });
        }
Richard
 
Posts: 707
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Dual control for Boeing 777

Postby Hooray » Thu May 19, 2016 1:13 pm

that's good, so no C++ changed needed then ?
I think we were actually talking about trying the model/scenery placement mode a few weeks ago ;-)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Aircraft

Who is online

Users browsing this forum: No registered users and 34 guests