voxelman/meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h

118 lines
4.1 KiB
C
Raw Normal View History

/*
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.
*/
#ifndef VOXEL_MESHER_TRANSVOXEL_H
#define VOXEL_MESHER_TRANSVOXEL_H
#include "../voxel_mesher.h"
#include "core/reference.h"
2019-09-04 18:33:19 +02:00
#include "transvoxel_cell_data.h"
#include "transvoxel_tables.h"
using namespace Transvoxel;
class VoxelMesherTransvoxel : public VoxelMesher {
GDCLASS(VoxelMesherTransvoxel, VoxelMesher)
public:
static const String BINDING_STRING_VOXEL_ENTRY_INDICES;
static const String BINDING_STRING_VOXEL_ENTRY_MASK;
enum VoxelEntryIndices {
VOXEL_ENTRY_INDEX_000 = 0,
VOXEL_ENTRY_INDEX_100 = 1,
VOXEL_ENTRY_INDEX_001 = 2,
VOXEL_ENTRY_INDEX_101 = 3,
VOXEL_ENTRY_INDEX_010 = 4,
VOXEL_ENTRY_INDEX_110 = 5,
VOXEL_ENTRY_INDEX_011 = 6,
VOXEL_ENTRY_INDEX_111 = 7,
VOXEL_ENTRIES_SIZE = 8,
};
enum VoxelEntryMask {
VOXEL_ENTRY_MASK_000 = 1 << 0,
VOXEL_ENTRY_MASK_100 = 1 << 1,
VOXEL_ENTRY_MASK_001 = 1 << 2,
VOXEL_ENTRY_MASK_101 = 1 << 3,
VOXEL_ENTRY_MASK_010 = 1 << 4,
VOXEL_ENTRY_MASK_110 = 1 << 5,
VOXEL_ENTRY_MASK_011 = 1 << 6,
VOXEL_ENTRY_MASK_111 = 1 << 7,
};
int get_texture_scale() const;
void set_texture_scale(const int value);
//arr should have a size of 8
void get_voxel_type_array(int *arr, VoxelChunk *chunk, const int x, const int y, const int z, const int size = 1);
int get_case_code_from_arr(const int *data);
int get_case_code(VoxelChunk *chunk, const int x, const int y, const int z, const int size = 1);
int get_voxel_type(VoxelChunk *chunk, const int x, const int y, const int z, const int size = 1);
void _add_chunk(Node *p_chunk);
2019-06-08 19:47:17 +02:00
Vector3 corner_id_to_vertex(int corner_id) const;
int get_regular_cell_class(int index) const;
2019-09-04 18:33:19 +02:00
Ref<TransvoxelCellData> get_regular_cell_data(int index) const;
int get_regular_vertex_data(int index10, int index2) const;
2020-01-09 04:29:05 +01:00
// void set_regular_vertex_data(int index1, int index2, int value);
int get_regular_vertex_data_first_vertex(int index1, int index2) const;
int get_regular_vertex_data_second_vertex(int index1, int index2) const;
2019-06-08 19:47:17 +02:00
Vector3 get_regular_vertex_first_position(int index1, int index2) const;
Vector3 get_regular_vertex_second_position(int index1, int index2) const;
Vector3 get_regular_vertex_direction(int index1, int index2) const;
int get_transition_cell_class(int index) const;
2019-09-04 18:33:19 +02:00
Ref<TransvoxelCellData> get_transition_cell_data(int index) const;
int get_transition_corner_data(int index) const;
int get_transition_vertex_data(int index1, int index2) const;
int get_transition_vertex_data_first_vertex(int index1, int index2) const;
int get_transition_vertex_data_second_vertex(int index1, int index2) const;
2019-06-08 19:47:17 +02:00
Vector3 get_transition_vertex_first_position(int index1, int index2) const;
Vector3 get_transition_vertex_second_position(int index1, int index2) const;
Vector3 get_transition_vertex_direction(int index1, int index2) const;
VoxelMesherTransvoxel();
~VoxelMesherTransvoxel();
protected:
static void _bind_methods();
2019-09-04 18:33:19 +02:00
Ref<TransvoxelCellData> _regular_cell_datas[16];
Ref<TransvoxelCellData> _transition_cell_data[56];
int _texture_scale;
};
VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryIndices);
VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryMask);
#endif // VOXEL_MESHER_SMOOTH_H