Difference between revisions of "VESSEL2::clbkSetClassCaps"

From OrbiterWiki
Jump to navigation Jump to search
m
m
Line 11: Line 11:
 
==Example code==
 
==Example code==
  
{{Example ArtLicense}}
 
 
<pre>
 
<pre>
 
void MAYFLY::clbkSetClassCaps(FILEHANDLE cfg)
 
void MAYFLY::clbkSetClassCaps(FILEHANDLE cfg)

Revision as of 17:39, 4 March 2006

Description

Callback function used for creating the basic vessel parameters. Each setting in this callback overrides the settings of the configuration file. Use this function for creating the physical properties of a vessel.

Syntax

virtual void clbkSetClassCaps(FILEHANDLE cfg);

cfg
File handle for reading custom parameters out of the configuration file. This file handle can be used in the same way as in ovcSetClassCaps, ovcLoadStateEx, ovcLoadState, clbkLoadStateEx

Example code

void MAYFLY::clbkSetClassCaps(FILEHANDLE cfg)
{
	this->SetEnableFocus(false);
	char* pLine;
	while(oapiReadScenario_nextline(cfg, pLine))
	{
		if(!strnicmp(pLine, "LifeTime", 8))
		{
			char* pLine2 = pLine + 8;
			while(*pLine2 != '=' && *pLine2 != '\0')
			{
				pLine2++;
			}
			if(*pLine2 != '\0')
			{
				pLine2++;
				sscanf(pLine2, "%lf", &fRemainingLifeTime);
			}

		}
		else if(!strnicmp(pLine, "MaxCamDistance", 14))
		{
			char* pLine2 = pLine + 14;
			while(*pLine2 != '=' && *pLine2 != '\0')
			{
				pLine2++;
			}
			if(*pLine2 != '\0')
			{
				pLine2++;
				sscanf(pLine2, "%lf", &fMaxCameraDistance);
			}

		}
	}
}

See also