API Question Troubleshooting a virtual cockpit HUD

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
I'm having issues with the HUD in my lunar lander's VC.

The mesh group and hudspec are properly defined but i'm not getting any of the normal HUD data.

Observe...

picture.php


vs. the same exact view in glass cockpit.

picture.php


The docking gates, target box, and velocity piper should all be visible but they are not.


Camera and hud specs are as follows...

in clbkLoadVC ()'s "switch (id)" statement...
Code:
	case 2: // COAS Reticle
		SetCameraOffset (ASC_VC_CAMERAPOS[2] + ofs);	// Camera position
		SetCameraDefaultDirection (Y_AXIS);		// Camera direction
		SetCameraRotationRange ( 0, 0, 0, 0);	// I want a fixed camera while in overhead view 
   		oapiCameraSetCockpitDir ( 0, 0);		// Don't forget to center the camera				
		oapiVCSetNeighbours ( 0, 0, 0, 0);	// Set neighbors (any change returns us to default "0" position)	

		// Initialise HUD
		hud_COAS.nmesh = meshVC;
		hud_COAS.ngroup = GRP_VC_CoasHUDPlane;
		hud_COAS.hudcnt = ASC_VC_HUDPOS + ofs;
		hud_COAS.size = 0.05;

		oapiVCRegisterHUD (&hud_COAS);

		break;

"VCHUDSPEC hud_COAS" is a class member, "ofs" is the position of the VC mesh within the vessel. Camera and HUD position are as follows...

Code:
const VECTOR3	ASC_VC_CAMERAPOS[3]			= {{-0.50, 0.78, 1.19}, { 0.50, 0.78, 1.19}, [COLOR="red"]{-0.59, 0.78, 1.04}[/COLOR]};
const VECTOR3	ASC_VC_HUDPOS			= [COLOR="red"]{-0.59, 1.035, 1.04}[/COLOR];
 
Last edited:

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
232
Reaction score
117
Points
58
Location
Lehi, Utah
Do you have a clbkDrawHUD that is calling the base class method?

Code:
bool MyShip::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
	if (oapiCockpitMode() != COCKPIT_VIRTUAL) return false;

	// draw the default HUD
	VESSEL3::clbkDrawHUD(mode, hps, skp);
	return true;
}
 
Last edited:

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
clbkDrawHud has not been overloaded so everything should be default.

Additional interesting thing...

picture.php


Increasing "hud_COAS.size" from 0.05 to 0.5 causes parts of the display to become visible, but they are in the wrong place.
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
232
Reaction score
117
Points
58
Location
Lehi, Utah
I had to overload clbkDrawHUD just to get the default to work. I'm doing nothing in there other other then default functionality.

in clbkLoadVC I have this:

Code:
	static VCHUDSPEC huds = { 1, MESH_GROUP_HUD, {0.0, 0.8, 15.25}, 0.12 };
	oapiVCRegisterHUD(&huds); // HUD parameters

Then I overload the function listed above. That gives me a working default HUD.

From your description, it sounds like you are trying to customize the HUD but not calling the base class method. Or at least, Orbiter thinks you have overridden that method and is not calling the default implementation.

I've never done anything beyond implementing a default HUD, so beyond that I'm out of my element.
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
it sounds like you are trying to customize the HUD but not calling the base class method.

I'm not and I haven't.

clbkRenderHud is overloaded so I can display spacecraft status alerts in "glass cockpit mode" but clbkDrawHud (the VC's hud) is untouched.

I made hud_COAS a class variable, instead of a static, to avoid comparability issues with UMMU and to prevent other vessels derived from my LunarModule class from overriding the hud specs.

That said I tried your method.

Code:
static VCHUDSPEC huds = { meshVC, GRP_VC_CoasHUDPlane, (ASC_VC_HUDPOS + ofs), 0.15};
oapiVCRegisterHUD (&huds); // HUD parameters

Same problem.

---------- Post added at 09:32 ---------- Previous post was at 09:27 ----------

Orbiter thinks you have overridden that method and is not calling the default implementation.

If that were the case the case the "up" boundary arrows would not be appearing at the bottom of the draw area in the third screen shot. The HUD would simply be blank.
 
Last edited:

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
232
Reaction score
117
Points
58
Location
Lehi, Utah
Does your VC occupy the same coordinate space as it would in the vessel mesh? I notice you are applying an offset, so I assume it is being modeled separately.

I can duplicate the type of issues you are seeing if I intentionally alter the hudcnt property to some incorrect value, then the perspective needed to make the HUD work is wrong and you get a distorted view.

Long story short (and maybe not much help) I'm guessing the location of that mesh is incorrect with relation to the camera position.


Also from the 'you learn something new' department, I went back and commented out my clbkDrawHUD method and my HUD still works just fine. Less code is better.
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
Does your VC occupy the same coordinate space as it would in the vessel mesh?

It does, the offset is to account for shifts in the CoG due to staging. Without it the camera does not stay "in" the cockpit.

That is interesting though.
 

SiameseCat

Addon Developer
Addon Developer
Joined
Feb 9, 2008
Messages
1,699
Reaction score
1
Points
0
Location
Ontario
clbkDrawHud has not been overloaded so everything should be default.

Additional interesting thing...

picture.php


Increasing "hud_COAS.size" from 0.05 to 0.5 causes parts of the display to become visible, but they are in the wrong place.
I notice that, in the clbkLoadVC code, the camera direction is along the Y axis (instead of the Z axis). I wonder if the Orbiter HUD code is drawing the HUD as if the camera is facing along the Z axis instead.
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
I notice that, in the clbkLoadVC code, the camera direction is along the Y axis (instead of the Z axis). I wonder if the Orbiter HUD code is drawing the HUD as if the camera is facing along the Z axis instead.

That's it,

I moved the hud from the vc's docking window to the vc's "default" control panel view and now it works fine.

Looks like a bug report is in order.
 
Top