idk what's in there good luck future me
This commit is contained in:
parent
a342f96089
commit
8e7f73d172
@ -4,7 +4,7 @@ var rot_y = 0
|
||||
|
||||
@onready var world = $"../World/"
|
||||
|
||||
@export var PLAYER_SPEED = 20
|
||||
@export var PLAYER_SPEED = 1
|
||||
@export var PLAYER_REACH = 1000
|
||||
@export_range(0.00001, 0.01) var LOOK_SENSITIVITY = 0.002
|
||||
var move_x = 0
|
||||
@ -48,8 +48,8 @@ func _input(event):
|
||||
camera.rotate_object_local(Vector3(-1, 0, 0), rot_y) # then rotate in X
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
#process_noclip()
|
||||
process_physics_movements()
|
||||
process_noclip()
|
||||
#process_physics_movements()
|
||||
|
||||
#for hit_pos in ray_hit_positions:
|
||||
#DebugDraw3D.draw_sphere(hit_pos)
|
||||
|
||||
27
activation.gd
Normal file
27
activation.gd
Normal file
@ -0,0 +1,27 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
enum EnumWorld {CUBIC_WORLD, SMOOTH_WORLD}
|
||||
|
||||
@export var wanted_world: EnumWorld
|
||||
|
||||
var enabled_world: EnumWorld = EnumWorld.CUBIC_WORLD
|
||||
|
||||
signal change_world
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if enabled_world != wanted_world:
|
||||
print("changing world")
|
||||
emit_signal("change_world")
|
||||
|
||||
func _on_change_world():
|
||||
match wanted_world:
|
||||
EnumWorld.CUBIC_WORLD:
|
||||
if $SmoothWorld:
|
||||
$SmoothWorld.queue_free()
|
||||
add_child(load("res://cubic_world.tscn").instantiate())
|
||||
EnumWorld.SMOOTH_WORLD:
|
||||
if $CubicWorld:
|
||||
$CubicWorld.queue_free()
|
||||
add_child(load("res://smooth_world.tscn").instantiate())
|
||||
enabled_world = wanted_world
|
||||
1
activation.gd.uid
Normal file
1
activation.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://caefudn8tgqpr
|
||||
2
chunk.gd
2
chunk.gd
@ -25,7 +25,7 @@ const AXIS := [
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func init_blocks(_chunk_size: int, pos: Vector3i):
|
||||
|
||||
3
csgtest.tscn
Normal file
3
csgtest.tscn
Normal file
@ -0,0 +1,3 @@
|
||||
[gd_scene format=3 uid="uid://cjkb2c3lhmdpr"]
|
||||
|
||||
[node name="Csgtest" type="Node3D"]
|
||||
12
cube.mtl
Normal file
12
cube.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender 4.3.2 MTL File: 'None'
|
||||
# www.blender.org
|
||||
|
||||
newmtl Material
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
40
cube.obj
Normal file
40
cube.obj
Normal file
@ -0,0 +1,40 @@
|
||||
# Blender 4.3.2
|
||||
# www.blender.org
|
||||
mtllib cube.mtl
|
||||
o Cube
|
||||
v 1.238424 1.000000 -1.000000
|
||||
v 1.238424 -1.000000 -1.000000
|
||||
v 1.238424 1.000000 1.000000
|
||||
v 1.238424 -1.000000 1.000000
|
||||
v -1.238424 1.000000 -1.000000
|
||||
v -1.238424 -1.000000 -1.000000
|
||||
v -1.238424 1.000000 1.000000
|
||||
v -1.238424 -1.000000 1.000000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -1.0000 -0.0000
|
||||
vn 1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -0.0000 -1.0000
|
||||
vt 0.625000 0.500000
|
||||
vt 0.875000 0.500000
|
||||
vt 0.875000 0.750000
|
||||
vt 0.625000 0.750000
|
||||
vt 0.375000 0.750000
|
||||
vt 0.625000 1.000000
|
||||
vt 0.375000 1.000000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.625000 0.000000
|
||||
vt 0.625000 0.250000
|
||||
vt 0.375000 0.250000
|
||||
vt 0.125000 0.500000
|
||||
vt 0.375000 0.500000
|
||||
vt 0.125000 0.750000
|
||||
s 0
|
||||
usemtl Material
|
||||
f 1/1/1 5/2/1 7/3/1 3/4/1
|
||||
f 4/5/2 3/4/2 7/6/2 8/7/2
|
||||
f 8/8/3 7/9/3 5/10/3 6/11/3
|
||||
f 6/12/4 2/13/4 4/5/4 8/14/4
|
||||
f 2/13/5 1/1/5 3/4/5 4/5/5
|
||||
f 6/11/6 5/10/6 1/1/6 2/13/6
|
||||
25
cube.obj.import
Normal file
25
cube.obj.import
Normal file
@ -0,0 +1,25 @@
|
||||
[remap]
|
||||
|
||||
importer="wavefront_obj"
|
||||
importer_version=1
|
||||
type="Mesh"
|
||||
uid="uid://di45vy8c1e72o"
|
||||
path="res://.godot/imported/cube.obj-ecd20c75680354919967c1f74dc43511.mesh"
|
||||
|
||||
[deps]
|
||||
|
||||
files=["res://.godot/imported/cube.obj-ecd20c75680354919967c1f74dc43511.mesh"]
|
||||
|
||||
source_file="res://cube.obj"
|
||||
dest_files=["res://.godot/imported/cube.obj-ecd20c75680354919967c1f74dc43511.mesh", "res://.godot/imported/cube.obj-ecd20c75680354919967c1f74dc43511.mesh"]
|
||||
|
||||
[params]
|
||||
|
||||
generate_tangents=true
|
||||
generate_lods=true
|
||||
generate_shadow_mesh=true
|
||||
generate_lightmap_uv2=false
|
||||
generate_lightmap_uv2_texel_size=0.2
|
||||
scale_mesh=Vector3(1, 1, 1)
|
||||
offset_mesh=Vector3(0, 0, 0)
|
||||
force_disable_mesh_compression=false
|
||||
14
cubic_world.tscn
Normal file
14
cubic_world.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cpxo1on53gjyw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://l6xn27nsln1m" path="res://world.gd" id="1_n1x6j"]
|
||||
|
||||
[node name="CubicWorld" type="Node3D"]
|
||||
transform = Transform3D(1, 1.49012e-08, -7.45058e-09, 0, 1, 0, -7.45058e-09, 0, 1, 0, 0, 0)
|
||||
script = ExtResource("1_n1x6j")
|
||||
chunk_size = 8
|
||||
world_size = Vector3i(8, 16, 8)
|
||||
world_seed = 1
|
||||
noise_frequency = 0.011
|
||||
noise_threshold = -4.111
|
||||
cave_noise_frequency = 0.01
|
||||
cave_noise_threshold = -0.283
|
||||
24
player.tscn
Normal file
24
player.tscn
Normal file
@ -0,0 +1,24 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://chbs3naovk63w"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c1jlypyykqvfl" path="res://NoclipCamera.gd" id="1_4flbx"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_fj7yv"]
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_fj7yv"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_tlwt5"]
|
||||
|
||||
[node name="Player" type="RigidBody3D"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_fj7yv")
|
||||
gravity_scale = 0.0
|
||||
lock_rotation = true
|
||||
linear_damp = 1.0
|
||||
script = ExtResource("1_4flbx")
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="."]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_fj7yv")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_tlwt5")
|
||||
15
sample_point.gd
Normal file
15
sample_point.gd
Normal file
@ -0,0 +1,15 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
@export var distance = 0
|
||||
|
||||
var color = Color.SKY_BLUE
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if distance > 0:
|
||||
color = Color.MEDIUM_PURPLE
|
||||
else:
|
||||
color = Color.SKY_BLUE
|
||||
DebugDraw3D.draw_square(position, 0.2, color)
|
||||
|
||||
1
sample_point.gd.uid
Normal file
1
sample_point.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://likm24qx18tm
|
||||
6
sample_point.tscn
Normal file
6
sample_point.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bm0qtcmn8rna5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://likm24qx18tm" path="res://sample_point.gd" id="1_x8428"]
|
||||
|
||||
[node name="SamplePoint" type="Node3D"]
|
||||
script = ExtResource("1_x8428")
|
||||
163
smooth_world.gd
Normal file
163
smooth_world.gd
Normal file
@ -0,0 +1,163 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
const CENTER := Vector3.ZERO
|
||||
@export var RADIUS: float = 5.0
|
||||
|
||||
var sample_points = {}
|
||||
var surface_points = {}
|
||||
|
||||
@export var world_size = 16
|
||||
|
||||
@export var do_the_thing: bool = false
|
||||
@export var clear_the_thing: bool = false
|
||||
|
||||
var mesh
|
||||
var surface_tool: SurfaceTool = SurfaceTool.new()
|
||||
var SAMPLE_POINT = preload("res://sample_point.tscn")
|
||||
var SURFACE_POINT = preload("res://surface_point.tscn")
|
||||
|
||||
func _ready() -> void:
|
||||
initialize_sample_points()
|
||||
create_surface_points()
|
||||
create_surface_mesh(world_size)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
clear()
|
||||
create_surface_points()
|
||||
create_surface_mesh(world_size)
|
||||
|
||||
func clear():
|
||||
sample_points = {}
|
||||
for child in get_children():
|
||||
remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
func get_sample_value(index: Vector3i) -> float:
|
||||
return CENTER.distance_to(index) - RADIUS
|
||||
|
||||
func initialize_sample_points():
|
||||
for x in range(-world_size + 1, world_size):
|
||||
for y in range(-world_size + 1, world_size):
|
||||
for z in range(-world_size + 1, world_size):
|
||||
var sample_point = SAMPLE_POINT.instantiate()
|
||||
sample_point.distance = get_sample_value(Vector3i(x, y, z))
|
||||
sample_point.position = Vector3(float(x), float(y), float(z))
|
||||
sample_points[Vector3i(x, y, z)] = sample_point
|
||||
#add_child(sample_point)
|
||||
|
||||
func create_surface_points():
|
||||
for x in range(-world_size + 1, world_size):
|
||||
for y in range(-world_size + 1, world_size):
|
||||
for z in range(-world_size + 1, world_size):
|
||||
create_surface_point(Vector3i(x, y, z))
|
||||
|
||||
func create_surface_point(voxel: Vector3i):
|
||||
var average_distance_from_sample = 0
|
||||
for sample_point_to_check_index in range(SURFACE_AXIS.size()):
|
||||
var sample_point_to_check = SURFACE_AXIS[sample_point_to_check_index]
|
||||
average_distance_from_sample += get_sample_value(voxel + sample_point_to_check)
|
||||
average_distance_from_sample /= 8
|
||||
if average_distance_from_sample <= 0:
|
||||
var surface_point = SURFACE_POINT.instantiate()
|
||||
surface_point.position = Vector3(voxel)
|
||||
surface_points[voxel] = surface_point
|
||||
add_child(surface_point)
|
||||
|
||||
func create_surface_mesh(size: int = 6):
|
||||
surface_tool = SurfaceTool.new()
|
||||
surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
for x in range(-size, size):
|
||||
for y in range(-size, size):
|
||||
for z in range(-size, size):
|
||||
create_surface_mesh_quad(Vector3i(x,y,z));
|
||||
mesh = surface_tool.commit()
|
||||
var meshinstance = MeshInstance3D.new()
|
||||
meshinstance.mesh = mesh
|
||||
add_child(meshinstance)
|
||||
|
||||
func create_surface_mesh_quad(index: Vector3i):
|
||||
for axis_index in range(AXIS.size()):
|
||||
var axis = AXIS[axis_index]
|
||||
var sample_value1 = get_sample_value(index)
|
||||
var sample_value2 = get_sample_value(index + axis)
|
||||
|
||||
if sample_value1 < 0 and sample_value2 >= 0:
|
||||
add_quad(index, axis_index)
|
||||
elif sample_value1 >= 0 and sample_value2 < 0:
|
||||
add_reversed_quad(index, axis_index)
|
||||
|
||||
const AXIS := [
|
||||
Vector3i(1,0,0),
|
||||
Vector3i(0,1,0),
|
||||
Vector3i(0,0,1),
|
||||
]
|
||||
|
||||
const SURFACE_AXIS := [
|
||||
Vector3i(1,0,0),
|
||||
Vector3i(0,1,0),
|
||||
Vector3i(0,0,1),
|
||||
Vector3i(1,0,1),
|
||||
Vector3i(0,1,1),
|
||||
Vector3i(1,1,0),
|
||||
Vector3i(1,1,1),
|
||||
Vector3i(0,0,0),
|
||||
]
|
||||
|
||||
func add_quad(index: Vector3i, axis_index: int):
|
||||
var points = get_quad_points(index, axis_index)
|
||||
|
||||
surface_tool.set_normal(AXIS[axis_index])
|
||||
|
||||
surface_tool.add_vertex(points[0])
|
||||
surface_tool.add_vertex(points[1])
|
||||
surface_tool.add_vertex(points[2])
|
||||
|
||||
surface_tool.add_vertex(points[0])
|
||||
surface_tool.add_vertex(points[2])
|
||||
surface_tool.add_vertex(points[3])
|
||||
|
||||
func add_reversed_quad(index: Vector3i, axis_index: int):
|
||||
var points = get_quad_points(index, axis_index)
|
||||
|
||||
surface_tool.set_normal(-AXIS[axis_index])
|
||||
|
||||
surface_tool.add_vertex(points[0])
|
||||
surface_tool.add_vertex(points[2])
|
||||
surface_tool.add_vertex(points[1])
|
||||
|
||||
surface_tool.add_vertex(points[0])
|
||||
surface_tool.add_vertex(points[3])
|
||||
surface_tool.add_vertex(points[2])
|
||||
|
||||
func get_quad_points(index: Vector3i, axis_index: int):
|
||||
return [
|
||||
index + QUAD_POINTS[axis_index][0],
|
||||
index + QUAD_POINTS[axis_index][1],
|
||||
index + QUAD_POINTS[axis_index][2],
|
||||
index + QUAD_POINTS[axis_index][3],
|
||||
]
|
||||
|
||||
const QUAD_POINTS := [
|
||||
# x axis
|
||||
[
|
||||
Vector3i(0,0,-1),
|
||||
Vector3i(0,-1,-1),
|
||||
Vector3i(0,-1,0),
|
||||
Vector3i(0,0,0)
|
||||
],
|
||||
# y axis
|
||||
[
|
||||
Vector3i(0,0,-1),
|
||||
Vector3i(0,0,0),
|
||||
Vector3i(-1,0,0),
|
||||
Vector3i(-1,0,-1)
|
||||
],
|
||||
# z axis
|
||||
[
|
||||
Vector3i(0,0,0),
|
||||
Vector3i(0,-1,0),
|
||||
Vector3i(-1,-1,0),
|
||||
Vector3i(-1,0,0)
|
||||
],
|
||||
]
|
||||
1
smooth_world.gd.uid
Normal file
1
smooth_world.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bdfq22we54eul
|
||||
9
smooth_world.tscn
Normal file
9
smooth_world.tscn
Normal file
@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://llggsd0qmn4p"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bdfq22we54eul" path="res://smooth_world.gd" id="1_4h467"]
|
||||
|
||||
[node name="SmoothWorld" type="Node3D"]
|
||||
script = ExtResource("1_4h467")
|
||||
RADIUS = 4.182
|
||||
world_size = 8
|
||||
do_the_thing = true
|
||||
8
surface_point.gd
Normal file
8
surface_point.gd
Normal file
@ -0,0 +1,8 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
var color = Color.DARK_GOLDENROD
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
DebugDraw3D.draw_square(position, 0.2, color)
|
||||
1
surface_point.gd.uid
Normal file
1
surface_point.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dvsdeymqk67yh
|
||||
6
surface_point.tscn
Normal file
6
surface_point.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://ddm3uvrdtj725"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dvsdeymqk67yh" path="res://surface_point.gd" id="1_8mvgj"]
|
||||
|
||||
[node name="SurfacePoint" type="Node3D"]
|
||||
script = ExtResource("1_8mvgj")
|
||||
2
world.gd
2
world.gd
@ -24,7 +24,7 @@ var chunk_prototype = preload("res://chunk.tscn")
|
||||
func _ready() -> void:
|
||||
generate_chunks = true
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
if clear_chunks:
|
||||
clear_chunks = false
|
||||
clearChunks()
|
||||
|
||||
44
world.tscn
44
world.tscn
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dls7ggmf46ia0"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dls7ggmf46ia0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://l6xn27nsln1m" path="res://world.gd" id="1_tlwt5"]
|
||||
[ext_resource type="Script" uid="uid://c1jlypyykqvfl" path="res://NoclipCamera.gd" id="3_036b0"]
|
||||
[ext_resource type="Script" uid="uid://caefudn8tgqpr" path="res://activation.gd" id="1_tlwt5"]
|
||||
[ext_resource type="PackedScene" uid="uid://chbs3naovk63w" path="res://player.tscn" id="3_036b0"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_fj7yv"]
|
||||
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
@ -16,13 +16,9 @@ sky = SubResource("Sky_tlwt5")
|
||||
tonemap_mode = 2
|
||||
glow_enabled = true
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_fj7yv"]
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_fj7yv"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_tlwt5"]
|
||||
|
||||
[node name="Root" type="Node3D"]
|
||||
script = ExtResource("1_tlwt5")
|
||||
wanted_world = 1
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_aqk2v")
|
||||
@ -31,31 +27,7 @@ environment = SubResource("Environment_aqk2v")
|
||||
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="World" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 1.49012e-08, -7.45058e-09, 0, 1, 0, -7.45058e-09, 0, 1, 0, 0, 0)
|
||||
script = ExtResource("1_tlwt5")
|
||||
chunk_size = 8
|
||||
world_size = Vector3i(8, 16, 8)
|
||||
world_seed = 1
|
||||
noise_frequency = 0.011
|
||||
noise_threshold = -4.111
|
||||
cave_noise_frequency = 0.01
|
||||
cave_noise_threshold = -0.283
|
||||
[node name="Player" parent="." instance=ExtResource("3_036b0")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.182447, 0.6673207, 0.0726881)
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="Player" type="RigidBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20, 50, 20)
|
||||
physics_material_override = SubResource("PhysicsMaterial_fj7yv")
|
||||
lock_rotation = true
|
||||
linear_damp = 1.0
|
||||
script = ExtResource("3_036b0")
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="Player"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Player"]
|
||||
mesh = SubResource("SphereMesh_fj7yv")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
|
||||
shape = SubResource("SphereShape3D_tlwt5")
|
||||
[connection signal="change_world" from="." to="." method="_on_change_world"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user