Added buch of stuff
This commit is contained in:
16
nodes/world/BlockLibrary.tres
Normal file
16
nodes/world/BlockLibrary.tres
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="VoxelBlockyLibrary" load_steps=4 format=3 uid="uid://bsue4rd3wdfsl"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/world/BlockMaterial.tres" id="1_evy8o"]
|
||||
|
||||
[sub_resource type="VoxelBlockyModelEmpty" id="VoxelBlockyModelEmpty_o5qli"]
|
||||
|
||||
[sub_resource type="VoxelBlockyModelCube" id="VoxelBlockyModelCube_0wfyh"]
|
||||
material_override_0 = ExtResource("1_evy8o")
|
||||
tile_left = Vector2i(0, 1)
|
||||
tile_right = Vector2i(0, 1)
|
||||
tile_bottom = Vector2i(1, 0)
|
||||
tile_back = Vector2i(0, 1)
|
||||
tile_front = Vector2i(0, 1)
|
||||
|
||||
[resource]
|
||||
models = Array[VoxelBlockyModel]([SubResource("VoxelBlockyModelEmpty_o5qli"), SubResource("VoxelBlockyModelCube_0wfyh")])
|
||||
7
nodes/world/BlockMaterial.tres
Normal file
7
nodes/world/BlockMaterial.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://de6s8en5fcyyw"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bcctuptks33yd" path="res://nodes/world/blocky_game_atlas.webp" id="1_nmlo6"]
|
||||
|
||||
[resource]
|
||||
albedo_texture = ExtResource("1_nmlo6")
|
||||
texture_filter = 0
|
||||
6
nodes/world/Terrain.gd
Normal file
6
nodes/world/Terrain.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
class_name Terrain extends VoxelTerrain
|
||||
|
||||
static var instance:Terrain
|
||||
|
||||
func _init() -> void:
|
||||
instance = self
|
||||
1
nodes/world/Terrain.gd.uid
Normal file
1
nodes/world/Terrain.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cp4pflpo7neyq
|
||||
51
nodes/world/TerrainScene.tscn
Normal file
51
nodes/world/TerrainScene.tscn
Normal file
@@ -0,0 +1,51 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://bp6ewa3urgac8"]
|
||||
|
||||
[ext_resource type="VoxelBlockyLibrary" uid="uid://bsue4rd3wdfsl" path="res://nodes/world/BlockLibrary.tres" id="1_4rm5p"]
|
||||
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/world/BlockMaterial.tres" id="2_yirul"]
|
||||
[ext_resource type="PackedScene" uid="uid://ddyulj4dsrkms" path="res://nodes/world/terrain_editor.tscn" id="3_heupn"]
|
||||
[ext_resource type="Script" uid="uid://cp4pflpo7neyq" path="res://nodes/world/Terrain.gd" id="3_yirul"]
|
||||
[ext_resource type="PackedScene" uid="uid://cy0nvmw51bwof" path="res://nodes/camera/controllable_camera.tscn" id="4_ublpu"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_gadlc"]
|
||||
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_t8uwy"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_gadlc")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_5g68j"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_t8uwy")
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_v3kfg"]
|
||||
|
||||
[sub_resource type="VoxelGeneratorNoise2D" id="VoxelGeneratorNoise2D_mko3u"]
|
||||
channel = 0
|
||||
height_start = 0.0
|
||||
height_range = 20.0
|
||||
noise = SubResource("FastNoiseLite_v3kfg")
|
||||
|
||||
[sub_resource type="VoxelMesherBlocky" id="VoxelMesherBlocky_3tbtj"]
|
||||
library = ExtResource("1_4rm5p")
|
||||
|
||||
[node name="VoxelWorld" type="Node"]
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_5g68j")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0)
|
||||
generator = SubResource("VoxelGeneratorNoise2D_mko3u")
|
||||
mesher = SubResource("VoxelMesherBlocky_3tbtj")
|
||||
bounds = AABB(-1040, -32, -1040, 2080, 96, 2080)
|
||||
material_override = ExtResource("2_yirul")
|
||||
script = ExtResource("3_yirul")
|
||||
|
||||
[node name="TerrainEditor" parent="VoxelTerrain" instance=ExtResource("3_heupn")]
|
||||
|
||||
[node name="ControllableCamera" parent="." instance=ExtResource("4_ublpu")]
|
||||
transform = Transform3D(-0.61081, -0.620921, 0.491291, 0, 0.620492, 0.784213, -0.791777, 0.479005, -0.379003, 34.4662, 28.9798, -20.4)
|
||||
BIN
nodes/world/blocky_game_atlas.webp
Normal file
BIN
nodes/world/blocky_game_atlas.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
35
nodes/world/blocky_game_atlas.webp.import
Normal file
35
nodes/world/blocky_game_atlas.webp.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bcctuptks33yd"
|
||||
path.s3tc="res://.godot/imported/blocky_game_atlas.webp-23ee11425f1b691f850e88290909a9fb.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://nodes/world/blocky_game_atlas.webp"
|
||||
dest_files=["res://.godot/imported/blocky_game_atlas.webp-23ee11425f1b691f850e88290909a9fb.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=1
|
||||
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
|
||||
32
nodes/world/terrain_editor.gd
Normal file
32
nodes/world/terrain_editor.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Node
|
||||
|
||||
@onready var voxelTool := (get_parent() as VoxelTerrain).get_voxel_tool()
|
||||
|
||||
var block_edit := false
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseButton and event.is_pressed():
|
||||
if block_edit:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
perform_block_action(true)
|
||||
elif event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
get_tree().create_timer(0.15).timeout.connect(
|
||||
func():
|
||||
if not Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
|
||||
perform_block_action(false)
|
||||
)
|
||||
|
||||
func perform_block_action(add_block:bool)->void:
|
||||
var mouse_pos_2d := get_viewport().get_mouse_position()
|
||||
var current_camera := get_viewport().get_camera_3d()
|
||||
var origin := current_camera.project_ray_origin(mouse_pos_2d)
|
||||
var dir := current_camera.project_ray_normal(mouse_pos_2d)
|
||||
var res := voxelTool.raycast(origin, dir, 50)
|
||||
if res != null:
|
||||
if add_block:
|
||||
voxelTool.set_voxel(res.previous_position, 1)
|
||||
else:
|
||||
voxelTool.set_voxel(res.position, 0)
|
||||
|
||||
func _on_button_toggled(toggled_on: bool) -> void:
|
||||
block_edit = toggled_on
|
||||
1
nodes/world/terrain_editor.gd.uid
Normal file
1
nodes/world/terrain_editor.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://vnjdiql72brq
|
||||
22
nodes/world/terrain_editor.tscn
Normal file
22
nodes/world/terrain_editor.tscn
Normal file
@@ -0,0 +1,22 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://ddyulj4dsrkms"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://vnjdiql72brq" path="res://nodes/world/terrain_editor.gd" id="1_6evft"]
|
||||
|
||||
[node name="TerrainEditor" type="Node"]
|
||||
script = ExtResource("1_6evft")
|
||||
|
||||
[node name="Control" type="HBoxContainer" parent="."]
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
alignment = 1
|
||||
|
||||
[node name="Button" type="Button" parent="Control"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "Block Edit"
|
||||
|
||||
[connection signal="toggled" from="Control/Button" to="." method="_on_button_toggled"]
|
||||
Reference in New Issue
Block a user