gpt4 book ai didi

c++ - X-Plane 以 3D 模式启动(插件 C/C++)

转载 作者:行者123 更新时间:2023-11-30 01:59:52 25 4
gpt4 key购买 nike

我想以 3D 模式(3D 驾驶舱)启动 X-Plane 10,所以我创建了这个插件,但它不起作用。怎么了?我检查了 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”数据引用应设置为 1(对于 2D 面板)、2(对于 3D 面板)和 3(对于 lit 3D 面板)。

最佳答案

并非 X-Plane 中的所有内容都通过 Datarefs 访问。

您可以从插件 SDK 进入按键/操纵杆按钮分配系统。

试试这个片段:

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

结合这个“延迟初始化”代码:

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

合并后,您应该有一个插件可以启用 3D 驾驶舱模式。

关于c++ - X-Plane 以 3D 模式启动(插件 C/C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15744768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com