commit 7a861a19b0bd9df735d4a6b9b1efc797f3ac5656 Author: Daniel Bulant Date: Sun May 19 13:01:08 2024 +0200 first commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/de.jpg b/de.jpg new file mode 100644 index 0000000..3b154a6 Binary files /dev/null and b/de.jpg differ diff --git a/de.jpg.import b/de.jpg.import new file mode 100644 index 0000000..cc2204b --- /dev/null +++ b/de.jpg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://w1rxbv37o62n" +path.s3tc="res://.godot/imported/de.jpg-375fb5e746ebc72c2f7e234647368e57.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://de.jpg" +dest_files=["res://.godot/imported/de.jpg-375fb5e746ebc72c2f7e234647368e57.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/dice.blend b/dice.blend new file mode 100644 index 0000000..056e1ff Binary files /dev/null and b/dice.blend differ diff --git a/dice.blend.import b/dice.blend.import new file mode 100644 index 0000000..5be4dbc --- /dev/null +++ b/dice.blend.import @@ -0,0 +1,74 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://d3mvfdbhh2a0r" +path="res://.godot/imported/dice.blend-8f74aeec4cc72ad8192a100c1f57a211.scn" + +[deps] + +source_file="res://dice.blend" +dest_files=["res://.godot/imported/dice.blend-8f74aeec4cc72ad8192a100c1f57a211.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +import_script/path="" +_subresources={ +"meshes": { +"dice_Cube": { +"generate/lightmap_uv": 0, +"generate/lods": 0, +"generate/shadow_meshes": 0, +"lods/normal_merge_angle": 60.0, +"lods/normal_split_angle": 25.0, +"save_to_file/enabled": true, +"save_to_file/make_streamable": "", +"save_to_file/path": "res://dice.res" +} +}, +"nodes": { +"PATH:Camera": { +"import/skip_import": true +}, +"PATH:Cube": { +"generate/physics": true +}, +"PATH:Light": { +"import/skip_import": true +} +} +} +gltf/naming_version=1 +gltf/embedded_image_handling=1 +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/dice.fbx b/dice.fbx new file mode 100644 index 0000000..6d0c690 Binary files /dev/null and b/dice.fbx differ diff --git a/dice.gd b/dice.gd new file mode 100644 index 0000000..6d71985 --- /dev/null +++ b/dice.gd @@ -0,0 +1,38 @@ +extends RigidBody3D +class_name Dice + +@export var start_marker: Marker3D + +func random_throw() -> void: + global_position = start_marker.global_transform.origin + linear_velocity = Vector3(0, 0, 0) + angular_velocity = Vector3(0, 0, 0) + var lateral_variation = .04 + apply_central_impulse(Vector3(randf_range(-.08,-.14), randf_range(-lateral_variation, lateral_variation), randf_range(-lateral_variation, lateral_variation))) + var angular_variation = .02 + apply_torque_impulse(Vector3(randf_range(-angular_variation, angular_variation),randf_range(-angular_variation, angular_variation),randf_range(-angular_variation, angular_variation))) + +func can_be_thrown() -> bool: + return sleeping + +var dice_map := [ + Vector3.UP, + Vector3.RIGHT, + Vector3.FORWARD, + Vector3.BACK, + Vector3.LEFT, + Vector3.DOWN +] + +func get_value() -> int: + var rot = Vector3.UP * global_basis + var closest = -1 + var closest_dist = 1000 + + for i in range(6): + var dist = rot.distance_to(dice_map[i]) + if dist < closest_dist: + closest = i + closest_dist = dist + + return closest + 1 diff --git a/dice.res b/dice.res new file mode 100644 index 0000000..ecbbdf5 Binary files /dev/null and b/dice.res differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..3fe4f4a --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..cf735d0 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b5b4omm3i2vxh" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/main.gd b/main.gd new file mode 100644 index 0000000..9e1c965 --- /dev/null +++ b/main.gd @@ -0,0 +1,16 @@ +extends Node3D + +@onready var dice: Dice = $dice1 + +func _ready() -> void: + pass + +func _process(_delta: float) -> void: + pass + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("ui_accept"): + dice.random_throw() + +func _on_dice_1_sleeping_state_changed() -> void: + pass \ No newline at end of file diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..68e7d62 --- /dev/null +++ b/main.tscn @@ -0,0 +1,113 @@ +[gd_scene load_steps=13 format=3 uid="uid://bxphc5t7er28i"] + +[ext_resource type="Script" path="res://main.gd" id="1_h1pkq"] +[ext_resource type="ArrayMesh" uid="uid://6ygsl6phockr" path="res://dice.res" id="1_qesf4"] +[ext_resource type="Script" path="res://dice.gd" id="2_jh75e"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_kmncl"] +bounce = 0.06 + +[sub_resource type="BoxShape3D" id="BoxShape3D_jujds"] +size = Vector3(0.1, 0.1, 0.1) + +[sub_resource type="PlaneMesh" id="PlaneMesh_qwxpl"] +size = Vector2(1, 1) + +[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_xg2jp"] +plane = Plane(0, 0.5, 0.005, 0) + +[sub_resource type="BoxShape3D" id="BoxShape3D_i1dy0"] +size = Vector3(1, 0.499512, 0.0229492) + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_55efa"] +ground_bottom_color = Color(0.158328, 0.184483, 0.141961, 1) + +[sub_resource type="Sky" id="Sky_q42e0"] +sky_material = SubResource("ProceduralSkyMaterial_55efa") + +[sub_resource type="Environment" id="Environment_rm3d5"] +background_mode = 2 +sky = SubResource("Sky_q42e0") +ambient_light_source = 3 +reflected_light_source = 2 +tonemap_mode = 3 +ssao_enabled = true +ssil_enabled = true +sdfgi_enabled = true +glow_enabled = true + +[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_i6kyw"] + +[node name="Node3D" type="Node3D"] +script = ExtResource("1_h1pkq") + +[node name="dice1" type="RigidBody3D" parent="." node_paths=PackedStringArray("start_marker")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.31759, 0.217006, 0.0105869) +mass = 0.1 +physics_material_override = SubResource("PhysicsMaterial_kmncl") +continuous_cd = true +script = ExtResource("2_jh75e") +start_marker = NodePath("../DiceThrowStart") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="dice1"] +transform = Transform3D(0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0) +mesh = ExtResource("1_qesf4") +skeleton = NodePath("../..") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="dice1"] +shape = SubResource("BoxShape3D_jujds") + +[node name="CSGMesh3D" type="CSGMesh3D" parent="."] +use_collision = true +mesh = SubResource("PlaneMesh_qwxpl") + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +shape = SubResource("WorldBoundaryShape3D_xg2jp") + +[node name="StaticBody3D2" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.502418) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.250244, -0.0148926) +shape = SubResource("BoxShape3D_i1dy0") + +[node name="StaticBody3D3" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.469744) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D3"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.250244, -0.0148926) +shape = SubResource("BoxShape3D_i1dy0") + +[node name="StaticBody3D4" type="StaticBody3D" parent="."] +transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.473637, 0, 0.00503573) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D4"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.250244, -0.0148926) +shape = SubResource("BoxShape3D_i1dy0") + +[node name="StaticBody3D5" type="StaticBody3D" parent="."] +transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.502919, 0, 0.000281781) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D5"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.250244, -0.0148926) +shape = SubResource("BoxShape3D_i1dy0") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.323323, 0.972071) +current = true +near = 0.003 + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_rm3d5") +camera_attributes = SubResource("CameraAttributesPractical_i6kyw") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.751874, 0.659306, 0, -0.659306, 0.751874, 0, 1.52296, 0) +shadow_enabled = true + +[node name="DiceThrowStart" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.408271, 0.326392, 0) + +[connection signal="sleeping_state_changed" from="dice1" to="." method="_on_dice_1_sleeping_state_changed"] diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d39b7c0 --- /dev/null +++ b/project.godot @@ -0,0 +1,24 @@ +; 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=5 + +[application] + +config/name="programovani-kostky" +run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" + +[filesystem] + +import/fbx/enabled=false + +[rendering] + +anti_aliasing/quality/msaa_3d=2