Here's a screenshot of my most recent build just to give everyone an idea of what I'm trying to do...
I finally have the propellant tanks reading normally and am now working on the "Stack Parameters Column" along the right side of the display. CG Offset, Engine Gimbal, and Vessel Mass are all functional.
What's holding me up now is the Payload Mass and by extention dV available. (one being a function of the other). Apperently there's no function in the standard OAPI for getting the mass of a combined superstructure (yet there's a function for CG what gives?).
I found the following in the SDK sample of the Burn Time Calulator MFD but could use some help understanding what is happening in it and adapting it to my purposes.
I tried simply copy/pasting it into my source code along with the declaration, but the value it returned was always null.
I finally have the propellant tanks reading normally and am now working on the "Stack Parameters Column" along the right side of the display. CG Offset, Engine Gimbal, and Vessel Mass are all functional.
What's holding me up now is the Payload Mass and by extention dV available. (one being a function of the other). Apperently there's no function in the standard OAPI for getting the mass of a combined superstructure (yet there's a function for CG what gives?).
I found the following in the SDK sample of the Burn Time Calulator MFD but could use some help understanding what is happening in it and adapting it to my purposes.
Code:
double BurnTimeMFD::GetStackMass(VESSEL* vessel) {
//We don't have to worry about attachments. They either
//are compensated for in the main vessel code, or arent,
//in which case they have no mass. So, it's only docked
//vessels which we care about
//So, what we do is:
//Put the current vessel in the vessel-to-check list
double totalMass=0;
VESSEL* vesselsToCheck[100];
int vesselsStored=0;
vesselsToCheck[vesselsStored]=vessel;
vesselsStored++;
//For each vessel in the vessel-to-check list
for(int vesselsChecked=0;vesselsChecked<vesselsStored && vesselsChecked<100;vesselsChecked++) {
// Accumulate this vessel's mass
totalMass+=vesselsToCheck[vesselsChecked]->GetMass();
// For each docking port
UINT nDockingPorts=vesselsToCheck[vesselsChecked]->DockCount();
for(UINT i_dock=0;i_dock<nDockingPorts;i_dock++) {
// Get the docked vessel, if any,
DOCKHANDLE hDock=vesselsToCheck[vesselsChecked]->GetDockHandle(i_dock);
OBJHANDLE hVessel=vesselsToCheck[vesselsChecked]->GetDockStatus(hDock);
VESSEL* pVessel=NULL;
if(hVessel) pVessel=oapiGetVesselInterface(hVessel);
// If it is not already in the vessel-to-check list
bool hasVesselAlready=(pVessel==NULL);
for(int i_vessel=0;i_vessel<vesselsStored;i_vessel++) if (vesselsToCheck[i_vessel]==pVessel) hasVesselAlready=true;
if(!hasVesselAlready) {
// Add it to the end of the list
vesselsToCheck[vesselsStored]=pVessel;
vesselsStored++;
// end if
}
// end for
}
//end for
}
return totalMass;
}
I tried simply copy/pasting it into my source code along with the declaration, but the value it returned was always null.