Skip to content

Commit

Permalink
Cleaning up Sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
thygrrr committed Feb 28, 2024
1 parent 78154ad commit 7ec2dd2
Show file tree
Hide file tree
Showing 27 changed files with 227 additions and 219 deletions.
41 changes: 0 additions & 41 deletions examples/example-godot/BasicCubes/UI.tscn

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
using Godot;
using Vector3 = System.Numerics.Vector3;

namespace examples.godot.BasicCubes;
namespace examples.godot.CubeDemo;

[GlobalClass]
public partial class MultiMeshExample : Node3D
[Icon("res://icon.svg")]
public partial class CubeDemo : Node
{
private const int MaxEntities = 420_069;

Expand Down Expand Up @@ -124,9 +125,9 @@ private static void UpdatePositionForCube(ref int index, ref Matrix4X3 transform

// Apply a chaotic Lissajous-like motion for the cubes
var motionIndex = (index + uniform.Time * Mathf.Tau * 69f) % uniform.SmoothCount - uniform.SmoothCount/2f;

var entityRatio = uniform.SmoothCount / MaxEntities;

var phase1 = motionIndex * Mathf.Sin(motionIndex / 1500f * Mathf.Tau) * 7f * Mathf.Tau / uniform.SmoothCount;
var phase2 = motionIndex * Mathf.Sin(motionIndex / 1700f * Mathf.Tau) * 5f * Mathf.Tau / uniform.SmoothCount;
var phase3 = motionIndex * Mathf.Sin(motionIndex / 1000f * Mathf.Tau) * 11f * entityRatio * Mathf.Tau / uniform.SmoothCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
[gd_scene load_steps=19 format=3 uid="uid://dr2uc3nf0w2sy"]

[ext_resource type="Script" path="res://BasicCubes/Rotate.gd" id="1_tqr0u"]
[ext_resource type="Script" path="res://BasicCubes/MultiMeshExample.cs" id="1_yanug"]
[ext_resource type="Material" uid="uid://bnswggdiq40dw" path="res://BasicCubes/box_material.tres" id="2_ai16h"]
[ext_resource type="Script" path="res://FPSLabel.gd" id="2_pay0t"]
[ext_resource type="Script" path="res://BasicCubes/PivotSway.gd" id="3_c10c7"]
[ext_resource type="FontFile" uid="uid://cvmp81n8dc3uk" path="res://Fonts/BaiJamjuree-Regular.ttf" id="3_ih8bu"]
[ext_resource type="Theme" uid="uid://xobxg8yxjsmu" path="res://fennecs_theme.tres" id="3_ym7v2"]
[ext_resource type="Texture2D" uid="uid://bmw4r15o3hat4" path="res://fennecs-logo.png" id="4_58011"]
[ext_resource type="Material" uid="uid://vjeh1fpt4xak" path="res://BasicCubes/orange_light.tres" id="6_2hcul"]
[ext_resource type="Material" uid="uid://db1pq7ldj0yi6" path="res://BasicCubes/blue_light.tres" id="6_o8tf2"]
[gd_scene load_steps=18 format=3 uid="uid://dr2uc3nf0w2sy"]

[ext_resource type="Script" path="res://CubeDemo/CubeDemo.cs" id="1_1jicl"]
[ext_resource type="Material" uid="uid://bnswggdiq40dw" path="res://CubeDemo/Materials/box_material.tres" id="2_a5jon"]
[ext_resource type="Theme" uid="uid://xobxg8yxjsmu" path="res://zzzShared/fennecs_theme.tres" id="3_h31e3"]
[ext_resource type="FontFile" uid="uid://cvmp81n8dc3uk" path="res://zzzShared/BaiJamjuree-Regular.ttf" id="4_plwtk"]
[ext_resource type="PackedScene" uid="uid://bdfvsd3p00icf" path="res://zzzShared/user_interface.tscn" id="5_gh02a"]
[ext_resource type="Script" path="res://zzzShared/FPSLabel.gd" id="6_wvaw7"]
[ext_resource type="Script" path="res://CubeDemo/PivotSway.gd" id="7_1fct3"]
[ext_resource type="Script" path="res://CubeDemo/Rotate.gd" id="8_cipfs"]
[ext_resource type="Material" uid="uid://vjeh1fpt4xak" path="res://CubeDemo/Materials/orange_light.tres" id="9_t1ajc"]
[ext_resource type="Material" uid="uid://db1pq7ldj0yi6" path="res://CubeDemo/Materials/blue_light.tres" id="10_vph3x"]

[sub_resource type="BoxMesh" id="BoxMesh_so3e6"]
material = ExtResource("2_ai16h")
material = ExtResource("2_a5jon")
size = Vector3(3, 3, 3)

[sub_resource type="MultiMesh" id="MultiMesh_fdhkq"]
transform_format = 1
mesh = SubResource("BoxMesh_so3e6")

[sub_resource type="LabelSettings" id="LabelSettings_d0l4f"]
font = ExtResource("3_ih8bu")

[sub_resource type="LabelSettings" id="LabelSettings_557ru"]
font = ExtResource("3_ih8bu")
font_size = 48
[sub_resource type="LabelSettings" id="LabelSettings_tpdu5"]
font = ExtResource("4_plwtk")
font_size = 32

[sub_resource type="LabelSettings" id="LabelSettings_e5jui"]
font = ExtResource("3_ih8bu")
font_size = 24
[sub_resource type="LabelSettings" id="LabelSettings_d0l4f"]
font = ExtResource("4_plwtk")

[sub_resource type="SphereMesh" id="SphereMesh_1qaly"]
material = ExtResource("6_2hcul")
material = ExtResource("9_t1ajc")
radius = 7.0
height = 14.0

[sub_resource type="SphereMesh" id="SphereMesh_s2td0"]
material = ExtResource("6_o8tf2")
material = ExtResource("10_vph3x")
radius = 7.0
height = 14.0

Expand All @@ -53,31 +49,47 @@ fog_enabled = true
fog_light_color = Color(0, 0, 0.0156863, 1)
fog_density = 0.003

[node name="Entity Positioning Demo" type="Node3D"]
[node name="fennecs Cube Demo" type="Node3D"]

[node name="MultiMeshExample" type="Node3D" parent="." node_paths=PackedStringArray("MeshInstance", "Camera", "SimulatedSlider", "RenderedSlider")]
[node name="CubeDemo" type="Node" parent="." node_paths=PackedStringArray("MeshInstance", "Camera", "SimulatedSlider", "RenderedSlider")]
unique_name_in_owner = true
script = ExtResource("1_yanug")
script = ExtResource("1_1jicl")
MeshInstance = NodePath("MultiMeshInstance3D")
Camera = NodePath("../Camera Pivot/Camera3D")
SimulatedSlider = NodePath("../User Interface/VBoxContainer/SpawnController/SimulatedSlider")
RenderedSlider = NodePath("../User Interface/VBoxContainer/SpawnController/VisibleSlider")
SimulatedSlider = NodePath("../User Interface/Spawn Controls/Sliders/SimulatedSlider")
RenderedSlider = NodePath("../User Interface/Spawn Controls/Sliders/VisibleSlider")

[node name="MultiMeshInstance3D" type="MultiMeshInstance3D" parent="MultiMeshExample"]
[node name="MultiMeshInstance3D" type="MultiMeshInstance3D" parent="CubeDemo"]
multimesh = SubResource("MultiMesh_fdhkq")

[node name="User Interface" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 1.0
offset_right = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_ym7v2")
[node name="User Interface" parent="." instance=ExtResource("5_gh02a")]
offset_left = 0.0
offset_right = 0.0

[node name="VBoxContainer" type="VBoxContainer" parent="User Interface"]
[node name="Info Text" type="RichTextLabel" parent="User Interface"]
modulate = Color(1, 1, 1, 0.501961)
show_behind_parent = true
layout_mode = 1
offset_left = 10.0
offset_top = 10.0
offset_right = 363.0
offset_bottom = 383.0
size_flags_horizontal = 8
bbcode_enabled = true
text = "DemoCubes (Godot version)
This demo is 100% CPU simulation (no GPU). Here, we demonstrate a simple case how to update the positions of a large number of Entities.
State is stored in Components on the Entities:
[ul]
1x System.Numerics.Vector3 (as Position)
1x Matrix4x3 (custom struct, as Transform)
1x integer (as a simple identifier)
[/ul]
The state is transferred into the Godot Engine in bulk each frame using Query.Raw and submitting just the Matrix4x3 structs directly to a MultiMeshInstance3D."

[node name="Spawn Controls" type="VBoxContainer" parent="User Interface"]
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 1
anchors_preset = 3
Expand All @@ -93,40 +105,52 @@ grow_horizontal = 0
grow_vertical = 0
alignment = 2

[node name="SpawnController" type="HBoxContainer" parent="User Interface/VBoxContainer"]
[node name="FPS Label" type="Label" parent="User Interface/Spawn Controls"]
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 2
size_flags_horizontal = 8
theme_override_font_sizes/font_size = 40
text = "0 fps
0 entities
"
label_settings = SubResource("LabelSettings_tpdu5")
horizontal_alignment = 2
script = ExtResource("6_wvaw7")

[node name="Sliders" type="HBoxContainer" parent="User Interface/Spawn Controls"]
layout_mode = 2
size_flags_horizontal = 8

[node name="VisibleSlider" type="VSlider" parent="User Interface/VBoxContainer/SpawnController"]
[node name="VisibleSlider" type="VSlider" parent="User Interface/Spawn Controls/Sliders"]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 500)
layout_mode = 2
theme = ExtResource("3_ym7v2")
theme = ExtResource("3_h31e3")
min_value = 0.01
max_value = 1.0
step = 0.03
value = 0.31
tick_count = 20
ticks_on_borders = true

[node name="SimulatedSlider" type="VSlider" parent="User Interface/VBoxContainer/SpawnController"]
[node name="SimulatedSlider" type="VSlider" parent="User Interface/Spawn Controls/Sliders"]
custom_minimum_size = Vector2(60, 500)
layout_mode = 2
theme = ExtResource("3_ym7v2")
theme = ExtResource("3_h31e3")
min_value = 0.05
max_value = 1.0
step = 0.05
value = 0.4
tick_count = 20
ticks_on_borders = true

[node name="Panel" type="Panel" parent="User Interface/VBoxContainer"]
[node name="Panel" type="Panel" parent="User Interface/Spawn Controls"]
show_behind_parent = true
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8

[node name="HBoxContainer2" type="VBoxContainer" parent="User Interface/VBoxContainer/Panel"]
[node name="HBoxContainer2" type="VBoxContainer" parent="User Interface/Spawn Controls/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -140,7 +164,7 @@ grow_vertical = 2
rotation = 1.5708
mouse_filter = 2

[node name="SimulatedLabel" type="Label" parent="User Interface/VBoxContainer/Panel/HBoxContainer2"]
[node name="SimulatedLabel" type="Label" parent="User Interface/Spawn Controls/Panel/HBoxContainer2"]
show_behind_parent = true
layout_mode = 2
size_flags_horizontal = 8
Expand All @@ -149,7 +173,7 @@ label_settings = SubResource("LabelSettings_d0l4f")
horizontal_alignment = 2
vertical_alignment = 1

[node name="RenderedLabel" type="Label" parent="User Interface/VBoxContainer/Panel/HBoxContainer2"]
[node name="RenderedLabel" type="Label" parent="User Interface/Spawn Controls/Panel/HBoxContainer2"]
show_behind_parent = true
layout_mode = 2
size_flags_horizontal = 8
Expand All @@ -159,73 +183,17 @@ label_settings = SubResource("LabelSettings_d0l4f")
horizontal_alignment = 2
vertical_alignment = 1

[node name="Fennecs Logo" type="TextureRect" parent="User Interface"]
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -269.0
offset_top = -243.0
offset_right = 755.0
offset_bottom = 781.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.5, 0.5)
texture = ExtResource("4_58011")
stretch_mode = 3

[node name="FPS Label" type="Label" parent="User Interface"]
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -218.0
offset_top = 9.0
offset_right = -9.0
offset_bottom = 132.0
grow_horizontal = 0
size_flags_horizontal = 8
theme_override_font_sizes/font_size = 40
text = "0 fps
0 entities
"
label_settings = SubResource("LabelSettings_557ru")
horizontal_alignment = 2
script = ExtResource("2_pay0t")

[node name="Hyperlink" type="Label" parent="User Interface"]
modulate = Color(1, 1, 1, 0.501961)
show_behind_parent = true
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 5.0
offset_top = -34.0
offset_right = 234.0
offset_bottom = -4.0
grow_vertical = 0
size_flags_horizontal = 8
text = "https://fennecs.tech"
label_settings = SubResource("LabelSettings_e5jui")
horizontal_alignment = 2
vertical_alignment = 1

[node name="Camera Pivot" type="Node3D" parent="."]
script = ExtResource("3_c10c7")
script = ExtResource("7_1fct3")

[node name="Camera3D" type="Camera3D" parent="Camera Pivot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 200)

[node name="Light Pivot" type="Node3D" parent="."]
script = ExtResource("1_tqr0u")
script = ExtResource("8_cipfs")

[node name="Orange Light" type="OmniLight3D" parent="Light Pivot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 100, 0, 200)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 200)
light_color = Color(0.933333, 0.501961, 0, 1)
light_energy = 10.0
omni_range = 250.0
Expand All @@ -235,10 +203,10 @@ omni_attenuation = 0.233258
mesh = SubResource("SphereMesh_1qaly")

[node name="Blue Light" type="OmniLight3D" parent="Light Pivot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -200, 50, -100)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -200)
light_color = Color(0.243137, 0.462745, 0.996078, 1)
light_energy = 10.0
omni_range = 300.0
omni_range = 250.0
omni_attenuation = 0.233258

[node name="MeshInstance3D" type="MeshInstance3D" parent="Light Pivot/Blue Light"]
Expand All @@ -247,6 +215,6 @@ mesh = SubResource("SphereMesh_s2td0")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_q01bs")

[connection signal="value_changed" from="User Interface/VBoxContainer/SpawnController/VisibleSlider" to="MultiMeshExample" method="_on_rendered_slider_value_changed"]
[connection signal="drag_ended" from="User Interface/VBoxContainer/SpawnController/SimulatedSlider" to="MultiMeshExample" method="_on_simulated_slider_drag_ended"]
[connection signal="value_changed" from="User Interface/VBoxContainer/SpawnController/SimulatedSlider" to="MultiMeshExample" method="_on_simulated_slider_value_changed"]
[connection signal="value_changed" from="User Interface/Spawn Controls/Sliders/VisibleSlider" to="CubeDemo" method="_on_rendered_slider_value_changed"]
[connection signal="drag_ended" from="User Interface/Spawn Controls/Sliders/SimulatedSlider" to="CubeDemo" method="_on_simulated_slider_drag_ended"]
[connection signal="value_changed" from="User Interface/Spawn Controls/Sliders/SimulatedSlider" to="CubeDemo" method="_on_simulated_slider_value_changed"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Numerics;
using System.Runtime.InteropServices;

namespace examples.godot.BasicCubes;
namespace examples.godot.CubeDemo;

[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct Matrix4X3
Expand Down
File renamed without changes.
Binary file removed examples/example-godot/fennecs-head.png
Binary file not shown.
Loading

0 comments on commit 7ec2dd2

Please sign in to comment.