Question MFD's in VC cockpit Question

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Could someone paste me the code for having the basic 2 MFD's and HUD for window in a virtual cockpit...just THAT code only. It doesn't need to have the Vector 3's specified correctly, just specified. And only the code for MFD's and HUD. My VC contains these items but no other working instruments or lighted switches, not really a custom control board...just a custom cockpit with my pilots and items in it that I've alread meshed and set visibility on....Mesh works fine. Just need the code and am having a hard time knowing what to leave out of the DG vc code that's not important to mine. Also where in my vessel code should this go ....like"ClbkPostCreation" "SetVesselCaps" or what. I mean other than under" bool MyVessel::clbkLoadVC (int id)" ...are there any parts that would need to go somewhere else? I may be able to tell what I need to have from DG for the .h file, but I am not sure...so if somebody has that without all the rest I sure would be apprciative.
 
Last edited:

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,085
Reaction score
901
Points
128
Website
francisdrakex.deviantart.com
Well, it is not too easy. I tried to summarize the code snippets from my MPCV addon. They are simply stripped down from the DeltaGlider code.
This is a VESSEL2 code. Could be different for later vessel types.

Note: The 'panelMesh' must be textured. The texture can be black, or any other.

Code:
class CEV: public VESSEL2 {
...
public:
	VCHUDSPEC huds;
	VCMFDSPEC mfds_left;
	VCMFDSPEC mfds_right;
...
	void clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, HDC hDC);
        bool clbkLoadVC (int id);
}

// Constructor
CEV::CEV (OBJHANDLE hObj, int fmodel)
: VESSEL2(hObj, fmodel)
{
...
	mfds_left.ngroup  = 0;  // numbers depend on your mesh
	mfds_right.ngroup = 1;
	huds.ngroup       =	2;	
	huds.size         = 0.25;
}

void CEV::ReloadMeshes(void)
{
	UINT meshidx;
	ofs_hud =	 _V(0, 1.6, 2.5+dz);  // dz can be 0;
...
	meshidx = AddMesh (panelMesh, &ofs);
	SetMeshVisibilityMode (meshidx, MESHVIS_EXTERNAL | MESHVIS_VC);

	mfds_left.nmesh = meshidx; 
	mfds_right.nmesh = meshidx;
	
	huds.nmesh = meshidx;
	huds.hudcnt = ofs_hud;
	oapiVCRegisterHUD (&huds); // register changes in HUD parameters
}

bool CEV::clbkLoadVC (int id)
{
	...
	oapiVCRegisterHUD (&huds);
	oapiVCRegisterMFD (MFD_LEFT, &mfds_left);
	oapiVCRegisterMFD (MFD_RIGHT,&mfds_right);
	return true;
}
 
Last edited:

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Would this new constructor and all be listed below:
bool MyVessel::clbkLoadVC (int id)
Secondly, I didn't see any redraw events in your code. Doesn't the MFD's when displaying orbits have to constantly update and redraw? I have two squares textured with the buttons modeled and modified from Shuttle A, I think....the center had other controls which made the mfds tall and sort of thin...so I blanked out the part for the custom controls, but the two squares are part of my whole vc_mesh....do I need to detach their faces and make the squares into 2 meshes without joining solids for it to work?... I tried to think about stripping down DG or Shuttle A...to include anything about the two MFD's alone...but I know I will work for ever leaving one little detail out that is of all importance to having the thing function and I won't know what it is. Thanks for your help tho.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
This is what I use.

But for some reason I get nothing to show on the mfd squares in the vc mesh
Code:
bool RANGER1::clbkLoadVC(int id)
{
	VCHUDSPEC hud;
	VCMFDSPEC mfd;

	//Virtual cockpit elements
	if ((id >= 0) && (id<1)){
		if (id == 0){
			SetCameraDefaultDirection(_V(0, 0, 1));
			SetCameraOffset(_V(-.706, .903, .61));
			SetCameraShiftRange(_V(0, 0, 0.1), _V(-0.2, 0, 0), _V(0.2, 0, 0));
			oapiVCSetNeighbours(-1, -1, -1, -1);

			hud.nmesh = 1;
			hud.ngroup = 65;//HUD MESH
			hud.hudcnt = _V(0, 0, 0);
			hud.size = 1;
			oapiVCRegisterHUD(&hud);
			mfd.ngroup = 66;//LEFT MFD MESH
			mfd.nmesh = 1;
			oapiVCRegisterMFD(0, &mfd);
			mfd.ngroup = 67;//RIGHT MFD MESH
			mfd.nmesh = 1;
			oapiVCRegisterMFD(1, &mfd);
		}
	}
	return 1;
}
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,085
Reaction score
901
Points
128
Website
francisdrakex.deviantart.com
To use the clbkLoadVC(), all its parameters must be defined, as shown in the preceding functions. I think, the MFD redraw is done automatically by the clbk (callback) function, which is triggered in each timestep.

My panel mesh are simply 3 rectangles, that is 2 MFDs + 1 HUD.
This makes counting the mesh groups easy, to designate the correct rectangle.

The nice visual stuff I show in a separate cockpit mesh.
____
@gattis: Are the MFD & HUD rectangles textured? That means, if you comment out the code to show the MFDs/HUD, do you see a texture on them?
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
RANGERHUD2_zpstso4trub.jpg
You see a white box. I know you have to flag them as 2

What do you mean my textured?

MSHX1
GROUPS 3
LABEL MFDRIGHT
MATERIAL 1
TEXTURE 0
FLAG 2
GEOM 4 2 ;Group 0 (MFDRIGHT) mfd00
-.673419 .670013 1.350784 -.000034 .218138 -.975918 1 0
-.673418 .86388 1.394117 -.000035 .218138 -.975918 1 1
-.474768 .86388 1.39411 -.000034 .218138 -.975918 0 0
-.474769 .670013 1.350777 -.000034 .218137 -.975918 0 1
0 1 2
0 2 3
LABEL MFDLEFT
MATERIAL 1
TEXTURE 0
FLAG 2
GEOM 4 2 ;Group 1 (MFDLEFT) mfd00
-.978929 .670013 1.352165 -.000037 .21814 -.975917 1 0
-.978928 .86388 1.395498 -.000035 .218138 -.975918 1 1
-.780278 .86388 1.395491 -.000037 .21814 -.975917 0 0
-.780279 .670013 1.352157 -.000039 .218142 -.975917 0 1
0 1 2
0 2 3
LABEL CENTERHUD
MATERIAL 1
TEXTURE 0
FLAG 3
GEOM 4 2 ;Group 2 (CENTERHUD) mfd00
-1.118246 1.087693 1.297959 -.000036 -.001595 -.999999 1 0
-1.118246 1.491372 1.297315 -.000036 -.001595 -.999999 1 1
-.348128 1.491372 1.297287 -.000036 -.001595 -.999999 0 0
-.348128 1.087693 1.297931 -.000036 -.001595 -.999999 0 1
0 1 2
0 2 3
MATERIALS 1
mfd00
MATERIAL mfd00
1 1 1 1
.984314 .984314 .984314 1
.2 .2 .2 1 100
0 0 0 1
TEXTURES 0
 
Last edited:

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Here are some pics of the inside of my VC. The last one is the MFD panel of the Shuttle A. I found the actual .bmp in the files for the ship and it was 512 x 1024...both MFD's and some custom controls in the middle so I thought, hmm, that would be two .dds files 512x512 if I split it down the middle and blanked out the custom control half on each. This means the MFD part is only part of each square with my dummy control stick in the middle. Don't know if this is going to work or not. My two perfectly square textures are mapped onto Groups 28 and 29 in Mesh Wizard, they may not fit on the blank part tho. But I guess I need to put a square mesh group on the window too? Was reading that you would make it the color you are using as the transparent color, right? I want to see through the window???? Was wondering if I used someone elses code before I changed the VECTOR3's and stuff would I end up seeing floating green orbits and maps in the air in my cockpit until i put them where they are supposed to be? The complete code on Shuttle A and DG seem to be way more extensive then the above, even just in what's mentioned for HUD and MFDs. With redraw, redraw, probably cross-referenced with the 2D panels that I am not even doing. I think I've finally bitten off more than I can chew. I haven't started my shrinking of the Shuttle A code yet, but I know its just gonna bring me extreme pain with declarations and 100 errors needing to put extensive stuff in the header file...when I barely know what I'm doing. Would like to be able to put that beer toasting emoticon at the bottom of one of these messages tho...If I could get help and I could get this thing right. But I may have reached the end....not that I won't try tho.... not to be defeated ??? Hmm?:facepalm:
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
I got mine to work. But the texturing is off. I am using a plain white texture. What should I be using to check alignment,.....

Email me and I can help.

Code:
bool RANGER1::clbkLoadVC(int id)
{
	VCHUDSPEC hud;
	VCMFDSPEC mfd;

	//Virtual cockpit elements

	{
		SetCameraDefaultDirection(_V(0, 0, 1));
		SetCameraOffset(_V(-.706, .903, .61));
		SetCameraShiftRange(_V(0, 0, 0.1), _V(-0.2, 0, 0), _V(0.2, 0, 0));
		oapiVCSetNeighbours(-1, -1, -1, -1);

		hud.nmesh = 6;//WHICH MECH NUMBER
		hud.ngroup = 0;//HUD MESH GROUP
		hud.hudcnt = _V(0, 0, 0);
		hud.size = 1;
		oapiVCRegisterHUD(&hud);
		mfd.ngroup = 1;//LEFT MFD 
		mfd.nmesh = 6; //WHICH MECH NUMBER
		oapiVCRegisterMFD(0, &mfd);
		mfd.ngroup = 2;//RIGHT MFD 
		mfd.nmesh = 6;  //WHICH MECH NUMBER
		oapiVCRegisterMFD(1, &mfd);

	}
	return 1;
}
 
Last edited:

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,085
Reaction score
901
Points
128
Website
francisdrakex.deviantart.com
What do you mean my textured?

MSHX1
GROUPS 3
LABEL MFDRIGHT
MATERIAL 1
TEXTURE 0

The panel shall be textured in the modelling programm, before exporting it to Orbiter. So the Texture value in the mesh file would show a number, not 0.
The Texture list at the end of the file would then show like

TEXTURES 1
black.dds

or any other .dds file.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Thanks. I just made a texture with words/text so I can tell orientation,...

Got it going.
 

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Will your MFD's allow you to work all buttons on sides and bottom and let you monitor
and change flight aspects? I have all this code that you don't have, although it has not been tested , I'm trying to resolve only three errors in it. Posted that is SDK....
If your MFDs are indeed clickable and usable with easier code ...let me know ...and you bet I'll email for the help.

Code:
bool chippersat::clbkLoadVC (int id) 
{ 
 
	SetCameraOffset (_V(0,-1.75,-1.5)); SetCameraDefaultDirection (_V(0,-1,0)); 
 SetCameraRotationRange (RAD*180, RAD*180, RAD*180, RAD*180); 
 SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); 
 return 1; 
static VCMFDSPEC mfds_left  = {1, 23};
	static VCMFDSPEC mfds_right = {1, 24}; 
	static VCHUDSPEC hud_pilot  = {1, 52,{-0.600,2.441,16.5381},0.38};
	ReleaseSurfaces();

	switch (id) {
	case 0:
		// MFDs on the front panel
		oapiVCRegisterMFD (MFD_LEFT, &mfds_left);
		oapiVCRegisterMFD (MFD_RIGHT, &mfds_right);
		oapiVCRegisterHUD (&hud_pilot);
		
		 
		// MFD1  butto
		tex1 = oapiGetTextureHandle (vcmesh_tpl,13); 
		oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND,tex1);		
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS,
							_V(-0.873975f, 2.07783f, 16.3458f),
							_V(-0.898166f, 2.07693f, 16.3477f),
							_V(-0.873975f, 1.95705f, 16.2895f),
							_V(-0.898166f, 1.95616f, 16.2914f));
	
		oapiVCRegisterArea (AID_MFD1_RBUTTONS, _R( 49,9, 73,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND,tex1);
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_RBUTTONS,
							_V(-0.691069f, 2.08459f, 16.3313f),
							_V(-0.715260f, 2.08370f, 16.3332f),
							_V(-0.691069f, 1.96381f, 16.2750f),
							_V(-0.715260f, 1.96292f, 16.2769f));

		oapiVCRegisterArea (AID_MFD1_BBUTTONS,PANEL_REDRAW_NEVER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_BBUTTONS,
					_V(-0.833854424f,1.94565778f,16.28032296f),
					_V(-0.755381769f,1.948559073f,16.27410013f),
					_V(-0.833854424f,1.935458958f,16.27556799f),
					_V(-0.755381769f,1.938360251f,16.26934516f));
		
		//MFD2 buttons 
		oapiVCRegisterArea (AID_MFD2_LBUTTONS, _R(90 ,9,114,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND,tex1);		
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_LBUTTONS,
							_V(-0.424380f, 2.09445f, 16.3101f),
							_V(-0.448571f, 2.09356f, 16.3120f),
							_V(-0.424380f, 1.97367f, 16.2538f),
							_V(-0.448571f, 1.97278f, 16.2557f));
	
		oapiVCRegisterArea (AID_MFD2_RBUTTONS, _R( 131,9, 155,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND,tex1);
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_RBUTTONS,
							_V(-0.241474f, 2.10121f, 16.2956f),
							_V(-0.265665f, 2.10032f, 16.2975f),
							_V(-0.241474f, 1.98044f, 16.2393f),
							_V(-0.265665f, 1.97954f, 16.2412f));

		oapiVCRegisterArea (AID_MFD2_BBUTTONS,PANEL_REDRAW_NEVER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
		oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_BBUTTONS,
					_V(-0.384259211f,2.015958238f,16.26969654f),
					_V(-0.305786556f,2.018859532f,16.26347371f),
					_V(-0.384259211f,1.952081406f,16.23991538f),
					_V(-0.305786556f,1.954982699f,16.23369255f));
			
		
	 
		
	};

	InitPanel(-1);// VC is -1
 return true;
  


 }  
 bool chippersat::clbkVCMouseEvent (int id, int event, VECTOR3 &p)
{
	static int ctrl = 3;
	float th_level;
	int mode,pmode;
	int mfd;
	int mx,my;
	
	switch (id) {
	case AID_MFD1_LBUTTONS:
	case AID_MFD1_RBUTTONS:
	case AID_MFD2_LBUTTONS:
	case AID_MFD2_RBUTTONS:
		my=(int)(p.y*209);
		if (my%39 < 20) {
			mfd = (id <= AID_MFD1_RBUTTONS ? MFD_LEFT : MFD_RIGHT);
			int bt = my/39 + (id == AID_MFD1_LBUTTONS || id == AID_MFD2_LBUTTONS ? 0 : 6);
			oapiProcessMFDButton (mfd, bt, event);
			return true;
		}
		break;
	case AID_MFD1_BBUTTONS:
	case AID_MFD2_BBUTTONS:
		mfd = (id == AID_MFD1_BBUTTONS ? MFD_LEFT : MFD_RIGHT);
		mx=(int)(p.x * 133.0f);
		if      (mx <  32)            oapiToggleMFD_on (mfd);
		else if (mx >= 50 && mx < 82) oapiSendMFDKey (mfd, OAPI_KEY_F1);
		else if (mx >= 100)           oapiSendMFDKey (mfd, OAPI_KEY_GRAVE);
		return true;
	 

	}
return false;
}


// --------------------------------------------------------------
// Draw the virtual cockpit instruments
// --------------------------------------------------------------
bool chippersat::clbkVCRedrawEvent (int id, int event, SURFHANDLE surf)
{

	switch (id) {
	case AID_MFD1_LBUTTONS:
			RedrawPanel_MFDButton (surf, MFD_LEFT, 0);
			return true;
	case AID_MFD1_RBUTTONS:
			RedrawPanel_MFDButton (surf, MFD_LEFT, 1);
			return true;
	case AID_MFD2_LBUTTONS:
			RedrawPanel_MFDButton (surf, MFD_RIGHT, 0);
			return true;
	case AID_MFD2_RBUTTONS:
			RedrawPanel_MFDButton (surf, MFD_RIGHT, 1);
			return true;
	 

	}
return false;
};
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok this is weird. I just noticed my HUD display in VC mode only displays some of the info. Like only the top portion. No idea why it isn't.
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,085
Reaction score
901
Points
128
Website
francisdrakex.deviantart.com
You can influence the displayed area with parameters of
VCHUDSPEC huds;

Size:
huds.size = 0.25; // typical value

Location:
ofs_hud = _V(0, 1.6, 2.5); // define where it is
huds.hudcnt = ofs_hud;
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Weird. I adjusted the z camera value and can all the lines
 
Top