first commit

This commit is contained in:
Daniel Bulant 2024-05-19 13:01:08 +02:00
commit 7a861a19b0
14 changed files with 342 additions and 0 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

BIN
de.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

35
de.jpg.import Normal file
View file

@ -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

BIN
dice.blend Normal file

Binary file not shown.

74
dice.blend.import Normal file
View file

@ -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

BIN
dice.fbx Normal file

Binary file not shown.

38
dice.gd Normal file
View file

@ -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

BIN
dice.res Normal file

Binary file not shown.

1
icon.svg Normal file
View file

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z" fill="#478cbf"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 949 B

37
icon.svg.import Normal file
View file

@ -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

16
main.gd Normal file
View file

@ -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

113
main.tscn Normal file
View file

@ -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"]

24
project.godot Normal file
View file

@ -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