Exemple #1
0
	void Drawing::SetMessage(int x, int y, char* msg)
	{
		// Determine the size of the message and clear it if it is empty.
		size_t len = strnlen(msg, MSG_MAX - 1);
		if (len == 0)
		{
			ClearMessage();
			return;
		}

		// Set the message, location, and mark new lines.
		strncpy(msgVal, msg, len + 1);
		newLineCount = 0;
		for (size_t i = 0; i < len && newLineCount < MSG_LINE_MAX; ++i)
		{
			if (msgVal[i] == '\n' || msgVal[i] == '\r')
			{
				msgVal[i] = 0;
				newLines[newLineCount++] = i + 1;
			}
		}
		msgX = x < 0 ? 10 : x;
		msgY = y < 0 ? 600 : y;

		// Enable drawing if necessary
		if (!msgEnabled)
		{
            XPLMRegisterDrawCallback(MessageDrawCallback, xplm_Phase_Window, 0, NULL);
			msgEnabled = true;
		}
	}
const char * 	XPMPMultiplayerInit(
						const char * inCSLFolder, const char * inRelatedPath,
						const char * inTexturePath, const char * inDoc8643,
						const char * inDefaultPlane,
						int (* inIntPrefsFunc)(const char *, const char *, int),
						float (* inFloatPrefsFunc)(const char *, const char *, float))
{
	gDefaultPlane = inDefaultPlane;
	gIntPrefsFunc = inIntPrefsFunc;
	gFloatPrefsFunc = inFloatPrefsFunc;
	char	myPath[1024];
	char	airPath[1024];
	char	line[256];
	char	sysPath[1024];
	FILE *	fi;
	
	bool	problem = false;

//	TODO - FORM GOOD DIAGNOSTIC MESSAGES HERE!
	
	// Initialize our OpenGL Utilities
	OGL_UtilsInit();

	if (!CSL_LoadCSL(inCSLFolder, inRelatedPath, inDoc8643))
		problem = true;

	XPMPInitDefaultPlaneRenderer();	

	if (!CSL_Init(inTexturePath))
		problem = true;

	// Register the plane control calls.
	XPLMRegisterDrawCallback(XPMPControlPlaneCount,
		xplm_Phase_Gauges, 0, /* after*/ 0 /* hide planes*/);	

	XPLMRegisterDrawCallback(XPMPControlPlaneCount,
		xplm_Phase_Gauges, 1, /* before */ (void *) -1 /* show planes*/);	

	// Register the actual drawing func.
	XPLMRegisterDrawCallback(XPMPRenderMultiplayerPlanes,
		xplm_Phase_Airplanes, 0, /* after*/ 0 /* refcon */);	

	if (problem)		return "There were problems initializing XSquawkBox.  Please examine X-Plane's error.out file for detailed information.";
	else 				return "";
}
int	createGNSWindow()
{
    int res = 0;

    XPLMCreateWindow_t win;
    win.structSize = sizeof(XPLMCreateWindow_t);
    win.left = g_pos_x;
    win.top = g_pos_y + (int)(gpGNSIntf->bezel_height*g_zoom);
    win.right = g_pos_x+(int)(gpGNSIntf->bezel_width*g_zoom);
    win.bottom = g_pos_y;
    win.visible = true;
    win.drawWindowFunc = myDrawWindowCallback;
    win.handleMouseClickFunc = myHandleMouseClickCallback;
    win.handleKeyFunc = myHandleKeyCallback;
    win.handleCursorFunc = myHandleCursorCallback;
    win.handleMouseWheelFunc = myHandleMouseWheelFunc;
    win.refcon = NULL;



    //Register the Draw Window
    // Create a windows for displaying the projection info
    gWindow = XPLMCreateWindowEx(&win);

    logMessageEx("--- GNS Window created");

    initTextures();
    logMessageEx("--- Textures created");

    /// Register so that our gauge is drawing during the Xplane gauge phase
    XPLMRegisterDrawCallback(myDrawGNSCallback, xplm_Phase_Window, 1, NULL); // before window draw
    logMessageEx("--- DrawCallback registered");

    //Register the callback for gUpdateInterval.  Positive intervals
    //are in seconds, negative are the negative of sim frames.  Zero
    //registers but does not schedule a callback for time.
    XPLMRegisterFlightLoopCallback(myFlightLoopCallback, gUpdateInterval, NULL);
    logMessageEx("--- FlightLoopCallback registered");

    //Set the initial values of the COM and NAV
    gGNSx30Proxy.setCOMActiveFrequency(XPLMGetDatai(g_com1_active_ref)*10);
    gGNSx30Proxy.setCOMStandbyFrequency(XPLMGetDatai(g_com1_standby_ref)*10);
    gGNSx30Proxy.setNAVActiveFrequency(XPLMGetDatai(g_nav1_active_ref)*10);
    gGNSx30Proxy.setNAVStandbyFrequency(XPLMGetDatai(g_nav1_standby_ref)*10);


    gnsOpened = true;

    return res;
}
Exemple #4
0
	void Drawing::AddWaypoints(Waypoint points[], size_t numPoints)
	{
		if (numWaypoints + numPoints > WAYPOINT_MAX)
		{
			numPoints = WAYPOINT_MAX - numWaypoints;
		}
		size_t finalNumWaypoints = numPoints + numWaypoints;
		for (size_t i = 0; i < numPoints; ++i)
		{
			waypoints[numWaypoints + i] = points[i];
		}
		numWaypoints = finalNumWaypoints;

		if (!routeEnabled)
		{
			XPLMRegisterDrawCallback(RouteDrawCallback, xplm_Phase_Objects, 0, NULL);
		}
		if (!planeXref)
		{
			planeXref = XPLMFindDataRef("sim/flightmodel/position/local_x");
			planeYref = XPLMFindDataRef("sim/flightmodel/position/local_y");
			planeZref = XPLMFindDataRef("sim/flightmodel/position/local_z");
		}
	}
Exemple #5
0
PLUGIN_API int XPluginStart(
                        char *        outName,
                        char *        outSig,
                        char *        outDesc)
{
    strcpy(outName, "UDB HILSIM");
    strcpy(outSig, "UDB.HardwareInLoop");
    strcpy(outDesc, "UDB Hardware-In-Loop Simulator");
          
    drP = XPLMFindDataRef("sim/flightmodel/position/P");
	drQ = XPLMFindDataRef("sim/flightmodel/position/Q");
	drR = XPLMFindDataRef("sim/flightmodel/position/R");
    drLat = XPLMFindDataRef("sim/flightmodel/position/latitude");
	drLon = XPLMFindDataRef("sim/flightmodel/position/longitude");
	drElev = XPLMFindDataRef("sim/flightmodel/position/elevation");
	drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax");
	drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); 
	drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az");
	drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx");
	drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); 
	drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz");
	drLocalDays = XPLMFindDataRef("sim/time/local_date_days");
	drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec");
	drGroundSpeed = XPLMFindDataRef("sim/flightmodel/position/groundspeed");
	drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed");
	drHeading = XPLMFindDataRef("sim/flightmodel/position/psi");
	drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x");
	drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y");
	drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z");
	drPhi = XPLMFindDataRef("sim/flightmodel/position/phi");
	drTheta = XPLMFindDataRef("sim/flightmodel/position/theta");
    drPsi = XPLMFindDataRef("sim/flightmodel/position/psi");
	drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha");
	drBeta = XPLMFindDataRef("sim/flightmodel/position/beta");
	drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles");
	drPitchAxis = XPLMFindDataRef("sim/joystick/FC_ptch");
	drRollAxis = XPLMFindDataRef("sim/joystick/FC_roll");
	drYawAxis = XPLMFindDataRef("sim/joystick/FC_hdng");
	drThro = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use");

	fTextColour[0] = 1.0;
	fTextColour[1] = 1.0;
	fTextColour[2] = 1.0;

	XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL);
	XPLMRegisterDrawCallback(
					DrawStrings,
					xplm_Phase_Window, 	/* Draw when sim is doing objects */
					0,						/* After objects */
					NULL);					/* No refcon needed */
	
//	XPLMSetDatai(drOverRide, 1);		// Now overide surfaces, not yaw,roll,pitch

	/* Register our hot key for the new view. */
	gHotKey = XPLMRegisterHotKey(XPLM_VK_F8, xplm_DownFlag, 
				"Circling External View",
				MyHotKeyCallback,
				NULL);

	XPLMRegisterDrawCallback(
				MyDrawCallback,	
				xplm_Phase_Objects, 	/* Draw when sim is doing objects */
				0,						/* After objects */
				NULL);					/* No refcon needed */

	memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength);

	return 1;
}
Exemple #6
0
PLUGIN_API int XPluginStart(char* outName,
                            char* outSig,
                            char* outDesc)
{
	szString[0] = '\0';
	strcpy(outName, "UDB HILSIM");
	strcpy(outSig, "UDB.HardwareInLoop");
	strcpy(outDesc, "UDB Hardware-In-Loop Simulator");

	// P, Q, and R are roll, pitch, and yaw rates, degrees per second,
	// in the NED coordinate system, in "flight" (not body) frame of reference
	drP = XPLMFindDataRef("sim/flightmodel/position/P");
	drQ = XPLMFindDataRef("sim/flightmodel/position/Q");
	drR = XPLMFindDataRef("sim/flightmodel/position/R");

	// standard GPS lat, long, and elevation
	drLat  = XPLMFindDataRef("sim/flightmodel/position/latitude");
	drLon  = XPLMFindDataRef("sim/flightmodel/position/longitude");
	drElev = XPLMFindDataRef("sim/flightmodel/position/elevation");

	// acceleration, meters/sec/sec, in OGL frame of reference
	// note: this is NOT the same as what the accelerometers read
	drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax");
	drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); 
	drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az");

	// velocity, meters/sec, in OGL frame of reference
	drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx");
	drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); 
	drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz");

	drLocalDays = XPLMFindDataRef("sim/time/local_date_days");
	drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec");

	// 3D true airspeed, meters/second
	drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed");

	// location in OGL frame
	drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x");
	drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y");
	drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z");

	// Euler roll, pitch, and yaw angles, degrees, using NED
	// + phi is roll to the right (CCW around NED_x)
	// + theta is pitch up (CCW around NED_y)
	// + psi is yaw to the right (CCW around NED_z)
	drPhi   = XPLMFindDataRef("sim/flightmodel/position/phi");
	drTheta = XPLMFindDataRef("sim/flightmodel/position/theta");
	drPsi   = XPLMFindDataRef("sim/flightmodel/position/psi");

	// Euler angles of attack and sideslip, degrees, using NED
	// These are angles of body frame with respect to fight path
	// + alpha is pitch up (CCW around NED_y)
	// + beta is yaw right (CCW around NED_z)
	drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha");
	drBeta  = XPLMFindDataRef("sim/flightmodel/position/beta");

	drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles");
	drPitchAxis   = XPLMFindDataRef("sim/joystick/FC_ptch");
	drRollAxis    = XPLMFindDataRef("sim/joystick/FC_roll");
	drYawAxis     = XPLMFindDataRef("sim/joystick/FC_hdng");
	drThro        = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use");

// sim/operation/override/override_gearbrake	int	y	boolean	Override gear and brake staus
// sim/flightmodel/controls/parkbrake	float	y	???	Parking Brake

	drBrakeOverRide = XPLMFindDataRef("sim/operation/override/override_gearbrake");
	drBrake         = XPLMFindDataRef("sim/flightmodel/controls/parkbrake");

	// These are the values that the accelerometers read, in multiples of gravity
	// g_nrml is UDB_z
	// g_axil is UDB_y
	// g_side is UDB_x
	drg_nrml = XPLMFindDataRef("sim/flightmodel/forces/g_nrml");
	drg_axil = XPLMFindDataRef("sim/flightmodel/forces/g_axil");
	drg_side = XPLMFindDataRef("sim/flightmodel/forces/g_side");

	fTextColour[0] = 1.0;
	fTextColour[1] = 1.0;
	fTextColour[2] = 1.0;

	XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL);
	XPLMRegisterDrawCallback(
	    DrawStrings,
	    xplm_Phase_Window,      // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

//	XPLMSetDatai(drOverRide, 1);// Now overide surfaces, not yaw, roll, pitch

	// Register our hot key for the new view
	gHotKey = XPLMRegisterHotKey(
	    XPLM_VK_F8,
	    xplm_DownFlag, 
	    "Circling External View",
	    MyHotKeyCallback,
	    NULL);

	XPLMRegisterDrawCallback(
	    MyDrawCallback,
	    xplm_Phase_Objects,     // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

	XPLMRegisterKeySniffer(
		MyKeySniffer,           // Our callback
		1,                      // Receive input before plugin windows
		0);                     // Refcon - not used

	memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength);
	return 1;
}