Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Development
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Addon Development Developers post news, updates, & discussions here about your projects in development.

Reply
 
Thread Tools
Old 12-07-2016, 12:57 PM   #301
n122vu
Addon Developer
 
n122vu's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Thanks. I got the meshes to show. BUT. We need to external ship to show in the cockpit view also. This is why the interior and exterior were combined.

The reason is so in cockpit view you can see the ships docked.
Could you make only the relevant external parts that need to be visible actually be part of the VC?
n122vu is offline   Reply With Quote
Thanked by:
Old 12-07-2016, 01:18 PM   #302
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Well that would be the whole mesh. We have camera so you can see the 2 Landers and rangers docks. LEt me ask the others about the having those camera and then the cockpit view and vc are internal


Since you only have 1 external camera.

With the 256 x256 texture it seems to help also.
gattispilot is offline   Reply With Quote
Thanked by:
Old 12-09-2016, 11:06 PM   #303
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Confused. Iam using a 256x256 texture. I adjusted the values to fit the new texture. But no bars and no text?

So I am running the debugger.

It seems to break here:
Code:
	SetMeshVisibilityMode(meshi_Vessel = AddMesh(meshhg_Vessel = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\endurance14")), MESHVIS_ALWAYS | MESHVIS_EXTPASS);
	SetMeshVisibilityMode(meshi_VC1 = AddMesh(meshhg_Vessel), MESHVIS_VC);
	SetMeshVisibilityMode(meshi_VC = AddMesh(meshhg_VC = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\ENDURANCE36NEWvc")), MESHVIS_VC);
Code:
	MESHHANDLE meshhg_Vessel, meshhg1_Vessel, meshhg_VC, meshhg_CREW[5];
	UINT meshi_Vessel, meshi_VC, meshi_VC1, meshi_CREW[5];
It breaks on this line:
Code:
	SetMeshVisibilityMode(meshi_VC = AddMesh(meshhg_VC = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\ENDURANCE36NEWvc")), MESHVIS_VC);


---------- Post added 12-09-16 at 05:42 AM ---------- Previous post was 12-08-16 at 06:36 PM ----------

I redid the code following the DG example

but it still has a break here: where it loads the VC

Code:
SetMeshVisibilityMode(AddMesh(meshhg_Vessel = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\endurance14")), MESHVIS_EXTERNAL);


	//meshi_VC1 = AddMesh("INTERSTELLAR\\VESSEL\\ENDURANCE\\endurance14");
	//SetMeshVisibilityMode(meshi_VC1, MESHVIS_VC);


	SetMeshVisibilityMode(AddMesh(meshhg_VC = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\ENDURANCE36NEWvc")), MESHVIS_VC);
I also declared;
Code:
meshhg_VC = NULL;
	meshhg_Vessel = NULL;
and in the h:
Code:
MESHHANDLE meshhg_Vessel, meshhg_VC;


---------- Post added at 05:06 PM ---------- Previous post was at 05:42 AM ----------

Well I went back to this:
Code:
	SetMeshVisibilityMode(meshi_Vessel = AddMesh(meshhg_Vessel = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\endurance14")), MESHVIS_ALWAYS | MESHVIS_EXTPASS);
	SetMeshVisibilityMode(meshi_VC1 = AddMesh(meshhg_Vessel), MESHVIS_VC);
	SetMeshVisibilityMode(meshi_VC = AddMesh(meshhg_VC = oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\ENDURANCE\\ENDURANCE36NEWvc")), MESHVIS_VC);
Still no hud and bar and drawing on vc.

I put this here to see if it goes there and it does.
Code:
void TESTVC::RedrawPanel_Fuelstatus(SURFHANDLE surf, int part)

{
	
	sprintf(oapiDebugString(), "Fuel %f", fuel_percent);
	
	//SURFHANDLE const tex3 = oapiGetTextureHandle(meshhg_VC,5 );
	char cbuf[20];
	HDC hDC = oapiGetDC(surf);



	
	level2 = GetPropellantMass(tank);

	SelectObject(hDC, g_Param.hBrush[3]);//green box

	level3 = ((level2 / FUELMASS)*118.5);
	Rectangle(hDC, 2, 174, (int)(57.0 + level3), 217);  //fuel

	//THRUST
	level = GetThrusterLevel(th_main[0]);
	//double level2 = GetPropellantMass(tank);

	SelectObject(hDC, g_Param.hBrush[3]);//green box
	Rectangle(hDC, 57, 56, (int)(57 + level * (173 - 57)), 800);//thrust
	//POD
	SetTextColor(hDC, RGB(0, 153, 0));
	SetTextAlign(hDC, TA_LEFT);
	SetBkMode(hDC, TRANSPARENT);

	SelectObject(hDC, g_Param.hFont[2]);

	if (PODSel == 1) {
		sprintf(cbuf, "POD 1 Selected", 14);
		TextOut(hDC, 72, 200, cbuf, strlen(cbuf));
...
	}
Code:
bool TESTVC::clbkLoadGenericCockpit() {
	viewController->HandleLoadGC();
	return true;
}

bool TESTVC::clbkLoadVC(int id) { // ID is the Preset Camera Position
	SURFHANDLE const tex3 = oapiGetTextureHandle(meshhg_VC, TEX_ENDURANCE36NEWVC_ENDURANCEVC2F);


	viewController->HandleLoadVC(id);
mfdController->HandleLoadVC(id);	
	oapiVCRegisterArea(AID_FUELSTATUS, _R(0, 0, 256, 256), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
	//oapiVCRegisterArea(AID_THRUSTSTATUS, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
	//oapiVCRegisterArea(AID_PODSTATUS, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);

	oapiVCRegisterHUD(&huds);

	return HandleLoadVC(id);
}

bool TESTVC::HandleLoadVC(UINT const id)
{



	return true;
}

bool TESTVC::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{
	bool result = false;
	result = result || mfdController->HandleMouseEvent(id, event, p);
	result = result || VCMouseEvent(id, event, p);
	return result;
}

bool TESTVC::VCMouseEvent(int const id, int const event, VECTOR3& const p)
{



	return false; // We must return false, as we didn't processed the event!
}



bool TESTVC::clbkVCRedrawEvent(int id, int event, SURFHANDLE surf) {
	bool result = false;
	result = result || mfdController->HandleRedrawEvent(id, event, surf);


	result = result || VCRedrawEvent(id, event, surf);


	{

		switch (id) {
		case AID_FUELSTATUS:
			RedrawPanel_Fuelstatus(surf, id - AID_FUELSTATUS);
			//sprintf(oapiDebugString(), "Fuel %f", fuel_percent);
			return true;
	
		}
		//	return false;



	}
	return result;
}

bool TESTVC::VCRedrawEvent(int const id, int const event, SURFHANDLE const surf) {
	return false;
}
When I exit I get a ctd also.

Last edited by gattispilot; 12-09-2016 at 11:48 AM.
gattispilot is offline   Reply With Quote
Old 12-09-2016, 11:44 PM   #304
marcogavazzeni
Addon Developer
Default

Excluding the design of the bars, it works properly? Did you check that "tex3" corresponds to the right texture?
marcogavazzeni is offline   Reply With Quote
Old 12-09-2016, 11:59 PM   #305
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks. Well the bars and the text output.

Code:
	SURFHANDLE const tex3 = oapiGetTextureHandle(meshhg_VC, TEX_ENDURANCE36NEWVC_ENDURANCEVC2F);
It shows it has the 8 texture.
Code:
// Number of textures:
#define NTEX_ENDURANCE36NEWVC	 	8

// Named textures:
#define TEX_ENDURANCE36NEWVC_DG_VC1	 	2
#define TEX_ENDURANCE36NEWVC_ENDURANCECOLORS	 	7
#define TEX_ENDURANCE36NEWVC_ENDURANCENAVBUTTONSNEW	 	5
#define TEX_ENDURANCE36NEWVC_ENDURANCENEWCARGOCENTER	 	6
#define TEX_ENDURANCE36NEWVC_ENDURANCEVC2E	 	3
#define TEX_ENDURANCE36NEWVC_ENDURANCEVC2F	 	8
#define TEX_ENDURANCE36NEWVC_MFD_DYNAMIC_05	 	4
#define TEX_ENDURANCE36NEWVC_SCREEN	 	1
gattispilot is offline   Reply With Quote
Old 12-11-2016, 09:46 PM   #306
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Ok. Endurance and LAnder are using a 256 texture.

2 questions:
1 IS there a way to sharpen the text on the texture? I use Paint and added as text. I know I can paint on the texture but it will use fps?



2nd question. The center is a mfd but how can we write it to be on on with no the focus vessel?

When focused we can do this;
Code:
BEGIN_FOCUS
  Ship LANDER
END_FOCUS

BEGIN_CAMERA
  TARGET LANDER
  MODE Cockpit
  FOV 60.00
END_CAMERA

BEGIN_HUD
  TYPE Surface
END_HUD

BEGIN_MFD Left
  TYPE Orbit
  PROJ Frame
  FRAME Ecliptic
  REF Earth
END_MFD

BEGIN_MFD Right
  TYPE Orbit
  PROJ Frame
  FRAME Ecliptic
  REF Earth
END_MFD

BEGIN_MFD 5
  TYPE Surface
END_MFD

BEGIN_VC
END_VC
Or can hard code in on and always surface?
gattispilot is offline   Reply With Quote
Thanked by:
Old 12-16-2016, 10:53 AM   #307
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Well got good fps. I just painted on the labels that were fuzzy. All that we lack is the ranger. The code is the part we have to fix. I think I know what the issue is but not sure how to fix it. We have the code in a bitbucket if any one want s to dare.

---------- Post added 12-16-16 at 04:53 AM ---------- Previous post was 12-15-16 at 08:37 AM ----------

Well another issue. The Lander has 2 attachment points for cargo pods. Their are 2 keys of keys to attach/detach.

What happens is if one point has a pod. When you try to attach a new vessel/pod. It steals the attached vessel.

So how can I tell it only attached vessels not attached?

CARGO1 = CreateAttachment(false, _V(0, 3.365, 1.30), _V(0, 0, 1), _V(0, -1, 0), "CARGO1");
CARGO2 = CreateAttachment(false, _V(0, 3.365, -.35), _V(0, 0, 1), _V(0, -1, 0), "CARGO2");


Code:
void LANDER6::AttachCargo(){
	VECTOR3 aphpos, aphdir, aphrot, gaph;
	VECTOR3 shippos, shipdir, shiprot, gpship;

	// get attachment point positions based on selected point
	// get attachment point positions based on selected point


	GetAttachmentParams(CARGO1, aphpos, aphdir, aphrot);


	// change the position to a global one rather then a local one. This will allow me to offset it from the local center.
	// the local position is stored in gaph
	Local2Global(aphpos, gaph);

	for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
		OBJHANDLE hV = oapiGetVesselByIndex(i);    //get handle for ship
		//            if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0  ){  //restrict to only QuadJ ships to make it easy.

		// Look for any ship with a child attach point. This allows the Mule to grap any object
		if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...

		oapiGetGlobalPos(hV, &gpship); // get global postion of ship and put into gpship

		if (dist(gpship, gaph) < oapiGetSize(hV)) { // Make sure that the ship is close enough to the mule
			// looks close enough so lets look for that attach point

			VESSEL *v = oapiGetVesselInterface(hV);
			// Only look for child attach point
			DWORD nAttach = v->AttachmentCount(true); //Get attachment count. I do this so that I can grap any child point.
			if (nAttach > 0){ // Only continue if ship has a child attach point
				for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
					ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
					//* thiswould allow me to filter out all but QJ ships but I don't want to right now
					const char *id = v->GetAttachmentId(hAtt);
					if (strncmp(id, "LANDER", 6)) continue; // attachment point not compatible
					// */
					v->GetAttachmentParams(hAtt, shippos, shipdir, shiprot); //lets get the attach point position
					v->Local2Global(shippos, gpship); // and change it to a global position Recycle of gpship cause I can
					if (dist(gpship, gaph) < MAX_GRAP_DIST) { // Is it close enough to grab?
						apd = dist(gpship, gaph);
						// Yes! Then lets grab the little bugger and get out of here
						// Yes! Then lets grab the little bugger and get out of here
						if (do_attach > 0){
							do_attach = 0;


							if (!GetAttachmentStatus(CARGO1))
							{
								//Free so do the attach
								AttachChild(hV, CARGO1, hAtt);
								CARGO1ATTACH = 1;
							}
							else{
								//something already attached
							}


						}
					}
					return;
				}
			}
		} // End of for j
	}
}


void LANDER6::DetachCargo()
{
	DetachChild(CARGO1, 0.0);
	CARGO1OLDATTACH = 1;
	CARGO1ATTACH = 0;
}

void LANDER6::AttachCargo1(){
	VECTOR3 aphpos, aphdir, aphrot, gaph;
	VECTOR3 shippos, shipdir, shiprot, gpship;

	// get attachment point positions based on selected point
	// get attachment point positions based on selected point


	GetAttachmentParams(CARGO2, aphpos, aphdir, aphrot);


	// change the position to a global one rather then a local one. This will allow me to offset it from the local center.
	// the local position is stored in gaph
	Local2Global(aphpos, gaph);

	for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
		OBJHANDLE hV = oapiGetVesselByIndex(i);    //get handle for ship
		//            if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0  ){  //restrict to only QuadJ ships to make it easy.

		// Look for any ship with a child attach point. This allows the Mule to grap any object
		if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...

		oapiGetGlobalPos(hV, &gpship); // get global postion of ship and put into gpship

		if (dist(gpship, gaph) < oapiGetSize(hV)) { // Make sure that the ship is close enough to the mule
			// looks close enough so lets look for that attach point

			VESSEL *v = oapiGetVesselInterface(hV);
			// Only look for child attach point
			DWORD nAttach = v->AttachmentCount(true); //Get attachment count. I do this so that I can grap any child point.
			if (nAttach > 0){ // Only continue if ship has a child attach point
				for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
					ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
					//* thiswould allow me to filter out all but QJ ships but I don't want to right now
					const char *id = v->GetAttachmentId(hAtt);
					if (strncmp(id, "LANDER", 6)) continue; // attachment point not compatible
					// */
					v->GetAttachmentParams(hAtt, shippos, shipdir, shiprot); //lets get the attach point position
					v->Local2Global(shippos, gpship); // and change it to a global position Recycle of gpship cause I can
					if (dist(gpship, gaph) < MAX_GRAP_DIST) { // Is it close enough to grab?
						apd = dist(gpship, gaph);
						// Yes! Then lets grab the little bugger and get out of here
						// Yes! Then lets grab the little bugger and get out of here
						if (do_attach1 > 0){
							do_attach1 = 0;


							if (!GetAttachmentStatus(CARGO2))
							{
								//Free so do the attach
								AttachChild(hV, CARGO2, hAtt);
								CARGO2ATTACH = 1;
							}
							else{
								//something already attached
							}


						}
					}
					return;
				}
			}
		} // End of for j
	}
}

void LANDER6::DetachCargo1()
{
	DetachChild(CARGO2, 0.0);
	CARGO2OLDATTACH = 1;
	CARGO2ATTACH = 0;
}
gattispilot is offline   Reply With Quote
Old 12-26-2016, 04:11 PM   #308
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

OK. I have run into a coding issue

What I want to happen is this:

In Atmosphere the max thrust level for rcs is 15000. But in orbit reduce the max amount to 12000.

So in the poststep I have this.
Code:
	ATM = GetAtmDensity();

	if (ATM < 2)SetThrusterMax0(th_rcs[20], 15000); // IN ATMOSPHERE SO HIGHER THRUST
	else if (ATM < .05)SetThrusterMax0(th_rcs[20], 12000); //IN ORBIT SO REDUCE MAX THRUST
But the max amount doesn't change

fixed. I needed to change it all rcs.

Last edited by gattispilot; 12-26-2016 at 05:32 PM.
gattispilot is offline   Reply With Quote
Thanked by:
Old 12-30-2016, 01:39 PM   #309
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Ok. another issue. Not sure why this is happening.

saved state:
Code:
ENDURANCE:ENDURANCENEW
  STATUS Orbiting Earth
  RPOS 3678770.44 4280379.38 -3303680.79
  RVEL 6581.781 -3481.361 2694.598
  AROT -52.67 -56.93 -89.68
  AFCMODE 7
  PRPLEVEL 0:1.000000
  DOCKINFO 0:0,RANGER1 1:0,RANGER2 2:0,LANDER1 3:0,LANDER2
  NAVFREQ 0 0
  XPDR 0
  CARGO1 0 0.0000
  CARGO2 0 0.0000
  CARGO3 0 0.0000
  CARGO4 0 0.0000
  CARGO5 0 0.0000
  CARGO6 0 0.0000
  CARGO7 0 0.0000
  CARGO8 0 0.0000
  CARGO9 0 0.0000
  CARGO10 0 0.0000
  CARGO11 0 0.0000
  CARGO12 0 0.0000
  CARGO13 0 0.0000
  CARGO14 0 0.0000
  CARGO15 0 0.0000
  CARGO16 0 0.0000
  POD 1 
END
then we load this saved state and cargo 1 starts moving on its own. I exit and get this:
Code:
ENDURANCE:ENDURANCENEW
  STATUS Orbiting Earth
  RPOS 3707577.50 4265056.92 -3291821.25
  RVEL 6558.707 -3508.056 2715.202
  AROT -52.67 -56.93 -89.68
  AFCMODE 7
  PRPLEVEL 0:1.000000
  DOCKINFO 0:0,RANGER1 1:0,RANGER2 2:0,LANDER1 3:0,LANDER2
  NAVFREQ 0 0
  XPDR 0
  CARGO1 6 0.4384
  CARGO2 0 0.0000
  CARGO3 0 0.0000
  CARGO4 0 0.0000
  CARGO5 0 0.0000
  CARGO6 0 0.0000
  CARGO7 0 0.0000
  CARGO8 0 0.0000
  CARGO9 0 0.0000
  CARGO10 0 0.0000
  CARGO11 0 0.0000
  CARGO12 0 0.0000
  CARGO13 0 0.0000
  CARGO14 0 0.0000
  CARGO15 0 0.0000
  CARGO16 0 0.0000
  POD 1 
END
Code:
void TESTVC::clbkSaveState(FILEHANDLE scn)
{
	// ORBITER, default vessel parameters
	char cbuf[256];

	SaveDefaultState(scn);

	


	sprintf(cbuf, "%d %0.4f", CARGO1_status, CARGO1_proc);
	oapiWriteScenario_string(scn, "CARGO1", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO2_status, CARGO2_proc);
	oapiWriteScenario_string(scn, "CARGO2", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO3_status, CARGO3_proc);
	oapiWriteScenario_string(scn, "CARGO3", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO4_status, CARGO4_proc);
	oapiWriteScenario_string(scn, "CARGO4", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO5_status, CARGO5_proc);
	oapiWriteScenario_string(scn, "CARGO5", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO6_status, CARGO6_proc);
	oapiWriteScenario_string(scn, "CARGO6", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO7_status, CARGO7_proc);
	oapiWriteScenario_string(scn, "CARGO7", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO8_status, CARGO8_proc);
	oapiWriteScenario_string(scn, "CARGO8", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO9_status, CARGO9_proc);
	oapiWriteScenario_string(scn, "CARGO9", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO10_status, CARGO10_proc);
	oapiWriteScenario_string(scn, "CARGO10", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO11_status, CARGO11_proc);
	oapiWriteScenario_string(scn, "CARGO11", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO12_status, CARGO12_proc);
	oapiWriteScenario_string(scn, "CARGO12", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO13_status, CARGO13_proc);
	oapiWriteScenario_string(scn, "CARGO13", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO14_status, CARGO14_proc);
	oapiWriteScenario_string(scn, "CARGO14", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO15_status, CARGO15_proc);
	oapiWriteScenario_string(scn, "CARGO15", cbuf);

	sprintf(cbuf, "%d %0.4f", CARGO16_status, CARGO16_proc);
	oapiWriteScenario_string(scn, "CARGO16", cbuf);

	sprintf(cbuf, "%d ", PODSel);
	oapiWriteScenario_string(scn, "POD", cbuf);
	

	Crew.SaveAllMembersInOrbiterScenarios(scn);
	
}

void TESTVC::clbkLoadStateEx(FILEHANDLE scn, void *status)
{
char *line;
while (oapiReadScenario_nextline(scn, line))
{
	// UMMU, Load all saved member from scenario. 
	// Return TRUE when a "UMMUCREW" line is encountered 
	// FALSE when it must pass this line to you or default parser
	if (Crew.LoadAllMembersFromOrbiterScenario(line) == TRUE)
		continue;
	

	if (!_strnicmp(line, "CARGO1", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO1_status, &CARGO1_proc);
	}

	if (!_strnicmp(line, "CARGO2", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO2_status, &CARGO2_proc);
	}
	if (!_strnicmp(line, "CARGO3", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO3_status, &CARGO3_proc);
	}
	if (!_strnicmp(line, "CARGO4", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO4_status, &CARGO4_proc);
	}
	if (!_strnicmp(line, "CARGO5", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO5_status, &CARGO5_proc);
	}
	if (!_strnicmp(line, "CARGO6", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO6_status, &CARGO6_proc);
	}
	if (!_strnicmp(line, "CARGO7", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO7_status, &CARGO7_proc);
	}
	if (!_strnicmp(line, "CARGO8", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO8_status, &CARGO8_proc);
	}
	if (!_strnicmp(line, "CARGO9", 6)) {
		sscanf(line + 6, "%d%lf", &CARGO9_status, &CARGO9_proc);
	}
	
	if (!_strnicmp(line, "10CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO10_status, &CARGO10_proc);
	}
	
	if (!_strnicmp(line, "11CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO11_status, &CARGO11_proc);
	}
	if (!_strnicmp(line, "12CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO12_status, &CARGO12_proc);
	}
	if (!_strnicmp(line, "13CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO13_status, &CARGO13_proc);
	}
	if (!_strnicmp(line, "14CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO14_status, &CARGO14_proc);
	}
	if (!_strnicmp(line, "15CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO15_status, &CARGO15_proc);
	}
	if (!_strnicmp(line, "16CARGO", 7)) {
		sscanf(line + 7, "%d%lf", &CARGO16_status, &CARGO16_proc);
	}

	if (!_strnicmp(line, "POD", 3)) {
		sscanf(line + 3, "%d", &PODSel);
	}
	

	// ORBITER, unrecognised option - pass to Orbiter's generic parser
	ParseScenarioLineEx(line, status);
	
	CARGO1_pos.z = CARGO1_INT_POS - (CARGO1_proc * 5);
	CARGO2_pos.z = CARGO2_INT_POS - (CARGO2_proc * 5);
	CARGO3_pos.z = CARGO3_INT_POS - (CARGO3_proc * 5);
	CARGO4_pos.z = CARGO4_INT_POS - (CARGO4_proc * 5);
	CARGO5_pos.z = CARGO5_INT_POS - (CARGO5_proc * 5);
	CARGO6_pos.z = CARGO6_INT_POS - (CARGO6_proc * 5);
	CARGO7_pos.z = CARGO7_INT_POS - (CARGO7_proc * 5);
	CARGO8_pos.z = CARGO8_INT_POS - (CARGO8_proc * 5);
	CARGO9_pos.z = CARGO9_INT_POS - (CARGO9_proc * 5);
	CARGO10_pos.z = CARGO10_INT_POS - (CARGO10_proc * 5);
	CARGO11_pos.z = CARGO11_INT_POS - (CARGO11_proc * 5);
	CARGO12_pos.z = CARGO12_INT_POS - (CARGO12_proc * 5);
	CARGO13_pos.z = CARGO13_INT_POS - (CARGO13_proc * 5);
	CARGO14_pos.z = CARGO14_INT_POS - (CARGO14_proc * 5);
	CARGO15_pos.z = CARGO15_INT_POS - (CARGO15_proc * 5);
	CARGO16_pos.z = CARGO16_INT_POS - (CARGO16_proc * 5);

	
	SetAttachmentParams(CARGO1, CARGO1_pos, _V(0, -1, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO2, CARGO2_pos, _V(0, -1, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO3, CARGO3_pos, _V(-.866, -.5, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO4, CARGO4_pos, _V(-.866, -.5, 0), _V(0, 0, -1));

	SetAttachmentParams(CARGO5, CARGO5_pos, _V(-1, 0, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO6, CARGO6_pos, _V(-1, 0, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO7, CARGO7_pos, _V(-.866, .5, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO8, CARGO8_pos, _V(-.866, .5, 0), _V(0, 0, -1));

	SetAttachmentParams(CARGO9, CARGO9_pos, _V(0, 1, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO10, CARGO10_pos, _V(0, 1, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO11, CARGO11_pos, _V(.866, .5, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO12, CARGO12_pos, _V(.866, .5, 0), _V(0, 0, -1));

	SetAttachmentParams(CARGO13, CARGO13_pos, _V(1, 0, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO14, CARGO14_pos, _V(1, 0, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO15, CARGO15_pos, _V(.866, -.5, 0), _V(0, 0, -1));
	SetAttachmentParams(CARGO16, CARGO16_pos, _V(.866, -.5, 0), _V(0, 0, -1));





}

// as airlock state depend of your ship (you may have a real animated airlock)
// it's your responsabilites to save and reload UMmu airlock state and set it accordingly
// to your airlock. IE: call here "SetAirlockDoorState" TRUE of FALSE depend
// of your animated airlock
}
h.
Code:
	enum RACKStatus { RACK_UP, RACK_DOWN, RACK_RAISING, RACK_LOWERING }CARGO1_status, CARGO2_status, CARGO3_status, CARGO4_status, CARGO5_status, CARGO6_status, CARGO7_status, CARGO8_status, CARGO9_status, CARGO10_status, CARGO11_status, CARGO12_status, CARGO13_status, CARGO14_status, CARGO15_status, CARGO16_status;
gattispilot is offline   Reply With Quote
Old 01-09-2017, 01:51 PM   #310
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Closer. Manual is being written.

One thing Code wise not sure about.

Can you turn off rcs exhaust? Or movie the exhaust jets? For the Ranger the Nose has Rcs thrusters. But the nose animates for lift/drag. So either the exhaust jets are not seen in atmosphere or they move with the nose?
gattispilot is offline   Reply With Quote
Old 01-10-2017, 01:55 AM   #311
PDF
Addon Developer = Media Render
 
PDF's Avatar
Default

wow nice work guys
PDF is offline   Reply With Quote
Thanked by:
Old 01-31-2017, 11:33 AM   #312
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

As they say the devil is in the details.

So I have a save/load issue.

Here you can see the pitchtrim is set. And saved. But when It loads it is 0.000000



initialize:
Code:
LANDER6::LANDER6(OBJHANDLE hObj, int fmodel)
: VESSEL2(hObj, fmodel)
{

	PITCHTRIMLEVEL = 0;
	PITCHTRIMLEVELABS = 0;
}
Code:
void LANDER6::clbkSaveState(FILEHANDLE scn)
{
	// ORBITER, default vessel parameters
	char cbuf[256];

	SaveDefaultState(scn);
	sprintf(cbuf, "%d %0.4f", DOOR_status, DOOR_proc);
	oapiWriteScenario_string(scn, "DOOR", cbuf);

	sprintf(cbuf, "%d %0.4f", DOOR1_status, DOOR1_proc);
	oapiWriteScenario_string(scn, "DOOR1", cbuf);

	sprintf(cbuf, "%d %0.4f", BLASTWINDOW_status, BLASTWINDOW_proc);
	oapiWriteScenario_string(scn, "BLAST", cbuf);

	sprintf(cbuf, "%d %0.4f", UPPERDOCKDOOR_status, UPPERDOCKDOOR_proc);
	oapiWriteScenario_string(scn, "UPDOOR", cbuf);

	sprintf(cbuf, "%d %0.4f", LOWERDOCKDOOR_status, LOWERDOCKDOOR_proc);
	oapiWriteScenario_string(scn, "LODOOR", cbuf);

	sprintf(cbuf, "%d", smoke);
	oapiWriteScenario_string(scn, "SMOKE", cbuf);

	sprintf(cbuf, "%d", orbit);
	oapiWriteScenario_string(scn, "ORBIT", cbuf);

	sprintf(cbuf, "%0.2f", PITCHTRIMLEVEL);
	oapiWriteScenario_string(scn, "TRIMLEVEL", cbuf);


	


	Crew.SaveAllMembersInOrbiterScenarios(scn);

}

void LANDER6::clbkLoadStateEx(FILEHANDLE scn, void *status)
{
	char *line;
	while (oapiReadScenario_nextline(scn, line))
	{
		// UMMU, Load all saved member from scenario. 
		// Return TRUE when a "UMMUCREW" line is encountered 
		// FALSE when it must pass this line to you or default parser
		if (Crew.LoadAllMembersFromOrbiterScenario(line) == TRUE)
			continue;

		else if (!_strnicmp(line, "DOOR1", 5)) {
			sscanf(line + 5, "%d %lf", &DOOR1_status, &DOOR1_proc);
		}
		else if (!_strnicmp(line, "DOOR", 4)) {
			sscanf(line + 4, "%d %lf", &DOOR_status, &DOOR_proc);
		}
		else if (!_strnicmp(line, "BLAST", 5)) {
			sscanf(line + 5, "%d%lf", &BLASTWINDOW_status, &BLASTWINDOW_proc);
		}
		else if (!_strnicmp(line, "UPDOOR", 6)) {
			sscanf(line + 6, "%d%lf", &UPPERDOCKDOOR_status, &UPPERDOCKDOOR_proc);
		}
		else if (!_strnicmp(line, "LODOOR", 6)) {
			sscanf(line + 6, "%d%lf", &LOWERDOCKDOOR_status, &LOWERDOCKDOOR_proc);
		}
		else if (!_strnicmp(line, "SMOKE", 5)) {
			sscanf(line + 5, "%d", &smoke);
		}
		else if (!_strnicmp(line, "ORBIT", 5)) {
			sscanf(line + 5, "%d", &orbit);
		}
		else if (!_strnicmp(line, "TRIMLEVEL", 9)) {
			sscanf(line + 9, "%0.2f", &PITCHTRIMLEVEL);
		}
		else
			// ORBITER, unrecognised option - pass to Orbiter's generic parser
			ParseScenarioLineEx(line, status);
	}

	if (DOOR_proc>.5)Crew.SetAirlockDoorState(TRUE);//SETS AIRLOCK STATE
	if (DOOR1_proc>.5)Crew.SetAirlockDoorState(TRUE);//SETS AIRLOCK STATE

	SetAnimation(anim_DOOR1, DOOR1_proc);
	SetAnimation(anim_DOOR, DOOR_proc);
	SetAnimation(anim_LOWERDOCKDOOR, LOWERDOCKDOOR_proc);
	SetAnimation(anim_UPPERDOCKDOOR, UPPERDOCKDOOR_proc);
	SetAnimation(anim_BLASTWINDOW, BLASTWINDOW_proc);

	UpdateCrew();

	if (GetAttachmentStatus(CARGO1))CARGO1ATTACH = 1;
	if (GetAttachmentStatus(CARGO2))CARGO2ATTACH = 1;


	// as airlock state depend of your ship (you may have a real animated airlock)
	// it's your responsabilites to save and reload UMmu airlock state and set it accordingly
	// to your airlock. IE: call here "SetAirlockDoorState" TRUE of FALSE depend
	// of your animated airlock
}
I ran in debug and had it break in the load state and it was 0.0000

Here is the saved scenario:
Code:
LANDER:LANDER
  STATUS Orbiting Earth
  RPOS 5567540.32 2581279.18 1711508.43
  RVEL -39.756 -161.537 372.430
  AROT -12.40 11.35 63.04
  VROT -0.02 -0.00 -0.06
  AFCMODE 7
  PRPLEVEL 0:1.000000 1:1.000000 2:0.999994
  THLEVEL 27:0.020000 28:0.020000 29:0.020000 30:0.020000
  IDS 0:588 100 1:589 100
  NAVFREQ 0 0
  XPDR 0
  DOOR 0 0.0000
  DOOR1 0 0.0000
  BLAST 0 0.0000
  UPDOOR 0 0.0000
  LODOOR 0 0.0000
  SMOKE 1
  ORBIT 0
  TRIMLEVEL 0.02
END
gattispilot is offline   Reply With Quote
Old 01-31-2017, 12:31 PM   #313
GLS
Addon Developer
 
GLS's Avatar
Default

Change this
Code:
sscanf(line + 9, "%0.2f", &PITCHTRIMLEVEL);
to this
Code:
sscanf(line + 9, "%lf", &PITCHTRIMLEVEL);
GLS is offline   Reply With Quote
Thanked by:
Old 01-31-2017, 11:25 PM   #314
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks that worked
gattispilot is offline   Reply With Quote
Old 02-09-2017, 11:57 AM   #315
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

The other issue. Is we anim the nose based on the Elevator animation.

But we want 2 things. In space no animation to occur
in atmosphere animation occur but rcs thruster not be seen or have them follow the nose animation.

Code:
	RANGERNOSE = GetControlSurfaceLevel(AIRCTRL_ELEVATOR);
Code:
void RANGER::CreateControlSurfaces() {
	int i = 0;
	control_surfaces[i++] = CreateControlSurface3(AIRCTRL_ELEVATOR, 1.4, 1.5, _V(0, 0, -7.2), AIRCTRL_AXIS_XPOS, 1.0, anim_NOSE);//6.25
//	if (orbit == 0) control_surfaces[i++] = CreateControlSurface3(AIRCTRL_ELEVATOR, 1.4, 1.5, _V(0, 0, -7.2), AIRCTRL_AXIS_XPOS, 1.0);//6.25

	control_surfaces[i++] = CreateControlSurface3(AIRCTRL_AILERON, 9.68, 3.125, _V(-.5, .5, 3.83), AIRCTRL_AXIS_AUTO, 3.5);
	control_surfaces[i++] = CreateControlSurface3(AIRCTRL_AILERON, 9.68, 3.125, _V(+.5, .5, 3.83), AIRCTRL_AXIS_AUTO, 3.5);
	control_surfaces[i++] = CreateControlSurface3(AIRCTRL_RUDDER, 9.68, 3.125, _V(0, .5, 3.83), AIRCTRL_AXIS_AUTO, 3.5);
	control_surfaces[i++] = CreateControlSurface3(AIRCTRL_ELEVATORTRIM, 5, 10, _V(0, 0, -7.2), AIRCTRL_AXIS_XPOS, 1.0);

}
The commented line says if in space then no animation of the nose. But it did it all the time.
Code:
void CreateControlSurfaces();;
Any ideas?

---------- Post added 02-09-17 at 05:57 AM ---------- Previous post was 02-08-17 at 07:22 AM ----------

I can't seem to get this to work.
What is suggested to happen.
Get the Atmosphere density. If Density is less than .01 then fair=1. If density is less than .01 and fair =1 then start fairing detach.

But I open on Earth and the fairing start to detach.
Code:
RANGERLAUNCH::RANGERLAUNCH (OBJHANDLE hObj, int fmodel)
: VESSEL2 (hObj, fmodel)

{
	FAIR1_INTX_POS = 0;
	FAIR2_INTX_POS = 0;
	
	FAIR1_INTY_POS = 0;
	FAIR2_INTY_POS = 0;
	
	fair = 0;
	FAIR1_pos.x = 0;
	FAIR2_pos.x = 0;
	

	FAIR1_pos.y = 0;
	FAIR2_pos.y = 0;
	

	FAIR1_pos.z = -4;
	FAIR2_pos.z = -4;
	

	distance = 0;
	fair = 0;

}
and in the h:
Code:
int fair;
double distance, FAIR1_INTX_POS, FAIR2_INTX_POS, FAIR3_INTX_POS, FAIR4_INTX_POS, FAIR1_INTY_POS, FAIR2_INTY_POS,ATMOSPHERE;
VECTOR3 FAIR1_pos, FAIR2_pos;
Code:
void RANGERLAUNCH::clbkPostStep(double simt, double simdt, double mjd)
{
	ATMOSPHERE = GetAtmDensity();

	if (ATMOSPHERE < .01) fair = 1;


if((ATMOSPHERE < .01) && (fair == 1)){
		distance = (distance + .4);

		
		FAIR1_pos.y = FAIR1_INTY_POS - distance;

		SetAttachmentParams(FAIR1, FAIR1_pos, _V(0, 1, 0), _V(0, 0, 1));


		
		FAIR2_pos.y = FAIR2_INTY_POS + distance;
		SetAttachmentParams(FAIR2, FAIR2_pos, _V(0, 1, 0), _V(0, 0, 1));

		

		//sprintf(oapiDebugString(), "Fuel %f", distance);


		if (distance > 150){
			fair = 0;
			DetachChild(FAIR1, 1.0);
			DetachChild(FAIR2, 1.0);
			
		}

	}




	


}
when I run it in debug I get a break and the symbols not loaded. the breakpoint is distance = (distance + .4);

Last edited by gattispilot; 02-09-2017 at 12:01 PM.
gattispilot is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Development


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 03:09 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.