3rd mfd

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Can anyone help me get a 3rd ( & maybe 4th) mfd into a vc.

I know it has to be assigned to a mesh/group, but how ( in simple language if poss.) do I create it in the vessel module? An example of code would be perfect, but I can't find a source code with it in.
I'm talking about displaying an existing mfd in a vc, not coding a new mfd (future I hope)

If this is easy then I blush !

Thanks

JMW
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,923
Reaction score
231
Points
138
Location
Cape
It ain't easy, else everyone would be doing it. ;)
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Hmmm.
I haven't got the knowledge that's for sure - any offers???
JMW
PS: Am I in the right forum for this?

PSS: While I'm on, has anyone encountered a bug (lose pen/writing after 1 min. or so ) with Scrooge McDuck's RadarMFD, even refreshing at 1.5 secs.!
 
Last edited:

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,923
Reaction score
231
Points
138
Location
Cape
Sorry, I don't code, but one place to look, is in the SDK and look for examples, in the samples directory.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
It is pretty much the same as for the two other MFDs, except that you MFD_USER1 for the third MFD. And you have no keyboard control for it, except you implement that manually. But which third Shift key could you use?
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks guys,
I think from what I've read you have to create the buttons and control mfd from the screen. My 1st problem was to get the mfd to appear in the vc. I'll try the MFD_USER1 routine and see what happens.
Laters,
JMW
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Thanks guys,
I think from what I've read you have to create the buttons and control mfd from the screen. My 1st problem was to get the mfd to appear in the vc. I'll try the MFD_USER1 routine and see what happens.
Laters,
JMW

The call would be:

Code:
oapiVCRegisterMFD(MFD_USER1, &thirdmfdspec);
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Compiled code as below and got a blank screen in vc. Hopefully is 1st step.

static
VCHUDSPEC hud_pilot = {1, 101,{0,0.6,4.7},0.5};
static VCMFDSPEC mfds_left = {1, 112};
static VCMFDSPEC mfds_right = {1, 117};
static VCMFDSPEC mfds_user1 = {1, 116};

oapiVCRegisterHUD (&hud_pilot);
oapiVCRegisterMFD (MFD_LEFT, &mfds_left);
oapiVCRegisterMFD (MFD_RIGHT, &mfds_right);
oapiVCRegisterMFD (MFD_USER1, &mfds_user1);
return true;

Next, is to code buttons to switch it on etc. This will take me a long time, unless anyone can "translate" the text in SDK into actual code for me. (Obviously I've gotta specify the co-ordinates of the buttons) Yes, I'm lazy! (but mainly ignorant!!)
The code you gave me Urwumpe, is it for the buttons?
JMW
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
No, it is for drawing the MFD.

Did you check that the mesh groups of the MFD are correct and the groups in the mesh have no texture assigned, and also are flagged with "FLAG 3"?
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Hi,
tried using oapiVCRegisterMFD(MFD_USER1, &thirdmfdspec);
and get : error C2065: 'thirdmfdspec' : undeclared identifier

It compiles with code as I had before.
I have got group/flag 3 & no texture, but as I say, get a black screen in vc at assigned place.
Doesn't mfd need "PWR"ing up? through an assigned button to appear?
Also, tried assigning mfd_right to same mesh group & hey presto ! it appears, so I guess that side of it must be OK.
Any help creating/assigning buttons please? Do they have to be created individually?
I have not managed to create a mesh yet, I'm modifying other people's to suit my purpose (forgive me, but I can't get a mesh that works in Orbiter from Anim8or model - very frustrating !!Using 3ds2msh - seems to combine all the groups !)
Point is, I'll have to import some buttons from another mesh, then move 'em around to suit. Don't --:rofl:!!
JMW



-----Posted Added-----


Gotta go now - daughters home from work and "MUST use computer" (backed up by wife "What a waste of time!"- familiar???)
Any help would be appreciated - anytime.
Regards,
JMW
 

no matter

Addon Developer
Addon Developer
Joined
Mar 20, 2008
Messages
61
Reaction score
0
Points
0
Website
pagesperso-orange.fr
Of course you need either to power it by an oapiOpenMFD in your code (that's not what you want) or by clicking a dedicated power button for your third MFD.

So you have:
static VCMFDSPEC mfds_user1 = {1, 116};
oapiVCRegisterMFD (MFD_USER1, &mfds_user1);

now you need to register areas and "clickmodes" for MFD3's buttons:
don't forget to dedefine the buttons in your header (#define blahblahblah...)
// register+activate MFD3 power button
oapiVCRegisterArea (AID_MFD3_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
oapiVCSetAreaClickmode_Spherical(AID_MFD3_PWR, _V(-0.07,0.484,0.465), powerButtonRadius);

// MFD 3 menu&mode buttons
oapiVCRegisterArea (AID_MFD3_MENU, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
oapiVCSetAreaClickmode_Spherical(AID_MFD3_MENU, _V(0.054,0.484,0.465), functionButtonRadius2);
oapiVCRegisterArea (AID_MFD3_MODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
oapiVCSetAreaClickmode_Spherical(AID_MFD3_MODE, _V(0.073,0.484,0.465), functionButtonRadius2);

// MFD controls L&R buttons
oapiVCRegisterArea (AID_MFD3_LBUTTONS, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_LBUTTONS, _V(-0.096,0.621,0.486), _V(-0.083,0.621,0.486), _V(-0.096,0.49,0.486), _V(-0.083,0.49,0.486));
oapiVCRegisterArea (AID_MFD3_RBUTTONS, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_RBUTTONS, _V(0.085,0.621,0.484), _V(0.098,0.621,0.484), _V(0.085,0.49,0.486), _V(0.098,0.49,0.486));

Retrieving coordinates for oapiVCSetAreaClickmode_Quadrilateral is sometimes really hard (don't tell me about meshwizard.. I know...it is just the same with or without).

Then you need to tell what the button will do (inside clbkMouseEvent):
case AID_MFD3_MENU:
{
if (event & PANEL_MOUSE_LBDOWN)
{
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting)
{
oapiSendMFDKey (MFD_USER3, OAPI_KEY_GRAVE);
counting = false;
}
}
return true;
case AID_MFD3_MODE:
{
if (event & PANEL_MOUSE_LBDOWN)
{
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting)
{
oapiSendMFDKey (MFD_USER3, OAPI_KEY_F1);
counting = false;
}
}
return true;
case AID_MFD3_LBUTTONS:
case AID_MFD3_RBUTTONS:
{
double dp;
if (modf (p.y*23.0/4.0, &dp) < 0.75)
{
int bt = (int)dp + (id == AID_MFD3_LBUTTONS || id == AID_MFD3_LBUTTONS ? 0 : 6);
oapiProcessMFDButton (MFD_USER3, bt, event);
}
}
return true;

You can redraw the buttons to display their title, but that's another story ^^
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks, No Matter for the info - I'll get working !
JMW


-----Posted Added-----


Hi "No Matter" or (anyone that can help),

//Putting code into//
bool clbkVCMouseEvent (int id, int event, VECTOR3 &p);//I had to 'invent' this line. Am I right ?

case AID_MFD3_MENU:
{
if (event & PANEL_MOUSE_LBDOWN)
{
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting)
{
oapiSendMFDKey (MFD_USER3, OAPI_KEY_GRAVE);
counting = false;
}
}
return true;
case AID_MFD3_MODE:
{
if (event & PANEL_MOUSE_LBDOWN)
{
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting)
{
oapiSendMFDKey (MFD_USER3, OAPI_KEY_F1);
counting = false;
}
}
return true;
case AID_MFD3_LBUTTONS:
case AID_MFD3_RBUTTONS:
{
double dp;
if (modf (p.y*23.0/4.0, &dp) < 0.75)
{
int bt = (int)dp + (id == AID_MFD3_LBUTTONS || id == AID_MFD3_LBUTTONS ? 0 : 6);
oapiProcessMFDButton (MFD_USER3, bt, event);
}
}
return true;
//////////////
I get error message:
(1494) : error C2059: syntax error : 'case'
(1495) : error C2447: '{' : missing function header (old-style formal list?)
(1507) : error C2059: syntax error : 'return'
(1508) : error C2059: syntax error : 'case'
(1509) : error C2447: '{' : missing function header (old-style formal list?)
(1521) : error C2059: syntax error : 'return'
(1522) : error C2059: syntax error : 'case'
(1523) : error C2059: syntax error : 'case'
(1524) : error C2447: '{' : missing function header (old-style formal list?)
(1532) : error C2059: syntax error : 'return'
if I put a "{" before 'case' and after 'return true' I get:
(1493) : error C2447: '{' : missing function header (old-style formal list?)
Any ideas?
JMW
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
JMW: How good are your C++ skills really? Do you have already started at the basics or do you try to learn it on the fly?

The correct syntax for a function implementation is:

Code:
return-type class::function(parameter-list) {
 ...
}
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Yes - my C++ (or any coding) skills ARE less than basic !
Flying is what I enjoy;).
I have achieved quite a lot (modifying existing code by trial and error - but I haven't sat down and learned from scratch. I just don't have the time to do it. I realise this must be confusing for you guys, but it's just a hobby that I love.
Any help to get over brick walls that I come up against is much appreciated.
I have a lot of respect for you programmers.

I'll see if I can get anything to work with :

return-type class::function(parameter-list) {
...
}
Best wishes,
JMW
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
For example, like that:

Code:
bool BlackDart::clbkLoadVC(int iVCID) {
    oapiVCRegisterMFD(MFD_LEFT, &mdu_left);
    oapiVCRegisterMFD(MFD_RIGHT, &mdu_right);
    oapiVCRegisterHUD(&hud);

    switch(iVCID) {
    case VCID_PILOT:
        SetCameraOffset(BLACKDART_CAMERA_OFFSET);
        SetCameraDefaultDirection(_V(0.0, 0.0, 1.0));
        SetCameraRotationRange(170.0*RAD, 170.0*RAD, 90 * RAD, 75 * RAD);
        oapiVCSetNeighbours(-1, -1, -1, VCID_REAR);
        break;
    case VCID_REAR:
        SetCameraOffset(BLACKDART_REAR_OFFSET);
        SetCameraDefaultDirection(_V(0.0, 0.0, -1.0));
        SetCameraRotationRange(170.0*RAD, 170.0*RAD, 90 * RAD, 75 * RAD);
        oapiVCSetNeighbours(-1, -1, VCID_PILOT, VCID_HATCH);
        break;
    case VCID_HATCH:
        SetCameraOffset(BLACKDART_HATCH_OFFSET);
        SetCameraDefaultDirection(_V(0.0, 0.0, -1.0));
        SetCameraRotationRange(170.0*RAD, 170.0*RAD, 90 * RAD, 75 * RAD);
        oapiVCSetNeighbours(-1, -1, VCID_REAR, -1);
        break;

    }
    return true;
}

Now, if you just copy my code, it will not work. I use a different structure and symbols as your add-on. You need to understand the important syntax patterns.

And these are, for Orbiter: How to define a class and how to implement it?

The definition of the BlackDart class is in the BlackDart.h header file and written roughly like that:

Code:
class BlackDart:public VESSEL2 {
//Lots of cool stuff removed, as it takes a few pages A4 already.
public:
    BlackDart(OBJHANDLE hVessel, int iFlightModel);
    virtual ~BlackDart(void);
    
    virtual int clbkConsumeDirectKey(char *keystate);
    virtual int clbkConsumeBufferedKey(DWORD key, bool down, char *keystate);
    virtual void clbkDrawHUD(int iMode, const HUDPAINTSPEC *hps, HDC hdc);
    virtual void clbkLoadStateEx(FILEHANDLE scn, void *status);
    virtual bool clbkLoadGenericCockpit();
    virtual bool clbkLoadVC(int iVCID);
    virtual void clbkPostCreation( void );
    virtual void clbkPreStep(double fSimT, double fDeltaT, double fMJD);
    virtual void clbkPostStep(double fSimT, double fDeltaT, double fMJD);
    virtual void clbkSaveState(FILEHANDLE scn);
    virtual void clbkSetClassCaps(FILEHANDLE cfg);
};

As you can see, I have defined at this point, what the class should be able to do.

And the BlackDart.cpp, I implement the defined functions, which means: I tell the compiler, how the class can do it.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Hi,
Just an update on progress so far - Thanks to all for "wall climbing" abilities.
You can see from instruments on top right, why I want to get a digital display code. (On another thread - "Displaying Date/Time info in a VC" ) Any help with this would be appreciated - but remember my very limited programing knowledge.
Thanks again,
JMW
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,650
Reaction score
2,371
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Hey, I have found a user of SensorMFD! :)
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Yeah,
SensorMFD is OK, but it would be better for my application if the side buttons worked - I can only use it in Left/Right MFD positions (keyboard operated).

RadarMFD is good too - but it crashes on me after a minute or so no matter what refresh rate I use ! Is there a fix for this?

Thanks for the encouragement ! And a big thank you to Kev33 for the original vc mesh and a beautiful Mirage aircraft !
JMW
 
Top