简体   繁体   English

Android到虚幻引擎接口(C ++)

[英]Android to Unreal Engine Interface (C++)

How should I get camera/GPS information from an Android device to the Unreal Engine? 我应该如何将相机/ GPS信息从Android设备发送到虚幻引擎? I have searched everywhere and I'm not sure how to proceed. 我到处搜索,不确定如何继续。

Do I write a Java application for Android that communicates with Unreal via JNI or is there a more direct way to access the camera/GPS from Unreal via C++ by including libraries? 我是否编写了用于Android的Java应用程序,该应用程序通过JNI与虚幻引擎通信,或者是否有更直接的方法通过包含库通过C ++从虚幻引擎访问相机/ GPS?

Are there any APIs out there that already bridge this gap? 有没有已经弥合这种差距的API?

Thanks! 谢谢!

Assuming you are using UE4. 假设您正在使用UE4。 The concept of Unreal Engine4 is modules that can be used by C++ code not depending on the platform (whenever it is possible). 虚幻引擎4的概念是C ++代码可以使用的模块,而不取决于平台(只要有可能)。

Basically You need to create a module with C++ interface and implementations for different platforms. 基本上,您需要创建具有C ++接口和针对不同平台的实现的模块。 Your module most probably will be in the /Engine/Source/Runtime/<module_name> . 您的模块很可能位于/Engine/Source/Runtime/<module_name> It has to contain <module_name>.Build.cs file for the UnrealBuildTool and two folders: Public and Private . 它必须包含<module_name>.Build.cs文件和两个文件夹: PublicPrivate The first one will contain headers with your interface of the required functionality. 第一个将包含具有所需功能的接口的标头。 Private should contain set of folders for specific platform eg Android , IOS . Private应包含用于特定平台(例如AndroidIOS的文件夹集。 Each platform should implement functionality described in the interface. 每个平台都应实现界面中描述的功能。 For android you'll have to use JNI bindings, for iOS you'll be needing native Objective-C calls to the iPhoneSDK. 对于android,您将必须使用JNI绑定,对于iOS,您将需要对iPhoneSDK的本机Objective-C调用。 The tricky part here is defining common interface for all platforms that will be do both setting up the given functionality and using all required features of it. 这里最棘手的部分是为所有平台定义通用接口,这些接口既可以设置给定功能,也可以使用其所有必需的功能。

For references you can check WebBrowser module that has separate android implementation with unreal's new JNI wrapper. 作为参考,您可以检查WebBrowser模块,该模块具有单独的android实现和虚幻的新JNI包装器。

PS Modules you've created you can push to the UE4 repo as pull request. 您创建的PS模块可以作为拉取请求推送到UE4存储库。 This will help others when they'll be needing same functionality as you. 当其他人需要与您相同的功能时,这将为他们提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM