C++ Question Drawing MFD button labels in a 3D cockpit

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
279
Reaction score
62
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; }

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

Thank you in advance,

MrMartian
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,533
Reaction score
1,678
Points
203
Location
Dallas, TX
Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; }

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

Thank you in advance,

MrMartian
Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; }

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

Thank you in advance,

MrMartian
So what happens? I have done them. BUt willing to help
 

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
279
Reaction score
62
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
So what happens? I have done them. BUt willing to help
Hi Gattispilot, Thanks for your reply!

So just nothing is displayed, the buttons work, but there are no visible labels.

1639400432517.png

The above image shows what I have. I just placed a group over one of the buttons (circled in red). This group I have set the geometry for the entire left button array to fit into this small box (silly I know, but just wanted to see if any buttons appear). It is a square shape with a texture that fits perfectly into said shape, if this makes sense. I would have expected to see very small labels in this box, but instead nothing. Do you think it may have something to do with my texture positioning?

Thank you again.
 

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,724
Reaction score
581
Points
188
Not sure if this will help, do you know of this?


Its quite old, so I'm not sure if its still relevant.
 

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
279
Reaction score
62
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Hi both,

Thank you for your replies. Notebook thank you for the link that was worth a read. Realised I never loaded any fonts... Feel a bit stupid :oops:

I have button text working now, but one issue I can't seem to work around, is whenever I check any of the left mfd buttons, the labels for the right buttons dissapear, and don't reappear until I click on some of the right buttons. Anyone have any ideas as to what may be causing this? I thought it may have something to do with clbkVCRedrawEvent, but I'm really scratching my head here.

In clbkLoadVC it doesn't matter if I register the area for the left buttons or right buttons first, it will always be the right buttons that present this issue, left buttons work perfectly...

Many thanks in advance.
 

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
279
Reaction score
62
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Actually, I think I may have sorted it.

In clbkLoadVC, in the line where the area to print buttons on is registered, I have changed the line (below) to PANEL_REDRAW_ALWAYS. this line was just taken from Martins' ShuttleA source code, and was previously PANEL_REDRAW_USER.

oapiVCRegisterArea (AID_MFD1_RBUTTONS, _R( 30 ,100, 512,512), PANEL_REDRAW_MOUSE|[COLOR=rgb(250, 197, 28)]PANEL_REDRAW_ALWAYS[/COLOR],PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);

This works for now, and I don't see any issue that may arise from this, however if anyone knows a reason why it should be PANEL_REDRAW_USER I would be interested to understand this.

Thank you all!

MrMartian
 
Top