1

X-Plane 10 を 3D モード (3D コックピット) で起動したいので、このプラグインを作成しましたが、動作しません。どうしたの?X-Plane ログを確認したところ、プラグインは正常にロードされました。

/* This X-Plane plugin will enable 3D cockpit when X-Plane is started */

#pragma warning(disable: 4996) // Suppress warnings about unsafe operations in VS

#include <string.h>
#include <windows.h>
#include "XPLMDataAccess.h" // Required to get access to X-Plane data references

#if IBM
// Required if plugin is running on Windows
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}
#endif

/* This method is a part of the X-Plane plugin architecture. 
Will be executed when X-Plane loads the plugin. */
PLUGIN_API int XPluginStart(char* name, char* package, char* description) 
{
    // Describe our plugin to the X-Plane plugin system
    strcpy(name, "Enable3D");
    strcpy(package, "com.stackoverflow.enable3d");
    strcpy(description, "Enable 3D cockpit when X-Plane starts");

    // Contains the data reference file controlling the panel view
    XPLMDataRef panelRenderType = XPLMFindDataRef("sim/graphics/view/panel_render_type");

    // Set panel view to 3D cockpit
    XPLMSetDatai(panelRenderType, 2);

    // Initialization successful
    return 1;
}

/* This method is a part of the X-Plane plugin architecture.
Will be executed when X-Plane closes the plugin. */
PLUGIN_API void XPluginStop(void)
{
    // Do nothing
}

/* This method is a part of the X-Plane plugin architecture.
Will be executed when the user enables the plugin. */
PLUGIN_API int XPluginEnable(void)
{
    // Enabled successfully
    return 1;
}

/* This method is a part of the X-Plane plugin architecture.
Will be executed when the user disables the plugin. */
PLUGIN_API void XPluginDisable(void)
{
    // Do nothing
}

/* This method is a part of the X-Plane plugin architecture.
The method acts as a message handler. We don't have to do
anything here, but we must provide one. */
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID caller, long message, void* param)
{
    // Do nothing
}

ドキュメントによると、「sim/graphics/view/panel_render_type」データ参照は、2D パネルの場合は 1、3D パネルの場合は 2、3D パネルの場合は 3 に設定する必要があります。

4

2 に答える 2

4

X-Plane のすべてが Datarefs 経由でアクセスされるわけではありません。

プラグイン SDK からキー/ジョイスティック ボタンの割り当てシステムを利用できます。

このスニペットを試してください:

XPLMCommandOnce( XPLMFindCommand( "sim/view/3d_cockpit_cmd_look" ) );

この「遅延初期化」コードと組み合わせると、次のようになります。

http://www.xsquawkbox.net/xpsdk/mediawiki/DeferredInitialization#Example

組み合わせると、3D コックピット モードを有効にするプラグインが必要になります。

于 2013-05-02T16:40:38.817 に答える