mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-18 14:07:17 +01:00
The voxel mesher.
This commit is contained in:
parent
8559193d21
commit
602873755b
7
game/voxelman/FPSCounter.gd
Normal file
7
game/voxelman/FPSCounter.gd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
extends Label
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
text = str(Engine.get_frames_per_second()) + "FPS"
|
137
game/voxelman/TestScene.tscn
Normal file
137
game/voxelman/TestScene.tscn
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
[gd_scene load_steps=17 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2]
|
||||||
|
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://voxelman/cubic_mesher/CubicVoxelWorld.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://data/voxel_textures/a2.png" type="Texture" id=5]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library_2.tres" type="VoxelmanLibrarySimple" id=6]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=1]
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=8]
|
||||||
|
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="MC_Test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Camera" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( 0.844995, 0.247388, -0.474112, -0.0119927, 0.895109, 0.445686, 0.534639, -0.370917, 0.75933, -22.7583, 12.2082, 41.288 )
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
|
||||||
|
|
||||||
|
[node name="VoxelWorld" parent="." instance=ExtResource( 4 )]
|
||||||
|
library = ExtResource( 6 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
|
||||||
|
|
||||||
|
[node name="FPSCounter" type="Label" parent="."]
|
||||||
|
margin_right = 123.0
|
||||||
|
margin_bottom = 41.0
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
|
||||||
|
material_override = SubResource( 2 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="gizmo" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
||||||
|
|
||||||
|
[node name="gizmo2" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
21
game/voxelman/cubic_mesher/CubicVoxelChunk.gd
Normal file
21
game/voxelman/cubic_mesher/CubicVoxelChunk.gd
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
extends VoxelChunk
|
||||||
|
class_name CubicVoxelChunk
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var lod_data : Array = [
|
||||||
|
1, #CHUNK_INDEX_UP
|
||||||
|
1, #CHUNK_INDEX_DOWN
|
||||||
|
1, #CHUNK_INDEX_LEFT
|
||||||
|
1, #CHUNK_INDEX_RIGHT
|
||||||
|
1, #CHUNK_INDEX_FRONT
|
||||||
|
1 #CHUNK_INDEX_BACK
|
||||||
|
]
|
||||||
|
|
||||||
|
func _create_mesher():
|
||||||
|
mesher = VoxelMesherCubic.new()
|
||||||
|
# mesher = CubicVoxelMesher.new()
|
||||||
|
# mesher.base_light_value = 0.45
|
||||||
|
# mesher.ao_strength = 0.05
|
||||||
|
# mesher.ao_strength = 0.2
|
79
game/voxelman/cubic_mesher/CubicVoxelMesher.gd
Normal file
79
game/voxelman/cubic_mesher/CubicVoxelMesher.gd
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
extends VoxelMesherCubic
|
||||||
|
class_name GDCubicVoxelMesher
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var count : int = 0
|
||||||
|
|
||||||
|
func _add_chunk(buffer : VoxelChunk) -> void:
|
||||||
|
buffer.generate_ao();
|
||||||
|
|
||||||
|
var x_size : int = buffer.get_size_x() - 1
|
||||||
|
var y_size : int = buffer.get_size_y() - 1
|
||||||
|
var z_size : int = buffer.get_size_z() - 1
|
||||||
|
|
||||||
|
var voxel_size : float = lod_size
|
||||||
|
|
||||||
|
var cube_points : VoxelCubePoints = VoxelCubePoints.new()
|
||||||
|
|
||||||
|
var tile_uv_size : float = 1/4.0
|
||||||
|
var base_light : Color = Color(0.4, 0.4, 0.4)
|
||||||
|
|
||||||
|
for y in range(lod_size, y_size - lod_size, lod_size):
|
||||||
|
for z in range(lod_size, z_size - lod_size, lod_size):
|
||||||
|
for x in range(lod_size, x_size - lod_size, lod_size):
|
||||||
|
|
||||||
|
cube_points.setup(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
if not cube_points.has_points():
|
||||||
|
continue
|
||||||
|
|
||||||
|
for face in range(VoxelCubePoints.VOXEL_FACE_COUNT):
|
||||||
|
if not cube_points.is_face_visible(face):
|
||||||
|
continue
|
||||||
|
|
||||||
|
add_indices(get_vertex_count() + 2)
|
||||||
|
add_indices(get_vertex_count() + 1)
|
||||||
|
add_indices(get_vertex_count() + 0)
|
||||||
|
add_indices(get_vertex_count() + 3)
|
||||||
|
add_indices(get_vertex_count() + 2)
|
||||||
|
add_indices(get_vertex_count() + 0)
|
||||||
|
|
||||||
|
var vertices : Array = [
|
||||||
|
cube_points.get_point_for_face(face, 0),
|
||||||
|
cube_points.get_point_for_face(face, 1),
|
||||||
|
cube_points.get_point_for_face(face, 2),
|
||||||
|
cube_points.get_point_for_face(face, 3)
|
||||||
|
]
|
||||||
|
|
||||||
|
var normals : Array = [
|
||||||
|
(vertices[3] - vertices[0]).cross(vertices[1] - vertices[0]),
|
||||||
|
(vertices[0] - vertices[1]).cross(vertices[2] - vertices[1]),
|
||||||
|
(vertices[1] - vertices[2]).cross(vertices[3] - vertices[2]),
|
||||||
|
(vertices[2] - vertices[3]).cross(vertices[0] - vertices[3])
|
||||||
|
]
|
||||||
|
|
||||||
|
var face_light_direction : Vector3 = cube_points.get_face_light_direction(face)
|
||||||
|
|
||||||
|
for i in range(4):
|
||||||
|
|
||||||
|
var light : Color = cube_points.get_face_point_light_color(face, i)
|
||||||
|
light += base_light
|
||||||
|
|
||||||
|
var NdotL : float = clamp(normals[i].dot(face_light_direction), 0, 1.0)
|
||||||
|
|
||||||
|
light *= NdotL
|
||||||
|
|
||||||
|
light -= cube_points.get_face_point_ao_color(face, i) * ao_strength
|
||||||
|
add_color(light)
|
||||||
|
|
||||||
|
light.r = clamp(light.r, 0, 1.0)
|
||||||
|
light.g = clamp(light.g, 0, 1.0)
|
||||||
|
light.b = clamp(light.b, 0, 1.0)
|
||||||
|
|
||||||
|
add_uv((cube_points.get_point_uv_direction(face, i) + Vector2(0.5, 0.5)) * Vector2(tile_uv_size, tile_uv_size))
|
||||||
|
|
||||||
|
add_vertex((vertices[i] * voxel_size + Vector3(x, y, z)) * voxel_scale)
|
||||||
|
|
||||||
|
|
143
game/voxelman/cubic_mesher/CubicVoxelWorld.gd
Normal file
143
game/voxelman/cubic_mesher/CubicVoxelWorld.gd
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
extends VoxelWorld
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
enum GenType {
|
||||||
|
TEST, NORMAL
|
||||||
|
}
|
||||||
|
|
||||||
|
signal generation_finished
|
||||||
|
|
||||||
|
export(int) var gen_type : int = GenType.NORMAL
|
||||||
|
|
||||||
|
export(Array, MeshDataResource) var meshes : Array
|
||||||
|
|
||||||
|
var chunks : Dictionary = Dictionary()
|
||||||
|
var spawned : bool = false
|
||||||
|
|
||||||
|
var generation_queue : Array
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if not generation_queue.empty():
|
||||||
|
var chunk : VoxelChunk = generation_queue.front()
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL:
|
||||||
|
# generate(chunk)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
generate_terrarin(chunk)
|
||||||
|
|
||||||
|
generation_queue.remove(0)
|
||||||
|
|
||||||
|
if generation_queue.empty():
|
||||||
|
emit_signal("generation_finished")
|
||||||
|
|
||||||
|
func generate_terrarin(chunk : VoxelChunk) -> void:
|
||||||
|
var buffer : VoxelChunk = chunk.get_buffer()
|
||||||
|
buffer.create(int(size_x) + 3, int(size_y) + 3, int(size_z) + 3)
|
||||||
|
|
||||||
|
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
noise.seed = 10
|
||||||
|
noise.octaves = 4
|
||||||
|
noise.period = 200.0
|
||||||
|
noise.persistence = 0.8
|
||||||
|
|
||||||
|
var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
terr_noise.seed = 10 * 321 + 112
|
||||||
|
terr_noise.octaves = 4
|
||||||
|
terr_noise.period = 20.0
|
||||||
|
terr_noise.persistence = 0.9
|
||||||
|
|
||||||
|
for x in range(-1, size_x + 2):
|
||||||
|
for z in range(-1, size_z + 2):
|
||||||
|
var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val *= val
|
||||||
|
val *= 100
|
||||||
|
val += 2
|
||||||
|
|
||||||
|
var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val += tv * 2
|
||||||
|
|
||||||
|
var v : int = (int(val))
|
||||||
|
|
||||||
|
for y in range(-1, v):
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 200 + 55, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + 1)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 200 + 55, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
|
var light : VoxelLight = VoxelLight.new()
|
||||||
|
randomize()
|
||||||
|
light.color = Color(randf(), randf(), randf())
|
||||||
|
light.size = randi() % 5 + 5
|
||||||
|
light.set_world_position((chunk.position_x * chunk.size_x) + (randi() % chunk.size_x), (chunk.position_y * chunk.size_y) + (randi() % 6), (chunk.position_z * chunk.size_z) + (randi() % chunk.size_z))
|
||||||
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
|
# var light : VoxelLight = VoxelLight.new()
|
||||||
|
# light.color = Color(1.0, 0, 0)
|
||||||
|
# light.size = 10
|
||||||
|
# light.set_world_position((chunk.position_x * chunk.size_x) + (2), (chunk.position_y * chunk.size_y) + (7), (chunk.position_z * chunk.size_z) + (1))
|
||||||
|
# chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
# for x in range(16):
|
||||||
|
# for z in range(16):
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis().scaled(Vector3(0.2, 0.2, 0.2)), Vector3(2, 5, 0) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis(), Vector3(4, 3, 5) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
chunk.bake_lights()
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
# chunk.draw_debug_voxels(2000)
|
||||||
|
chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_chunk(x : int, y : int, z : int, lod_size : int = 1) -> void:
|
||||||
|
var name : String = "Chunk," + str(x) + "," + str(y) + "," + str(z)
|
||||||
|
var chunk : VoxelChunk = VoxelChunk.new()
|
||||||
|
# var chunk : VoxelChunk = MarchingCubesVoxelChunk.new()
|
||||||
|
|
||||||
|
chunk.voxel_world = self
|
||||||
|
chunk.set_chunk_position(x, y, z)
|
||||||
|
chunk.library = library
|
||||||
|
chunk.voxel_scale = voxel_scale
|
||||||
|
chunk.lod_size = lod_size
|
||||||
|
chunk.set_chunk_size(int(size_x), int(size_y), int(size_z))
|
||||||
|
|
||||||
|
chunk.create_mesher()
|
||||||
|
chunk.mesher.base_light_value = 0.6
|
||||||
|
|
||||||
|
chunks[name] = chunk
|
||||||
|
|
||||||
|
generation_queue.append(chunk)
|
||||||
|
|
||||||
|
|
||||||
|
func spawn() -> void:
|
||||||
|
var hsize : int = 4
|
||||||
|
|
||||||
|
# if gen_type == GenType.NORMAL:
|
||||||
|
for x in range(-hsize, hsize):
|
||||||
|
for z in range(-hsize, hsize):
|
||||||
|
for y in range(1):
|
||||||
|
# spawn_chunk(x, y, z, abs(int(ceil(x / 2))) + 1)
|
||||||
|
spawn_chunk(x, y, z, 1)
|
||||||
|
|
||||||
|
#func set_player(p_player : Spatial) -> void:
|
||||||
|
# player = p_player
|
||||||
|
|
||||||
|
# if _spawned:
|
||||||
|
# clear()
|
||||||
|
#
|
||||||
|
# spawn()
|
||||||
|
# pass
|
||||||
|
|
12
game/voxelman/cubic_mesher/CubicVoxelWorld.tscn
Normal file
12
game/voxelman/cubic_mesher/CubicVoxelWorld.tscn
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/cubic_mesher/CubicVoxelWorld.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library.tres" type="VoxelmanLibrarySimple" id=4]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="VoxelWorld" type="VoxelWorld"]
|
||||||
|
library = ExtResource( 4 )
|
||||||
|
voxel_scale = 2.0
|
||||||
|
player_path = NodePath("Camera")
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
gen_type = 2
|
137
game/voxelman/mc_mesher/MCTestScene.tscn
Normal file
137
game/voxelman/mc_mesher/MCTestScene.tscn
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/mc_mesher/MCVoxelWorld.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2]
|
||||||
|
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://data/voxel_textures/a2.png" type="Texture" id=5]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=1]
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=8]
|
||||||
|
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="MC_Test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Camera" parent="." instance=ExtResource( 4 )]
|
||||||
|
transform = Transform( -0.999922, -0.00920995, -0.00840917, -0.0115497, 0.938254, 0.345753, 0.00470557, 0.345823, -0.938288, 6.00985, 6.90149, -5.3643 )
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
|
||||||
|
|
||||||
|
[node name="VoxelWorld" parent="." instance=ExtResource( 1 )]
|
||||||
|
voxel_scale = 1.0
|
||||||
|
gen_type = 0
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
|
||||||
|
|
||||||
|
[node name="FPSCounter" type="Label" parent="."]
|
||||||
|
margin_right = 123.0
|
||||||
|
margin_bottom = 41.0
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
|
||||||
|
material_override = SubResource( 2 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="gizmo" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
||||||
|
|
||||||
|
[node name="gizmo2" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
201
game/voxelman/mc_mesher/MCVoxelWorld.gd
Normal file
201
game/voxelman/mc_mesher/MCVoxelWorld.gd
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
extends VoxelWorld
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
enum GenType {
|
||||||
|
TEST, NORMAL, NOISE3D
|
||||||
|
}
|
||||||
|
|
||||||
|
signal generation_finished
|
||||||
|
|
||||||
|
export(int) var gen_type : int = GenType.NORMAL
|
||||||
|
|
||||||
|
export(Array, MeshDataResource) var meshes : Array
|
||||||
|
|
||||||
|
var chunks : Dictionary = Dictionary()
|
||||||
|
var spawned : bool = false
|
||||||
|
|
||||||
|
var generation_queue : Array
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if not generation_queue.empty():
|
||||||
|
var chunk : VoxelChunk = generation_queue.front()
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL:
|
||||||
|
#
|
||||||
|
generate_terrarin(chunk)
|
||||||
|
elif gen_type == GenType.NOISE3D:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
generate_test(chunk)
|
||||||
|
|
||||||
|
generation_queue.remove(0)
|
||||||
|
|
||||||
|
if generation_queue.empty():
|
||||||
|
emit_signal("generation_finished")
|
||||||
|
|
||||||
|
func generate_terrarin(chunk : VoxelChunk) -> void:
|
||||||
|
chunk.set_size(int(chunk_size_x) + 3, int(chunk_size_y) + 3, int(chunk_size_z) + 3)
|
||||||
|
|
||||||
|
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
noise.seed = 10
|
||||||
|
noise.octaves = 4
|
||||||
|
noise.period = 200.0
|
||||||
|
noise.persistence = 0.8
|
||||||
|
|
||||||
|
var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
terr_noise.seed = 10 * 321 + 112
|
||||||
|
terr_noise.octaves = 4
|
||||||
|
terr_noise.period = 20.0
|
||||||
|
terr_noise.persistence = 0.9
|
||||||
|
|
||||||
|
for x in range(-1, chunk_size_x + 2):
|
||||||
|
for z in range(-1, chunk_size_z + 2):
|
||||||
|
var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val *= val
|
||||||
|
val *= 100
|
||||||
|
val += 2
|
||||||
|
|
||||||
|
var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val += tv * 2
|
||||||
|
|
||||||
|
var v : int = (int(val))
|
||||||
|
|
||||||
|
for y in range(-1, v):
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y)
|
||||||
|
chunk.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(randi() % 200 + 55, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + 1)
|
||||||
|
chunk.set_voxel(1, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(randi() % 200 + 55, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
|
var light : VoxelLight = VoxelLight.new()
|
||||||
|
randomize()
|
||||||
|
light.color = Color(randf(), randf(), randf())
|
||||||
|
light.size = randi() % 5 + 5
|
||||||
|
light.set_world_position((chunk.position_x * chunk.size_x) + (randi() % chunk.size_x), (chunk.position_y * chunk.size_y) + (randi() % 6), (chunk.position_z * chunk.size_z) + (randi() % chunk.size_z))
|
||||||
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
|
# var light : VoxelLight = VoxelLight.new()
|
||||||
|
# light.color = Color(1.0, 0, 0)
|
||||||
|
# light.size = 10
|
||||||
|
# light.set_world_position((chunk.position_x * chunk.size_x) + (2), (chunk.position_y * chunk.size_y) + (7), (chunk.position_z * chunk.size_z) + (1))
|
||||||
|
# chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
# for x in range(16):
|
||||||
|
# for z in range(16):
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis().scaled(Vector3(0.2, 0.2, 0.2)), Vector3(2, 5, 0) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis(), Vector3(4, 3, 5) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
chunk.bake_lights()
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
# chunk.draw_debug_voxels(2000)
|
||||||
|
chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_chunk(x : int, y : int, z : int, lod_size : int = 1) -> void:
|
||||||
|
var name : String = "Chunk," + str(x) + "," + str(y) + "," + str(z)
|
||||||
|
# var chunk : VoxelChunk = VoxelChunk.new()
|
||||||
|
var chunk : VoxelChunk = MarchingCubesVoxelChunk.new()
|
||||||
|
|
||||||
|
chunk.voxel_world = self
|
||||||
|
chunk.set_chunk_position(x, y, z)
|
||||||
|
chunk.library = library
|
||||||
|
chunk.voxel_scale = voxel_scale
|
||||||
|
chunk.lod_size = lod_size
|
||||||
|
chunk.set_chunk_size(int(chunk_size_x), int(chunk_size_y), int(chunk_size_z))
|
||||||
|
|
||||||
|
chunk.create_mesher()
|
||||||
|
chunk.mesher.base_light_value = 0.6
|
||||||
|
|
||||||
|
chunks[name] = chunk
|
||||||
|
|
||||||
|
generation_queue.append(chunk)
|
||||||
|
|
||||||
|
|
||||||
|
func spawn() -> void:
|
||||||
|
var hsize : int = 4
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL or gen_type == GenType.NOISE3D:
|
||||||
|
for x in range(-hsize, hsize):
|
||||||
|
for z in range(-hsize, hsize):
|
||||||
|
for y in range(1):
|
||||||
|
# spawn_chunk(x, y, z, abs(int(ceil(x / 2))) + 1)
|
||||||
|
spawn_chunk(x, y, z, 1)
|
||||||
|
else:
|
||||||
|
spawn_chunk(0, 0, 0, 1)
|
||||||
|
|
||||||
|
#func set_player(p_player : Spatial) -> void:
|
||||||
|
# player = p_player
|
||||||
|
|
||||||
|
# if _spawned:
|
||||||
|
# clear()
|
||||||
|
#
|
||||||
|
# spawn()
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func generate_test(chunk : VoxelChunk) ->void:
|
||||||
|
chunk.set_size(40, 40, 40)
|
||||||
|
|
||||||
|
var i : int = 1
|
||||||
|
|
||||||
|
# for y in range(4):
|
||||||
|
# for z in range(8):
|
||||||
|
# for x in range(8):
|
||||||
|
# spawn_equiv_class(chunk, i, x * 4 + 1, y * 4 + 1, z * 4 + 1)
|
||||||
|
# i += 1
|
||||||
|
|
||||||
|
spawn_equiv_class(chunk,127, 4, 4, 4)
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
chunk.draw_debug_voxels(2000)
|
||||||
|
# chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_equiv_class(chunk : VoxelChunk, cls : int, x : int, y : int, z : int) -> void:
|
||||||
|
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_000:
|
||||||
|
chunk.set_voxel(1, x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_100:
|
||||||
|
chunk.set_voxel(1, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_001:
|
||||||
|
chunk.set_voxel(1, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_101:
|
||||||
|
chunk.set_voxel(1, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_010:
|
||||||
|
chunk.set_voxel(1, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_110:
|
||||||
|
chunk.set_voxel(1, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_011:
|
||||||
|
chunk.set_voxel(1, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_111:
|
||||||
|
chunk.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
chunk.set_voxel(255, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
|
||||||
|
|
11
game/voxelman/mc_mesher/MCVoxelWorld.tscn
Normal file
11
game/voxelman/mc_mesher/MCVoxelWorld.tscn
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/mc_mesher/MCVoxelWorld.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library.tres" type="VoxelmanLibrarySimple" id=4]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="VoxelWorld" type="VoxelWorld"]
|
||||||
|
player_path = NodePath("Camera")
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
library = ExtResource( 4 )
|
||||||
|
voxel_scale = 2.0
|
1351
game/voxelman/mc_mesher/MarchingCobesVoxelMesher.gd
Normal file
1351
game/voxelman/mc_mesher/MarchingCobesVoxelMesher.gd
Normal file
File diff suppressed because it is too large
Load Diff
14
game/voxelman/mc_mesher/MarchingCubesVoxelChunk.gd
Normal file
14
game/voxelman/mc_mesher/MarchingCubesVoxelChunk.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends VoxelChunk
|
||||||
|
class_name MarchingCubesVoxelChunk
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
#export (Vector3) var chunk_position : Vector3
|
||||||
|
#var world : VoxelWorld
|
||||||
|
|
||||||
|
#func _ready():
|
||||||
|
# world = get_node("..")
|
||||||
|
|
||||||
|
func _create_mesher():
|
||||||
|
mesher = MarchingCubesVoxelMesher.new()
|
460
game/voxelman/table_generator/TableGenerator.gd
Normal file
460
game/voxelman/table_generator/TableGenerator.gd
Normal file
@ -0,0 +1,460 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
export(NodePath) var text_edit_path : NodePath
|
||||||
|
|
||||||
|
const VOXEL_ENTRY_INDEX_000 : int = 0
|
||||||
|
const VOXEL_ENTRY_INDEX_100 : int = 1
|
||||||
|
const VOXEL_ENTRY_INDEX_010 : int = 4
|
||||||
|
const VOXEL_ENTRY_INDEX_110 : int = 5
|
||||||
|
const VOXEL_ENTRY_INDEX_001 : int = 2
|
||||||
|
const VOXEL_ENTRY_INDEX_101 : int = 3
|
||||||
|
const VOXEL_ENTRY_INDEX_011 : int = 6
|
||||||
|
const VOXEL_ENTRY_INDEX_111 : int = 7
|
||||||
|
const VOXEL_ENTRIES_SIZE : int = 8
|
||||||
|
|
||||||
|
const VOXEL_ENTRY_MASK_000 : int = 1
|
||||||
|
const VOXEL_ENTRY_MASK_100 : int = 2
|
||||||
|
const VOXEL_ENTRY_MASK_010 : int = 16
|
||||||
|
const VOXEL_ENTRY_MASK_110 : int = 32
|
||||||
|
const VOXEL_ENTRY_MASK_001 : int = 4
|
||||||
|
const VOXEL_ENTRY_MASK_101 : int = 8
|
||||||
|
const VOXEL_ENTRY_MASK_011 : int = 64
|
||||||
|
const VOXEL_ENTRY_MASK_111 : int = 128
|
||||||
|
|
||||||
|
var entry_index_x_rotations : Array = [
|
||||||
|
VOXEL_ENTRY_INDEX_010, #from VOXEL_ENTRY_INDEX_000
|
||||||
|
VOXEL_ENTRY_INDEX_110, #from VOXEL_ENTRY_INDEX_100
|
||||||
|
VOXEL_ENTRY_INDEX_000, #from VOXEL_ENTRY_INDEX_001
|
||||||
|
VOXEL_ENTRY_INDEX_100, #from VOXEL_ENTRY_INDEX_101
|
||||||
|
VOXEL_ENTRY_INDEX_011, #from VOXEL_ENTRY_INDEX_010
|
||||||
|
VOXEL_ENTRY_INDEX_111, #from VOXEL_ENTRY_INDEX_110
|
||||||
|
VOXEL_ENTRY_INDEX_001, #from VOXEL_ENTRY_INDEX_011
|
||||||
|
VOXEL_ENTRY_INDEX_101, #from VOXEL_ENTRY_INDEX_111
|
||||||
|
]
|
||||||
|
|
||||||
|
var entry_index_y_rotations : Array = [
|
||||||
|
VOXEL_ENTRY_INDEX_100, #from VOXEL_ENTRY_INDEX_000
|
||||||
|
VOXEL_ENTRY_INDEX_101, #from VOXEL_ENTRY_INDEX_100
|
||||||
|
VOXEL_ENTRY_INDEX_000, #from VOXEL_ENTRY_INDEX_001
|
||||||
|
VOXEL_ENTRY_INDEX_001, #from VOXEL_ENTRY_INDEX_101
|
||||||
|
VOXEL_ENTRY_INDEX_110, #from VOXEL_ENTRY_INDEX_010
|
||||||
|
VOXEL_ENTRY_INDEX_111, #from VOXEL_ENTRY_INDEX_110
|
||||||
|
VOXEL_ENTRY_INDEX_010, #from VOXEL_ENTRY_INDEX_011
|
||||||
|
VOXEL_ENTRY_INDEX_011, #from VOXEL_ENTRY_INDEX_111
|
||||||
|
]
|
||||||
|
|
||||||
|
var entry_index_z_rotations : Array = [
|
||||||
|
VOXEL_ENTRY_INDEX_100, #from VOXEL_ENTRY_INDEX_000
|
||||||
|
VOXEL_ENTRY_INDEX_110, #from VOXEL_ENTRY_INDEX_100
|
||||||
|
VOXEL_ENTRY_INDEX_101, #from VOXEL_ENTRY_INDEX_001
|
||||||
|
VOXEL_ENTRY_INDEX_111, #from VOXEL_ENTRY_INDEX_101
|
||||||
|
VOXEL_ENTRY_INDEX_000, #from VOXEL_ENTRY_INDEX_010
|
||||||
|
VOXEL_ENTRY_INDEX_010, #from VOXEL_ENTRY_INDEX_110
|
||||||
|
VOXEL_ENTRY_INDEX_001, #from VOXEL_ENTRY_INDEX_011
|
||||||
|
VOXEL_ENTRY_INDEX_011, #from VOXEL_ENTRY_INDEX_111
|
||||||
|
]
|
||||||
|
|
||||||
|
var entry_index_names : Array = [
|
||||||
|
"VOXEL_ENTRY_INDEX_000", #VOXEL_ENTRY_INDEX_000
|
||||||
|
"VOXEL_ENTRY_INDEX_100", #VOXEL_ENTRY_INDEX_100
|
||||||
|
"VOXEL_ENTRY_INDEX_001", #VOXEL_ENTRY_INDEX_001
|
||||||
|
"VOXEL_ENTRY_INDEX_101", #VOXEL_ENTRY_INDEX_101
|
||||||
|
"VOXEL_ENTRY_INDEX_010", #VOXEL_ENTRY_INDEX_010
|
||||||
|
"VOXEL_ENTRY_INDEX_110", #VOXEL_ENTRY_INDEX_110
|
||||||
|
"VOXEL_ENTRY_INDEX_011", #VOXEL_ENTRY_INDEX_011
|
||||||
|
"VOXEL_ENTRY_INDEX_111", #VOXEL_ENTRY_INDEX_111
|
||||||
|
]
|
||||||
|
|
||||||
|
var class_match_table : Array = [
|
||||||
|
0, #0
|
||||||
|
VOXEL_ENTRY_MASK_000, #1
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100, #2
|
||||||
|
VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001, #3
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001, #4
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101, #5
|
||||||
|
VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_001, #6
|
||||||
|
VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_000, #7
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_101, #8
|
||||||
|
VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_101, #9
|
||||||
|
VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_001, #10
|
||||||
|
VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101, #11
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_110, #12
|
||||||
|
VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_110, #13
|
||||||
|
VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101, #14
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_011 | VOXEL_ENTRY_MASK_110, #15
|
||||||
|
VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_011, #16
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_011, #17
|
||||||
|
|
||||||
|
VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_001, #18 eqv to 3 (36)
|
||||||
|
VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_011 | VOXEL_ENTRY_MASK_001, #19 eqv to 3 (126)
|
||||||
|
VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_110, #20 eqv to 2 (63)
|
||||||
|
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_011, #21 eqv to 1 (127)
|
||||||
|
VOXEL_ENTRY_MASK_000 | VOXEL_ENTRY_MASK_100 | VOXEL_ENTRY_MASK_001 | VOXEL_ENTRY_MASK_101 | VOXEL_ENTRY_MASK_010 | VOXEL_ENTRY_MASK_110 | VOXEL_ENTRY_MASK_011 | VOXEL_ENTRY_MASK_111, #22 eqv to 0
|
||||||
|
]
|
||||||
|
|
||||||
|
var equivalence_classes_data : Array = [
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||||
|
3, 3, 2, 1, 0
|
||||||
|
]
|
||||||
|
|
||||||
|
var vertices_data : Array = [
|
||||||
|
[],
|
||||||
|
#1 1
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5) ],
|
||||||
|
#3 2
|
||||||
|
[ Vector3(0, 0, 0.5), Vector3(0, 0, 0.5), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#6 3
|
||||||
|
[ Vector3(-0.5, 0, 0), Vector3(0, 0, 0.5), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0, -0.5), Vector3(0, 0.5, 0) ],
|
||||||
|
#7 4
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0.5, 0, 0) ],
|
||||||
|
#15 5
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#22 6
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0, 0.5), Vector3(0, -0.5, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0, 0.5, 0), Vector3(-0.5, 0, 0),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0, -0.5), Vector3(0, 0.5, 0) ],
|
||||||
|
#23 7
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#25 8
|
||||||
|
[ Vector3(0, 0, 0.5), Vector3(0, 0, 0.5), Vector3(0.5, 0, 0), Vector3(0.5, 0, 0),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(-0.5, 0, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#27 9
|
||||||
|
[ Vector3(0, 0, 0.5), Vector3(0, 0, 0.5), Vector3(-0.5, 0, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#29 10
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0, -0.5), Vector3(0.5, 0, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0, 0.5, 0) ],
|
||||||
|
#30 11
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(-0.5, 0, 0),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0, -0.5, 0), Vector3(0.5, 0, 0) ],
|
||||||
|
#31 12
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0.5, 0, 0) ],
|
||||||
|
#60 13
|
||||||
|
[ Vector3(0, 0, 0.5), Vector3(0, 0, 0.5), Vector3(0, -0.5, 0), Vector3(0, -0.5, 0),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(0, 0, -0.5), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0) ],
|
||||||
|
#61 14
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, -0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0, 0.5), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, -0.5) ],
|
||||||
|
#105 15
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(-0.5, 0, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(-0.5, 0, 0), Vector3(0, -0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(0.5, 0, 0), Vector3(0, -0.5, 0) ],
|
||||||
|
#107 16
|
||||||
|
[ Vector3(0, 0, 0.5), Vector3(-0.5, 0, 0),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(-0.5, 0, 0),
|
||||||
|
Vector3(0, 0, 0.5), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(0.5, 0, 0), Vector3(0, -0.5, 0) ],
|
||||||
|
#111 17
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0.5, 0, 0), Vector3(0, 0, -0.5),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(-0.5, 0, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(-0.5, 0, 0), Vector3(0, 0.5, 0),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(0, 0, -0.5), Vector3(0, 0.5, 0) ],
|
||||||
|
#36 18
|
||||||
|
[ Vector3(-0.5, 0, 0), Vector3(0, -0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0.5, 0), Vector3(0.5, 0, 0), Vector3(0, 0, -0.5) ],
|
||||||
|
|
||||||
|
#126 19
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5),
|
||||||
|
Vector3(0, 0, -0.5), Vector3(0, -0.5, 0), Vector3(-0.5, 0, 0) ],
|
||||||
|
#63
|
||||||
|
[ Vector3(0, 0.5, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5), Vector3(0, 0, 0.5) ],
|
||||||
|
|
||||||
|
#127 20
|
||||||
|
[ Vector3(0.5, 0, 0), Vector3(0, 0.5, 0), Vector3(0, 0, 0.5) ],
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
|
||||||
|
var vertex_corner_data : Array = [
|
||||||
|
[],
|
||||||
|
#1 1
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_000 ],
|
||||||
|
#3 2
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_100 ],
|
||||||
|
#6 3
|
||||||
|
[ VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#7 4
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#15 5
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_101 ],
|
||||||
|
#22 6
|
||||||
|
[ VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010,
|
||||||
|
VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#23 7
|
||||||
|
[ VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010,
|
||||||
|
VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#25 8
|
||||||
|
[ VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_000,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101 ],
|
||||||
|
#27 9
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101,
|
||||||
|
VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_100 ],
|
||||||
|
#29 10
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_101,
|
||||||
|
VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#30 11
|
||||||
|
[ VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_001,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_100, VOXEL_ENTRY_INDEX_001,
|
||||||
|
VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010 ],
|
||||||
|
#31 12
|
||||||
|
[ VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_100,
|
||||||
|
VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_010 ],
|
||||||
|
#60 13
|
||||||
|
[ VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_010,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
#61 14
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_010,
|
||||||
|
VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_001,
|
||||||
|
VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101 ],
|
||||||
|
#105 15
|
||||||
|
[ VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_000,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101,
|
||||||
|
VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_011 ],
|
||||||
|
#107 16
|
||||||
|
[ VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_101,
|
||||||
|
VOXEL_ENTRY_INDEX_000, VOXEL_ENTRY_INDEX_000,
|
||||||
|
VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_011 ],
|
||||||
|
#111 17
|
||||||
|
[ VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_011,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_000,
|
||||||
|
VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_000 ],
|
||||||
|
#36 18
|
||||||
|
[ VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_001 ],
|
||||||
|
|
||||||
|
|
||||||
|
#126 18 (3)
|
||||||
|
[ VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_110,
|
||||||
|
VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_100 ],
|
||||||
|
#63
|
||||||
|
[ VOXEL_ENTRY_INDEX_001, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_010, VOXEL_ENTRY_INDEX_110 ],
|
||||||
|
|
||||||
|
#127 19 (1)
|
||||||
|
[ VOXEL_ENTRY_INDEX_011, VOXEL_ENTRY_INDEX_101, VOXEL_ENTRY_INDEX_110 ],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
|
||||||
|
func index_entry_to_mask_entry(entry : int) -> int:
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_000:
|
||||||
|
return VOXEL_ENTRY_MASK_000
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_100:
|
||||||
|
return VOXEL_ENTRY_MASK_100
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_010:
|
||||||
|
return VOXEL_ENTRY_MASK_010
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_110:
|
||||||
|
return VOXEL_ENTRY_MASK_110
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_001:
|
||||||
|
return VOXEL_ENTRY_MASK_001
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_101:
|
||||||
|
return VOXEL_ENTRY_MASK_101
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_011:
|
||||||
|
return VOXEL_ENTRY_MASK_011
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_INDEX_111:
|
||||||
|
return VOXEL_ENTRY_MASK_111
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
func mask_entry_to_index_entry(entry : int) -> int:
|
||||||
|
if entry == VOXEL_ENTRY_MASK_000:
|
||||||
|
return VOXEL_ENTRY_INDEX_000
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_100:
|
||||||
|
return VOXEL_ENTRY_INDEX_100
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_010:
|
||||||
|
return VOXEL_ENTRY_INDEX_010
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_110:
|
||||||
|
return VOXEL_ENTRY_INDEX_110
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_001:
|
||||||
|
return VOXEL_ENTRY_INDEX_001
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_101:
|
||||||
|
return VOXEL_ENTRY_INDEX_101
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_011:
|
||||||
|
return VOXEL_ENTRY_INDEX_011
|
||||||
|
|
||||||
|
if entry == VOXEL_ENTRY_MASK_111:
|
||||||
|
return VOXEL_ENTRY_INDEX_111
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
func generate() -> String:
|
||||||
|
|
||||||
|
var i : int = 0
|
||||||
|
var a : String = ""
|
||||||
|
|
||||||
|
for y in range(4):
|
||||||
|
for z in range(8):
|
||||||
|
for x in range(8):
|
||||||
|
var data : Array = get_equiv_data(i)
|
||||||
|
|
||||||
|
var index : int = data[0]
|
||||||
|
var rx : int = data[1]
|
||||||
|
var ry : int = data[2]
|
||||||
|
var rz : int = data[3]
|
||||||
|
|
||||||
|
var owners : Array = get_rotate_owners(index, rx, ry, rz)
|
||||||
|
|
||||||
|
# a += str(i) + " -> " + str(equivalence_classes_data[index]) + " (" + str(data) + ")\n"
|
||||||
|
a += str(i) + " -> " + str(equivalence_classes_data[index]) + " (" + str(data) + ")" + " (" + str(debug_index_to_str(vertex_corner_data[index])) + " " + str(debug_index_to_str(owners)) + ")\n"
|
||||||
|
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return a
|
||||||
|
|
||||||
|
func get_rotate_owners(index : int, x : int, y : int, z : int) -> Array:
|
||||||
|
var owners : Array = vertex_corner_data[index]
|
||||||
|
var nowners : Array = []
|
||||||
|
|
||||||
|
for index in owners:
|
||||||
|
var i : int = index
|
||||||
|
|
||||||
|
for rx in range(x):
|
||||||
|
i = entry_index_x_rotations[i]
|
||||||
|
|
||||||
|
for ry in range(y):
|
||||||
|
i = entry_index_y_rotations[i]
|
||||||
|
|
||||||
|
for rz in range(z):
|
||||||
|
i = entry_index_z_rotations[i]
|
||||||
|
|
||||||
|
nowners.append(i)
|
||||||
|
|
||||||
|
return nowners
|
||||||
|
|
||||||
|
|
||||||
|
func find_equiv_index(cls : int) -> int:
|
||||||
|
for x in range(4):
|
||||||
|
for y in range(4):
|
||||||
|
for z in range(4):
|
||||||
|
var cl : int = rotate_index(cls, x, y, z)
|
||||||
|
|
||||||
|
for i in range(len(class_match_table)):
|
||||||
|
if class_match_table[i] == cl:
|
||||||
|
return i
|
||||||
|
|
||||||
|
return -1
|
||||||
|
|
||||||
|
func get_equiv_data(cls : int) -> Array:
|
||||||
|
var res : Array = []
|
||||||
|
|
||||||
|
for x in range(4):
|
||||||
|
for y in range(4):
|
||||||
|
for z in range(4):
|
||||||
|
var cl : int = rotate_index(cls, x, y, z)
|
||||||
|
|
||||||
|
for i in range(len(class_match_table)):
|
||||||
|
if class_match_table[i] == cl:
|
||||||
|
|
||||||
|
res.append(i)
|
||||||
|
res.append(x)
|
||||||
|
res.append(y)
|
||||||
|
res.append(z)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
func rotate_index(cls : int, x : int, y : int, z : int) -> int:
|
||||||
|
var corners : Array = [
|
||||||
|
cls & 1 << 0,
|
||||||
|
cls & 1 << 1,
|
||||||
|
cls & 1 << 2,
|
||||||
|
cls & 1 << 3,
|
||||||
|
cls & 1 << 4,
|
||||||
|
cls & 1 << 5,
|
||||||
|
cls & 1 << 6,
|
||||||
|
cls & 1 << 7,
|
||||||
|
]
|
||||||
|
|
||||||
|
for i in range(len(corners)):
|
||||||
|
if corners[i] == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var index : int = mask_entry_to_index_entry(corners[i])
|
||||||
|
|
||||||
|
for rx in range(x):
|
||||||
|
index = entry_index_x_rotations[index]
|
||||||
|
|
||||||
|
for ry in range(y):
|
||||||
|
index = entry_index_y_rotations[index]
|
||||||
|
|
||||||
|
for rz in range(z):
|
||||||
|
index = entry_index_z_rotations[index]
|
||||||
|
|
||||||
|
corners[i] = index_entry_to_mask_entry((index))
|
||||||
|
|
||||||
|
var res : int = 0
|
||||||
|
|
||||||
|
for e in corners:
|
||||||
|
res = res | e
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
func debug_index_to_str(array : Array) -> Array:
|
||||||
|
var o : Array = []
|
||||||
|
|
||||||
|
for e in array:
|
||||||
|
if e == VOXEL_ENTRY_INDEX_000:
|
||||||
|
o.append("000")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_100:
|
||||||
|
o.append("100")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_010:
|
||||||
|
o.append("010")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_110:
|
||||||
|
o.append("110")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_001:
|
||||||
|
o.append("001")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_101:
|
||||||
|
o.append("101")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_011:
|
||||||
|
o.append("011")
|
||||||
|
elif e == VOXEL_ENTRY_INDEX_111:
|
||||||
|
o.append("111")
|
||||||
|
else:
|
||||||
|
o.append("!")
|
||||||
|
|
||||||
|
return o
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_pressed():
|
||||||
|
var text_edit : TextEdit = get_node(text_edit_path) as TextEdit
|
||||||
|
|
||||||
|
text_edit.text = generate()
|
38
game/voxelman/table_generator/TableGenerator.tscn
Normal file
38
game/voxelman/table_generator/TableGenerator.tscn
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/table_generator/TableGenerator.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="TableGenerator" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
text_edit_path = NodePath("PanelContainer/VBoxContainer/TextEdit")
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||||
|
margin_left = 14.0
|
||||||
|
margin_top = 14.0
|
||||||
|
margin_right = 1010.0
|
||||||
|
margin_bottom = 586.0
|
||||||
|
|
||||||
|
[node name="TextEdit" type="TextEdit" parent="PanelContainer/VBoxContainer"]
|
||||||
|
margin_right = 996.0
|
||||||
|
margin_bottom = 527.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer"]
|
||||||
|
margin_top = 535.0
|
||||||
|
margin_right = 996.0
|
||||||
|
margin_bottom = 572.0
|
||||||
|
text = "Generate"
|
||||||
|
[connection signal="pressed" from="PanelContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"]
|
137
game/voxelman/transvoxel_mesher/TVTestScene.tscn
Normal file
137
game/voxelman/transvoxel_mesher/TVTestScene.tscn
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2]
|
||||||
|
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://data/voxel_textures/a2.png" type="Texture" id=5]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=1]
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=8]
|
||||||
|
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="MC_Test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Camera" parent="." instance=ExtResource( 4 )]
|
||||||
|
transform = Transform( -0.999922, -0.00920995, -0.00840917, -0.0115497, 0.938254, 0.345753, 0.00470557, 0.345823, -0.938288, 6.00985, 6.90149, -5.3643 )
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
|
||||||
|
|
||||||
|
[node name="VoxelWorld" parent="." instance=ExtResource( 1 )]
|
||||||
|
voxel_scale = 1.0
|
||||||
|
chunk_spawn_range = 2
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
|
||||||
|
|
||||||
|
[node name="FPSCounter" type="Label" parent="."]
|
||||||
|
margin_right = 123.0
|
||||||
|
margin_bottom = 41.0
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
|
||||||
|
material_override = SubResource( 2 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="gizmo" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
||||||
|
|
||||||
|
[node name="gizmo2" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
259
game/voxelman/transvoxel_mesher/TVVoxelChunk.gd
Normal file
259
game/voxelman/transvoxel_mesher/TVVoxelChunk.gd
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
extends VoxelChunk
|
||||||
|
class_name TVVoxelChunk
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var _prop_texture_packer : TexturePacker
|
||||||
|
var _textures : Array
|
||||||
|
var _prop_material : SpatialMaterial
|
||||||
|
var _entities_spawned : bool
|
||||||
|
|
||||||
|
var lod_data : Array = [
|
||||||
|
1, #CHUNK_INDEX_UP
|
||||||
|
1, #CHUNK_INDEX_DOWN
|
||||||
|
1, #CHUNK_INDEX_LEFT
|
||||||
|
1, #CHUNK_INDEX_RIGHT
|
||||||
|
1, #CHUNK_INDEX_FRONT
|
||||||
|
1 #CHUNK_INDEX_BACK
|
||||||
|
]
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
connect("visibility_changed", self, "visibility_changed")
|
||||||
|
|
||||||
|
set_notify_transform(true)
|
||||||
|
|
||||||
|
func _create_mesher():
|
||||||
|
mesher = TVVoxelMesher.new()
|
||||||
|
mesher.base_light_value = 0.45
|
||||||
|
mesher.ao_strength = 0.2
|
||||||
|
var m : float = 1.0 / 16.0
|
||||||
|
|
||||||
|
mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
|
||||||
|
|
||||||
|
_prop_texture_packer = TexturePacker.new()
|
||||||
|
_prop_texture_packer.max_atlas_size = 1024
|
||||||
|
_prop_texture_packer.margin = 1
|
||||||
|
_prop_texture_packer.background_color = Color(0, 0, 0, 1)
|
||||||
|
_prop_texture_packer.texture_flags = Texture.FLAG_MIPMAPS
|
||||||
|
|
||||||
|
func _process_props():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func spawn_prop_entities(parent_transform : Transform, prop : PropData):
|
||||||
|
for i in range(prop.get_prop_count()):
|
||||||
|
var p : PropDataEntry = prop.get_prop(i)
|
||||||
|
|
||||||
|
if p is PropDataEntity:
|
||||||
|
var pentity : PropDataEntity = p as PropDataEntity
|
||||||
|
|
||||||
|
if pentity.entity_data_id != 0:
|
||||||
|
Entities.spawn_mob(pentity.entity_data_id, pentity.level, parent_transform.origin)
|
||||||
|
|
||||||
|
|
||||||
|
if p is PropDataProp and p.prop != null:
|
||||||
|
var vmanpp : PropDataProp = p as PropDataProp
|
||||||
|
|
||||||
|
spawn_prop_entities(get_prop_mesh_transform(parent_transform * p.transform, vmanpp.snap_to_mesh, vmanpp.snap_axis), p.prop)
|
||||||
|
|
||||||
|
func build_phase_prop_mesh() -> void:
|
||||||
|
mesher.reset()
|
||||||
|
|
||||||
|
if get_prop_count() == 0:
|
||||||
|
next_phase()
|
||||||
|
return
|
||||||
|
|
||||||
|
if get_prop_mesh_rid() == RID():
|
||||||
|
allocate_prop_mesh()
|
||||||
|
|
||||||
|
if _prop_material == null:
|
||||||
|
_prop_material = SpatialMaterial.new()
|
||||||
|
_prop_material.flags_vertex_lighting = true
|
||||||
|
_prop_material.vertex_color_use_as_albedo = true
|
||||||
|
_prop_material.params_specular_mode = SpatialMaterial.SPECULAR_DISABLED
|
||||||
|
_prop_material.metallic = 0
|
||||||
|
|
||||||
|
VisualServer.instance_geometry_set_material_override(get_prop_mesh_instance_rid(), _prop_material.get_rid())
|
||||||
|
mesher.material = _prop_material
|
||||||
|
|
||||||
|
for i in range(get_prop_count()):
|
||||||
|
var prop : VoxelChunkPropData = get_prop(i)
|
||||||
|
|
||||||
|
if prop.mesh != null and prop.mesh_texture != null:
|
||||||
|
var at : AtlasTexture = _prop_texture_packer.add_texture(prop.mesh_texture)
|
||||||
|
_textures.append(at)
|
||||||
|
|
||||||
|
if prop.prop != null:
|
||||||
|
prop.prop.add_textures_into(_prop_texture_packer)
|
||||||
|
|
||||||
|
if _prop_texture_packer.get_texture_count() > 0:
|
||||||
|
_prop_texture_packer.merge()
|
||||||
|
|
||||||
|
_prop_material.albedo_texture = _prop_texture_packer.get_generated_texture(0)
|
||||||
|
|
||||||
|
for i in range(get_prop_count()):
|
||||||
|
var prop : VoxelChunkPropData = get_prop(i)
|
||||||
|
|
||||||
|
if prop.mesh != null:
|
||||||
|
var t : Transform = get_prop_transform(prop, prop.snap_to_mesh, prop.snap_axis)
|
||||||
|
|
||||||
|
prop.prop.add_meshes_into(mesher, _prop_texture_packer, t, self)
|
||||||
|
|
||||||
|
if prop.prop != null:
|
||||||
|
var vmanpp : PropData = prop.prop as PropData
|
||||||
|
var t : Transform = get_prop_transform(prop, vmanpp.snap_to_mesh, vmanpp.snap_axis)
|
||||||
|
|
||||||
|
prop.prop.add_meshes_into(mesher, _prop_texture_packer, t, self)
|
||||||
|
|
||||||
|
mesher.bake_colors(self)
|
||||||
|
mesher.build_mesh(get_prop_mesh_rid())
|
||||||
|
mesher.material = null
|
||||||
|
|
||||||
|
if not _entities_spawned:
|
||||||
|
for i in range(get_prop_count()):
|
||||||
|
var prop : VoxelChunkPropData = get_prop(i)
|
||||||
|
|
||||||
|
if prop.prop != null:
|
||||||
|
spawn_prop_entities(get_prop_transform(prop, false, Vector3(0, -1, 0)), prop.prop)
|
||||||
|
|
||||||
|
next_phase()
|
||||||
|
|
||||||
|
func build_phase_lights() -> void:
|
||||||
|
var vl : VoxelLight = VoxelLight.new()
|
||||||
|
|
||||||
|
for i in range(get_prop_count()):
|
||||||
|
var prop : VoxelChunkPropData = get_prop(i)
|
||||||
|
|
||||||
|
if prop.light == null and prop.prop == null:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var t : Transform = get_prop_transform(prop, prop.snap_to_mesh, prop.snap_axis)
|
||||||
|
|
||||||
|
if prop.light != null:
|
||||||
|
var pl : PropDataLight = prop.light
|
||||||
|
|
||||||
|
vl.set_world_position(prop.x + position_x * size_x, prop.y + position_y * size_y, prop.z + position_z * size_z)
|
||||||
|
vl.color = pl.light_color
|
||||||
|
vl.size = pl.light_size
|
||||||
|
|
||||||
|
bake_light(vl)
|
||||||
|
|
||||||
|
if prop.prop != null:
|
||||||
|
prop.prop.add_prop_lights_into(self, t, true)
|
||||||
|
|
||||||
|
next_phase()
|
||||||
|
|
||||||
|
func get_prop_transform(prop : VoxelChunkPropData, snap_to_mesh: bool, snap_axis: Vector3) -> Transform:
|
||||||
|
var pos : Vector3 = Vector3(prop.x * voxel_scale, prop.y * voxel_scale, prop.z * voxel_scale)
|
||||||
|
|
||||||
|
var t : Transform = Transform(Basis(prop.rotation).scaled(prop.scale), pos)
|
||||||
|
|
||||||
|
if snap_to_mesh:
|
||||||
|
var global_pos : Vector3 = to_global(t.origin)
|
||||||
|
var world_snap_axis : Vector3 = to_global(t.xform(snap_axis))
|
||||||
|
var world_snap_dir : Vector3 = (world_snap_axis - global_pos) * 100
|
||||||
|
|
||||||
|
var space_state : PhysicsDirectSpaceState = get_world().direct_space_state
|
||||||
|
var result : Dictionary = space_state.intersect_ray(global_pos - world_snap_dir, global_pos + world_snap_dir, [], 1)
|
||||||
|
|
||||||
|
if result.size() > 0:
|
||||||
|
t.origin = to_local(result["position"])
|
||||||
|
|
||||||
|
return t
|
||||||
|
|
||||||
|
func get_prop_mesh_transform(base_transform : Transform, snap_to_mesh: bool, snap_axis: Vector3) -> Transform:
|
||||||
|
if snap_to_mesh:
|
||||||
|
var pos : Vector3 = to_global(base_transform.origin)
|
||||||
|
var world_snap_axis : Vector3 = to_global(base_transform.xform(snap_axis))
|
||||||
|
var world_snap_dir : Vector3 = (world_snap_axis - pos) * 100
|
||||||
|
|
||||||
|
var space_state : PhysicsDirectSpaceState = get_world().direct_space_state
|
||||||
|
var result : Dictionary = space_state.intersect_ray(pos - world_snap_dir, pos + world_snap_dir, [], 1)
|
||||||
|
|
||||||
|
if result.size() > 0:
|
||||||
|
base_transform.origin = to_local(result["position"])
|
||||||
|
|
||||||
|
return base_transform
|
||||||
|
|
||||||
|
func _build_phase(phase):
|
||||||
|
if phase == VoxelChunk.BUILD_PHASE_LIGHTS:
|
||||||
|
clear_baked_lights()
|
||||||
|
generate_random_ao()
|
||||||
|
|
||||||
|
var vl : VoxelLight = VoxelLight.new()
|
||||||
|
|
||||||
|
bake_lights()
|
||||||
|
|
||||||
|
set_physics_process_internal(true)
|
||||||
|
elif phase == VoxelChunk.BUILD_PHASE_PROP_MESH:
|
||||||
|
set_physics_process_internal(true)
|
||||||
|
elif phase == VoxelChunk.BUILD_PHASE_FINALIZE:
|
||||||
|
._build_phase(phase)
|
||||||
|
|
||||||
|
notification(NOTIFICATION_TRANSFORM_CHANGED)
|
||||||
|
else:
|
||||||
|
._build_phase(phase)
|
||||||
|
|
||||||
|
func _prop_added(prop):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func generate_random_ao() -> void:
|
||||||
|
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
noise.seed = 123
|
||||||
|
noise.octaves = 4
|
||||||
|
noise.period = 6
|
||||||
|
noise.persistence = 0.3
|
||||||
|
|
||||||
|
for x in range(0, size_x + 1):
|
||||||
|
for z in range(0, size_z + 1):
|
||||||
|
for y in range(0, size_y + 1):
|
||||||
|
var val : float = noise.get_noise_3d(x + (position_x * size_x), y + (position_y * size_y), z + (position_z * size_z))
|
||||||
|
|
||||||
|
val *= 0.6
|
||||||
|
|
||||||
|
if val > 1:
|
||||||
|
val = 1
|
||||||
|
|
||||||
|
if val < 0:
|
||||||
|
val = -val
|
||||||
|
|
||||||
|
set_voxel(int(val * 255.0), x, y, z, VoxelChunk.DEFAULT_CHANNEL_RANDOM_AO)
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if current_build_phase == VoxelChunk.BUILD_PHASE_LIGHTS:
|
||||||
|
build_phase_lights()
|
||||||
|
set_physics_process_internal(false)
|
||||||
|
|
||||||
|
elif current_build_phase == VoxelChunk.BUILD_PHASE_PROP_MESH:
|
||||||
|
build_phase_prop_mesh()
|
||||||
|
set_physics_process_internal(false)
|
||||||
|
|
||||||
|
func visibility_changed() -> void:
|
||||||
|
if get_mesh_instance_rid() != RID():
|
||||||
|
VisualServer.instance_set_visible(get_mesh_instance_rid(), visible)
|
||||||
|
|
||||||
|
if get_prop_mesh_instance_rid() != RID():
|
||||||
|
VisualServer.instance_set_visible(get_prop_mesh_instance_rid(), visible)
|
||||||
|
|
||||||
|
|
||||||
|
func _notification(what: int) -> void:
|
||||||
|
if what == NOTIFICATION_TRANSFORM_CHANGED:
|
||||||
|
if get_mesh_instance_rid() != RID():
|
||||||
|
VisualServer.instance_set_transform(get_mesh_instance_rid(), transform)
|
||||||
|
|
||||||
|
if get_prop_mesh_instance_rid() != RID():
|
||||||
|
VisualServer.instance_set_transform(get_prop_mesh_instance_rid(), transform)
|
||||||
|
|
||||||
|
if get_body_rid() != RID():
|
||||||
|
PhysicsServer.body_set_state(get_body_rid(), PhysicsServer.BODY_STATE_TRANSFORM, transform)
|
||||||
|
|
||||||
|
if get_prop_body_rid() != RID():
|
||||||
|
PhysicsServer.body_set_state(get_prop_body_rid(), PhysicsServer.BODY_STATE_TRANSFORM, transform)
|
||||||
|
|
||||||
|
#func _draw_debug_voxel_lights(debug_drawer):
|
||||||
|
# for light in _lightsarr:
|
||||||
|
# var pos_x = (light.get_world_position_x() - (size_x * position_x)) ;
|
||||||
|
# var pos_y = (light.get_world_position_y() - (size_y * position_y)) ;
|
||||||
|
# var pos_z = (light.get_world_position_z() - (size_z * position_z)) ;
|
||||||
|
## print(Vector3(pos_x, pos_y, pos_z))
|
||||||
|
# draw_cross_voxels_fill(Vector3(pos_x, pos_y, pos_z), 1)
|
475
game/voxelman/transvoxel_mesher/TVVoxelMesher.gd
Normal file
475
game/voxelman/transvoxel_mesher/TVVoxelMesher.gd
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
extends VoxelMesherTransvoxel
|
||||||
|
class_name TVVoxelMesher
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var transition_sides : int = 0
|
||||||
|
|
||||||
|
const VOXEL_CHUNK_SIDE_FRONT : int = 1 << 0
|
||||||
|
const VOXEL_CHUNK_SIDE_BACK : int = 1 << 1
|
||||||
|
const VOXEL_CHUNK_SIDE_LEFT : int = 1 << 2
|
||||||
|
const VOXEL_CHUNK_SIDE_RIGHT : int = 1 << 3
|
||||||
|
const VOXEL_CHUNK_SIDE_TOP : int = 1 << 4
|
||||||
|
const VOXEL_CHUNK_SIDE_BOTTOM : int = 1 << 5
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CHUNK_INDEX_UP = 0,
|
||||||
|
CHUNK_INDEX_DOWN = 1,
|
||||||
|
CHUNK_INDEX_LEFT = 2,
|
||||||
|
CHUNK_INDEX_RIGHT = 3,
|
||||||
|
CHUNK_INDEX_FRONT = 4,
|
||||||
|
CHUNK_INDEX_BACK = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
var lod_data : Array = [
|
||||||
|
1, #CHUNK_INDEX_UP
|
||||||
|
1, #CHUNK_INDEX_DOWN
|
||||||
|
1, #CHUNK_INDEX_LEFT
|
||||||
|
1, #CHUNK_INDEX_RIGHT
|
||||||
|
1, #CHUNK_INDEX_FRONT
|
||||||
|
1 #CHUNK_INDEX_BACK
|
||||||
|
]
|
||||||
|
|
||||||
|
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
||||||
|
var case_code : int = 0
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_000
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_010
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_001
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_011
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_100
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_110
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_101
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_111
|
||||||
|
|
||||||
|
return case_code
|
||||||
|
|
||||||
|
func get_voxel_type(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
||||||
|
var type : int = 0
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
if type != 0:
|
||||||
|
return type
|
||||||
|
|
||||||
|
type = buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
return type
|
||||||
|
|
||||||
|
func _add_chunk(buffer : VoxelChunk) -> void:
|
||||||
|
var b : bool = true
|
||||||
|
|
||||||
|
for l in lod_data:
|
||||||
|
if l != 1:
|
||||||
|
b = false
|
||||||
|
break
|
||||||
|
|
||||||
|
if lod_size == 1 and b:
|
||||||
|
add_buffer_normal(buffer)
|
||||||
|
else:
|
||||||
|
add_buffer_lod(buffer)
|
||||||
|
|
||||||
|
func add_buffer_normal(buffer : VoxelChunk) -> void:
|
||||||
|
buffer.generate_ao()
|
||||||
|
|
||||||
|
var x_size : int = buffer.get_size_x()
|
||||||
|
var y_size : int = buffer.get_size_y()
|
||||||
|
var z_size : int = buffer.get_size_z()
|
||||||
|
|
||||||
|
for y in range(0, y_size, lod_size):
|
||||||
|
for z in range(0, z_size, lod_size):
|
||||||
|
for x in range(0, x_size, lod_size):
|
||||||
|
|
||||||
|
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
if case_code == 0 or case_code == 255:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var regular_cell_class : int = get_regular_cell_class(case_code)
|
||||||
|
|
||||||
|
var cell_data : TransvoxelCellData = get_regular_cell_data(regular_cell_class)
|
||||||
|
|
||||||
|
var index_count : int = cell_data.get_triangle_count() * 3
|
||||||
|
var vertex_count : int = cell_data.get_vertex_count()
|
||||||
|
|
||||||
|
for i in range(index_count):
|
||||||
|
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
|
||||||
|
add_indices(ind)
|
||||||
|
|
||||||
|
var temp_verts : Array = Array()
|
||||||
|
|
||||||
|
var type_id : int = get_voxel_type(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
var surface : VoxelSurface = library.get_voxel_surface(type_id)
|
||||||
|
|
||||||
|
for i in range(vertex_count):
|
||||||
|
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
||||||
|
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
|
||||||
|
|
||||||
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
|
var type0 : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
# var type1 : int = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
var fill : int = 0
|
||||||
|
|
||||||
|
var vert_pos : Vector3
|
||||||
|
var vert_dir : Vector3
|
||||||
|
|
||||||
|
if type0 == 0:
|
||||||
|
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_first_position(case_code, i)
|
||||||
|
else:
|
||||||
|
fill = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_first_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_second_position(case_code, i)
|
||||||
|
|
||||||
|
vert_dir = vert_dir - vert_pos
|
||||||
|
|
||||||
|
vert_pos += vert_dir * (fill / 256.0)
|
||||||
|
|
||||||
|
temp_verts.append(vert_pos)
|
||||||
|
|
||||||
|
# if regular_uv_entries.size() > uvs[i]:
|
||||||
|
# add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
||||||
|
|
||||||
|
# add_uv(Vector2(0, 0))
|
||||||
|
|
||||||
|
var temp_normals : Array = Array()
|
||||||
|
|
||||||
|
#warning-ignore:unused_variable
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
temp_normals.append(Vector3())
|
||||||
|
|
||||||
|
#generate normals
|
||||||
|
for i in range(0, index_count, 3):
|
||||||
|
var indices : Array = [
|
||||||
|
cell_data.get_vertex_index(i),
|
||||||
|
cell_data.get_vertex_index(i + 1),
|
||||||
|
cell_data.get_vertex_index(i + 2)
|
||||||
|
]
|
||||||
|
|
||||||
|
var vertices : Array = [
|
||||||
|
temp_verts[indices[0]],
|
||||||
|
temp_verts[indices[1]],
|
||||||
|
temp_verts[indices[2]],
|
||||||
|
]
|
||||||
|
|
||||||
|
temp_normals[indices[0]] += (vertices[1] - vertices[0]).cross(vertices[0] - vertices[2])
|
||||||
|
temp_normals[indices[1]] += (vertices[2] - vertices[1]).cross(vertices[1] - vertices[0])
|
||||||
|
temp_normals[indices[2]] += (vertices[2] - vertices[1]).cross(vertices[2] - vertices[0])
|
||||||
|
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
temp_normals[i] = (temp_normals[i] as Vector3).normalized()
|
||||||
|
|
||||||
|
for cvi in range(len(temp_verts)):
|
||||||
|
var vertex : Vector3 = temp_verts[cvi]
|
||||||
|
var normal : Vector3 = temp_normals[cvi]
|
||||||
|
|
||||||
|
var s : Vector3 = Vector3()
|
||||||
|
var t : Vector3 = Vector3()
|
||||||
|
t.x = vertex.z
|
||||||
|
t.y = vertex.z
|
||||||
|
t.z = vertex.y
|
||||||
|
|
||||||
|
s.x = vertex.y
|
||||||
|
s.y = vertex.x
|
||||||
|
s.z = vertex.x
|
||||||
|
|
||||||
|
var bx : float = abs(normal.x)
|
||||||
|
var by : float = abs(normal.y)
|
||||||
|
var bz : float = abs(normal.z)
|
||||||
|
|
||||||
|
# if case_code == 7 and cvi == 0:
|
||||||
|
# print(str(bx) + " " + str(by) + " " + str(bz))
|
||||||
|
# add_uv(surface.transform_uv(VoxelSurface.VOXEL_SIDE_SIDE, Vector2(s.z, t.z)))
|
||||||
|
|
||||||
|
if (bx + 0.0001 > by and bx + 0.0001 > bz):
|
||||||
|
var uv : Vector2 = Vector2(s.x, t.x)
|
||||||
|
var umargin : Rect2 = uv_margin
|
||||||
|
uv.x *= umargin.size.x
|
||||||
|
uv.y *= umargin.size.y
|
||||||
|
|
||||||
|
uv.x += umargin.position.x
|
||||||
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
|
add_uv(surface.transform_uv(VoxelSurface.VOXEL_SIDE_SIDE, uv))
|
||||||
|
elif (bz + 0.0001 > bx and bz + 0.0001 > by):
|
||||||
|
var uv : Vector2 = Vector2(s.z, t.z)
|
||||||
|
var umargin : Rect2 = uv_margin
|
||||||
|
uv.x *= umargin.size.x
|
||||||
|
uv.y *= umargin.size.y
|
||||||
|
|
||||||
|
uv.x += umargin.position.x
|
||||||
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
|
add_uv(surface.transform_uv(VoxelSurface.VOXEL_SIDE_SIDE, uv))
|
||||||
|
else:
|
||||||
|
var uv : Vector2 = Vector2(s.y, t.y)
|
||||||
|
var umargin : Rect2 = uv_margin
|
||||||
|
uv.x *= umargin.size.x
|
||||||
|
uv.y *= umargin.size.y
|
||||||
|
|
||||||
|
uv.x += umargin.position.x
|
||||||
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
|
add_uv(surface.transform_uv(VoxelSurface.VOXEL_SIDE_TOP, uv))
|
||||||
|
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
|
||||||
|
var vert_pos : Vector3 = temp_verts[i] as Vector3
|
||||||
|
|
||||||
|
vert_pos *= float(lod_size)
|
||||||
|
vert_pos += Vector3(x, y, z)
|
||||||
|
|
||||||
|
var normal : Vector3 = temp_normals[i] as Vector3
|
||||||
|
|
||||||
|
var vpx : int = int(vert_pos.x)
|
||||||
|
var vpy : int = int(vert_pos.y)
|
||||||
|
var vpz : int = int(vert_pos.z)
|
||||||
|
|
||||||
|
var light : Color = Color(buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0)
|
||||||
|
var ao : float = (buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_AO) / 255.0) * ao_strength
|
||||||
|
var rao : float = (buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_RANDOM_AO) / 255.0)
|
||||||
|
ao += rao
|
||||||
|
|
||||||
|
light.r += base_light_value
|
||||||
|
light.g += base_light_value
|
||||||
|
light.b += base_light_value
|
||||||
|
|
||||||
|
light.r -= ao
|
||||||
|
light.g -= ao
|
||||||
|
light.b -= ao
|
||||||
|
|
||||||
|
light.r = clamp(light.r, 0, 1.0)
|
||||||
|
light.g = clamp(light.g, 0, 1.0)
|
||||||
|
light.b = clamp(light.b, 0, 1.0)
|
||||||
|
|
||||||
|
# if regular_cell_class == 11:
|
||||||
|
# print("asd")
|
||||||
|
# if case_code == 112 + 2:
|
||||||
|
## print(regular_cell_class)
|
||||||
|
## print("asd")
|
||||||
|
# light.r = 1
|
||||||
|
# light.g = 1
|
||||||
|
# light.b = 1
|
||||||
|
|
||||||
|
|
||||||
|
add_color(light)
|
||||||
|
|
||||||
|
vert_pos *= float(voxel_scale)
|
||||||
|
|
||||||
|
add_normal(normal)
|
||||||
|
add_vertex(vert_pos)
|
||||||
|
|
||||||
|
|
||||||
|
# if case_code == 7:
|
||||||
|
#
|
||||||
|
# #reset
|
||||||
|
# set_regular_vertex_data(case_code, 2, 0x3304)
|
||||||
|
#
|
||||||
|
# set_regular_vertex_data(case_code, 3, 0x2315)
|
||||||
|
# set_regular_vertex_data(case_code, 4, 0x4113)
|
||||||
|
# set_regular_vertex_data(case_code, 5, 0x1326)
|
||||||
|
#
|
||||||
|
# set_regular_vertex_data(case_code, 6, 0x3304)
|
||||||
|
# set_regular_vertex_data(case_code, 7, 0x2315)
|
||||||
|
# set_regular_vertex_data(case_code, 8, 0x2315)
|
||||||
|
|
||||||
|
func add_buffer_lod(buffer : VoxelChunk) -> void:
|
||||||
|
if lod_data[CHUNK_INDEX_UP] < lod_size:
|
||||||
|
# generate_side_lod_mesh(0, buffer)
|
||||||
|
pass
|
||||||
|
|
||||||
|
# CHUNK_INDEX_DOWN = 1,
|
||||||
|
# CHUNK_INDEX_LEFT = 2,
|
||||||
|
# CHUNK_INDEX_RIGHT = 3,
|
||||||
|
# CHUNK_INDEX_FRONT = 4,
|
||||||
|
# CHUNK_INDEX_BACK = 5,
|
||||||
|
|
||||||
|
#generate_main_lod_mesh(buffer)
|
||||||
|
|
||||||
|
func generate_side_lod_mesh(sx : int, ex : int, sy : int, ey : int, sz : int, ez : int, buffer : VoxelChunk) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func generate_main_lod_mesh(buffer : VoxelChunk) -> void:
|
||||||
|
buffer.generate_ao()
|
||||||
|
|
||||||
|
var x_size : int = buffer.get_size_x() - 1
|
||||||
|
var y_size : int = buffer.get_size_y() - 1
|
||||||
|
var z_size : int = buffer.get_size_z() - 1
|
||||||
|
|
||||||
|
for y in range(0, y_size, lod_size):
|
||||||
|
for z in range(0, z_size, lod_size):
|
||||||
|
for x in range(0, x_size, lod_size):
|
||||||
|
|
||||||
|
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
if case_code == 0 or case_code == 255:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var regular_cell_class : int = get_regular_cell_class(case_code)
|
||||||
|
|
||||||
|
var cell_data : TransvoxelCellData = get_regular_cell_data(regular_cell_class)
|
||||||
|
|
||||||
|
var index_count : int = cell_data.get_triangle_count() * 3
|
||||||
|
var vertex_count : int = cell_data.get_vertex_count()
|
||||||
|
|
||||||
|
for i in range(index_count):
|
||||||
|
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
|
||||||
|
add_indices(ind)
|
||||||
|
|
||||||
|
var temp_verts : Array = Array()
|
||||||
|
|
||||||
|
for i in range(vertex_count):
|
||||||
|
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
||||||
|
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
|
||||||
|
|
||||||
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
|
var type0 : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
# var type1 : int = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
var fill : int = 0
|
||||||
|
|
||||||
|
var vert_pos : Vector3
|
||||||
|
var vert_dir : Vector3
|
||||||
|
|
||||||
|
if type0 == 0:
|
||||||
|
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_first_position(case_code, i)
|
||||||
|
else:
|
||||||
|
fill = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_first_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_second_position(case_code, i)
|
||||||
|
|
||||||
|
vert_dir = vert_dir - vert_pos
|
||||||
|
|
||||||
|
vert_pos += vert_dir * (fill / 256.0)
|
||||||
|
|
||||||
|
temp_verts.append(vert_pos)
|
||||||
|
|
||||||
|
# if regular_uv_entries.size() > uvs[i]:
|
||||||
|
# add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
||||||
|
|
||||||
|
# add_uv(Vector2(0, 0))
|
||||||
|
|
||||||
|
var temp_normals : Array = Array()
|
||||||
|
|
||||||
|
#warning-ignore:unused_variable
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
temp_normals.append(Vector3())
|
||||||
|
|
||||||
|
#generate normals
|
||||||
|
for i in range(0, index_count, 3):
|
||||||
|
var indices : Array = [
|
||||||
|
cell_data.get_vertex_index(i),
|
||||||
|
cell_data.get_vertex_index(i + 1),
|
||||||
|
cell_data.get_vertex_index(i + 2)
|
||||||
|
]
|
||||||
|
|
||||||
|
var vertices : Array = [
|
||||||
|
temp_verts[indices[0]],
|
||||||
|
temp_verts[indices[1]],
|
||||||
|
temp_verts[indices[2]],
|
||||||
|
]
|
||||||
|
|
||||||
|
temp_normals[indices[0]] += (vertices[1] - vertices[0]).cross(vertices[0] - vertices[2])
|
||||||
|
temp_normals[indices[1]] += (vertices[2] - vertices[1]).cross(vertices[1] - vertices[0])
|
||||||
|
temp_normals[indices[2]] += (vertices[2] - vertices[1]).cross(vertices[2] - vertices[0])
|
||||||
|
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
temp_normals[i] = (temp_normals[i] as Vector3).normalized()
|
||||||
|
|
||||||
|
for cvi in range(len(temp_verts)):
|
||||||
|
var vertex : Vector3 = temp_verts[cvi]
|
||||||
|
var normal : Vector3 = temp_normals[cvi]
|
||||||
|
|
||||||
|
var s : Vector3 = Vector3()
|
||||||
|
var t : Vector3 = Vector3()
|
||||||
|
t.x = vertex.z
|
||||||
|
t.y = vertex.z
|
||||||
|
t.z = vertex.y
|
||||||
|
|
||||||
|
s.x = vertex.y
|
||||||
|
s.y = vertex.x
|
||||||
|
s.z = vertex.x
|
||||||
|
|
||||||
|
var bx : float = abs(normal.x)
|
||||||
|
var by : float = abs(normal.y)
|
||||||
|
var bz : float = abs(normal.z)
|
||||||
|
|
||||||
|
if (bx > by and bx > bz):
|
||||||
|
add_uv(Vector2(s.x, t.x))
|
||||||
|
elif (bz > bx and bz > by):
|
||||||
|
add_uv(Vector2(s.z, t.z))
|
||||||
|
else:
|
||||||
|
add_uv(Vector2(s.y, t.y))
|
||||||
|
|
||||||
|
for i in range(len(temp_verts)):
|
||||||
|
|
||||||
|
var vert_pos : Vector3 = temp_verts[i] as Vector3
|
||||||
|
|
||||||
|
vert_pos *= float(lod_size)
|
||||||
|
vert_pos += Vector3(x, y, z)
|
||||||
|
|
||||||
|
var normal : Vector3 = temp_normals[i] as Vector3
|
||||||
|
|
||||||
|
vert_pos *= float(voxel_scale)
|
||||||
|
|
||||||
|
add_normal(normal)
|
||||||
|
add_vertex(vert_pos)
|
163
game/voxelman/transvoxel_mesher/TVVoxelWorld.gd
Normal file
163
game/voxelman/transvoxel_mesher/TVVoxelWorld.gd
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
tool
|
||||||
|
extends VoxelWorld
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
export(Array, MeshDataResource) var meshes : Array
|
||||||
|
|
||||||
|
export (bool) var editor_generate : bool = false setget set_editor_generate, get_editor_generate
|
||||||
|
export (bool) var show_loading_screen : bool = true
|
||||||
|
|
||||||
|
var initial_generation : bool = true
|
||||||
|
|
||||||
|
var spawned : bool = false
|
||||||
|
|
||||||
|
var _editor_generate : bool
|
||||||
|
|
||||||
|
var _player_file_name : String
|
||||||
|
var _player : Entity
|
||||||
|
|
||||||
|
#func _process(delta : float) -> void:
|
||||||
|
# if not generation_queue.empty():
|
||||||
|
# var chunk : VoxelChunk = generation_queue.front()
|
||||||
|
|
||||||
|
# refresh_chunk_lod_level_data(chunk)
|
||||||
|
|
||||||
|
# level_generator.generate_chunk(chunk)
|
||||||
|
|
||||||
|
# generation_queue.remove(0)
|
||||||
|
#
|
||||||
|
# if generation_queue.empty():
|
||||||
|
# emit_signal("generation_finished")
|
||||||
|
# initial_generation = false
|
||||||
|
#
|
||||||
|
# if show_loading_screen and not Engine.editor_hint:
|
||||||
|
# get_node("..").hide_loading_screen()
|
||||||
|
|
||||||
|
func _generation_finished():
|
||||||
|
initial_generation = false
|
||||||
|
|
||||||
|
if show_loading_screen and not Engine.editor_hint:
|
||||||
|
get_node("..").hide_loading_screen()
|
||||||
|
|
||||||
|
#TODO hack, do this properly
|
||||||
|
if _player:
|
||||||
|
_player.set_physics_process(true)
|
||||||
|
|
||||||
|
func _prepare_chunk_for_generation(chunk):
|
||||||
|
refresh_chunk_lod_level_data(chunk)
|
||||||
|
|
||||||
|
func refresh_chunk_lod_level_data(chunk : VoxelChunk) -> void:
|
||||||
|
var cpx : int = chunk.position_x
|
||||||
|
var cpy : int = chunk.position_y
|
||||||
|
var cpz : int = chunk.position_z
|
||||||
|
|
||||||
|
var chunk_lod : int = chunk.lod_size
|
||||||
|
|
||||||
|
var carr : Array = [
|
||||||
|
get_chunk_lod_level(cpx, cpy + 1, cpz, chunk_lod), #CHUNK_INDEX_UP
|
||||||
|
get_chunk_lod_level(cpx, cpy - 1, cpz, chunk_lod), #CHUNK_INDEX_DOWN
|
||||||
|
get_chunk_lod_level(cpx + 1, cpy, cpz, chunk_lod), #CHUNK_INDEX_LEFT
|
||||||
|
get_chunk_lod_level(cpx - 1, cpy, cpz, chunk_lod), #CHUNK_INDEX_RIGHT
|
||||||
|
get_chunk_lod_level(cpx, cpy, cpz - 1, chunk_lod), #CHUNK_INDEX_FRONT
|
||||||
|
get_chunk_lod_level(cpx, cpy, cpz + 1, chunk_lod) #CHUNK_INDEX_BACK
|
||||||
|
]
|
||||||
|
|
||||||
|
chunk.lod_data = carr
|
||||||
|
|
||||||
|
|
||||||
|
func get_chunk_lod_level(x : int, y : int, z : int, default : int) -> int:
|
||||||
|
# var key : String = str(x) + "," + str(y) + "," + str(z)
|
||||||
|
|
||||||
|
var ch : VoxelChunk = get_chunk(x, y, z)
|
||||||
|
|
||||||
|
if ch == null:
|
||||||
|
return default
|
||||||
|
|
||||||
|
return ch.lod_size
|
||||||
|
|
||||||
|
func _create_chunk(x : int, y : int, z : int, pchunk : Node) -> VoxelChunk:
|
||||||
|
var chunk : VoxelChunk = TVVoxelChunk.new()
|
||||||
|
|
||||||
|
chunk.lod_size = 1
|
||||||
|
|
||||||
|
return ._create_chunk(x, y, z, chunk)
|
||||||
|
|
||||||
|
func spawn() -> void:
|
||||||
|
for x in range(-chunk_spawn_range, chunk_spawn_range):
|
||||||
|
for z in range(-chunk_spawn_range, chunk_spawn_range):
|
||||||
|
for y in range(-1, 1):
|
||||||
|
create_chunk(x, y, z)
|
||||||
|
|
||||||
|
set_process(true)
|
||||||
|
|
||||||
|
|
||||||
|
func get_editor_generate() -> bool:
|
||||||
|
return _editor_generate
|
||||||
|
|
||||||
|
func set_editor_generate(value : bool) -> void:
|
||||||
|
if value:
|
||||||
|
library.refresh_rects()
|
||||||
|
|
||||||
|
level_generator.setup(self, current_seed, false, library)
|
||||||
|
spawn()
|
||||||
|
else:
|
||||||
|
spawned = false
|
||||||
|
clear()
|
||||||
|
|
||||||
|
_editor_generate = value
|
||||||
|
|
||||||
|
func add_light(x : int, y : int, z : int, size : int, color : Color) -> void:
|
||||||
|
var chunkx : int = int(x / chunk_size_x)
|
||||||
|
var chunky : int = int(y / chunk_size_y)
|
||||||
|
var chunkz : int = int(z / chunk_size_z)
|
||||||
|
|
||||||
|
var light : VoxelLight = VoxelLight.new()
|
||||||
|
light.color = color
|
||||||
|
light.size = size
|
||||||
|
light.set_world_position(x, y, z)
|
||||||
|
|
||||||
|
for xx in range(chunkx - 1, chunkx + 1):
|
||||||
|
for yy in range(chunky - 1, chunky + 1):
|
||||||
|
for zz in range(chunkz - 1, chunkz + 1):
|
||||||
|
var chunk : VoxelChunk = get_chunk(xx, yy, zz)
|
||||||
|
|
||||||
|
if chunk == null:
|
||||||
|
continue
|
||||||
|
|
||||||
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
|
func setup_client_seed(pseed : int) -> void:
|
||||||
|
# _player_file_name = ""
|
||||||
|
# _player = null
|
||||||
|
|
||||||
|
Server.sset_seed(pseed)
|
||||||
|
|
||||||
|
if level_generator != null:
|
||||||
|
level_generator.setup(self, pseed, false, library)
|
||||||
|
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func load_character(file_name : String) -> void:
|
||||||
|
_player_file_name = file_name
|
||||||
|
_player = Entities.load_player(file_name, Vector3(5, 10, 5), 1) as Entity
|
||||||
|
#TODO hack, do this properly
|
||||||
|
_player.set_physics_process(false)
|
||||||
|
|
||||||
|
Server.sset_seed(_player.sseed)
|
||||||
|
|
||||||
|
if level_generator != null:
|
||||||
|
level_generator.setup(self, _player.sseed, true, library)
|
||||||
|
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func needs_loading_screen() -> bool:
|
||||||
|
return show_loading_screen
|
||||||
|
|
||||||
|
func save() -> void:
|
||||||
|
if _player == null or _player_file_name == "":
|
||||||
|
return
|
||||||
|
|
||||||
|
Entities.save_player(_player, _player_file_name)
|
12
game/voxelman/transvoxel_mesher/TVVoxelWorld.tscn
Normal file
12
game/voxelman/transvoxel_mesher/TVVoxelWorld.tscn
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library_2.tres" type="VoxelmanLibrarySimple" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="World" type="VoxelWorld"]
|
||||||
|
library = ExtResource( 3 )
|
||||||
|
voxel_scale = 2.0
|
||||||
|
player_path = NodePath("Camera")
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
editor_generate = null
|
433
game/voxelman/transvoxel_mesher/TestVoxelMesher.gd
Normal file
433
game/voxelman/transvoxel_mesher/TestVoxelMesher.gd
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
extends VoxelMesherTransvoxel
|
||||||
|
class_name TestVoxelMesher
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var count : int = 0
|
||||||
|
|
||||||
|
var regular_uv_entries : Array = [
|
||||||
|
[ 0, 0 ], #0
|
||||||
|
[ 1, 0 ], #1
|
||||||
|
[ 0, 1 ], #2
|
||||||
|
[ 1, 1 ], #3
|
||||||
|
]
|
||||||
|
|
||||||
|
var regular_uv_data : Array = [
|
||||||
|
[],
|
||||||
|
#[ 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 2, 1, 3 ], #h top s, n, s
|
||||||
|
#[ 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 2, 1, 0 ], #h top s, s, n
|
||||||
|
#[ 0x5102, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 0, 1, 2, 3 ], #h top n, s, s, n
|
||||||
|
#[ 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 5 ], #h top
|
||||||
|
#[ 0x3304, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 2, 1, 0 ], #h top
|
||||||
|
#[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 3, 1, 0, 2, 3 ], #h top
|
||||||
|
#[ 0x4113, 0x8337, 0x4223 ],
|
||||||
|
[ 3, 1, 0 ], #h top
|
||||||
|
#[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 3, 0, 2, 0, 3, 1 ], #h top
|
||||||
|
#[ 0x6201, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0, 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x5102, 0x4113, 0x8337, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top s, s, n, n
|
||||||
|
#[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201 ],
|
||||||
|
[ 3, 1, 0, 2, 2 ], #h top s, n, n, n, s
|
||||||
|
#[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
[ 2, 3, 1, 0, 2 ], #h top s, n, n, n, s
|
||||||
|
#[ 0x3304, 0x2315, 0x8337, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top n, n, n, n
|
||||||
|
#[ 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 2, 0, 3 ], # h bottom n, s, s
|
||||||
|
#[ 0x6201, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x3304, 0x1146, 0x2245, 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x4223, 0x6201, 0x2315, 0x8337, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x4223, 0x8337, 0x2315, 0x2245, 0x1146, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x4113, 0x8337, 0x1326, 0x1146, 0x2245, 0x6201 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2245, 0x2315, 0x8337, 0x1326, 0x1146 ],
|
||||||
|
#[ 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
#[ 0x4113, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x1326, 0x3304, 0x2245, 0x8157, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x4223 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8337, 0x8157, 0x2245, 0x6201 ],
|
||||||
|
[ 0x8157, 0x8337, 0x1326, 0x3304, 0x2245 ],
|
||||||
|
#[ 0x2315, 0x3304, 0x1146, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x5102, 0x1146, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1326, 0x4223, 0x6201, 0x2315, 0x8157, 0x1146 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1326, 0x1146, 0x8157, 0x4113, 0x4223 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x8337, 0x4223, 0x6201 ],
|
||||||
|
[ 0x4223, 0x5102, 0x1146, 0x8157, 0x8337 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4113, 0x8337, 0x1326 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x1326, 0x1146, 0x8157, 0x2315 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1146, 0x8157, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
#[ 0x1326, 0x1146, 0x8157, 0x8337 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
#[ 0x5102, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x1146, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x1146, 0x8267, 0x4223, 0x4113, 0x2315, 0x3304 ],
|
||||||
|
[ 0x4113, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x8267, 0x1146, 0x5102 ],
|
||||||
|
[ 0x1146, 0x3304, 0x2315, 0x8337, 0x8267 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x2315, 0x4113, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x6201, 0x4223, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x4223, 0x8267, 0x2245, 0x2315 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x6201, 0x2315, 0x8337 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8267, 0x2245, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8267, 0x8337, 0x4113, 0x5102 ],
|
||||||
|
[ 0x8337, 0x8267, 0x2245, 0x6201, 0x4113 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8337, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x2315, 0x8337, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157, 0x4113 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8157, 0x4113, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x8337, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8157, 0x8337, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x8267, 0x8157, 0x2315, 0x6201, 0x5102, 0x1326 ],
|
||||||
|
[ 0x8267, 0x1326, 0x3304, 0x6201, 0x4113, 0x8157 ],
|
||||||
|
[ 0x8267, 0x8157, 0x4113, 0x5102, 0x1326 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x8157, 0x2315, 0x3304 ],
|
||||||
|
[ 0x2315, 0x6201, 0x4223, 0x8267, 0x8157 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4223, 0x8267, 0x8157, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x4223, 0x8267, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x8157, 0x2315, 0x6201, 0x5102, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x8157, 0x8337, 0x4223, 0x6201, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8267, 0x8157, 0x8337, 0x4223 ],
|
||||||
|
[ 0x8267, 0x8157, 0x2315, 0x3304, 0x5102, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x8157, 0x2315 ],
|
||||||
|
[ 0x6201, 0x3304, 0x5102, 0x8337, 0x8267, 0x8157 ],
|
||||||
|
#[ 0x8337, 0x8267, 0x8157 ],
|
||||||
|
#[ 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315 ],
|
||||||
|
[ 0x3304, 0x2315, 0x8157, 0x8267, 0x4223, 0x5102 ],
|
||||||
|
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8157, 0x4113, 0x6201, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x1326, 0x5102, 0x6201, 0x2315, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8267, 0x1326, 0x3304, 0x2315, 0x8157 ],
|
||||||
|
[ 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2315, 0x8157, 0x8267, 0x4223, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x1146, 0x2245, 0x6201, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x8267, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x1146, 0x2245, 0x2315, 0x8157, 0x8267 ],
|
||||||
|
#[ 0x2315, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x2315, 0x2245, 0x8267 ],
|
||||||
|
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x3304, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
#[ 0x6201, 0x2245, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8267, 0x4223, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4113, 0x2315, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x8267, 0x1326, 0x3304, 0x6201 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
#[ 0x3304, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146 ],
|
||||||
|
[ 0x5102, 0x1146, 0x8267, 0x8337, 0x2315, 0x6201 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8267, 0x8337, 0x4113, 0x6201 ],
|
||||||
|
[ 0x8337, 0x4113, 0x5102, 0x1146, 0x8267 ],
|
||||||
|
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1146, 0x8267, 0x8337, 0x2315, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x8267, 0x8337, 0x4113, 0x6201, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x8267, 0x8337 ],
|
||||||
|
[ 0x3304, 0x2315, 0x4113, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x2315, 0x6201, 0x5102, 0x1146, 0x8267, 0x4223, 0x4113 ],
|
||||||
|
[ 0x1146, 0x8267, 0x4223, 0x6201, 0x3304 ],
|
||||||
|
#[ 0x5102, 0x1146, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8267, 0x1326, 0x5102, 0x4113, 0x2315, 0x3304, 0x1146 ],
|
||||||
|
[ 0x6201, 0x4113, 0x2315, 0x1326, 0x1146, 0x8267 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1146, 0x8267, 0x1326, 0x5102 ],
|
||||||
|
#[ 0x1326, 0x1146, 0x8267 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x1326, 0x8337, 0x8157, 0x1146 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x5102, 0x3304, 0x2315, 0x1326, 0x8337, 0x8157, 0x1146 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223 ],
|
||||||
|
[ 0x6201, 0x4223, 0x8337, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x1146, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x1146, 0x8157, 0x2315, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2315, 0x8157, 0x1146, 0x1326 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x1146, 0x5102 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0x2315, 0x8157, 0x1146, 0x5102, 0x6201 ],
|
||||||
|
#[ 0x2315, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x2245, 0x2315, 0x4113, 0x5102, 0x1326, 0x8337, 0x8157 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x3304, 0x5102 ],
|
||||||
|
[ 0x8157, 0x2245, 0x6201, 0x4223, 0x8337 ],
|
||||||
|
[ 0x2245, 0x3304, 0x5102, 0x4223, 0x8337, 0x8157, 0x4113, 0x6201, 0x2315 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x8157, 0x2245, 0x3304, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1326, 0x4223, 0x4113, 0x8157, 0x2245, 0x6201, 0x5102 ],
|
||||||
|
[ 0x8157, 0x2245, 0x3304, 0x1326, 0x4223, 0x6201, 0x2315 ],
|
||||||
|
[ 0x5102, 0x1326, 0x4223, 0x2315, 0x8157, 0x2245 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4113, 0x8157, 0x2245 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x2245, 0x6201 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x2315, 0x8157, 0x2245 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245 ],
|
||||||
|
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x6201, 0x2245, 0x1146, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
[ 0x2245, 0x1146, 0x1326, 0x8337, 0x4113, 0x5102, 0x3304 ],
|
||||||
|
[ 0x5102, 0x1146, 0x2245, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0x1146, 0x3304, 0x6201, 0x4223, 0x8337, 0x2315, 0x2245 ],
|
||||||
|
[ 0x8337, 0x4113, 0x6201, 0x2245, 0x1146, 0x5102, 0x4223 ],
|
||||||
|
[ 0x4223, 0x8337, 0x4113, 0x3304, 0x2245, 0x1146 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1146, 0x1326, 0x4223, 0x4113, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x1326, 0x4223, 0x6201, 0x2245, 0x1146 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x1146, 0x1326 ],
|
||||||
|
[ 0x2245, 0x1146, 0x5102, 0x4113, 0x2315 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x3304, 0x6201 ],
|
||||||
|
#[ 0x6201, 0x2245, 0x1146, 0x5102 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x3304, 0x2245, 0x1146 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x8337, 0x2315 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8337, 0x2315, 0x6201 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
#[ 0x5102, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x4223, 0x8337, 0x2315, 0x3304, 0x5102 ],
|
||||||
|
#[ 0x6201, 0x4223, 0x8337, 0x2315 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4223, 0x8337, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x4223, 0x8337 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x4113, 0x2315, 0x3304, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1326, 0x4223, 0x4113, 0x2315, 0x6201, 0x5102 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x4223, 0x6201 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x5102, 0x1326, 0x4223 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x5102, 0x4113, 0x2315, 0x3304 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x6201, 0x4113, 0x2315 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x6201, 0x3304, 0x5102 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
|
||||||
|
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
||||||
|
var case_code : int = 0
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_000
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_010
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_001
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_011
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_100
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_110
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_101
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_111
|
||||||
|
|
||||||
|
return case_code
|
||||||
|
|
||||||
|
func _add_chunk(buffer : VoxelChunk) -> void:
|
||||||
|
var x_size : int = buffer.get_size_x() - 1
|
||||||
|
var y_size : int = buffer.get_size_y() - 1
|
||||||
|
var z_size : int = buffer.get_size_z() - 1
|
||||||
|
|
||||||
|
for y in range(0, y_size, lod_size):
|
||||||
|
for z in range(0, z_size, lod_size):
|
||||||
|
for x in range(0, x_size, lod_size):
|
||||||
|
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
if case_code == 0 or case_code == 255:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var regular_cell_class : int = get_regular_cell_class(case_code)
|
||||||
|
|
||||||
|
var cell_data : TransvoxelCellData = get_regular_cell_data(regular_cell_class)
|
||||||
|
|
||||||
|
var index_count : int = cell_data.get_triangle_count() * 3
|
||||||
|
var vertex_count : int = cell_data.get_vertex_count()
|
||||||
|
|
||||||
|
var uvs : Array = regular_uv_data[case_code]
|
||||||
|
|
||||||
|
for i in range(index_count):
|
||||||
|
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
|
||||||
|
add_indices(ind)
|
||||||
|
|
||||||
|
for i in range(vertex_count):
|
||||||
|
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
||||||
|
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
|
||||||
|
|
||||||
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
|
var type0 : int = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
var type1 : int = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
var fill : int = 0
|
||||||
|
|
||||||
|
var vert_pos : Vector3
|
||||||
|
var vert_dir : Vector3
|
||||||
|
|
||||||
|
if type0 == 0:
|
||||||
|
fill = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_first_position(case_code, i)
|
||||||
|
else:
|
||||||
|
fill = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_first_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_second_position(case_code, i)
|
||||||
|
|
||||||
|
vert_dir = vert_dir - vert_pos
|
||||||
|
|
||||||
|
vert_pos += vert_dir * (fill / 256.0)
|
||||||
|
vert_pos *= float(lod_size)
|
||||||
|
vert_pos += Vector3(x, y, z)
|
||||||
|
vert_pos *= float(voxel_scale)
|
||||||
|
|
||||||
|
if regular_uv_entries.size() > uvs[i]:
|
||||||
|
add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
||||||
|
|
||||||
|
add_uv(Vector2(0, 0))
|
||||||
|
|
||||||
|
add_vertex(vert_pos)
|
||||||
|
|
||||||
|
|
||||||
|
func create_Debug_triangle(position : Vector3):
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position)
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position + Vector3(2, 0, 0))
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position + Vector3(0, 0, 2))
|
||||||
|
|
||||||
|
print(get_vertex_count())
|
||||||
|
|
||||||
|
|
138
game/voxelman/transvoxel_mesher_gen_uv/TVGUTestScene.tscn
Normal file
138
game/voxelman/transvoxel_mesher_gen_uv/TVGUTestScene.tscn
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
[gd_scene load_steps=17 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2]
|
||||||
|
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://data/voxel_textures/a2.png" type="Texture" id=5]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library.tres" type="VoxelmanLibrarySimple" id=6]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=1]
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=8]
|
||||||
|
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="MC_Test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Camera" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( -0.999922, -0.00920995, -0.00840917, -0.0115497, 0.938254, 0.345753, 0.00470557, 0.345823, -0.938288, 6.00985, 6.90149, -5.3643 )
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
|
||||||
|
|
||||||
|
[node name="VoxelWorld" parent="." instance=ExtResource( 4 )]
|
||||||
|
library = ExtResource( 6 )
|
||||||
|
voxel_scale = 1.0
|
||||||
|
|
||||||
|
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
|
||||||
|
|
||||||
|
[node name="FPSCounter" type="Label" parent="."]
|
||||||
|
margin_right = 123.0
|
||||||
|
margin_bottom = 41.0
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
|
||||||
|
material_override = SubResource( 2 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="gizmo" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
||||||
|
|
||||||
|
[node name="gizmo2" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
14
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelChunk.gd
Normal file
14
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelChunk.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends VoxelChunk
|
||||||
|
class_name TVGUVoxelChunk
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
#export (Vector3) var chunk_position : Vector3
|
||||||
|
#var world : VoxelWorld
|
||||||
|
|
||||||
|
#func _ready():
|
||||||
|
# world = get_node("..")
|
||||||
|
|
||||||
|
func _create_mesher():
|
||||||
|
mesher = TVGUVoxelMesher.new()
|
1351
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelMesher.gd
Normal file
1351
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelMesher.gd
Normal file
File diff suppressed because it is too large
Load Diff
205
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.gd
Normal file
205
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.gd
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
extends VoxelWorld
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
enum GenType {
|
||||||
|
TEST, NORMAL, NOISE3D
|
||||||
|
}
|
||||||
|
|
||||||
|
signal generation_finished
|
||||||
|
|
||||||
|
export(int) var gen_type : int = GenType.NORMAL
|
||||||
|
|
||||||
|
export(Array, MeshDataResource) var meshes : Array
|
||||||
|
|
||||||
|
var chunks : Dictionary = Dictionary()
|
||||||
|
var spawned : bool = false
|
||||||
|
|
||||||
|
var generation_queue : Array
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if not generation_queue.empty():
|
||||||
|
var chunk : VoxelChunk = generation_queue.front()
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL:
|
||||||
|
#
|
||||||
|
generate_terrarin(chunk)
|
||||||
|
elif gen_type == GenType.NOISE3D:
|
||||||
|
# generate(chunk)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
generate_test(chunk)
|
||||||
|
|
||||||
|
generation_queue.remove(0)
|
||||||
|
|
||||||
|
if generation_queue.empty():
|
||||||
|
emit_signal("generation_finished")
|
||||||
|
|
||||||
|
func generate_terrarin(chunk : VoxelChunk) -> void:
|
||||||
|
var buffer : VoxelChunk = chunk.get_buffer()
|
||||||
|
buffer.create(int(size_x) + 3, int(size_y) + 3, int(size_z) + 3)
|
||||||
|
|
||||||
|
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
noise.seed = 10
|
||||||
|
noise.octaves = 4
|
||||||
|
noise.period = 200.0
|
||||||
|
noise.persistence = 0.8
|
||||||
|
|
||||||
|
var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
terr_noise.seed = 10 * 321 + 112
|
||||||
|
terr_noise.octaves = 4
|
||||||
|
terr_noise.period = 20.0
|
||||||
|
terr_noise.persistence = 0.9
|
||||||
|
|
||||||
|
for x in range(-1, size_x + 2):
|
||||||
|
for z in range(-1, size_z + 2):
|
||||||
|
var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val *= val
|
||||||
|
val *= 100
|
||||||
|
val += 2
|
||||||
|
|
||||||
|
var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val += tv * 2
|
||||||
|
|
||||||
|
var v : int = (int(val))
|
||||||
|
|
||||||
|
for y in range(-1, v):
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 50 + 205, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + 1)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 50 + 205, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
|
var light : VoxelLight = VoxelLight.new()
|
||||||
|
randomize()
|
||||||
|
light.color = Color(randf(), randf(), randf())
|
||||||
|
light.size = randi() % 5 + 5
|
||||||
|
light.set_world_position((chunk.position_x * chunk.size_x) + (randi() % chunk.size_x), (chunk.position_y * chunk.size_y) + (randi() % 6), (chunk.position_z * chunk.size_z) + (randi() % chunk.size_z))
|
||||||
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
|
# var light : VoxelLight = VoxelLight.new()
|
||||||
|
# light.color = Color(1.0, 0, 0)
|
||||||
|
# light.size = 10
|
||||||
|
# light.set_world_position((chunk.position_x * chunk.size_x) + (2), (chunk.position_y * chunk.size_y) + (7), (chunk.position_z * chunk.size_z) + (1))
|
||||||
|
# chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
# for x in range(16):
|
||||||
|
# for z in range(16):
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis().scaled(Vector3(0.2, 0.2, 0.2)), Vector3(2, 5, 0) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis(), Vector3(4, 3, 5) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
chunk.bake_lights()
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
# chunk.draw_debug_voxels(2000)
|
||||||
|
# chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_chunk(x : int, y : int, z : int, lod_size : int = 1) -> void:
|
||||||
|
var name : String = "Chunk," + str(x) + "," + str(y) + "," + str(z)
|
||||||
|
# var chunk : VoxelChunk = VoxelChunk.new()
|
||||||
|
var chunk : VoxelChunk = TVGUVoxelChunk.new()
|
||||||
|
|
||||||
|
chunk.voxel_world = self
|
||||||
|
chunk.set_chunk_position(x, y, z)
|
||||||
|
chunk.library = library
|
||||||
|
chunk.voxel_scale = voxel_scale
|
||||||
|
chunk.lod_size = lod_size
|
||||||
|
chunk.set_chunk_size(int(size_x), int(size_y), int(size_z))
|
||||||
|
|
||||||
|
chunk.create_mesher()
|
||||||
|
chunk.mesher.base_light_value = 0.6
|
||||||
|
|
||||||
|
chunks[name] = chunk
|
||||||
|
|
||||||
|
generation_queue.append(chunk)
|
||||||
|
|
||||||
|
|
||||||
|
func spawn() -> void:
|
||||||
|
var hsize : int = 4
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL or gen_type == GenType.NOISE3D:
|
||||||
|
for x in range(-hsize, hsize):
|
||||||
|
for z in range(-hsize, hsize):
|
||||||
|
for y in range(1):
|
||||||
|
# spawn_chunk(x, y, z, abs(int(ceil(x / 2))) + 1)
|
||||||
|
spawn_chunk(x, y, z, 1)
|
||||||
|
else:
|
||||||
|
spawn_chunk(0, 0, 0, 1)
|
||||||
|
|
||||||
|
#func set_player(p_player : Spatial) -> void:
|
||||||
|
# player = p_player
|
||||||
|
|
||||||
|
# if _spawned:
|
||||||
|
# clear()
|
||||||
|
#
|
||||||
|
# spawn()
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func generate_test(chunk : VoxelChunk) ->void:
|
||||||
|
var buffer : VoxelChunk = chunk.get_buffer()
|
||||||
|
|
||||||
|
buffer.create(40, 40, 40)
|
||||||
|
|
||||||
|
var i : int = 1
|
||||||
|
|
||||||
|
for y in range(4):
|
||||||
|
for z in range(8):
|
||||||
|
for x in range(8):
|
||||||
|
spawn_equiv_class(buffer, i, x * 4 + 1, y * 4 + 1, z * 4 + 1)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
# spawn_equiv_class(buffer,127, 4, 4, 4)
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
chunk.draw_debug_voxels(2000)
|
||||||
|
# chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_equiv_class(buffer : VoxelChunk, cls : int, x : int, y : int, z : int) -> void:
|
||||||
|
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_000:
|
||||||
|
buffer.set_voxel(1, x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_100:
|
||||||
|
buffer.set_voxel(1, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_001:
|
||||||
|
buffer.set_voxel(1, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_101:
|
||||||
|
buffer.set_voxel(1, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_010:
|
||||||
|
buffer.set_voxel(1, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_110:
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_011:
|
||||||
|
buffer.set_voxel(1, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_111:
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
|
||||||
|
|
11
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.tscn
Normal file
11
game/voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.tscn
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library_2.tres" type="VoxelmanLibrarySimple" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="VoxelWorld" type="VoxelWorld"]
|
||||||
|
player_path = NodePath("Camera")
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
library = ExtResource( 3 )
|
||||||
|
voxel_scale = 2.0
|
138
game/voxelman/transvoxel_mesher_normal_uv/TVNUTestScene.tscn
Normal file
138
game/voxelman/transvoxel_mesher_normal_uv/TVNUTestScene.tscn
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2]
|
||||||
|
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://data/voxel_textures/a2.png" type="Texture" id=5]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=1]
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=8]
|
||||||
|
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[sub_resource type="PrismMesh" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
|
||||||
|
albedo_texture = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="MC_Test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Camera" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( -0.999922, -0.00920995, -0.00840917, -0.0115497, 0.938254, 0.345753, 0.00470557, 0.345823, -0.938288, 6.00985, 6.90149, -5.3643 )
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
|
||||||
|
|
||||||
|
[node name="VoxelWorld" parent="." instance=ExtResource( 4 )]
|
||||||
|
voxel_scale = 1.0
|
||||||
|
gen_type = 0
|
||||||
|
editor_generate = null
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
|
||||||
|
|
||||||
|
[node name="FPSCounter" type="Label" parent="."]
|
||||||
|
margin_right = 123.0
|
||||||
|
margin_bottom = 41.0
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
|
||||||
|
material_override = SubResource( 2 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="gizmo" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
||||||
|
|
||||||
|
[node name="gizmo2" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
|
||||||
|
|
||||||
|
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
|
||||||
|
material_override = SubResource( 5 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
|
||||||
|
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
|
||||||
|
mesh = SubResource( 9 )
|
||||||
|
material/0 = SubResource( 10 )
|
14
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelChunk.gd
Normal file
14
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelChunk.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends VoxelChunk
|
||||||
|
class_name TVNUVoxelChunk
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
#export (Vector3) var chunk_position : Vector3
|
||||||
|
#var world : VoxelWorld
|
||||||
|
|
||||||
|
#func _ready():
|
||||||
|
# world = get_node("..")
|
||||||
|
|
||||||
|
func _create_mesher():
|
||||||
|
mesher = TVNUVoxelMesher.new()
|
435
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelMesher.gd
Normal file
435
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelMesher.gd
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
extends VoxelMesherTransvoxel
|
||||||
|
class_name TVNUVoxelMesher
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
var count : int = 0
|
||||||
|
|
||||||
|
var regular_uv_entries : Array = [
|
||||||
|
[ 0, 0 ], #0
|
||||||
|
[ 1, 0 ], #1
|
||||||
|
[ 0, 1 ], #2
|
||||||
|
[ 1, 1 ], #3
|
||||||
|
]
|
||||||
|
|
||||||
|
var regular_uv_data : Array = [
|
||||||
|
[],
|
||||||
|
#[ 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 2, 1, 3 ], #h top s, n, s
|
||||||
|
#[ 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 2, 1, 0 ], #h top s, s, n
|
||||||
|
#[ 0x5102, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 0, 1, 2, 3 ], #h top n, s, s, n
|
||||||
|
#[ 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 5 ], #h top
|
||||||
|
#[ 0x3304, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 2, 1, 0 ], #h top
|
||||||
|
#[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 3, 1, 0, 2, 3 ], #h top
|
||||||
|
#[ 0x4113, 0x8337, 0x4223 ],
|
||||||
|
[ 3, 1, 0 ], #h top
|
||||||
|
#[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 3, 0, 2, 0, 3, 1 ], #h top
|
||||||
|
#[ 0x6201, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0, 2, 3, 1, 0 ], #h top
|
||||||
|
#[ 0x5102, 0x4113, 0x8337, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top s, s, n, n
|
||||||
|
#[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201 ],
|
||||||
|
[ 3, 1, 0, 2, 2 ], #h top s, n, n, n, s
|
||||||
|
#[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
[ 2, 3, 1, 0, 2 ], #h top s, n, n, n, s
|
||||||
|
#[ 0x3304, 0x2315, 0x8337, 0x1326 ],
|
||||||
|
[ 2, 3, 1, 0 ], #h top n, n, n, n
|
||||||
|
#[ 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 2, 0, 3 ], # h bottom n, s, s
|
||||||
|
#[ 0x6201, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x3304, 0x1146, 0x2245, 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x4223, 0x6201, 0x2315, 0x8337, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x4223, 0x8337, 0x2315, 0x2245, 0x1146, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x4113, 0x8337, 0x1326, 0x1146, 0x2245, 0x6201 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2245, 0x2315, 0x8337, 0x1326, 0x1146 ],
|
||||||
|
#[ 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
#[ 0x4113, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x1326, 0x3304, 0x2245, 0x8157, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x4223 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8337, 0x8157, 0x2245, 0x6201 ],
|
||||||
|
[ 0x8157, 0x8337, 0x1326, 0x3304, 0x2245 ],
|
||||||
|
#[ 0x2315, 0x3304, 0x1146, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x5102, 0x1146, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1326, 0x4223, 0x6201, 0x2315, 0x8157, 0x1146 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1326, 0x1146, 0x8157, 0x4113, 0x4223 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8157, 0x8337, 0x4223, 0x6201 ],
|
||||||
|
[ 0x4223, 0x5102, 0x1146, 0x8157, 0x8337 ],
|
||||||
|
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4113, 0x8337, 0x1326 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x1326, 0x1146, 0x8157, 0x2315 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1146, 0x8157, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
#[ 0x1326, 0x1146, 0x8157, 0x8337 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
#[ 0x5102, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x1146, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x1146, 0x8267, 0x4223, 0x4113, 0x2315, 0x3304 ],
|
||||||
|
[ 0x4113, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304 ],
|
||||||
|
[ 0x6201, 0x2315, 0x8337, 0x8267, 0x1146, 0x5102 ],
|
||||||
|
[ 0x1146, 0x3304, 0x2315, 0x8337, 0x8267 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x2315, 0x4113, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x6201, 0x4223, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x4223, 0x8267, 0x2245, 0x2315 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x6201, 0x2315, 0x8337 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8267, 0x2245, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8267, 0x8337, 0x4113, 0x5102 ],
|
||||||
|
[ 0x8337, 0x8267, 0x2245, 0x6201, 0x4113 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8337, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x2315, 0x8337, 0x8267, 0x2245 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157, 0x4113 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8157, 0x4113, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x1326, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304, 0x2315, 0x2245, 0x8157 ],
|
||||||
|
[ 0x8337, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8157, 0x8337, 0x8267, 0x1146 ],
|
||||||
|
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x8267, 0x8157, 0x2315, 0x6201, 0x5102, 0x1326 ],
|
||||||
|
[ 0x8267, 0x1326, 0x3304, 0x6201, 0x4113, 0x8157 ],
|
||||||
|
[ 0x8267, 0x8157, 0x4113, 0x5102, 0x1326 ],
|
||||||
|
[ 0x5102, 0x4223, 0x8267, 0x8157, 0x2315, 0x3304 ],
|
||||||
|
[ 0x2315, 0x6201, 0x4223, 0x8267, 0x8157 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4223, 0x8267, 0x8157, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x4223, 0x8267, 0x8157 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x8157, 0x2315, 0x6201, 0x5102, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
|
||||||
|
[ 0x8157, 0x8337, 0x4223, 0x6201, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8267, 0x8157, 0x8337, 0x4223 ],
|
||||||
|
[ 0x8267, 0x8157, 0x2315, 0x3304, 0x5102, 0x4113, 0x8337 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x8157, 0x2315 ],
|
||||||
|
[ 0x6201, 0x3304, 0x5102, 0x8337, 0x8267, 0x8157 ],
|
||||||
|
#[ 0x8337, 0x8267, 0x8157 ],
|
||||||
|
#[ 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x6201, 0x5102, 0x3304, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315 ],
|
||||||
|
[ 0x3304, 0x2315, 0x8157, 0x8267, 0x4223, 0x5102 ],
|
||||||
|
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8157, 0x4113, 0x6201, 0x3304, 0x1326, 0x8267 ],
|
||||||
|
[ 0x1326, 0x5102, 0x6201, 0x2315, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8267, 0x1326, 0x3304, 0x2315, 0x8157 ],
|
||||||
|
[ 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x8337, 0x8157, 0x8267 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x2315, 0x8157, 0x8267, 0x4223, 0x5102, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x1146, 0x2245, 0x6201, 0x4113, 0x8157, 0x8267 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x8267, 0x1326, 0x3304, 0x1146, 0x2245 ],
|
||||||
|
[ 0x1326, 0x1146, 0x2245, 0x2315, 0x8157, 0x8267 ],
|
||||||
|
#[ 0x2315, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0x5102, 0x4113, 0x8337, 0x8267, 0x2245, 0x3304 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x2315, 0x2245, 0x8267 ],
|
||||||
|
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x3304, 0x2245, 0x8267, 0x8337 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113 ],
|
||||||
|
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
#[ 0x6201, 0x2245, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x2245, 0x8267, 0x4223, 0x5102 ],
|
||||||
|
[ 0x5102, 0x4113, 0x2315, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x8267, 0x1326, 0x3304, 0x6201 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
#[ 0x3304, 0x2245, 0x8267, 0x1326 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146 ],
|
||||||
|
[ 0x5102, 0x1146, 0x8267, 0x8337, 0x2315, 0x6201 ],
|
||||||
|
[ 0x3304, 0x1146, 0x8267, 0x8337, 0x4113, 0x6201 ],
|
||||||
|
[ 0x8337, 0x4113, 0x5102, 0x1146, 0x8267 ],
|
||||||
|
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x1146, 0x8267, 0x8337, 0x2315, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x8267, 0x8337, 0x4113, 0x6201, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x8267, 0x8337 ],
|
||||||
|
[ 0x3304, 0x2315, 0x4113, 0x4223, 0x8267, 0x1146 ],
|
||||||
|
[ 0x2315, 0x6201, 0x5102, 0x1146, 0x8267, 0x4223, 0x4113 ],
|
||||||
|
[ 0x1146, 0x8267, 0x4223, 0x6201, 0x3304 ],
|
||||||
|
#[ 0x5102, 0x1146, 0x8267, 0x4223 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8267, 0x1326, 0x5102, 0x4113, 0x2315, 0x3304, 0x1146 ],
|
||||||
|
[ 0x6201, 0x4113, 0x2315, 0x1326, 0x1146, 0x8267 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1146, 0x8267, 0x1326, 0x5102 ],
|
||||||
|
#[ 0x1326, 0x1146, 0x8267 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x1326, 0x8337, 0x8157, 0x1146 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x5102, 0x3304, 0x2315, 0x1326, 0x8337, 0x8157, 0x1146 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223 ],
|
||||||
|
[ 0x6201, 0x4223, 0x8337, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x1146, 0x3304, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326 ],
|
||||||
|
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x1146, 0x8157, 0x2315, 0x6201, 0x4223, 0x1326 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2315, 0x8157, 0x1146, 0x1326 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x1146, 0x5102 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x6201, 0x4113, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0x2315, 0x8157, 0x1146, 0x5102, 0x6201 ],
|
||||||
|
#[ 0x2315, 0x8157, 0x1146, 0x3304 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157 ],
|
||||||
|
[ 0x6201, 0x2245, 0x8157, 0x8337, 0x1326, 0x5102 ],
|
||||||
|
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157, 0x6201, 0x2315, 0x4113 ],
|
||||||
|
[ 0x2245, 0x2315, 0x4113, 0x5102, 0x1326, 0x8337, 0x8157 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x3304, 0x5102 ],
|
||||||
|
[ 0x8157, 0x2245, 0x6201, 0x4223, 0x8337 ],
|
||||||
|
[ 0x2245, 0x3304, 0x5102, 0x4223, 0x8337, 0x8157, 0x4113, 0x6201, 0x2315 ],
|
||||||
|
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x2315, 0x4113 ],
|
||||||
|
[ 0x4113, 0x8157, 0x2245, 0x3304, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1326, 0x4223, 0x4113, 0x8157, 0x2245, 0x6201, 0x5102 ],
|
||||||
|
[ 0x8157, 0x2245, 0x3304, 0x1326, 0x4223, 0x6201, 0x2315 ],
|
||||||
|
[ 0x5102, 0x1326, 0x4223, 0x2315, 0x8157, 0x2245 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4113, 0x8157, 0x2245 ],
|
||||||
|
#[ 0x4113, 0x8157, 0x2245, 0x6201 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x2245, 0x3304 ],
|
||||||
|
#[ 0x2315, 0x8157, 0x2245 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245 ],
|
||||||
|
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x6201, 0x2245, 0x1146, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
[ 0x2245, 0x1146, 0x1326, 0x8337, 0x4113, 0x5102, 0x3304 ],
|
||||||
|
[ 0x5102, 0x1146, 0x2245, 0x2315, 0x8337, 0x4223 ],
|
||||||
|
[ 0x1146, 0x3304, 0x6201, 0x4223, 0x8337, 0x2315, 0x2245 ],
|
||||||
|
[ 0x8337, 0x4113, 0x6201, 0x2245, 0x1146, 0x5102, 0x4223 ],
|
||||||
|
[ 0x4223, 0x8337, 0x4113, 0x3304, 0x2245, 0x1146 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1146, 0x1326, 0x4223, 0x4113, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
|
||||||
|
[ 0x1326, 0x4223, 0x6201, 0x2245, 0x1146 ],
|
||||||
|
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x1146, 0x1326 ],
|
||||||
|
[ 0x2245, 0x1146, 0x5102, 0x4113, 0x2315 ],
|
||||||
|
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x3304, 0x6201 ],
|
||||||
|
#[ 0x6201, 0x2245, 0x1146, 0x5102 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x3304, 0x2245, 0x1146 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x8337, 0x2315 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x5102, 0x1326, 0x8337, 0x2315, 0x6201 ],
|
||||||
|
[ 0x6201, 0x3304, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
#[ 0x5102, 0x1326, 0x8337, 0x4113 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x4223, 0x8337, 0x2315, 0x3304, 0x5102 ],
|
||||||
|
#[ 0x6201, 0x4223, 0x8337, 0x2315 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
[ 0x3304, 0x5102, 0x4223, 0x8337, 0x4113, 0x6201 ],
|
||||||
|
#[ 0x4113, 0x4223, 0x8337 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[ 0x4113, 0x2315, 0x3304, 0x1326, 0x4223 ],
|
||||||
|
[ 0x1326, 0x4223, 0x4113, 0x2315, 0x6201, 0x5102 ],
|
||||||
|
#[ 0x3304, 0x1326, 0x4223, 0x6201 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x5102, 0x1326, 0x4223 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x5102, 0x4113, 0x2315, 0x3304 ],
|
||||||
|
[ 0, 1, 2, 3 ],
|
||||||
|
#[ 0x6201, 0x4113, 0x2315 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
#[ 0x6201, 0x3304, 0x5102 ],
|
||||||
|
[ 0, 1, 4 ],
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
|
||||||
|
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
||||||
|
var case_code : int = 0
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_000
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_010
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_001
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_011
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_100
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_110
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_101
|
||||||
|
|
||||||
|
if (buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_111
|
||||||
|
|
||||||
|
return case_code
|
||||||
|
|
||||||
|
func _add_chunk(buffer : VoxelChunk) -> void:
|
||||||
|
var x_size : int = buffer.get_size_x() - 1
|
||||||
|
var y_size : int = buffer.get_size_y() - 1
|
||||||
|
var z_size : int = buffer.get_size_z() - 1
|
||||||
|
|
||||||
|
for y in range(0, y_size, lod_size):
|
||||||
|
for z in range(0, z_size, lod_size):
|
||||||
|
for x in range(0, x_size, lod_size):
|
||||||
|
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
|
||||||
|
|
||||||
|
if case_code == 0 or case_code == 255:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var regular_cell_class : int = get_regular_cell_class(case_code)
|
||||||
|
|
||||||
|
var cell_data : TransvoxelCellData = get_regular_cell_data(regular_cell_class)
|
||||||
|
|
||||||
|
var index_count : int = cell_data.get_triangle_count() * 3
|
||||||
|
var vertex_count : int = cell_data.get_vertex_count()
|
||||||
|
|
||||||
|
var uvs : Array = regular_uv_data[case_code]
|
||||||
|
|
||||||
|
for i in range(index_count):
|
||||||
|
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
|
||||||
|
add_indices(ind)
|
||||||
|
|
||||||
|
for i in range(vertex_count):
|
||||||
|
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
||||||
|
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
|
||||||
|
|
||||||
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
|
var type0 : int = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
var type1 : int = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
|
||||||
|
var fill : int = 0
|
||||||
|
|
||||||
|
var vert_pos : Vector3
|
||||||
|
var vert_dir : Vector3
|
||||||
|
|
||||||
|
if type0 == 0:
|
||||||
|
fill = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_first_position(case_code, i)
|
||||||
|
else:
|
||||||
|
fill = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
vert_pos = get_regular_vertex_first_position(case_code, i)
|
||||||
|
vert_dir = get_regular_vertex_second_position(case_code, i)
|
||||||
|
|
||||||
|
vert_dir = vert_dir - vert_pos
|
||||||
|
|
||||||
|
vert_pos += vert_dir * (fill / 256.0)
|
||||||
|
vert_pos *= float(lod_size)
|
||||||
|
vert_pos += Vector3(x, y, z)
|
||||||
|
vert_pos *= float(voxel_scale)
|
||||||
|
|
||||||
|
if regular_uv_entries.size() > uvs[i]:
|
||||||
|
add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
||||||
|
|
||||||
|
add_uv(Vector2(0, 0))
|
||||||
|
|
||||||
|
add_vertex(vert_pos)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func create_Debug_triangle(position : Vector3):
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position)
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position + Vector3(2, 0, 0))
|
||||||
|
add_indices(get_indices_count())
|
||||||
|
add_vertex(position + Vector3(0, 0, 2))
|
||||||
|
|
||||||
|
print(get_vertex_count())
|
||||||
|
|
||||||
|
|
204
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelWorld.gd
Normal file
204
game/voxelman/transvoxel_mesher_normal_uv/TVNUVoxelWorld.gd
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
extends VoxelWorld
|
||||||
|
|
||||||
|
# Copyright Péter Magyar relintai@gmail.com
|
||||||
|
# MIT License, might be merged into the Voxelman engine module
|
||||||
|
|
||||||
|
enum GenType {
|
||||||
|
TEST, NORMAL, NOISE3D
|
||||||
|
}
|
||||||
|
|
||||||
|
signal generation_finished
|
||||||
|
|
||||||
|
export(int) var gen_type : int = GenType.NORMAL
|
||||||
|
|
||||||
|
export(Array, MeshDataResource) var meshes : Array
|
||||||
|
|
||||||
|
var chunks : Dictionary = Dictionary()
|
||||||
|
var spawned : bool = false
|
||||||
|
|
||||||
|
var generation_queue : Array
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
spawn()
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if not generation_queue.empty():
|
||||||
|
var chunk : VoxelChunk = generation_queue.front()
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL:
|
||||||
|
#
|
||||||
|
generate_terrarin(chunk)
|
||||||
|
elif gen_type == GenType.NOISE3D:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
generate_test(chunk)
|
||||||
|
|
||||||
|
generation_queue.remove(0)
|
||||||
|
|
||||||
|
if generation_queue.empty():
|
||||||
|
emit_signal("generation_finished")
|
||||||
|
|
||||||
|
func generate_terrarin(chunk : VoxelChunk) -> void:
|
||||||
|
var buffer : VoxelChunk = chunk.get_buffer()
|
||||||
|
buffer.create(int(size_x) + 3, int(size_y) + 3, int(size_z) + 3)
|
||||||
|
|
||||||
|
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
noise.seed = 10
|
||||||
|
noise.octaves = 4
|
||||||
|
noise.period = 200.0
|
||||||
|
noise.persistence = 0.8
|
||||||
|
|
||||||
|
var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||||
|
terr_noise.seed = 10 * 321 + 112
|
||||||
|
terr_noise.octaves = 4
|
||||||
|
terr_noise.period = 20.0
|
||||||
|
terr_noise.persistence = 0.9
|
||||||
|
|
||||||
|
for x in range(-1, size_x + 2):
|
||||||
|
for z in range(-1, size_z + 2):
|
||||||
|
var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val *= val
|
||||||
|
val *= 100
|
||||||
|
val += 2
|
||||||
|
|
||||||
|
var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
|
||||||
|
val += tv * 2
|
||||||
|
|
||||||
|
var v : int = (int(val))
|
||||||
|
|
||||||
|
for y in range(-1, v):
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 50 + 205, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + 1)
|
||||||
|
buffer.set_voxel(1, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(randi() % 50 + 205, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
|
var light : VoxelLight = VoxelLight.new()
|
||||||
|
randomize()
|
||||||
|
light.color = Color(randf(), randf(), randf())
|
||||||
|
light.size = randi() % 5 + 5
|
||||||
|
light.set_world_position((chunk.position_x * chunk.size_x) + (randi() % chunk.size_x), (chunk.position_y * chunk.size_y) + (randi() % 6), (chunk.position_z * chunk.size_z) + (randi() % chunk.size_z))
|
||||||
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
|
# var light : VoxelLight = VoxelLight.new()
|
||||||
|
# light.color = Color(1.0, 0, 0)
|
||||||
|
# light.size = 10
|
||||||
|
# light.set_world_position((chunk.position_x * chunk.size_x) + (2), (chunk.position_y * chunk.size_y) + (7), (chunk.position_z * chunk.size_z) + (1))
|
||||||
|
# chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
# for x in range(16):
|
||||||
|
# for z in range(16):
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis().scaled(Vector3(0.2, 0.2, 0.2)), Vector3(2, 5, 0) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
# chunk.add_prop(Transform(Basis(), Vector3(4, 3, 5) * voxel_scale), meshes[0])
|
||||||
|
|
||||||
|
chunk.bake_lights()
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
# chunk.draw_debug_voxels(2000)
|
||||||
|
# chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_chunk(x : int, y : int, z : int, lod_size : int = 1) -> void:
|
||||||
|
var name : String = "Chunk," + str(x) + "," + str(y) + "," + str(z)
|
||||||
|
# var chunk : VoxelChunk = VoxelChunk.new()
|
||||||
|
var chunk : VoxelChunk = TVNUVoxelChunk.new()
|
||||||
|
|
||||||
|
chunk.voxel_world = self
|
||||||
|
chunk.set_chunk_position(x, y, z)
|
||||||
|
chunk.library = library
|
||||||
|
chunk.voxel_scale = voxel_scale
|
||||||
|
chunk.lod_size = lod_size
|
||||||
|
chunk.set_chunk_size(int(size_x), int(size_y), int(size_z))
|
||||||
|
|
||||||
|
chunk.create_mesher()
|
||||||
|
chunk.mesher.base_light_value = 0.6
|
||||||
|
|
||||||
|
chunks[name] = chunk
|
||||||
|
|
||||||
|
generation_queue.append(chunk)
|
||||||
|
|
||||||
|
|
||||||
|
func spawn() -> void:
|
||||||
|
var hsize : int = 4
|
||||||
|
|
||||||
|
if gen_type == GenType.NORMAL or gen_type == GenType.NOISE3D:
|
||||||
|
for x in range(-hsize, hsize):
|
||||||
|
for z in range(-hsize, hsize):
|
||||||
|
for y in range(1):
|
||||||
|
# spawn_chunk(x, y, z, abs(int(ceil(x / 2))) + 1)
|
||||||
|
spawn_chunk(x, y, z, 1)
|
||||||
|
else:
|
||||||
|
spawn_chunk(0, 0, 0, 1)
|
||||||
|
|
||||||
|
#func set_player(p_player : Spatial) -> void:
|
||||||
|
# player = p_player
|
||||||
|
|
||||||
|
# if _spawned:
|
||||||
|
# clear()
|
||||||
|
#
|
||||||
|
# spawn()
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func generate_test(chunk : VoxelChunk) ->void:
|
||||||
|
var buffer : VoxelChunk = chunk.get_buffer()
|
||||||
|
|
||||||
|
buffer.create(40, 40, 40)
|
||||||
|
|
||||||
|
var i : int = 1
|
||||||
|
|
||||||
|
for y in range(4):
|
||||||
|
for z in range(8):
|
||||||
|
for x in range(8):
|
||||||
|
spawn_equiv_class(buffer, i, x * 4 + 1, y * 4 + 1, z * 4 + 1)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
# spawn_equiv_class(buffer,127, 4, 4, 4)
|
||||||
|
|
||||||
|
chunk.build()
|
||||||
|
chunk.draw_debug_voxels(2000)
|
||||||
|
# chunk.draw_debug_voxel_lights()
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_equiv_class(buffer : VoxelChunk, cls : int, x : int, y : int, z : int) -> void:
|
||||||
|
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_000:
|
||||||
|
buffer.set_voxel(1, x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_100:
|
||||||
|
buffer.set_voxel(1, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_001:
|
||||||
|
buffer.set_voxel(1, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_101:
|
||||||
|
buffer.set_voxel(1, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_010:
|
||||||
|
buffer.set_voxel(1, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_110:
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_011:
|
||||||
|
buffer.set_voxel(1, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
if cls & VoxelMesherTransvoxel.VOXEL_ENTRY_MASK_111:
|
||||||
|
buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
buffer.set_voxel(255, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://voxelman/transvoxel_mesher_normal_uv/TVNUVoxelWorld.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://data/voxel_libraries/main_library_2.tres" type="VoxelmanLibrarySimple" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="VoxelWorld" type="VoxelWorld"]
|
||||||
|
player_path = NodePath("Camera")
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
library = ExtResource( 3 )
|
||||||
|
voxel_scale = 2.0
|
Loading…
Reference in New Issue
Block a user