[Export] for different objects

master
Sascha 2023-09-15 16:24:24 +07:00
parent e0bd43bfe5
commit 33a63b1aa9
18 changed files with 147 additions and 48 deletions

@ -21,7 +21,7 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -21,7 +21,7 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -20,8 +20,8 @@ compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
compress/channel_pack=1
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""

@ -12,11 +12,13 @@ albedo_texture = ExtResource("2_cxio0")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6qu7a"]
albedo_texture = ExtResource("3_re2y4")
[node name="Box" type="Node3D"]
[node name="Box" type="Node3D" node_paths=PackedStringArray("numberLabels")]
script = ExtResource("1_1tgir")
numberLabels = [NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel1"), NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel2"), NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel3"), NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel4"), NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel5"), NodePath("BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox/NumberLabel6")]
[node name="BoxRigidBody3D" type="RigidBody3D" parent="."]
mass = 1.5
contact_monitor = true
[node name="BoxCollisionShapeBox" type="CollisionShape3D" parent="BoxRigidBody3D"]
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
@ -26,9 +28,46 @@ shape = SubResource("BoxShape3D_6js7j")
material_override = SubResource("StandardMaterial3D_dsxvl")
material = SubResource("StandardMaterial3D_6qu7a")
[node name="NumberLabel" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
[node name="NumberLabel1" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.501989)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[node name="NumberLabel2" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -0.507081)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[node name="NumberLabel3" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.501548, 0, 0.00197419)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[node name="NumberLabel4" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -0.518733, 0, 0.00849569)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[node name="NumberLabel5" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0149789, 0.503353, -0.023538)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[node name="NumberLabel6" type="Label3D" parent="BoxRigidBody3D/BoxCollisionShapeBox/BoxCSGBox"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.506804, 0.0168197)
modulate = Color(0, 0, 0, 1)
outline_modulate = Color(1, 1, 1, 1)
text = "1"
font_size = 64
[connection signal="body_entered" from="BoxRigidBody3D" to="." method="_on_box_rigid_body_3d_body_entered"]

@ -1,8 +1,14 @@
[gd_scene load_steps=8 format=3 uid="uid://bwn0di86nkots"]
[gd_scene load_steps=14 format=3 uid="uid://bwn0di86nkots"]
[ext_resource type="Script" path="res://scripts/World.cs" id="1_2chdl"]
[ext_resource type="PackedScene" uid="uid://bpf3krgeeo7pt" path="res://scenes/Box.tscn" id="2_gmm05"]
[ext_resource type="PackedScene" uid="uid://dqp4wlr2qj31f" path="res://scenes/GreenBox.tscn" id="3_621lc"]
[ext_resource type="Texture2D" uid="uid://b22evacwu3r6f" path="res://graphics/texture_06.svg" id="3_c3cx5"]
[ext_resource type="Script" path="res://scripts/Floor.cs" id="3_q36sk"]
[ext_resource type="PackedScene" uid="uid://djtfmrjbe01c7" path="res://scenes/OrangeBox.tscn" id="4_1w77b"]
[ext_resource type="PackedScene" uid="uid://bxa0dvonmob7f" path="res://scenes/RedBox.tscn" id="5_o3ohm"]
[ext_resource type="PackedScene" uid="uid://dgufgjsdd5407" path="res://scenes/PurpleBox.tscn" id="6_kqrbp"]
[ext_resource type="Script" path="res://scripts/ShootController.cs" id="9_tfx87"]
[sub_resource type="Sky" id="Sky_kc6p3"]
@ -29,8 +35,13 @@ size = Vector3(100, 0.1, 100)
albedo_texture = ExtResource("3_c3cx5")
uv1_scale = Vector3(32, 32, 32)
[node name="World" type="Node3D"]
[node name="World" type="Node3D" node_paths=PackedStringArray("fpsLabel", "boxesLabel", "collisionsLabel")]
script = ExtResource("1_2chdl")
boxScenes = [ExtResource("2_gmm05"), ExtResource("3_621lc"), ExtResource("4_1w77b"), ExtResource("5_o3ohm"), ExtResource("6_kqrbp")]
maxTimer = 0.1
fpsLabel = NodePath("CanvasGroup/FPS")
boxesLabel = NodePath("CanvasGroup/Boxes")
collisionsLabel = NodePath("CanvasGroup/Collisions")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_0d0eg")
@ -73,3 +84,25 @@ offset_top = 50.0
offset_right = 76.0
offset_bottom = 76.0
text = "Boxes: 0"
[node name="Collisions" type="Label" parent="CanvasGroup"]
offset_left = 31.0
offset_top = 76.0
offset_right = 95.0
offset_bottom = 102.0
text = "Collisions: 0"
[node name="ShootController" type="Node" parent="."]
script = ExtResource("9_tfx87")
[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 19, 0)
emitting = false
amount = 1
lifetime = 10.0
one_shot = true
trail_enabled = true
[node name="GPUParticlesCollisionBox3D" type="GPUParticlesCollisionBox3D" parent="GPUParticles3D"]
[node name="GPUParticlesCollisionSphere3D" type="GPUParticlesCollisionSphere3D" parent="GPUParticles3D/GPUParticlesCollisionBox3D"]

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Godot;
using Godot.Collections;
namespace Evolution.scripts;
@ -7,6 +8,7 @@ public partial class Box : Node3D {
private RigidBody3D rb;
private Vector3 rotation;
private const double randomRange = 1;
[Export] private Array<Label3D> numberLabels = new();
public override void _Ready() {
rb = GetChild<RigidBody3D>(0);
@ -22,11 +24,20 @@ public partial class Box : Node3D {
rotation = new((float)GD.RandRange(-randomRange, randomRange), (float)GD.RandRange(-randomRange, randomRange), (float)GD.RandRange(-randomRange, randomRange));
rb.AddConstantTorque(rotation);
Label3D numberLabel = cs.GetChild<CsgBox3D>(0).GetChild<Label3D>(0);
numberLabel.Text = $"{World.Instance.BoxCount}";
foreach (Label3D numberLabel in numberLabels) {
numberLabel.Text = $"{World.Instance.BoxCount}";
}
}
public override void _Process(double delta) {
// Array<Node3D> collidingBodies = rb.GetCollidingBodies();
// if (collidingBodies.Count > 0) {
// foreach (Node3D collidingBody in collidingBodies) {
// GD.Print($"{collidingBody.Name}");
// World.Instance.Collisions++;
// }
// }
if (rb.Position.Y < -50) {
World.Instance.DestroyBox();
QueueFree();

@ -0,0 +1,15 @@
using Godot;
namespace Evolution.scripts;
public partial class ShootController : Node
{
public override void _Input(InputEvent @event) {
if (@event is InputEventMouseButton eventMouseButton)
GD.Print($"Mouse Click/Unclick at: {eventMouseButton.Position}");
else if (@event is InputEventMouseMotion eventMouseMotion)
GD.Print($"Mouse Motion at: {eventMouseMotion.Position}");
}
}

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Godot;
using Godot.Collections;
namespace Evolution.scripts;
@ -8,27 +9,27 @@ public partial class World : Node3D {
public static World Instance { get; private set; }
public int BoxCount { get; private set; }
private readonly List<PackedScene> boxScenes = new();
private double maxTimer = 0.01;
public int Collisions {
get => collisions;
set {
collisions = value;
collisionsLabel.Text = $"Collisions: {collisions}";
}
}
[Export] private Array<PackedScene> boxScenes = new();
[Export] private double maxTimer = 0.01;
private double timer;
private double fpsTimer;
private Label fpsLabel;
private Label boxesLabel;
[Export] private Label fpsLabel;
[Export] private Label boxesLabel;
[Export] private Label collisionsLabel;
private int frameCount;
private readonly List<int> frameCounts = new();
public override void _Ready() {
Instance = this;
boxScenes.Add(GD.Load<PackedScene>("res://scenes/GreenBox.tscn"));
boxScenes.Add(GD.Load<PackedScene>("res://scenes/OrangeBox.tscn"));
boxScenes.Add(GD.Load<PackedScene>("res://scenes/PurpleBox.tscn"));
boxScenes.Add(GD.Load<PackedScene>("res://scenes/RedBox.tscn"));
boxScenes.Add(GD.Load<PackedScene>("res://scenes/Box.tscn"));
fpsLabel = GetNode<Label>("CanvasGroup/FPS");
boxesLabel = GetNode<Label>("CanvasGroup/Boxes");
}
private int collisions;
public override void _Ready() => Instance = this;
public override void _Process(double delta) {
frameCount++;