-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added camera feed and plane detection (both vertical and horizontal)
Wip on light estimation and depth estimation too but the later needs a new feature in Godot.
- Loading branch information
Showing
36 changed files
with
311,028 additions
and
680 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ google-services.json | |
|
||
# Android Profiling | ||
*.hprof | ||
|
||
# IDE | ||
.vscode |
This file was deleted.
Oops, something went wrong.
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
Submodule godot-cpp
updated
62 files
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
extends MeshInstance3D | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
func _process(delta): | ||
rotate(Vector3(0, 0, 1), delta) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,18 @@ | ||
extends Node3D | ||
extends Node2D | ||
|
||
# TODO: Update to match your plugin's name | ||
var _plugin_name = "ARCorePlugin" | ||
var ARCorePlugin | ||
var _android_plugin | ||
|
||
var simultaneous_scene = preload("res://main3D.tscn").instantiate() | ||
|
||
func _ready(): | ||
if Engine.has_singleton(_plugin_name): | ||
ARCorePlugin = Engine.get_singleton(_plugin_name) | ||
|
||
# This sets up access to the environment and godot classes | ||
ARCorePlugin.initializeEnvironment() | ||
_android_plugin = Engine.get_singleton(_plugin_name) | ||
else: | ||
printerr("Couldn't find plugin " + _plugin_name) | ||
|
||
func _process(delta): | ||
# Display the XRCamera position we get from ARCore | ||
# print($XROrigin3D.position) | ||
# print($XROrigin3D/XRCamera3D.fov) | ||
$CanvasLayer/Control/VBoxContainer/MarginContainer2/VBoxContainer/CameraPositionLabel.text = "XRCamera3D.position: " + str($XROrigin3D/XRCamera3D.position) | ||
$CanvasLayer/Control/VBoxContainer/MarginContainer2/VBoxContainer/TrackingState.text = "Tracking State: " + get_tracking_state() | ||
|
||
func _on_start_ar_button_pressed(): | ||
print("ARCoreInterfaceInstance") | ||
|
||
# This should be named "ARCoreInterface" but there is a name clash with the registered class "ARCoreInterface" | ||
ARCoreInterfaceInstance.start() | ||
|
||
func get_tracking_state() -> String: | ||
var status = ARCoreInterfaceInstance.get_tracking_status() | ||
|
||
if status == XRInterface.XR_NOT_TRACKING: | ||
return "Not Tracking" | ||
elif status == XRInterface.XR_NORMAL_TRACKING: | ||
return "Normal Tracking" | ||
else: | ||
return "Unknown Tracking" | ||
#if ARCoreInterfaceInstance.get_tracking_status() == 0: | ||
# return "Not Tracking" | ||
#else: | ||
# return "Unknown State" | ||
func _on_Button_pressed(): | ||
if _android_plugin: | ||
# TODO: Update to match your plugin's API | ||
get_tree().root.add_child(simultaneous_scene) |
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 |
---|---|---|
@@ -1,132 +1,19 @@ | ||
[gd_scene load_steps=10 format=3 uid="uid://cg3hylang5fxn"] | ||
[gd_scene load_steps=2 format=3 uid="uid://cg3hylang5fxn"] | ||
|
||
[ext_resource type="Script" path="res://main.gd" id="1_j0gfq"] | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rr52s"] | ||
bg_color = Color(0.2655, 0.317775, 0.45, 1) | ||
border_width_left = 4 | ||
border_width_top = 4 | ||
border_width_right = 4 | ||
border_width_bottom = 4 | ||
border_color = Color(0.206182, 0.248662, 0.360116, 1) | ||
corner_radius_top_left = 20 | ||
corner_radius_top_right = 20 | ||
corner_radius_bottom_right = 20 | ||
corner_radius_bottom_left = 20 | ||
|
||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_x8ygb"] | ||
albedo_color = Color(0, 0, 1, 1) | ||
|
||
[sub_resource type="BoxMesh" id="BoxMesh_wukjl"] | ||
material = SubResource("StandardMaterial3D_x8ygb") | ||
size = Vector3(0.4, 0.4, 0.4) | ||
|
||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_trvgj"] | ||
albedo_color = Color(1, 0, 0, 1) | ||
|
||
[sub_resource type="SphereMesh" id="SphereMesh_yvi2r"] | ||
material = SubResource("StandardMaterial3D_trvgj") | ||
radius = 0.05 | ||
height = 0.1 | ||
|
||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_lvyi5"] | ||
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) | ||
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) | ||
|
||
[sub_resource type="Sky" id="Sky_vwrey"] | ||
sky_material = SubResource("ProceduralSkyMaterial_lvyi5") | ||
|
||
[sub_resource type="Environment" id="Environment_603g6"] | ||
background_mode = 2 | ||
sky = SubResource("Sky_vwrey") | ||
tonemap_mode = 2 | ||
|
||
[node name="Main" type="Node3D"] | ||
[node name="Main" type="Node2D"] | ||
script = ExtResource("1_j0gfq") | ||
|
||
[node name="CanvasLayer" type="CanvasLayer" parent="."] | ||
|
||
[node name="Control" type="Control" parent="CanvasLayer"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control"] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
[node name="Button" type="Button" parent="."] | ||
anchors_preset = 14 | ||
anchor_top = 0.5 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
|
||
[node name="MarginContainer2" type="MarginContainer" parent="CanvasLayer/Control/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/margin_left = 50 | ||
theme_override_constants/margin_top = 100 | ||
theme_override_constants/margin_right = 50 | ||
theme_override_constants/margin_bottom = 50 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control/VBoxContainer/MarginContainer2"] | ||
layout_mode = 2 | ||
|
||
[node name="CameraPositionLabel" type="Label" parent="CanvasLayer/Control/VBoxContainer/MarginContainer2/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 30 | ||
text = "XRCamera.position: [0, 0, 0]" | ||
|
||
[node name="TrackingState" type="Label" parent="CanvasLayer/Control/VBoxContainer/MarginContainer2/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 30 | ||
text = "Tracking State: Not tracking" | ||
|
||
[node name="Spacer" type="Control" parent="CanvasLayer/Control/VBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/Control/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/margin_left = 60 | ||
theme_override_constants/margin_top = 30 | ||
theme_override_constants/margin_right = 60 | ||
theme_override_constants/margin_bottom = 120 | ||
|
||
[node name="StartARButton" type="Button" parent="CanvasLayer/Control/VBoxContainer/MarginContainer"] | ||
custom_minimum_size = Vector2(0, 150) | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 60 | ||
theme_override_styles/normal = SubResource("StyleBoxFlat_rr52s") | ||
text = "Start AR" | ||
|
||
[node name="XROrigin3D" type="XROrigin3D" parent="."] | ||
current = true | ||
|
||
[node name="MeshInstance3D" type="MeshInstance3D" parent="XROrigin3D"] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) | ||
mesh = SubResource("BoxMesh_wukjl") | ||
|
||
[node name="Origin" type="MeshInstance3D" parent="XROrigin3D"] | ||
mesh = SubResource("SphereMesh_yvi2r") | ||
|
||
[node name="Label3D" type="Label3D" parent="XROrigin3D/Origin"] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.190765, 0) | ||
pixel_size = 0.0005 | ||
text = "Origin | ||
↓" | ||
font_size = 120 | ||
outline_size = 30 | ||
|
||
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D"] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.476125) | ||
fov = 60.0 | ||
|
||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] | ||
environment = SubResource("Environment_603g6") | ||
|
||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] | ||
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0) | ||
shadow_enabled = true | ||
|
||
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/MarginContainer/StartARButton" to="." method="_on_start_ar_button_pressed"] | ||
anchor_bottom = 0.5 | ||
offset_left = 40.0 | ||
offset_top = 250.0 | ||
offset_right = 320.0 | ||
offset_bottom = 312.0 | ||
text = "Hello GDExtension World" | ||
|
||
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"] |
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,75 @@ | ||
extends Node3D | ||
|
||
var _plugin_name = "ARCorePlugin" | ||
var _android_plugin | ||
|
||
var is_estimating_light = false | ||
var original_light_trsf: Transform3D; | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
for s in Engine.get_singleton_list(): | ||
print("MCT " + s.get_basename()) | ||
if Engine.has_singleton(_plugin_name): | ||
print("MCT found plugin") | ||
_android_plugin = Engine.get_singleton(_plugin_name) | ||
else: | ||
printerr("MCT Couldn't find plugin " + _plugin_name) | ||
|
||
print("MCT before initialize_wrapper") | ||
_android_plugin.initializeEnvironment() | ||
|
||
print("MCT called initialize_wrapper") | ||
|
||
var ar_interface = ARCoreInterfaceInstance.get_interface() | ||
var interface_name = ar_interface.get_name() | ||
print("MCT " + interface_name) | ||
|
||
ARCoreInterfaceInstance.start() | ||
|
||
original_light_trsf = $DirectionalLight3D.transform | ||
|
||
func _exit_tree(): | ||
_android_plugin.uninitializeEnvironment() | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
func _process(delta): | ||
if (is_estimating_light): | ||
var light_dir = ARCoreInterfaceInstance.get_light_main_hdr_direction() | ||
$DirectionalLight3D.rotation = light_dir | ||
var intensity = ARCoreInterfaceInstance.get_light_main_hdr_intensity() | ||
$DirectionalLight3D.light_intensity_lumens = intensity.x; | ||
else: | ||
$DirectionalLight3D.transform = original_light_trsf | ||
|
||
|
||
func _on_node_2d_estimate_depthmap_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_depth_estimation(toggled) | ||
|
||
func _on_node_2d_show_depthmap_toggled(toggled): | ||
ARCoreInterfaceInstance.show_depth_map(toggled) | ||
|
||
func _on_node_2d_far_changed(value): | ||
ARCoreInterfaceInstance.set_max_depth_meters(value) | ||
|
||
func _on_node_2d_vertical_planes_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_vertical_plane_detection(toggled) | ||
|
||
func _on_node_2d_horizontal_planes_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_horizontal_plane_detection(toggled) | ||
|
||
func _on_node_2d_images_detection_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_images_detection(toggled) | ||
|
||
func _on_node_2d_instant_placement_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_instant_placement(toggled) | ||
|
||
func _on_node_2d_light_estimation_toggled(toggled): | ||
is_estimating_light = toggled | ||
ARCoreInterfaceInstance.enable_light_estimation(toggled) | ||
|
||
func _on_node_2d_point_cloud_detection_toggled(toggled): | ||
ARCoreInterfaceInstance.enable_point_cloud_detection(toggled) | ||
|
||
func _on_node_2d_switch_orientation(vertical): | ||
ARCoreInterfaceInstance.switch_orientation(vertical) |
Oops, something went wrong.