OHM CMG v2.0

Michael_Chr

New member
Joined
Jul 16, 2013
Messages
153
Reaction score
0
Points
0
Location
Virklund
Any solutions to the earlier reported HUD issue?

My screen res is 1920 by 1200 and the data that the CMG vessel put on the HUD doesnt look that fine. Switching to 1024*768 solves it...but that is not really a solution.
If the original author is not active anymore maybe another "wizard" can help remake the original CMG. I can see the source file are in the SDK folder:).
There are also the HUDdrawer solution that Enjo has created...hint hint :tiphat:
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
Here is the code for the HUD.
I am not if just change the position of where things get displayed
Code:
bool CMG::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
	double w = hps->W;
	//DRAW UNCHANGEABLE TEXT ON HUD
	char Enabled[] = {"ENABLED"};
	char Disabled[] = {"DISABLED"};

	//CHANNELS CAPTIONS
	{

		skp->SetTextColor(RGB(255,255,255));
		char RotRateText[] = {"Rotation rate[°/s]:"};
		skp->Text(20,200,RotRateText,strlen(RotRateText));

		char AttitudeChannelText[] = {"Attitude keeping:"};
		skp->Text(20,240,AttitudeChannelText,strlen(AttitudeChannelText));

		char FreeDriftStatus[] = {"Free drift status:"};
		skp->Text(20,260,FreeDriftStatus,strlen(FreeDriftStatus));

		char ZeroAngularStatus[] = {"Zero Angular status:"};
		skp->Text(20,280,ZeroAngularStatus,strlen(ZeroAngularStatus));
	}

	//DRAW IF ENABLED OR DISABLED
	if(bAtt)
	{
		skp->SetTextColor(0x00ff00);
		skp->Text(210,240,Enabled,strlen(Enabled));
	}
	else
	{
		skp->SetTextColor(0x0000ff);
		skp->Text(210,240,Disabled,strlen(Disabled));
	}

	if(bFree)
	{
		skp->SetTextColor( 0x00ff00);
		skp->Text(210,260,Enabled,strlen(Enabled));
	}
	else
	{
		skp->SetTextColor( 0x0000ff);
		skp->Text(210,260,Disabled,strlen(Disabled));
	}

	if(bZero)
	{
		skp->SetTextColor( 0x00ff00);
		skp->Text(210,280,Enabled,strlen(Enabled));
	}
	else
	{
		skp->SetTextColor( 0x0000ff);
		skp->Text(210,280,Disabled,strlen(Disabled));
	}

	//DISPLAY ROTATION RATE TEXT
	skp->SetTextColor(RGB(0,255,0));
	char cRotRate[5];
	sprintf(cRotRate,"%.3lf",dRotSpeed/PI*180);
	skp->Text(210,200,cRotRate,5);

	//DISPLAY KEY SUMMARY
	skp->SetTextColor(RGB(255,255,255));
	char cOperateAtt[] = {"Attitude keeping mode - 3"};
	skp->Text(w-260,240,cOperateAtt,strlen(cOperateAtt));

	char cZeroAngular[] = {"Zero Angular mode - G"};
	skp->Text(w-260,260,cZeroAngular,strlen(cZeroAngular));
	
	char cFreeDrift[] = {"Free Drift mode - K"};
	skp->Text(w-260,280,cFreeDrift,strlen(cFreeDrift));




	//DISPLAY TARGETS CAPTIONS
	skp->SetTextColor( 0x00ffff);
	char cTgtP[] = {"Target pitch:"};
	skp->Text(20,400,cTgtP,strlen(cTgtP));
	
	char cTgtY[] = {"Target yaw:"};
	skp->Text(20,420,cTgtY,strlen(cTgtY));

	char cTgtR[] = {"Target roll:"};
	skp->Text(20,440,cTgtR,strlen(cTgtR));


	//DISPLAY TARGETS VALUES
	skp->SetTextColor( 0xffffff);
	char buf[4];
	sprintf(buf,"%.1lf",TargetAttitude.x);
	skp->Text(150,400,buf,strlen(buf));

	sprintf(buf,"%.1lf",TargetAttitude.y);
	skp->Text(150,420,buf,strlen(buf));

	sprintf(buf,"%.1lf",TargetAttitude.z);
	skp->Text(150,440,buf,strlen(buf));


	//DISPLAY CHANNEL MODIFICATION KEYS
	skp->SetTextColor( 0xbbbbbb);
	char cModP[] = {"Modify pitch target - NUM8/NUM2"};
	skp->Text(w-350,400,cModP,strlen(cModP));

	char cModY[] = {"Modify yaw target - NUM1/NUM3"};
	skp->Text(w-350,420,cModY,strlen(cModY));

	char cModR[] = {"Modify roll target - NUM4/NUM6"};
	skp->Text(w-350,440,cModR,strlen(cModR));

	char cEntP[] = {"Open pitch input box - CTRL-1"};
	skp->Text(w-350,460,cEntP,strlen(cEntP));

	char cEntY[] = {"Open yaw input box - CTRL-2"};
	skp->Text(w-350,480,cEntY,strlen(cEntY));

	char cEntR[] = {"Open roll input box - CTRL-3"};
	skp->Text(w-350,500,cEntR,strlen(cEntR));

	char cEntS[] = {"Open rotation rate input box - CTRL-4"};
	skp->Text(w-350,520,cEntS,strlen(cEntS));

	return true;
}
 

garyw

O-F Administrator
Administrator
Moderator
Addon Developer
Tutorial Publisher
Joined
May 14, 2008
Messages
10,485
Reaction score
209
Points
138
Location
Kent
Website
blog.gdwnet.com
My screen res is 1920 by 1200 and the data that the CMG vessel put on the HUD doesnt look that fine. Switching to 1024*768 solves it...but that is not really a solution.
If the original author is not active anymore maybe another "wizard" can help remake the original CMG. I can see the source file are in the SDK folder:).
There are also the HUDdrawer solution that Enjo has created...hint hint :tiphat:

Change the screen size, make a note of the keys, change the screen size back.

That's what I did but then I only use it for the ISS and to keep it pointing into the velocity vector.
 

Michael_Chr

New member
Joined
Jul 16, 2013
Messages
153
Reaction score
0
Points
0
Location
Virklund
Change the screen size, make a note of the keys, change the screen size back.

Way ahead of you...All the keys are by now printed out and pinned to the wall next to my workstation :lol:

But thx anyway :thumbup:
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,286
Reaction score
3,255
Points
203
Location
Toulouse
I don't want to stray too far from the original thread but... Is there an Universal solution for a similar CMG simulation ? Also, does it support high time warp factors ? Focus switch ?

My idea is to have something similar for various satellites that need to have their dishes/antennas/instruments pointed at a GBody center, a surface bac.. err base, or even another spacecraft ?

The finality of this would be to allow the player to build a satellite network that really works (if you've played RemoteTech in KSP, that's the idea). :hmm:
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
I thought about making a dialogue window/box with the outputs in it. Not done that with real numbers. I think the DG has stuff like that for an example
 

Cras

Spring of Life!
Donator
Joined
Apr 13, 2011
Messages
2,215
Reaction score
0
Points
36
Location
Los Angeles
Website
www.youtube.com
It is a CMG, a way to maintain attitude for a space station without having to use RCS thrusters.

---------- Post added at 01:09 PM ---------- Previous post was at 01:09 PM ----------

It is also a must-have addon for anyone doing space station related flights in Orbiter.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
ok. I am in new territory. I want to take the input value and display in a dialogue window.
Looking at the DG code.
Code:
void UpdateDamage (HWND hTab, DeltaGlider *dg)
{
	int i;
	char cbuf[256];

	i = (int)(dg->lwingstatus*100.0+0.5);
	sprintf (cbuf, "%d %%", i);
	SetWindowText (GetDlgItem (hTab, IDC_LEFTWING_STATUS), cbuf);
	oapiSetGaugePos (GetDlgItem (hTab, IDC_LEFTWING_SLIDER), i);
	i = (int)(dg->rwingstatus*100.0+0.5);
	sprintf (cbuf, "%d %%", i);
	SetWindowText (GetDlgItem (hTab, IDC_RIGHTWING_STATUS), cbuf);
	oapiSetGaugePos (GetDlgItem (hTab, IDC_RIGHTWING_SLIDER), i);
}

So what I need to display is what is entered for

Code:
case OAPI_KEY_4:
			{
				oapiOpenInputBox("Enter rotation rate(>0.001):",RotRateCallback,"",20,this);
				return 1;
			}

So when you open the dialogue i want it to display the info.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
I am getting no where but frustration on building an interface for this.

I have a dialogue box :
So you can push a button to enable the items. And it show show the values. But I haven't gotten it to change on the box like it does for rms.
 

Cras

Spring of Life!
Donator
Joined
Apr 13, 2011
Messages
2,215
Reaction score
0
Points
36
Location
Los Angeles
Website
www.youtube.com
I can feel your pain, but cannot offer any help, for the last time I attempted to code dialog boxes for an add-on of mine it truly kicked my rear end hard. All I got was non-working buttons, or CTDs.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
Ok. I started again to try to make a pop up interface.

But I have run into a weird issue. First I want the buttons to bool (true/false)

But I can't this HUD display to show. It is like it is not seeing it to go to it.
cpp
Code:
bool CMG4::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
//{
//bool CMG4::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
	//double w = hps->W;
	//DRAW UNCHANGEABLE TEXT ON HUD
	char engineDisplay[] = { "ENABLED" };
	char Disabled[] = { "DISABLED" };


	//strcpy(engineDisplay(), "Hover Thrust selected");
	//DRAW IF ENABLED OR DISABLED
	//if (bAtt)
	{
		skp->SetTextColor(0x00ff00);
		//skp->Text(210, 240, Enabled, strlen(Enabled));
		//skp->Text(210, 240, Enabled, strlen(Enabled));
		skp->Text(5, hps->H / 60 * 22, engineDisplay, strlen(engineDisplay));
	}
	//else
	//{
	//	skp->SetTextColor(0x0000ff);
	//	skp->Text(210, 240, Disabled, strlen(Disabled));
	//}

	sprintf(oapiDebugString(), "anim %2.2f", LGEAR_proc);

	return true;
}

h
Code:
	bool clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp);


---------- Post added 03-16-15 at 07:39 AM ---------- Previous post was 03-15-15 at 06:54 PM ----------

Got the HUD to work :)

But the biggest issue is how to display the values entered on the pop up window. I am looking at the Delta glider for examples. Of course any help would be nice:)

---------- Post added at 09:49 PM ---------- Previous post was at 07:39 AM ----------

looking at the DG damage control. I have this. But can't find this
UpdateDamage(hTab, CM);

in the dg code:

Code:
OOL CALLBACK EdPg3Proc (HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	DeltaGlider *dg;

	switch (uMsg) {
	case WM_INITDIALOG: {
		dg = (DeltaGlider*)oapiGetVesselInterface ((OBJHANDLE)lParam);
		GAUGEPARAM gp = { 0, 100, GAUGEPARAM::LEFT, GAUGEPARAM::BLACK };
		oapiSetGaugeParams (GetDlgItem (hTab, IDC_LEFTWING_SLIDER), &gp);
		oapiSetGaugeParams (GetDlgItem (hTab, IDC_RIGHTWING_SLIDER), &gp);
		UpdateDamage (hTab, dg);
		} break;
	case WM_COMMAND:
		switch (LOWORD (wParam)) {
		case IDC_REPAIR:
			dg = GetDG(hTab);
			dg->RepairDamage ();
			UpdateDamage (hTab, dg);
			return TRUE;
		}
		break;
Code:
BOOL CALLBACK EdPg3Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG4 *CM;

	switch (uMsg) {
	case WM_INITDIALOG: {
							CM = (CMG4*)oapiGetVesselInterface((OBJHANDLE)lParam);
							
							UpdateDamage(hTab, CM);
	} break;
	case WM_COMMAND:
		
		break;
	}
	return FALSE;
}



void UpdateDamage(HWND hTab, CMG4 *CM)
{
	int i;
	char cbuf[256];
	CM->lwingstatus = 10;
	i = (int)(CM->lwingstatus*100.0 + 0.5);
	sprintf(cbuf, "%d %%", i);
	SetWindowText(GetDlgItem(hTab, IDC_LEFTWING_STATUS), cbuf);
	
	
}


---------- Post added 03-17-15 at 06:24 AM ---------- Previous post was 03-16-15 at 09:49 PM ----------

This is what I have. But when i run it only what I have at the start shows up. It needs to go to Updatedamage. But not sure why this is undefined.
Error 3 error C3861: 'UpdateDamage': identifier not found C:\orbiter100830\Orbitersdk\samples\NEWCMG\CMG4.CPP 172 1 NEWCMG

Code:
CMG4 *GetCMG4(HWND hDlg)
{
	// retrieve DG interface from scenario editor
	OBJHANDLE hVessel;
//	SendMessage(hDlg, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
	return (CMG4*)oapiGetVesselInterface(hVessel);
}
BOOL CALLBACK CMG4_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG4 *sts = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
	// pointer to vessel instance was passed as dialog context

	switch (uMsg) {
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			oapiCloseDialog(hWnd);
			return TRUE;
			//case IDC_PLBAYOP:
			//	sts->plop->OpenDialog();
			//	break;
		case IDC_RMSOP1:
			oapiOpenDialogEx(g_Param.hDLL, IDD_DISPLAY, Damage_DlgProc, DLG_CAPTIONCLOSE, sts);
			break;


		}
		break;
	}
	return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

// ==============================================================
// Message callback function for RMS control dialog box
// ==============================================================
BOOL CALLBACK EdPg3Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG4 *CM;

	switch (uMsg) {
	case WM_INITDIALOG: {
							CM = (CMG4*)oapiGetVesselInterface((OBJHANDLE)lParam);
							CM = GetCMG4(hTab);
							UpdateDamage(hTab, CM);
	case WM_COMMAND:

		break;
	}
	}
	return FALSE;
}

BOOL CALLBACK Damage_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG4 *CM = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
	// pointer to vessel instance was passed as dialog context

	switch (uMsg) {
	case WM_INITDIALOG:
		return FALSE;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			oapiCloseDialog(hWnd);
			return TRUE;
		
		}
		break;
	}
	return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

void UpdateDamage(HWND hTab, CMG4 *CM)
{
	int i;
	char cbuf[256];
	CM->NEWHEADING = 10;
	i = (int)(CM->NEWHEADING);
	sprintf(cbuf, "%d %%", i);
	SetWindowText(GetDlgItem(hTab, IDC_HEADING), cbuf);
	
	
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
Somebody did a lot of math for this, right? :huh:
Yes.

But back to the display. Not sure when this is undefined?
Code:
Error    3    error C3861: 'UpdateDamage': identifier not found    C:\orbiter100830\Orbitersdk\samples\NEWCMG\CMG4.CPP    166    1    NEWCMG

It is there. It need to go to there to update the values.

void UpdateDamage(HWND hTab, CMG4 *CM)
{
int i;
char cbuf[256];
CM->NEWHEADING = 10;
i = (int)(CM->NEWHEADING);
sprintf(cbuf, "%d %%", i);
SetWindowText(GetDlgItem(hTab, IDC_HEADING), cbuf);
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
I decided to relook at this.
I am using the Deltaglider code as a guide.

I got the window to open but when I press on the button it does nothing.

Code:
BOOL CALLBACK Ctrl_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG *dg = (uMsg == WM_INITDIALOG ? (CMG*)lParam : (CMG*)oapiGetDialogContext(hWnd));
	// pointer to vessel instance was passed as dialog context

	switch (uMsg) {
	case WM_INITDIALOG:
		//UpdateCtrlDialog(dg, hWnd);
		return FALSE;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			oapiCloseDialog(hWnd);
			return TRUE;

			case IDC_HUD:
				oapiOpenDialog(g_Param.hDLL, IDD_HUDNEW, EdPg2Proc, dg);
				//oapiOpenDialog(g_Param.hDLL, IDD_HUD, EdPg2Proc, dg);
				break;
		}
		break;
	}
	return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}
trying to get oapiOpenDialog(g_Param.hDLL, IDD_HUDNEW, EdPg2Proc, dg); to open from the first window,
Code:
BOOL CALLBACK EdPg2Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CMG *dg;
	int i;

	switch (uMsg) {
	case WM_INITDIALOG: {
							char cbuf[256];
							dg = (CMG*)oapiGetVesselInterface((OBJHANDLE)lParam);
							for (i = 0; i < 4; i++)
								//SendDlgItemMessage(hTab, IDC_CHECK1 + i, BM_SETCHECK, dg->psngr[i] ? BST_CHECKED : BST_UNCHECKED, 0);
							sprintf(cbuf, "%0.2f kg", dg->GetMass());
							SetWindowText(GetDlgItem(hTab, IDC_MASS1), cbuf);
	} break;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		//case IDC_CHECK1:
		//case IDC_CHECK2:
		//case IDC_CHECK3:
		//case IDC_CHECK4: {
			//				 char cbuf[256];
				//			 i = SendDlgItemMessage(hTab, LOWORD(wParam), BM_GETCHECK, 0, 0);
					//		 dg = GetDG(hTab);
						//	 dg->psngr[LOWORD(wParam) - IDC_CHECK1] = (i ? true : false);
							// dg->SetPassengerVisuals();
							// dg->SetEmptyMass();
							// sprintf(cbuf, "%0.2f kg", dg->GetMass());
							// SetWindowText(GetDlgItem(hTab, IDC_MASS), cbuf);
		//} break;
		}
		break;
	}
	return FALSE;
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,715
Reaction score
2,684
Points
203
Location
Dallas, TX
OK. I got it to display info. But in the CMG code.
Code:
	sprintf(buf, "%.1lf", TargetAttitude.x);
	skp->Text(150, 400, buf, strlen(buf));

	sprintf(buf, "%.1lf", TargetAttitude.y);
	skp->Text(150, 420, buf, strlen(buf));

	sprintf(buf, "%.1lf", TargetAttitude.z);
	skp->Text(150, 440, buf, strlen(buf));

trying to get TargetAttitude.x,.... to display in the window
It has these values which need to be displayed in the window or mfd. Lisias mention using scenario editor code
he asked here

http://www.orbiter-forum.com/showthread.php?p=514234&postcount=40

how to use it but haven't seen a response. It has tied to another subject.
 
Top