Update HEADS to grab Voxelman with the transvoxel mesher port. Also removed a few experimental meshers.

This commit is contained in:
Relintai 2020-02-13 14:00:19 +01:00
parent d30e33a122
commit 7de251a0cf
22 changed files with 45 additions and 5165 deletions

2
HEADS
View File

@ -1 +1 @@
{"engine": {"3.2": "8a0f94a688f18a9565a21657bf44791550aec96a", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "09372b146936fda509f5c23a522e998d12f38e13"}, "entity_spell_system": {"master": "0bdf71c431b62b24d56c1fc178dbcb792e5dca3d"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "201ea0ce1f7e170affc911be60128ca807b246aa"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "00f6c128bd0e9799b7f7f86e118ed68277fbe27d"}, "fast_quadratic_mesh_simplifier": {"master": "d3f3a829eff40a93464f6b321c13ce26d44e11e3"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "prop_tool": {"master": "df438053ebc900966f8f842fc65f0264f1271d49"}}
{"engine": {"3.2": "8a0f94a688f18a9565a21657bf44791550aec96a", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "09372b146936fda509f5c23a522e998d12f38e13"}, "entity_spell_system": {"master": "0bdf71c431b62b24d56c1fc178dbcb792e5dca3d"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "8b08a9b14ff98f54a3658a9b79f247bafd723d44"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "00f6c128bd0e9799b7f7f86e118ed68277fbe27d"}, "fast_quadratic_mesh_simplifier": {"master": "d3f3a829eff40a93464f6b321c13ce26d44e11e3"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "prop_tool": {"master": "df438053ebc900966f8f842fc65f0264f1271d49"}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -69,16 +69,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scripts/resources/ManResource.gd"
}, {
"base": "VoxelChunk",
"class": "MarchingCubesVoxelChunk",
"language": "GDScript",
"path": "res://voxelman/mc_mesher/MarchingCubesVoxelChunk.gd"
}, {
"base": "VoxelMesherTransvoxel",
"class": "MarchingCubesVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/mc_mesher/MarchingCobesVoxelMesher.gd"
}, {
"base": "Control",
"class": "Menu",
"language": "GDScript",
@ -140,26 +130,6 @@ _global_script_classes=[ {
"path": "res://scripts/spells/gd_spell_script.gd"
}, {
"base": "VoxelChunk",
"class": "TVGUVoxelChunk",
"language": "GDScript",
"path": "res://voxelman/transvoxel_mesher_gen_uv/TVGUVoxelChunk.gd"
}, {
"base": "VoxelMesherTransvoxel",
"class": "TVGUVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/transvoxel_mesher_gen_uv/TVGUVoxelMesher.gd"
}, {
"base": "VoxelChunk",
"class": "TVNUVoxelChunk",
"language": "GDScript",
"path": "res://voxelman/transvoxel_mesher_normal_uv/TVNUVoxelChunk.gd"
}, {
"base": "VoxelMesherTransvoxel",
"class": "TVNUVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/transvoxel_mesher_normal_uv/TVNUVoxelMesher.gd"
}, {
"base": "VoxelChunk",
"class": "TVVoxelChunk",
"language": "GDScript",
"path": "res://voxelman/transvoxel_mesher/TVVoxelChunk.gd"
@ -192,8 +162,6 @@ _global_script_class_icons={
"MainDungeonGenerator": "",
"MainPlanetGenerator": "",
"ManaResource": "",
"MarchingCubesVoxelChunk": "",
"MarchingCubesVoxelMesher": "",
"Menu": "",
"NetworkedPlayerGD": "",
"PlayerGD": "",
@ -206,10 +174,6 @@ _global_script_class_icons={
"PropToolScene": "",
"SpellEffectVisualBasic": "",
"SpellGD": "",
"TVGUVoxelChunk": "",
"TVGUVoxelMesher": "",
"TVNUVoxelChunk": "",
"TVNUVoxelMesher": "",
"TVVoxelChunk": "",
"TVVoxelMesher": "",
"TestVoxelMesher": "",

View File

@ -1,137 +0,0 @@
[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 )

View File

@ -1,221 +0,0 @@
extends VoxelWorld
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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)

View File

@ -1,10 +0,0 @@
[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/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2]
[node name="VoxelWorld" type="VoxelWorld"]
library = ExtResource( 2 )
voxel_scale = 2.0
player_path = NodePath("Camera")
script = ExtResource( 1 )

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
extends VoxelChunk
class_name MarchingCubesVoxelChunk
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#export (Vector3) var chunk_position : Vector3
#var world : VoxelWorld
#func _ready():
# world = get_node("..")
func _create_mesher():
add_mesher(MarchingCubesVoxelMesher.new())

View File

@ -1,480 +0,0 @@
extends Control
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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()

View File

@ -1,38 +0,0 @@
[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"]

View File

@ -24,45 +24,19 @@ class_name TVVoxelMesher
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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
]
const TEXTURE_SCALE = 4
func get_voxel_type_array(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> Array:
func get_voxel_type_array(chunk : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> Array:
var arr : Array = [
buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
chunk.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
]
return arr
@ -96,102 +70,91 @@ func get_case_code_from_arr(data : Array) -> int:
return case_code
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
func get_case_code(chunk : 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):
if (chunk.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):
if (chunk.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):
if (chunk.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):
if (chunk.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):
if (chunk.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):
if (chunk.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):
if (chunk.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):
if (chunk.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:
func get_voxel_type(chunk : 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)
type = chunk.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)
type = chunk.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)
type = chunk.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)
type = chunk.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)
type = chunk.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)
type = chunk.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)
type = chunk.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)
type = chunk.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
return type
func _add_chunk(buffer : VoxelChunk) -> void:
var b : bool = true
func n_add_chunk(b : Node) -> void:
var chunk : VoxelChunk = b as VoxelChunk
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()
chunk.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()
var x_size : int = chunk.get_size_x()
var y_size : int = chunk.get_size_y()
var z_size : int = chunk.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 type_arr : Array = get_voxel_type_array(buffer, x, y, z, lod_size)
var type_arr : Array = get_voxel_type_array(chunk, x, y, z, lod_size)
var case_code : int = get_case_code_from_arr(type_arr)
if case_code == 0 or case_code == 255:
@ -274,7 +237,7 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
var type : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
var type : int = chunk.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
var fill : int = 0
@ -282,12 +245,12 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
var vert_dir : Vector3
if type == 0:
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
fill = chunk.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)
fill = chunk.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)
@ -385,9 +348,9 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
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 vpx : int = int(vert_pos.x)
#var vpy : int = int(vert_pos.y)
#var vpz : int = int(vert_pos.z)
add_color(Color(1, 1, 1, surface_ratio))
vert_pos *= float(voxel_scale)
@ -396,144 +359,3 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
add_vertex(vert_pos)
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 type : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
var fill : int = 0
var vert_pos : Vector3
var vert_dir : Vector3
if type == 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)
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)

View File

@ -1,134 +0,0 @@
[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_gen_uv/TVGUVoxelWorld.tscn" type="PackedScene" id=4]
[ext_resource path="res://data/voxel_textures/grass_albedo.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="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 )]
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 )

View File

@ -1,34 +0,0 @@
extends VoxelChunk
class_name TVGUVoxelChunk
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#export (Vector3) var chunk_position : Vector3
#var world : VoxelWorld
#func _ready():
# world = get_node("..")
func _create_meshers():
add_mesher(TVGUVoxelMesher.new())

File diff suppressed because it is too large Load Diff

View File

@ -1,225 +0,0 @@
extends VoxelWorld
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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(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)
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(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:
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)

View File

@ -1,10 +0,0 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=1]
[ext_resource path="res://voxelman/transvoxel_mesher_gen_uv/TVGUVoxelWorld.gd" type="Script" id=2]
[node name="VoxelWorld" type="VoxelWorld"]
library = ExtResource( 1 )
voxel_scale = 2.0
player_path = NodePath("Camera")
script = ExtResource( 2 )

View File

@ -1,138 +0,0 @@
[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 )

View File

@ -1,14 +0,0 @@
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():
add_mesher(TVNUVoxelMesher.new())

View File

@ -1,455 +0,0 @@
extends VoxelMesherTransvoxel
class_name TVNUVoxelMesher
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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())

View File

@ -1,224 +0,0 @@
extends VoxelWorld
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
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(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)
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(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:
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)

View File

@ -1,10 +0,0 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=1]
[ext_resource path="res://voxelman/transvoxel_mesher_normal_uv/TVNUVoxelWorld.gd" type="Script" id=2]
[node name="VoxelWorld" type="VoxelWorld"]
library = ExtResource( 1 )
voxel_scale = 2.0
player_path = NodePath("Camera")
script = ExtResource( 2 )