[3.0] Simplify list of branches in the README (#1255)

This commit is contained in:
Aaron Franke
2025-10-02 15:47:37 -07:00
parent 3e4f49cef7
commit ab9be2e79d
89 changed files with 624 additions and 1156 deletions

View File

@@ -1,4 +1,3 @@
extends Node
signal purchase_success(item_name)

View File

@@ -1,4 +1,3 @@
extends Control
onready var alert = get_node("alert")
@@ -13,7 +12,7 @@ func _ready():
iap.connect("consume_success", self, "on_consume_success")
iap.connect("consume_fail", self, "on_consume_fail")
iap.connect("sku_details_complete", self, "on_sku_details_complete")
get_node("purchase").connect("pressed", self, "button_purchase")
get_node("consume").connect("pressed", self, "button_consume")
get_node("request").connect("pressed", self, "button_request")

View File

@@ -1,11 +1,11 @@
extends Node
# Below are a number of helper functions that show how you can use the raw sensor data to determine the orientation
# Below are a number of helper functions that show how you can use the raw sensor data to determine the orientation
# of your phone/device. The cheapest phones only have an accelerometer only the most expensive phones have all three.
# Note that none of this logic filters data. Filters introduce lag but also provide stability. There are plenty
# of examples on the internet on how to implement these. I wanted to keep this straight forward.
# We draw a few arrow objects to visualize the vectors and two cubes to show two implementation for orientating
# We draw a few arrow objects to visualize the vectors and two cubes to show two implementation for orientating
# these cubes to our phones orientation.
# This is a 3D example however reading the phones orientation is also invaluable for 2D
@@ -13,52 +13,52 @@ extends Node
# care about the rotation around this axis.
func get_basis_for_arrow(p_vector):
var rotate = Basis()
# as our arrow points up, Y = our direction vector
rotate.y = p_vector.normalized()
# get an arbitrary vector we can use to calculate our other two vectors
var v = Vector3(1.0, 0.0, 0.0)
if abs(v.dot(rotate.y)) > 0.9:
v = Vector3(0.0, 1.0, 0.0)
# use our vector to get a vector perpendicular to our two vectors
rotate.x = rotate.y.cross(v).normalized()
# and the cross product again gives us our final vector perpendicular to our previous two vectors
rotate.z = rotate.x.cross(rotate.y).normalized()
return rotate
# This function combines the magnetometer reading with the gravity vector to get a vector that points due north
func calc_north(p_grav, p_mag):
# Always use normalized vectors!
p_grav = p_grav.normalized()
# Calculate east (or is it west) by getting our cross product.
# The cross product of two normalized vectors returns a vector that
# is perpendicular to our two vectors
var east = p_grav.cross(p_mag.normalized()).normalized()
# Cross again to get our horizon aligned north
return east.cross(p_grav).normalized()
# This function creates an orientation matrix using the magnetometer and gravity vector as inputs.
func orientate_by_mag_and_grav(p_mag, p_grav):
var rotate = Basis()
# as always, normalize!
p_mag = p_mag.normalized()
# gravity points down, so - gravity points up!
rotate.y = -p_grav.normalized()
# Cross products with our magnetic north gives an aligned east (or west, I always forget)
rotate.x = rotate.y.cross(p_mag)
# And cross product again and we get our aligned north completing our matrix
rotate.z = rotate.x.cross(rotate.y)
return rotate
# This function takes our gyro input and update an orientation matrix accordingly
@@ -66,28 +66,28 @@ func orientate_by_mag_and_grav(p_mag, p_grav):
# rotational velocity. This is why we multiply our values with delta.
func rotate_by_gyro(p_gyro, p_basis, p_delta):
var rotate = Basis()
rotate = rotate.rotated(p_basis.x, -p_gyro.x * p_delta)
rotate = rotate.rotated(p_basis.y, -p_gyro.y * p_delta)
rotate = rotate.rotated(p_basis.z, -p_gyro.z * p_delta)
return rotate * p_basis
# This function corrects the drift in our matrix by our gravity vector
# This function corrects the drift in our matrix by our gravity vector
func drift_correction(p_basis, p_grav):
# as always, make sure our vector is normalized but also invert as our gravity points down
var real_up = -p_grav.normalized()
# start by calculating the dot product, this gives us the cosine angle between our two vectors
var dot = p_basis.y.dot(real_up)
# if our dot is 1.0 we're good
if dot < 1.0:
# the cross between our two vectors gives us a vector perpendicular to our two vectors
var axis = p_basis.y.cross(real_up).normalized()
var correction = Basis(axis, acos(dot))
p_basis = correction * p_basis
return p_basis
func _process(delta):
@@ -96,12 +96,12 @@ func _process(delta):
var grav = Input.get_gravity()
var mag = Input.get_magnetometer()
var gyro = Input.get_gyroscope()
# Show our base values
get_node("Control/Accelerometer").text = 'Accelerometer: ' + str(acc) + ', gravity: ' + str(grav)
get_node("Control/Magnetometer").text = 'Magnetometer: ' + str(mag)
get_node("Control/Gyroscope").text = 'Gyroscope: ' + str(gyro)
# Check if we have all needed data
if grav.length() < 0.1:
if acc.length() < 0.1:
@@ -110,31 +110,31 @@ func _process(delta):
else:
# The gravity vector is calculated by the OS by combining the other sensor inputs.
# If we don't have a gravity vector, from now on, use accelerometer...
grav = acc
grav = acc
if mag.length() < 0.1:
mag = Vector3(1.0, 0.0, 0.0)
# Update our arrow showing gravity
get_node("Arrows/AccelerometerArrow").transform.basis = get_basis_for_arrow(grav)
# Update our arrow showing our magnetometer
# Note that in absense of other strong magnetic forces this will point to magnetic north, which is not horizontal thanks to the earth being, uhm, round
get_node("Arrows/MagnetoArrow").transform.basis = get_basis_for_arrow(mag)
# Calculate our north vector and show that
var north = calc_north(grav,mag)
get_node("Arrows/NorthArrow").transform.basis = get_basis_for_arrow(north)
# Combine our magnetometer and gravity vector to position our box. This will be fairly accurate
# but our magnetometer can be easily influenced by magnets. Cheaper phones often don't have gyros
# so it is a good backup.
var mag_and_grav = get_node("Boxes/MagAndGrav")
mag_and_grav.transform.basis = orientate_by_mag_and_grav(mag, grav).orthonormalized()
# Using our gyro and do a drift correction using our gravity vector gives the best result
var gyro_and_grav = get_node("Boxes/GyroAndGrav")
var new_basis = rotate_by_gyro(gyro, gyro_and_grav.transform.basis, delta).orthonormalized()
gyro_and_grav.transform.basis = drift_correction(new_basis, grav)

View File

@@ -1,4 +1,3 @@
extends Control
# Member variables