HHS81 / c182s

Cessna C182S (1996 model) for FlightGear
GNU General Public License v2.0
27 stars 9 forks source link

Idea/ Concept: place chocks/ safetycones/ fuel-trucks etc. via model-manager #55

Closed HHS81 closed 8 years ago

HHS81 commented 8 years ago

Place the chocks/ safetycones via model-manager like the walker

Advantage:

Challenge: nasal script and making the objects remove from scenery when not needed

Basic Idea: Walker

HHS81 commented 8 years ago

@gilbertohasnofb Because:

if one is set to true, force the other to false and add a star to that respective side

Let's play this: both button false = no ladders left button true = left ladder, left radio/checkbox checked and the right button false and no right ladder right button true = right ladder, right radio/checkbox checked and left button false and no left ladder

and then both button again to false ?

1.) The gui doesn't allow to check a radio/checkbox via nasal without doing anything.

2.) "Unfortunately" as well: the whole thing about is not making an object visible. The whole thing is about creating a model dynamically and placing it into the scene. That is what the script is doing. This is only working by a setlistener, otherwise you create thousand of instances of the same model. So you need to create the ladder as single model into the scene once and only like that- then it can be animated.

So this what I did: I only create one model in the scene using the ladder.ac:

The setlistener registrates the checkbox is checked and creates the model. When unchecked it deletes the model from the scene. When clicking the radio-button in the dialog-box it will change the side by a simple animation.

No need to have two ladder-models and hide one of them, no need to create another 30 lines of nasal-script for just another identical ladder-model, no need for fancy-complex nasal-scripts.

Simple, but still effective - the ladder will keep its place in the scenery - like in real life. But you can change the side where it will appear.

HHS81 commented 8 years ago

Done!

wlbragg commented 1 year ago

@hbeni sorry to resurrect this closed issue, but I figured this was the best place to bring this to your attention. Even though it looks like this was not your work I wanted to bring up the idea reducing some code. I noticed the c182 uses a bunch of duplication of code for the ground equipment models. I had some fairly streamline code in place to place models, I think I picked it up originally from the space shuttle. I used it though when introducing your c182 ground services instead of looking at how you placed modeles here. While I was looking at some other systems in place for your ground equipment I noticed how the models were placed here and that there was a lot of extra code compared to the model placement code I use in most of the aircraft I work on. If you compare it to how it is done in the c182 you'll see the difference and notice how much unnecessary duplicate code is used. Anyway, I'm just letting you know there is a more streamlined way to do it. I have no idea if it saves any resources or real overhead, but I wanted to bring it to your attention anyway.

This is the basics of it I am using in the AirCrane. In the Cub and the 172 there are some custom modifications for other ground equipment like the mooring anchor.

############################################
# Static objects
############################################

var StaticModel = {
    new: func (name, file) {
        var m = {
            parents: [StaticModel],
            model: nil,
            model_file: file
        };

        setlistener("/sim/" ~ name ~ "/enable", func (node) {
            if (node.getBoolValue()) {
                m.add();
            }
            else {
                m.remove();
            }
        });

        return m;
    },

    add: func {
        var manager = props.globals.getNode("/models", 1);
        var i = 0;
        for (; 1; i += 1) {
            if (manager.getChild("model", i, 0) == nil) {
                break;
            }
        }
        var position = geo.aircraft_position().set_alt(getprop("/position/ground-elev-m"));
        me.model = geo.put_model(me.model_file, position, getprop("/orientation/heading-deg"));
    },

    remove: func {
        if (me.model != nil) {
            me.model.remove();
            me.model = nil;
        }
    }
};

StaticModel.new("coneR", "Aircraft/AirCrane/Models/Ground-Equipment/safety-cone/safety-cone_R.xml");
StaticModel.new("coneL", "Aircraft/AirCrane/Models/Ground-Equipment/safety-cone/safety-cone_L.xml");
StaticModel.new("gpu", "Aircraft/AirCrane/Models/Ground-Equipment/external-power/external-power.xml");
StaticModel.new("ladder", "Aircraft/AirCrane/Models/Ground-Equipment/ladder/ladder.xml");
StaticModel.new("fueltanktrailer", "Aircraft/AirCrane/Models/Ground-Equipment/fueltanktrailer/fueltanktrailer.ac");
StaticModel.new("externalheater", "Aircraft/AirCrane/Models/Ground-Equipment/external-heater/RedDragonEnginePreHeater.ac");

Also I noticed something else I will likely change. The 182 uses a timer to check for aircraft movement to remove some of the ground models. Probably not as efficient as a listener. If you decide to make any changes to the c182 and make an issue I can add any other optimizations opportunities I happen to notice.

And while I am at it, I also want to thank all involved for the Ground Services work. It is really cool and I am adding it to the Cub and AirCrane. I haven't added attributes to the creators yet, but I will before it is all done.

wlbragg commented 1 year ago

One more thought. It just dawned on me how much work I am duplicating for each aircraft just adding the ground services systems. This whole system might be a good candidate for an Addon. The main issue would be the connections to the electrical, and fuel systems of each individual model and the placement, size, and brand name of the ground equipment used. But it is really tempting.