Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Konclan committed Jun 6, 2024
0 parents commit e629c09
Show file tree
Hide file tree
Showing 24 changed files with 1,185 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/
Binary file added Assets/Models/arrow.blend
Binary file not shown.
Binary file added Assets/Models/arrow.blend1
Binary file not shown.
Binary file added Assets/Models/arrow.glb
Binary file not shown.
47 changes: 47 additions & 0 deletions Assets/Models/arrow.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dswjcq8yh6fax"
path="res://.godot/imported/arrow.glb-efb3afd670c1a18eea7b96a71b203212.scn"

[deps]

source_file="res://Assets/Models/arrow.glb"
dest_files=["res://.godot/imported/arrow.glb-efb3afd670c1a18eea7b96a71b203212.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": {
"arrow_Cylinder_001": {
"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://Assets/Models/arrow.res"
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Binary file added Assets/Models/arrow.res
Binary file not shown.
44 changes: 44 additions & 0 deletions Editor.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[gd_scene load_steps=7 format=3 uid="uid://dwegml4v5p4vy"]

[ext_resource type="PackedScene" uid="uid://76sja71fjsp2" path="res://player.tscn" id="1_pmneb"]
[ext_resource type="PackedScene" uid="uid://cfsxeoyq6xih7" path="res://Voxels/Blocks/block.tscn" id="2_55sfc"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_vljmq"]

[sub_resource type="Sky" id="Sky_8pojv"]
sky_material = SubResource("ProceduralSkyMaterial_vljmq")

[sub_resource type="Environment" id="Environment_iydjw"]
background_mode = 2
sky = SubResource("Sky_8pojv")

[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_pwd5p"]

[node name="Editor" type="Node"]

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_iydjw")

[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.707107, -0.612373, 0.353553, 0, 0.5, 0.866025, -0.707107, -0.612372, 0.353553, 0, 3, 0)
shadow_enabled = true

[node name="Player" parent="." instance=ExtResource("1_pmneb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 3)

[node name="Boxes" type="Node" parent="."]

[node name="Voxels" type="Node" parent="."]

[node name="Blocks" type="Node" parent="Voxels"]

[node name="Block" parent="Voxels/Blocks" instance=ExtResource("2_55sfc")]

[node name="Panels" type="Node" parent="Voxels"]

[node name="Panes" type="Node" parent="Voxels"]

[node name="StaticBody3D" type="StaticBody3D" parent="."]

[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("WorldBoundaryShape3D_pwd5p")
3 changes: 3 additions & 0 deletions Main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://dp6834easkvem"]

[node name="Main" type="Node"]
34 changes: 34 additions & 0 deletions UI.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
extends Control

var save_path = "user://variable.save"
var textbox_text := ""

@onready var textbox = $LineEdit

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
textbox_text = textbox.text

func save_data():
var file = FileAccess.open(save_path,FileAccess.WRITE)
file.store_var(textbox_text)
print("Data saved.")

func load_data():
if FileAccess.file_exists(save_path):
var file = FileAccess.open(save_path, FileAccess.READ)
textbox.text = file.get_var()
print("Data loaded")
else:
print("No Data loaded")

func _on_save_button_pressed():
save_data()

func _on_load_button_pressed():
load_data()
54 changes: 54 additions & 0 deletions Voxels/Blocks/block.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
extends StaticBody3D

@onready var mesh_instance = $MeshInstance3D

func _ready():
create_colored_cube()

func create_colored_cube():
# Define cube data
var vertices = [
Vector3(-0.5, -0.5, -0.5), Vector3(-0.5, -0.5, 0.5), Vector3(-0.5, 0.5, 0.5), Vector3(-0.5, 0.5, -0.5),
Vector3(0.5, -0.5, -0.5), Vector3(0.5, -0.5, 0.5), Vector3(0.5, 0.5, 0.5), Vector3(0.5, 0.5, -0.5)
]
var faces = [
[3, 2, 1, 0], [4, 5, 6, 7], [0, 1, 5, 4], [1, 2, 6, 5], [2, 3, 7, 6], [4, 7, 3, 0]
]
var colors = [
Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, Color.MAGENTA, Color.CYAN
]

# Create a new ArrayMesh and SurfaceTool
var mesh = ArrayMesh.new()
var surface_tool = SurfaceTool.new()
surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)

# Loop through each face
for i in range(faces.size()):
# Set the color for the vertices of this face
surface_tool.set_color(colors[i])
surface_tool.set_smooth_group(i)
# Add the vertices for this face
for j in range(4):
surface_tool.add_vertex(vertices[faces[i][j]])
# Add two triangles for this face
surface_tool.add_index(i*4)
surface_tool.add_index(i*4 + 1)
surface_tool.add_index(i*4 + 2)
surface_tool.add_index(i*4)
surface_tool.add_index(i*4 + 2)
surface_tool.add_index(i*4 + 3)

# Generate normals and tangents
surface_tool.generate_normals()
#surface_tool.generate_tangents()

# Commit to the mesh
surface_tool.commit(mesh)

# Set the MeshInstance's mesh
mesh_instance.mesh = mesh

var material = StandardMaterial3D.new()
material.vertex_color_use_as_albedo = true
mesh_instance.set_surface_override_material(0, material)
13 changes: 13 additions & 0 deletions Voxels/Blocks/block.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://cfsxeoyq6xih7"]

[ext_resource type="Script" path="res://Voxels/Blocks/block.gd" id="1_xso7n"]

[sub_resource type="BoxShape3D" id="BoxShape3D_7lpxm"]

[node name="Block" type="StaticBody3D"]
script = ExtResource("1_xso7n")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_7lpxm")
39 changes: 39 additions & 0 deletions edi4C3.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_scene load_steps=7 format=3 uid="uid://dwegml4v5p4vy"]

[ext_resource type="PackedScene" uid="uid://76sja71fjsp2" path="res://player.tscn" id="1_pmneb"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_vljmq"]

[sub_resource type="Sky" id="Sky_8pojv"]
sky_material = SubResource("ProceduralSkyMaterial_vljmq")

[sub_resource type="Environment" id="Environment_iydjw"]
background_mode = 2
sky = SubResource("Sky_8pojv")

[sub_resource type="PlaneMesh" id="PlaneMesh_j0ry4"]
size = Vector2(10, 10)

[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_wkvn4"]

[node name="editor_scene" type="Node3D"]

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_iydjw")

[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.707107, -0.612373, 0.353553, 0, 0.5, 0.866025, -0.707107, -0.612372, 0.353553, 0, 3, 0)

[node name="Player" parent="." instance=ExtResource("1_pmneb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 3)

[node name="Floor" type="StaticBody3D" parent="."]

[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor"]
mesh = SubResource("PlaneMesh_j0ry4")
skeleton = NodePath("")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor"]
shape = SubResource("WorldBoundaryShape3D_wkvn4")

[node name="Boxes" type="Node3D" parent="."]
1 change: 1 addition & 0 deletions icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions icon.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ckg1hiots1h58"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}

[deps]

source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
95 changes: 95 additions & 0 deletions plaB900.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[gd_scene load_steps=6 format=3 uid="uid://76sja71fjsp2"]

[ext_resource type="Script" path="res://player.gd" id="1_oyd4n"]
[ext_resource type="ArrayMesh" uid="uid://c6t4k3omgds31" path="res://Assets/Models/arrow.res" id="2_8er4n"]
[ext_resource type="Script" path="res://UI.gd" id="2_cpo05"]

[sub_resource type="SphereMesh" id="SphereMesh_kdx6p"]
radius = 0.1
height = 0.2

[sub_resource type="SphereShape3D" id="SphereShape3D_8epwk"]
radius = 0.1

[node name="Player" type="CharacterBody3D"]
motion_mode = 1
script = ExtResource("1_oyd4n")

[node name="Arrow" type="Node3D" parent="."]
top_level = true

[node name="MeshInstance3D" type="MeshInstance3D" parent="Arrow"]
mesh = ExtResource("2_8er4n")
skeleton = NodePath("../..")

[node name="CameraController" type="Node3D" parent="."]
top_level = true

[node name="TwistPivot" type="Node3D" parent="CameraController"]

[node name="PitchPivot" type="Node3D" parent="CameraController/TwistPivot"]
transform = Transform3D(1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 0, 0)

[node name="SpringArm3D" type="SpringArm3D" parent="CameraController/TwistPivot/PitchPivot"]
collision_mask = 0
spring_length = 5.0
margin = 0.1

[node name="Camera3D" type="Camera3D" parent="CameraController/TwistPivot/PitchPivot/SpringArm3D"]
fov = 90.0

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_kdx6p")

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_8epwk")
disabled = true

[node name="UI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("2_cpo05")

[node name="GridContainer" type="GridContainer" parent="UI"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -92.0
offset_right = 92.0
offset_bottom = 40.0
grow_horizontal = 2
columns = 3

[node name="SaveButton" type="Button" parent="UI/GridContainer"]
layout_mode = 2
text = "Save Data"

[node name="VSeparator" type="VSeparator" parent="UI/GridContainer"]
layout_mode = 2

[node name="LoadButton" type="Button" parent="UI/GridContainer"]
layout_mode = 2
text = "Load Data"

[node name="LineEdit" type="LineEdit" parent="UI"]
layout_mode = 2
offset_left = 484.0
offset_top = 40.0
offset_right = 670.0
offset_bottom = 71.0

[node name="debug_text" type="RichTextLabel" parent="UI"]
layout_mode = 0
offset_right = 439.0
offset_bottom = 220.0
text = "help"

[connection signal="pressed" from="UI/GridContainer/SaveButton" to="UI" method="_on_save_button_pressed"]
[connection signal="pressed" from="UI/GridContainer/LoadButton" to="UI" method="_on_load_button_pressed"]
[connection signal="focus_entered" from="UI/LineEdit" to="." method="_on_line_edit_focus_entered"]
[connection signal="focus_exited" from="UI/LineEdit" to="." method="_on_line_edit_focus_exited"]
Loading

0 comments on commit e629c09

Please sign in to comment.