-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OpenXR fb_render_model extension wrapper and OpenXRFBRenderModel …
…node
- Loading branch information
1 parent
4962575
commit 01ac31e
Showing
10 changed files
with
619 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
godotopenxrmeta/src/main/cpp/include/openxr_fb_render_model.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/**************************************************************************/ | ||
/* openxr_fb_render_model.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT XR */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ | ||
/* */ | ||
/* Original contributed implementation: */ | ||
/* Copyright (c) 2022-2023 MattaKis Consulting Kft. (Migeran) */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#ifndef OPENXR_FB_RENDER_MODEL_H | ||
#define OPENXR_FB_RENDER_MODEL_H | ||
|
||
#include <godot_cpp/classes/node3d.hpp> | ||
|
||
namespace godot { | ||
|
||
class OpenXRFbRenderModel : public Node3D { | ||
GDCLASS(OpenXRFbRenderModel, Node3D) | ||
|
||
private: | ||
String render_model_path; | ||
Node3D *render_model = nullptr; | ||
|
||
void load_render_model(); | ||
|
||
protected: | ||
void _notification(int p_what); | ||
|
||
static void _bind_methods(); | ||
|
||
public: | ||
void set_render_model_path(String p_render_model_path); | ||
String get_render_model_path(); | ||
|
||
static TypedArray<String> get_valid_paths(); | ||
bool has_render_model(); | ||
Node3D *get_render_model(); | ||
}; | ||
|
||
} //namespace godot | ||
|
||
#endif |
119 changes: 119 additions & 0 deletions
119
godotopenxrmeta/src/main/cpp/include/openxr_fb_render_model_extension_wrapper.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/**************************************************************************/ | ||
/* openxr_fb_render_model_extension_wrapper.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT XR */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ | ||
/* */ | ||
/* Original contributed implementation: */ | ||
/* Copyright (c) 2022-2023 MattaKis Consulting Kft. (Migeran) */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#ifndef OPENXR_FB_RENDER_MODEL_EXTENSION_WRAPPER_H | ||
#define OPENXR_FB_RENDER_MODEL_EXTENSION_WRAPPER_H | ||
|
||
#include <openxr/openxr.h> | ||
#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp> | ||
#include <godot_cpp/variant/utility_functions.hpp> | ||
#include <map> | ||
|
||
#include "util.h" | ||
|
||
using namespace godot; | ||
|
||
// Wrapper for the set of Facebook render model extension. | ||
class OpenXRFbRenderModelExtensionWrapper : public OpenXRExtensionWrapperExtension { | ||
GDCLASS(OpenXRFbRenderModelExtensionWrapper, OpenXRExtensionWrapperExtension); | ||
|
||
public: | ||
uint64_t _set_system_properties_and_get_next_pointer(void *next_pointer) override; | ||
|
||
godot::Dictionary _get_requested_extensions() override; | ||
|
||
void _on_instance_created(uint64_t instance) override; | ||
|
||
void _on_instance_destroyed() override; | ||
|
||
void _on_state_stopping() override; | ||
|
||
static OpenXRFbRenderModelExtensionWrapper *get_singleton(); | ||
|
||
bool is_enabled() const; | ||
TypedArray<String> get_valid_paths(); | ||
PackedByteArray get_buffer(const String &p_path); | ||
|
||
OpenXRFbRenderModelExtensionWrapper(); | ||
~OpenXRFbRenderModelExtensionWrapper(); | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
private: | ||
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateRenderModelPathsFB, | ||
(XrSession), session, | ||
(uint32_t), pathCapacityInput, | ||
(uint32_t *), pathCountOutput, | ||
(XrRenderModelPathInfoFB *), path); | ||
|
||
EXT_PROTO_XRRESULT_FUNC3(xrGetRenderModelPropertiesFB, | ||
(XrSession), session, | ||
(XrPath), path, | ||
(XrRenderModelPropertiesFB *), properties); | ||
|
||
EXT_PROTO_XRRESULT_FUNC3(xrLoadRenderModelFB, | ||
(XrSession), session, | ||
(const XrRenderModelLoadInfoFB *), info, | ||
(XrRenderModelBufferFB *), buffer); | ||
|
||
EXT_PROTO_XRRESULT_FUNC5(xrPathToString, | ||
(XrInstance), instance, | ||
(XrPath), path, | ||
(uint32_t), bufferCapacityInput, | ||
(uint32_t *), bufferCountOutput, | ||
(char *), buffer); | ||
|
||
EXT_PROTO_XRRESULT_FUNC3(xrStringToPath, | ||
(XrInstance), instance, | ||
(const char *), pathString, | ||
(XrPath *), path); | ||
|
||
bool initialize_fb_render_model_extension(const XrInstance instance); | ||
|
||
void cleanup(); | ||
|
||
void populate_valid_paths(); | ||
|
||
String _xr_path_to_string(XrPath p_path); | ||
|
||
XrPath _string_to_xr_path(const String &p_path); | ||
|
||
static OpenXRFbRenderModelExtensionWrapper *singleton; | ||
|
||
std::map<godot::String, bool *> request_extensions; | ||
bool fb_render_model_ext = false; | ||
TypedArray<String> valid_paths = TypedArray<String>(); | ||
XrSystemRenderModelPropertiesFB system_render_model_properties; | ||
}; | ||
|
||
#endif // OPENXR_FB_RENDER_MODEL_EXTENSION_WRAPPER_H |
Oops, something went wrong.