init
This commit is contained in:
commit
3fc766e6ae
21 changed files with 606 additions and 0 deletions
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.DS_Store
|
||||||
|
.import/
|
||||||
|
*.import
|
||||||
|
|
||||||
|
**/.DS_Store
|
||||||
|
**/.import/
|
||||||
|
**/*.import
|
||||||
59
Global.gd
Normal file
59
Global.gd
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#scene changing
|
||||||
|
var _scenelist = ["res://Main.tscn", "res://oscScene.tscn"]
|
||||||
|
var _sceneidx = 0
|
||||||
|
|
||||||
|
func nextScene():
|
||||||
|
_sceneidx = (_sceneidx + 1) % _scenelist.size()
|
||||||
|
get_tree().change_scene(_scenelist[_sceneidx])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#gdpd (pd interface with godot)
|
||||||
|
var _gdpd
|
||||||
|
var _patches = []
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
_gdpd = load("res://addons/gdpd/bin/gdpd.gdns").new()
|
||||||
|
var inps = _gdpd.get_available_input_devices()
|
||||||
|
var outs = _gdpd.get_available_output_devices()
|
||||||
|
_gdpd.init_devices(inps[0], outs[0])
|
||||||
|
_gdpd.subscribe("toGodot")
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
if _patches.size() != 0:
|
||||||
|
print()
|
||||||
|
print("! ======== * purging leftover opened patches ... * ======== !")
|
||||||
|
print()
|
||||||
|
for id in _patches:
|
||||||
|
_gdpd.closePatch(id)
|
||||||
|
_patches.clear()
|
||||||
|
_gdpd.stop()
|
||||||
|
|
||||||
|
func load_patch(pd_patch) -> int:
|
||||||
|
#the patch path should be the absolute one
|
||||||
|
#separate file name from directory
|
||||||
|
var patch_name = pd_patch.split("/")[-1]
|
||||||
|
var patch_dir = pd_patch.trim_suffix(patch_name)
|
||||||
|
|
||||||
|
#load patch
|
||||||
|
var id = _gdpd.openPatch(patch_name, patch_dir)
|
||||||
|
_patches.append(id)
|
||||||
|
|
||||||
|
return id
|
||||||
|
|
||||||
|
func close_patch(id):
|
||||||
|
if id in _patches:
|
||||||
|
_gdpd.closePatch(id)
|
||||||
|
_patches.erase(id)
|
||||||
|
|
||||||
|
func _process(_delta) :
|
||||||
|
while _gdpd.has_message():
|
||||||
|
var msg = _gdpd.get_next()
|
||||||
|
print(msg)
|
||||||
|
# if msg[0] == "random":
|
||||||
|
# print("r")
|
||||||
6
Global.tscn
Normal file
6
Global.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Global.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Global" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
7
Main.gd
Normal file
7
Main.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
randomize()
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
Global.nextScene()
|
||||||
48
Main.tscn
Normal file
48
Main.tscn
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Main.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=1]
|
||||||
|
extents = Vector3( 30, 1, 30 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=3]
|
||||||
|
resource_name = "grass3"
|
||||||
|
params_cull_mode = 2
|
||||||
|
albedo_color = Color( 0.8, 0.8, 0.8, 1 )
|
||||||
|
roughness = 0.0764706
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=2]
|
||||||
|
material = SubResource( 3 )
|
||||||
|
size = Vector3( 60, 2, 60 )
|
||||||
|
|
||||||
|
[node name="Main" type="Node"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
|
||||||
|
collision_mask = 0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_group_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 60, 0 )
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 0 )
|
||||||
|
collision_layer = 2
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 2.0
|
||||||
|
one_shot = true
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
81
Player.gd
Normal file
81
Player.gd
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
extends KinematicBody
|
||||||
|
|
||||||
|
var camera_angle = 0
|
||||||
|
var mouse_sensitivity = 0.3
|
||||||
|
var camera_change = Vector2()
|
||||||
|
|
||||||
|
var velocity = Vector3()
|
||||||
|
var direction = Vector3()
|
||||||
|
|
||||||
|
var _oldtf = Transform()
|
||||||
|
|
||||||
|
|
||||||
|
#fly variables
|
||||||
|
const FLY_SPEED = 20
|
||||||
|
const FLY_ACCEL = 4
|
||||||
|
|
||||||
|
var mouse_captured = true
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
|
||||||
|
if mouse_captured:
|
||||||
|
aim()
|
||||||
|
fly(delta)
|
||||||
|
# emit signal - playerinfo_updated
|
||||||
|
var tf = $Head/Camera.get_global_transform_interpolated()
|
||||||
|
if tf != _oldtf:
|
||||||
|
PlayerInfo.emit_signal("player_transform_updated", $Head/Camera.get_global_translation(), $Head.global_rotation.y)
|
||||||
|
_oldtf = tf
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed('toggle_mouse'):
|
||||||
|
if mouse_captured:
|
||||||
|
mouse_captured = false
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
|
else:
|
||||||
|
mouse_captured = true
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
camera_change = event.relative
|
||||||
|
|
||||||
|
func fly(delta):
|
||||||
|
# reset the direction of the player
|
||||||
|
direction = Vector3()
|
||||||
|
|
||||||
|
# get the rotation of the camera
|
||||||
|
var aim = $Head/Camera.get_global_transform().basis
|
||||||
|
|
||||||
|
# check input and change direction
|
||||||
|
if Input.is_action_pressed("move_forward"):
|
||||||
|
direction -= aim.z
|
||||||
|
if Input.is_action_pressed("move_backward"):
|
||||||
|
direction += aim.z
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
direction -= aim.x
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
direction += aim.x
|
||||||
|
|
||||||
|
direction = direction.normalized()
|
||||||
|
|
||||||
|
# where would the player go at max speed
|
||||||
|
var target = direction * FLY_SPEED
|
||||||
|
|
||||||
|
# calculate a portion of the distance to go
|
||||||
|
velocity = velocity.linear_interpolate(target, FLY_ACCEL * delta)
|
||||||
|
|
||||||
|
# move
|
||||||
|
move_and_slide(velocity)
|
||||||
|
|
||||||
|
func aim():
|
||||||
|
if camera_change.length() > 0:
|
||||||
|
$Head.rotate_y(deg2rad(-camera_change.x * mouse_sensitivity))
|
||||||
|
|
||||||
|
var change = -camera_change.y * mouse_sensitivity
|
||||||
|
if change + camera_angle < 90 and change + camera_angle > -90:
|
||||||
|
$Head/Camera.rotate_x(deg2rad(change))
|
||||||
|
camera_angle += change
|
||||||
|
camera_change = Vector2()
|
||||||
21
Player.tscn
Normal file
21
Player.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=1]
|
||||||
|
radius = 0.6
|
||||||
|
height = 2.0
|
||||||
|
|
||||||
|
[node name="Player" type="KinematicBody"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.52113, 0.98772 )
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Capsule" type="CollisionShape" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Head" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="Head"]
|
||||||
|
far = 10000.0
|
||||||
5
PlayerInfo.gd
Normal file
5
PlayerInfo.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal player_transform_updated(position, heading)
|
||||||
|
# position : Vector3
|
||||||
|
# heading : Vector2 (projected x-z plane, and normalized)
|
||||||
6
PlayerInfo.tscn
Normal file
6
PlayerInfo.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://PlayerInfo.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="PlayerInfo" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
8
addons/gdpd/bin/gdpd.gdns
Normal file
8
addons/gdpd/bin/gdpd.gdns
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/gdpd/bin/libgdpd.gdnlib" type="GDNativeLibrary" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_name = "gdpd"
|
||||||
|
class_name = "Gdpd"
|
||||||
|
library = ExtResource( 1 )
|
||||||
18
addons/gdpd/bin/libgdpd.gdnlib
Normal file
18
addons/gdpd/bin/libgdpd.gdnlib
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[general]
|
||||||
|
|
||||||
|
singleton=false
|
||||||
|
load_once=false
|
||||||
|
symbol_prefix="godot_"
|
||||||
|
reloadable=true
|
||||||
|
|
||||||
|
[entry]
|
||||||
|
|
||||||
|
X11.64="res://addons/gdpd/bin/x11/libgdpd.so"
|
||||||
|
Windows.64="res://addons/gdpd/bin/win/libgdpd.dll"
|
||||||
|
OSX.64="res://addons/gdpd/bin/osx/libgdpd.dylib"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
X11.64=[ ]
|
||||||
|
Windows.64=[ ]
|
||||||
|
OSX.64=[ ]
|
||||||
BIN
addons/gdpd/bin/osx/libgdpd.dylib
Executable file
BIN
addons/gdpd/bin/osx/libgdpd.dylib
Executable file
Binary file not shown.
7
default_env.tres
Normal file
7
default_env.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
background_mode = 2
|
||||||
|
background_sky = SubResource( 1 )
|
||||||
73
export_presets.cfg
Normal file
73
export_presets.cfg
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="Mac OSX"
|
||||||
|
platform="Mac OSX"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="./moraepado.dmg"
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
application/name=""
|
||||||
|
application/info="Made with Godot Engine"
|
||||||
|
application/icon=""
|
||||||
|
application/identifier="in.dianaband.soundballs"
|
||||||
|
application/signature=""
|
||||||
|
application/app_category="Games"
|
||||||
|
application/short_version="1.0"
|
||||||
|
application/version="1.0"
|
||||||
|
application/copyright=""
|
||||||
|
display/high_res=false
|
||||||
|
privacy/microphone_usage_description=""
|
||||||
|
privacy/camera_usage_description=""
|
||||||
|
privacy/location_usage_description=""
|
||||||
|
privacy/address_book_usage_description=""
|
||||||
|
privacy/calendar_usage_description=""
|
||||||
|
privacy/photos_library_usage_description=""
|
||||||
|
privacy/desktop_folder_usage_description=""
|
||||||
|
privacy/documents_folder_usage_description=""
|
||||||
|
privacy/downloads_folder_usage_description=""
|
||||||
|
privacy/network_volumes_usage_description=""
|
||||||
|
privacy/removable_volumes_usage_description=""
|
||||||
|
codesign/enable=true
|
||||||
|
codesign/identity=""
|
||||||
|
codesign/timestamp=false
|
||||||
|
codesign/hardened_runtime=false
|
||||||
|
codesign/replace_existing_signature=true
|
||||||
|
codesign/entitlements/custom_file=""
|
||||||
|
codesign/entitlements/allow_jit_code_execution=false
|
||||||
|
codesign/entitlements/allow_unsigned_executable_memory=false
|
||||||
|
codesign/entitlements/allow_dyld_environment_variables=false
|
||||||
|
codesign/entitlements/disable_library_validation=true
|
||||||
|
codesign/entitlements/audio_input=false
|
||||||
|
codesign/entitlements/camera=false
|
||||||
|
codesign/entitlements/location=false
|
||||||
|
codesign/entitlements/address_book=false
|
||||||
|
codesign/entitlements/calendars=false
|
||||||
|
codesign/entitlements/photos_library=false
|
||||||
|
codesign/entitlements/apple_events=false
|
||||||
|
codesign/entitlements/debugging=false
|
||||||
|
codesign/entitlements/app_sandbox/enabled=false
|
||||||
|
codesign/entitlements/app_sandbox/network_server=false
|
||||||
|
codesign/entitlements/app_sandbox/network_client=false
|
||||||
|
codesign/entitlements/app_sandbox/device_usb=false
|
||||||
|
codesign/entitlements/app_sandbox/device_bluetooth=false
|
||||||
|
codesign/entitlements/app_sandbox/files_downloads=0
|
||||||
|
codesign/entitlements/app_sandbox/files_pictures=0
|
||||||
|
codesign/entitlements/app_sandbox/files_music=0
|
||||||
|
codesign/entitlements/app_sandbox/files_movies=0
|
||||||
|
codesign/custom_options=PoolStringArray( )
|
||||||
|
notarization/enable=false
|
||||||
|
notarization/apple_id_name=""
|
||||||
|
notarization/apple_id_password=""
|
||||||
|
notarization/apple_team_id=""
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
76
osc-node.pd
Normal file
76
osc-node.pd
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#N canvas 67 146 456 518 12;
|
||||||
|
#X obj 361 21 loadbang;
|
||||||
|
#X msg 361 51 \; pd dsp 1;
|
||||||
|
#X obj 80 277 osc~ 440;
|
||||||
|
#X obj 21 150 random 900;
|
||||||
|
#X obj 21 174 + 500;
|
||||||
|
#X floatatom 21 198 5 0 0 0 - - -;
|
||||||
|
#X obj 21 467 s toGodot;
|
||||||
|
#X obj 21 437 list;
|
||||||
|
#X msg 21 407 random \$1;
|
||||||
|
#X obj 21 22 r fromGodot\$0;
|
||||||
|
#X obj 21 46 list trim;
|
||||||
|
#X obj 303 253 hsl 100 20 -1 1 0 0 empty empty empty -2 -10 0 12 -262144
|
||||||
|
-1 -1 0 1;
|
||||||
|
#X obj 300 349 line~;
|
||||||
|
#X msg 300 325 \$1 100;
|
||||||
|
#X obj 300 278 expr ($f1 + 1)/8;
|
||||||
|
#X floatatom 300 302 5 0 0 0 - - -;
|
||||||
|
#N canvas 68 97 450 300 pan2~ 0;
|
||||||
|
#X obj 51 98 cos~;
|
||||||
|
#X obj 111 98 cos~;
|
||||||
|
#X obj 33 128 *~;
|
||||||
|
#X obj 93 128 *~;
|
||||||
|
#X obj 33 158 outlet~;
|
||||||
|
#X obj 93 158 outlet~;
|
||||||
|
#X obj 33 24 inlet~;
|
||||||
|
#X obj 111 24 inlet~;
|
||||||
|
#X obj 111 74 +~ 0.75;
|
||||||
|
#X connect 0 0 2 1;
|
||||||
|
#X connect 1 0 3 1;
|
||||||
|
#X connect 2 0 4 0;
|
||||||
|
#X connect 3 0 5 0;
|
||||||
|
#X connect 6 0 2 0;
|
||||||
|
#X connect 6 0 3 0;
|
||||||
|
#X connect 7 0 8 0;
|
||||||
|
#X connect 7 0 0 0;
|
||||||
|
#X connect 8 0 1 0;
|
||||||
|
#X restore 199 437 pd pan2~;
|
||||||
|
#X obj 199 467 dac~ 1 2;
|
||||||
|
#X obj 199 407 *~;
|
||||||
|
#X obj 189 230 line~;
|
||||||
|
#X msg 189 206 \$1 100;
|
||||||
|
#X obj 189 127 unpack f f;
|
||||||
|
#X floatatom 296 159 5 0 0 0 - - -;
|
||||||
|
#X obj 296 182 sin;
|
||||||
|
#X floatatom 296 206 5 0 0 0 - - -;
|
||||||
|
#X floatatom 189 177 5 0 0 0 - - -;
|
||||||
|
#X obj 21 70 route bang panvol;
|
||||||
|
#X connect 0 0 1 0;
|
||||||
|
#X connect 2 0 18 0;
|
||||||
|
#X connect 3 0 4 0;
|
||||||
|
#X connect 4 0 5 0;
|
||||||
|
#X connect 5 0 2 0;
|
||||||
|
#X connect 5 0 8 0;
|
||||||
|
#X connect 7 0 6 0;
|
||||||
|
#X connect 8 0 7 0;
|
||||||
|
#X connect 9 0 10 0;
|
||||||
|
#X connect 10 0 26 0;
|
||||||
|
#X connect 11 0 14 0;
|
||||||
|
#X connect 12 0 16 1;
|
||||||
|
#X connect 13 0 12 0;
|
||||||
|
#X connect 14 0 15 0;
|
||||||
|
#X connect 15 0 13 0;
|
||||||
|
#X connect 16 0 17 0;
|
||||||
|
#X connect 16 1 17 1;
|
||||||
|
#X connect 18 0 16 0;
|
||||||
|
#X connect 19 0 18 1;
|
||||||
|
#X connect 20 0 19 0;
|
||||||
|
#X connect 21 0 25 0;
|
||||||
|
#X connect 21 1 22 0;
|
||||||
|
#X connect 22 0 23 0;
|
||||||
|
#X connect 23 0 24 0;
|
||||||
|
#X connect 24 0 11 0;
|
||||||
|
#X connect 25 0 20 0;
|
||||||
|
#X connect 26 0 3 0;
|
||||||
|
#X connect 26 1 21 0;
|
||||||
47
osc.gd
Normal file
47
osc.gd
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
extends RigidBody
|
||||||
|
|
||||||
|
var _my_patch = "res://osc-node.pd"
|
||||||
|
var _my_id = 0
|
||||||
|
export (float) var audible_range_max = 10
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# load patch
|
||||||
|
_my_id = Global.load_patch(ProjectSettings.globalize_path(_my_patch))
|
||||||
|
|
||||||
|
# relocate randomly
|
||||||
|
look_at_from_position(Vector3(randf()*60 - 30, randf()*2 + 1, randf()*60 - 30), Vector3.FORWARD, Vector3.UP)
|
||||||
|
|
||||||
|
# send a 'individual' bang.
|
||||||
|
Global._gdpd.start_message(1)
|
||||||
|
Global._gdpd.add_symbol('bang') # there's no 'add_bang', only 'add_symbol' => add_symbol('bang') is a pseudo-bang
|
||||||
|
Global._gdpd.finish_list("fromGodot" + String(_my_id)) # send msg. individually ($0)
|
||||||
|
|
||||||
|
# listen 'player_transform_updated' event
|
||||||
|
PlayerInfo.connect("player_transform_updated", self, "_on_PlayerInfo_player_transform_updated")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_PlayerInfo_player_transform_updated(playerpos, playerheading):
|
||||||
|
var mypos = get_global_translation()
|
||||||
|
var mypos2d = Vector2(mypos.x, mypos.z)
|
||||||
|
var playerpos2d = Vector2(playerpos.x, playerpos.z)
|
||||||
|
# calculate distance
|
||||||
|
var distance = mypos.distance_to(playerpos)
|
||||||
|
# calculate angle
|
||||||
|
var angle = fmod(fmod(playerpos2d.angle_to_point(mypos2d) + playerheading - PI/2, PI*2) + PI*2, PI*2)
|
||||||
|
if angle > PI:
|
||||||
|
angle = angle - PI*2
|
||||||
|
# (check)
|
||||||
|
# print(str(_my_id) +" : ("+ str(distance) +","+ str(angle) +")")
|
||||||
|
# calculate gain
|
||||||
|
var gain = max(1 - distance/audible_range_max, 0)
|
||||||
|
# send to the patch
|
||||||
|
Global._gdpd.start_message(3)
|
||||||
|
Global._gdpd.add_symbol("panvol")
|
||||||
|
Global._gdpd.add_float(gain)
|
||||||
|
Global._gdpd.add_float(angle)
|
||||||
|
Global._gdpd.finish_list("fromGodot" + String(_my_id))
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
Global.close_patch(_my_id)
|
||||||
|
pass
|
||||||
22
osc.tscn
Normal file
22
osc.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://osc.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="PhysicsMaterial" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=2]
|
||||||
|
|
||||||
|
[node name="osc" type="RigidBody" groups=["sounders"]]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 0
|
||||||
|
physics_material_override = SubResource( 3 )
|
||||||
|
gravity_scale = 0.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
mesh = SubResource( 2 )
|
||||||
12
oscScene.gd
Normal file
12
oscScene.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var osctscn = load("res://osc.tscn")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
for i in range(18):
|
||||||
|
var oscnode = osctscn.instance()
|
||||||
|
add_child(oscnode)
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
Global.nextScene()
|
||||||
41
oscScene.tscn
Normal file
41
oscScene.tscn
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://oscScene.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://osc.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=1]
|
||||||
|
extents = Vector3( 30, 1, 30 )
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=2]
|
||||||
|
size = Vector3( 60, 2, 60 )
|
||||||
|
|
||||||
|
[node name="oscScene" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 0.158589, 0.987345, 0, -0.987345, 0.158589, 0, 57.3999, 0 )
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 2.0
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="osc" parent="." instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -21.352, 2, 22.3 )
|
||||||
|
|
||||||
|
[node name="osc2" parent="." instance=ExtResource( 3 )]
|
||||||
|
|
||||||
|
[node name="osc3" parent="." instance=ExtResource( 3 )]
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
62
project.godot
Normal file
62
project.godot
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=4
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="moraepado"
|
||||||
|
run/main_scene="res://Main.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Global="*res://Global.tscn"
|
||||||
|
PlayerInfo="*res://PlayerInfo.tscn"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_forward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_backward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
toggle_mouse={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="world"
|
||||||
|
3d_physics/layer_2="player"
|
||||||
|
3d_physics/layer_3="sounder"
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/default_environment="res://default_env.tres"
|
||||||
Loading…
Reference in a new issue