Project Boeing 747 Development Thread

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,678
Reaction score
902
Points
128
Location
Code 347
Wow! Very nice!
Another possible variant......
wX5bNBoNsnrxgygEJptQSn.jpg
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,051
Reaction score
630
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Hello friends, here I am again with some noob problems.
It turns out that I am adding the buttons to control the MFDs, for now I am configuring only one MFD and only when it works well will I configure the others. The problem is that I have defined the action areas but when I run Orbiter and switch to the virtual cockpit a SEGFAULT occurs.

Surely it must be nonsense, a very easy mistake but I can't find the solution.

I am using the G42-200 code as an example to learn.

This is my code:
C++:
bool B747SP::clbkLoadVC(int id){

    switch(id){
        case 0 : //Commander
            SetCameraOffset(Captains_camera_Location);
            SetCameraDefaultDirection(_V(0, 0, 1));
            SetCameraRotationRange(RAD*120, RAD*120, RAD*60, RAD*60);
            oapiVCSetNeighbours(-1, 1, -1, 2);
        break;

        case 1 : //First officer
            SetCameraOffset(First_officer_camera_Location);
            SetCameraDefaultDirection(_V(0, 0, 1));
            SetCameraRotationRange(RAD*120, RAD*120, RAD*60, RAD*60);
            oapiVCSetNeighbours(0, 2, -1, -1);
        break;

        case 2: //Engineer
            SetCameraOffset(Engineer_camera_Location);
            SetCameraDefaultDirection(_V(1, 0, 0));
            SetCameraRotationRange(RAD*120, RAD*120, RAD*60, RAD*60);
            oapiVCSetNeighbours(1, -1, -1, -1);
        break;
    }


    //MFDs setup

    static VCMFDSPEC mfds1 = {1, 20};
    oapiVCRegisterMFD(MFD_LEFT, &mfds1);

    static const VECTOR3 mfdKeyPositions[12] = {
        MFD1_BTN1_Location,
        MFD1_BTN2_Location,
        MFD1_BTN3_Location,
        MFD1_BTN4_Location,
        MFD1_BTN5_Location,
        MFD1_BTN6_Location,
        MFD1_BTN7_Location,
        MFD1_BTN8_Location,
        MFD1_BTN9_Location,
        MFD1_BTN10_Location,
        MFD1_BTN11_Location,
        MFD1_BTN12_Location,
    };
    for(int i = 0 ; i < 12; i++){
        oapiVCRegisterArea(101, _R(1, 1, 1, 1), PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_LBUP, PANEL_MAP_NONE, NULL);
        oapiVCSetAreaClickmode_Spherical(101, mfdKeyPositions[i], 0.2);
    }

    static const VECTOR3 mfdCtrlPositions[3] = {
        MFD1_SEL_Location,
        MFD1_PWR_Location,
        MFD1_MNU_Location,
    };
    for(int i = 0; i < 3; i++){
        oapiVCRegisterArea(102, _R(1, 1, 1, 1), PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN, PANEL_MAP_NONE, NULL);
        oapiVCSetAreaClickmode_Spherical(102, mfdCtrlPositions[i], 0.2);
    }

    vcMfdTex = oapiGetTextureHandle(mhcockpit_mesh, 9);
    oapiVCRegisterArea(2, _R(1, 1, 1, 1), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, vcMfdTex);

    return true;
}

C++:
// Auto generated code file.  Blender: 3.3.9  Blender Tools: (2, 1, 3)
// Date: Fri Feb  9 18:16:47 2024


#include "Orbitersdk.h"

#ifndef __747cockpitdefinitions_H
#define __747cockpitdefinitions_H


    const UINT Autopilot_panel_Id = 0;
    const UINT Autopilot_screen1_Id = 1;
    const UINT Autopilot_screen2_Id = 2;
    const UINT Autopilot_screen3_Id = 3;
    const UINT Autopilot_screen4_Id = 4;
    const UINT Brake_lever_Id = 5;
    const UINT Captain_seat_Id = 6;
    const UINT Central_pedestal_Id = 7;
    const UINT Central_pedestal_MFD1_Id = 8;
    const UINT Central_pedestal_MFD2_Id = 9;
    const UINT Central_pedestal_MFD3_Id = 10;
    const UINT Cockpit_fuselage_Id = 11;
    const UINT Engineer_panel_Id = 12;
    const UINT Engineer_seat_Id = 13;
    const UINT First_officer_seat_Id = 14;
    const UINT Flaps_lever_Id = 15;
    const UINT LYoke_Id = 16;
    const UINT LYoke_column_Id = 17;
    const UINT LYoke_column_pedestal_Id = 18;
    const UINT Landing_gear_lever_Id = 19;
    const UINT MFD1_Id = 20;
    const UINT MFD1_BTN1_Id = 21;
    const UINT MFD1_BTN10_Id = 22;
    const UINT MFD1_BTN11_Id = 23;
    const UINT MFD1_BTN12_Id = 24;
    const UINT MFD1_BTN2_Id = 25;
    const UINT MFD1_BTN3_Id = 26;
    const UINT MFD1_BTN4_Id = 27;
    const UINT MFD1_BTN5_Id = 28;
    const UINT MFD1_BTN6_Id = 29;
    const UINT MFD1_BTN7_Id = 30;
    const UINT MFD1_BTN8_Id = 31;
    const UINT MFD1_BTN9_Id = 32;
    const UINT MFD1_MNU_Id = 33;
    const UINT MFD1_PWR_Id = 34;
    const UINT MFD1_SEL_Id = 35;
    const UINT MFD2_Id = 36;
    const UINT MFD3_Id = 37;
    const UINT MFD4_Id = 38;
    const UINT MFD5_Id = 39;
    const UINT MFD6_Id = 40;
    const UINT Main_windows_Id = 41;
    const UINT Panel_Id = 42;
    const UINT RYoke_Id = 43;
    const UINT RYoke_column_Id = 44;
    const UINT RYoke_column_pedestal_Id = 45;
    const UINT Upper_panel_Id = 46;
    constexpr VECTOR3 Axis_LYoke_column_Location =     {-0.6843, 7.7549, 22.7443};
    constexpr VECTOR3 Axis_RYoke_column_Location =     {0.7956, 7.7505, 22.7433};
    constexpr VECTOR3 Axis_landing_gear_lever_Location =     {0.1746, 8.1530, 22.9745};
    constexpr VECTOR3 PL1_Location =     {-1.0490, 8.6757, 22.2532};
    constexpr VECTOR3 PL2_Location =     {1.2582, 8.6757, 22.2532};
    constexpr VECTOR3 Autopilot_panel_Location =     {0.0519, 8.3417, 22.9115};
    constexpr VECTOR3 Autopilot_screen2_Location =     {-0.0058, 8.3716, 22.8684};
    constexpr VECTOR3 Autopilot_screen3_Location =     {0.1238, 8.3723, 22.8680};
    constexpr VECTOR3 Autopilot_screen4_Location =     {0.2545, 8.3710, 22.8684};
    constexpr VECTOR3 Autopilot_screen1_Location =     {-0.1317, 8.3724, 22.8687};
    constexpr VECTOR3 Captains_camera_Location =     {-0.6788, 8.5281, 22.0996};
    constexpr VECTOR3 Captain_seat_Location =     {-0.6981, 8.1981, 22.0368};
    constexpr VECTOR3 Cockpit_fuselage_Location =     {0.0378, 8.0917, 22.2575};
    constexpr VECTOR3 Upper_panel_Location =     {0.0411, 8.9389, 21.5910};
    constexpr VECTOR3 First_officer_seat_Location =     {0.8019, 8.1981, 22.0368};
    constexpr VECTOR3 LYoke_Location =     {-0.6868, 8.2174, 22.6788};
    constexpr VECTOR3 LYoke_column_Location =     {-0.6846, 8.0161, 22.7373};
    constexpr VECTOR3 LYoke_column_pedestal_Location =     {-0.6846, 7.7376, 22.7435};
    constexpr VECTOR3 Panel_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 RYoke_Location =     {0.7932, 8.2128, 22.6788};
    constexpr VECTOR3 RYoke_column_Location =     {0.7954, 8.0116, 22.7373};
    constexpr VECTOR3 RYoke_column_pedestal_Location =     {0.7954, 7.7330, 22.7435};
    constexpr VECTOR3 Central_pedestal_Location =     {0.0337, 7.8247, 22.2326};
    constexpr VECTOR3 Main_windows_Location =     {0.0411, 8.4046, 22.5669};
    constexpr VECTOR3 MFD1_Location =     {-0.6414, 8.1462, 22.9341};
    constexpr VECTOR3 MFD2_Location =     {-0.4264, 8.1462, 22.9341};
    constexpr VECTOR3 MFD3_Location =     {-0.2015, 8.1559, 22.9387};
    constexpr VECTOR3 MFD4_Location =     {0.0382, 8.1468, 22.9377};
    constexpr VECTOR3 Landing_gear_lever_Location =     {0.1742, 8.0810, 22.9029};
    constexpr VECTOR3 MFD6_Location =     {0.7051, 8.1354, 22.9341};
    constexpr VECTOR3 MFD5_Location =     {0.5004, 8.1462, 22.9341};
    constexpr VECTOR3 Central_pedestal_MFD1_Location =     {0.0328, 8.0019, 22.8584};
    constexpr VECTOR3 Central_pedestal_MFD2_Location =     {0.0331, 7.9435, 22.0611};
    constexpr VECTOR3 Central_pedestal_MFD3_Location =     {0.0445, 8.0056, 22.7361};
    constexpr VECTOR3 Engineer_seat_Location =     {0.2569, 8.1981, 21.2978};
    constexpr VECTOR3 First_officer_camera_Location =     {0.8212, 8.5281, 22.0996};
    constexpr VECTOR3 Engineer_camera_Location =     {0.2981, 8.5281, 21.1919};
    constexpr VECTOR3 MFD1_BTN1_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN2_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN3_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN4_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN5_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN6_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN7_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN8_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN9_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN10_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN11_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_BTN12_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_SEL_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_MNU_Location =     {0.0371, 8.1096, 23.1863};
    constexpr VECTOR3 MFD1_PWR_Location =     {0.0371, 8.1096, 23.1863};


#endif
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,604
Reaction score
2,324
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I have not looked in detail on the code, but
Code:
_R(1, 1, 1, 1)
sounds weird. Shouldn't it be
Code:
_R(0, 0, 1, 1)
if it is supposed to do what you want?
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,051
Reaction score
630
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
I have not looked in detail on the code, but
Code:
_R(1, 1, 1, 1)
sounds weird. Shouldn't it be
Code:
_R(0, 0, 1, 1)
if it is supposed to do what you want?
Thank you! Now the SEGFAULT does not occur, however the buttons do not work so I will have to continue checking.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,604
Reaction score
2,324
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Thank you! Now the SEGFAULT does not occur, however the buttons do not work so I will have to continue checking.

Maybe its also because you actually create two conflicting areas, AFAIR the first definition is for 2D panels, not for 3D. Just the spherical or rectangular calls for 3D should be enough for a VC. But don't trust me, check it. My memory is rusty
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
232
Reaction score
118
Points
58
Location
Lehi, Utah
Does the clbkVCMouseEvent get called?

Also, the locations for the buttons all appear to be the same, as well as the ids. Still, I would expect the callback to fire.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,051
Reaction score
630
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Does the clbkVCMouseEvent get called?

Also, the locations for the buttons all appear to be the same, as well as the ids. Still, I would expect the callback to fire.
Oh Lord!
I now realize that I read half of the Orbiter Programmer's Guide documentation. For some absurd reason I read < to be completed > in the section "You should also define mouse-active areas for the three bottom MFD buttons".

Sorry, I'll continue programming.

PS: Does anyone have the Manual for the Correct Use of the Human Brain to read things?
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
232
Reaction score
118
Points
58
Location
Lehi, Utah
I assume you are placing an 'Empty' object at the coordinates in your VC mesh where the button will be and then asking Blender to write that location to the header file. Blender can get funny with transforms, and its possible they have not really moved to where they belong. Click on them and look at the Item->Transform->Location (the little window that pops out from the right side of the 3D Viewport window in Blender.

MFDs in VCs can be hard to wrap your head around. I have this note in the SR71r code:

// This can be confusing: oapiVCRegisterArea takes a RECT that is in TEXTURE space, not MESH space, this
// tells Orbiter where to redraw. The area ID is then also associated with a mouse event. HOWEVER the
// mouse event area is defined in the oapiVCSetAreaClickmode_Spherical call below. That takes a mesh location.

Focus on getting one of the static buttons (power, sel, mnu) working with the event showing up in the callback function. Then you can move on the the more dynamic buttons.
 
Top