SDK Question Add MFD Labels and buttons in VC

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,706
Reaction score
2,681
Points
203
Location
Dallas, TX
In the VC I have added 2 MFd's in the Ranger. But now I want to add more. The problem I ran into how to turn them on and switch screens.
So it has been suggested to make a VC.

So I have looked at the dg code.

Right now I have a mesh for the main body for the VC just a black rectangle and buttons that overlay. From the DG vc mesh it has the buttons for the MFD as none texture.


But how to I dynamically label the buttons?

---------- Post added 09-14-15 at 05:53 AM ---------- Previous post was 09-13-15 at 09:26 PM ----------

I know I need to set where to click to activate the buttons. But how to I measure that area? no 2d panel just a 3d.

this is my front display in the regular mesh:
RANGERNOMFD_zpssfivursa.jpg


and my vc mesh. I can label the pwr, SEl and MNU button and set the texture as D

MFDOVERLAY_zpspnbpkbpt.jpg
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Regarding the button labels: you have various options there:

  1. You could get a Sketchpad environment for the texture covering a button and simply write the label text onto it using Sketchpad methods. This is the easiest option, but probably also the least supported by graphics clients and the least efficient (which probably doesn't matter much since the labels are not updated often). It also probably requires the texture to be marked with 'D' (dynamic) in the mesh file to prevent it from being optimised.
  2. You could have a source texture containing all printable ASCII characters in the appropriate font and size, and blit the letters individually into the MFD button texture with oapiBlt.
  3. You could define each letter on each button as a little rectangular surface consisting of two triangles, and display the appropriate letter by adjusting the texture coordinates of that box. This avoids the blitting, but creates a more complex mesh
For MFD buttons, option 2 is probably the best. For readouts that change continuously, option 3 might be worth a consideration, because the higher mesh complexity might be more efficient than texture blitting at every frame.

Regarding the click position: You need to know where the buttons are located in the 3D vessel frame (which you do since you've created the mesh). Then you simply create an active area for your VC with oapiVCSetAreaClickmode_xxx. There is a spherical and a quadrilateral version. You could define either a spherical click area for each individual button, or a quadrilateral one that covers the entire button row. In the latter case, you need to examine the relative mouse position returned by the mouse event handler to figure out which button was clicked.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,706
Reaction score
2,681
Points
203
Location
Dallas, TX
On the DG they use the dynamic texture method, I think.
So I can add a texture and marked as D. But it seems only the PWR, SEL and MNU are done that way.

I assume the other button which would be specific to the mfd are loaded differently?

On the 3d frame so the coordinates are based off the 3d mesh?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,706
Reaction score
2,681
Points
203
Location
Dallas, TX
Thanks. Would that apply to 3d panels also?

I think because of the rotation of the panels I think a 3d panel is what we need.

We are justing to get the labels of the mfd buttons,.....
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Thanks. Would that apply to 3d panels also?

Essentially yes. There isn't much difference between 2D and 3D panels except the mesh for the 2D panel is projected onto the plane z=0.

The method for creating the MFD buttons I outlined in that tutorial is method 2 from my post above (I had forgotten all about the tutorial ...)

On the DG they use the dynamic texture method, I think.
Maybe for the old (2010) code. Definitely not for newer versions of the DG code.
So I can add a texture and marked as D. But it seems only the PWR, SEL and MNU are done that way.
Unlikely. Those three buttons never change their labels. So they can just be statically defined directly in the texture. No need to update anything.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,706
Reaction score
2,681
Points
203
Location
Dallas, TX
Thanks.

So it looks like since my VC is just the MFD screen and buttons can I follow part 2 of the tutorial.

Make an image with the alphabet for the labels also
 

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,816
Reaction score
640
Points
188
Yes, I did reuse the code from the tutorial that has the text string that is blitted into the display. That part I could nearly understand. Couldn't get the switches example to work, that would be my fault though.
I'll be interested when you get it completed, I'd like to finish the project it was part of.

N.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,706
Reaction score
2,681
Points
203
Location
Dallas, TX
Thanks. So since we are using an overlay. I need to get the x,y, z of the panel and then get the position of the buttons,.... and the mesh group for the display and buttons


Getting the labels will overwhelming. But I would think that you only need PWR, SEL and MNU as the other are specific to the MFd, right.
 

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,816
Reaction score
640
Points
188
From what I remember, yes. Its a long time since I looked at the project.
As I said its the only project I'd like to get back to because of the programming and graphics. I'll dig out my old files and peruse...

N.
 
Top