On 12/11/02 at 1:09 PM ace project wrote:

>Our (ACE/ICE) multiplayer engine is ready to draw
>planes in the game now, but I cant seem to figure out
>how to add them to the drawing graph in a way that I
>can actually see them.
>
>Does anyone know how to do this or know the pitfalls
>why is it failing ?
>
>

Leon,

The following code will put a C172 floating above the San Fransisco runway
about 100m down from the startup location if it is instantiated and the
Init and Update functions called:

//
----------------------------------------------------------------------------
-----
// PutModel.hxx

#ifndef _PUT_MODEL_HXX
#define _PUT_MODEL_HXX

#include <Model/model.hxx>
#include <plib/sg.h>
#include <plib/ssg.h>

class PutModel {

public:

    void Init();

    // Run the internal calculations
    void Update(double dt);

private:

    char* model_path;   //Path to the 3D model
    FGModelPlacement aip;
        
    void Transform();
};

#endif // _PUT_MODEL_HXX
//
----------------------------------------------------------------------------


//
---------------------------------------------------------------------------
// PutModel.cxx

#include <Main/globals.hxx>
#include <Main/location.hxx>
#include <Scenery/scenery.hxx>
#include <simgear/misc/sg_path.hxx>
#include <string>

#include "PutModel.hxx"

void PutModel::Init() {
    // Hack alert - Hardwired path!!
    string planepath = "Aircraft/c172/Models/c172-dpm.ac";
    SGPath path = globals->get_fg_root();
    path.append(planepath);
    aip.init(planepath.c_str());
    aip.setVisible(true);
    globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
}

void PutModel::Update(double dt) {
    Transform();        // FIXME - only need to do this if position has changed
}

void PutModel::Transform() {
    aip.setPosition(-122.361925, 37.613137, 10.0);
    aip.setOrientation(0.0, 0.0, 270.0);
    aip.update();    
}
//
---------------------------------------------------------------------------


With regard to your code below, I don't see a call to
FGModelPlacement.init(...) or FGModelPlacement.setVisible(...)

Maybe that is what you're missing?

>From previous discussions of this on the list, I was under the impression
that one could add properties to the /models branch of the property tree
and they would be automatically rendered by the modelmgr.  I've never
managed to do it though :-(, so maybe I was mistaken?

Cheers - Dave 


>Tries so far:
>---
>
>class fgPeer::FGModelPlacement (from Model/model.cxx)
>loading a ".ac"-model(Geometry/Models/glider.ac) in
>init() 
>
>Adding the ssgEntity from
>FGModelPlacement.getSceneGraph() to the Flight Gear
>Graph using the following 2 functions:
>globals->get_scenery()->get_models_branch()->addKid(myFGPeer)
>-or- (which one is good ?)
>globals->get_scenery()->get_scene_graph()->addKid(myFGPeer)
>
>as seen in Model/modelmgr.cxx.
>
>and calling 
>FGModelPlacement.setPostion(...)
>FGModelPlacement.setOrientation(...)
>FGModelPlacement.update()
>
>everytime a new update arives.
>
>---




_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to