2017-08-19 21:10:31 +02:00
|
|
|
#include "cube_tables.h"
|
|
|
|
|
2018-09-30 20:37:39 +02:00
|
|
|
namespace Cube {
|
2017-08-19 21:10:31 +02:00
|
|
|
|
|
|
|
// The following tables respect the following conventions
|
|
|
|
//
|
|
|
|
// 7-------6
|
|
|
|
// /| /|
|
|
|
|
// / | / | Corners
|
|
|
|
// 4-------5 |
|
|
|
|
// | 3----|--2
|
2018-10-06 00:51:55 +02:00
|
|
|
// | / | / y z
|
|
|
|
// |/ |/ |/ OpenGL axis convention
|
|
|
|
// 0-------1 x--o
|
2017-08-19 21:10:31 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// o---10----o
|
|
|
|
// /| /|
|
|
|
|
// 11 7 9 6 Edges
|
|
|
|
// / | / |
|
|
|
|
// o----8----o |
|
|
|
|
// | o---2-|---o
|
|
|
|
// 4 / 5 /
|
|
|
|
// | 3 | 1
|
|
|
|
// |/ |/
|
|
|
|
// o----0----o
|
|
|
|
//
|
|
|
|
// Sides are ordered according to the Voxel::Side enum.
|
2018-09-30 02:55:09 +02:00
|
|
|
// Edges are ordered according to the Voxel::Edge enum (only g_edge_inormals!).
|
2017-08-19 21:10:31 +02:00
|
|
|
//
|
|
|
|
|
2018-10-06 00:51:55 +02:00
|
|
|
// Ordered as per the cube corners diagram
|
2017-08-19 21:10:31 +02:00
|
|
|
const Vector3 g_corner_position[CORNER_COUNT] = {
|
|
|
|
Vector3(1, 0, 0),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3(0, 0, 0),
|
2017-08-19 21:10:31 +02:00
|
|
|
Vector3(0, 0, 1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3(1, 0, 1),
|
2017-08-19 21:10:31 +02:00
|
|
|
Vector3(1, 1, 0),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3(0, 1, 0),
|
|
|
|
Vector3(0, 1, 1),
|
|
|
|
Vector3(1, 1, 1)
|
2017-08-19 21:10:31 +02:00
|
|
|
};
|
|
|
|
|
2018-09-30 20:37:39 +02:00
|
|
|
const int g_side_quad_triangles[SIDE_COUNT][6] = {
|
2018-10-06 00:51:55 +02:00
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // LEFT (+x)
|
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // RIGHT (-x)
|
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // BOTTOM (-y)
|
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // TOP (+y)
|
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // BACK (-z)
|
|
|
|
{ 0, 2, 1, 0, 3, 2 }, // FRONT (+z)
|
2017-08-19 21:10:31 +02:00
|
|
|
};
|
|
|
|
|
2018-10-06 00:51:55 +02:00
|
|
|
//const unsigned int g_side_coord[SIDE_COUNT] = { 0, 0, 1, 1, 2, 2 };
|
|
|
|
//const unsigned int g_side_sign[SIDE_COUNT] = { 0, 1, 0, 1, 0, 1 };
|
2017-08-19 21:10:31 +02:00
|
|
|
|
2018-09-30 20:37:39 +02:00
|
|
|
const Vector3i g_side_normals[SIDE_COUNT] = {
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(1, 0, 0), // LEFT
|
|
|
|
Vector3i(-1, 0, 0), // RIGHT
|
|
|
|
Vector3i(0, -1, 0), // BOTTOM
|
|
|
|
Vector3i(0, 1, 0), // TOP
|
|
|
|
Vector3i(0, 0, -1), // BACK
|
|
|
|
Vector3i(0, 0, 1), // FRONT
|
2017-08-19 21:10:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Corners have same winding, relative to the face's normal
|
2018-09-30 20:37:39 +02:00
|
|
|
const unsigned int g_side_corners[SIDE_COUNT][4] = {
|
2017-08-19 21:10:31 +02:00
|
|
|
{ 3, 0, 4, 7 },
|
|
|
|
{ 1, 2, 6, 5 },
|
|
|
|
{ 1, 0, 3, 2 },
|
|
|
|
{ 4, 5, 6, 7 },
|
|
|
|
{ 0, 1, 5, 4 },
|
|
|
|
{ 2, 3, 7, 6 }
|
|
|
|
};
|
|
|
|
|
2018-09-30 20:37:39 +02:00
|
|
|
const unsigned int g_side_edges[SIDE_COUNT][4] = {
|
2017-08-19 21:10:31 +02:00
|
|
|
{ 3, 7, 11, 4 },
|
|
|
|
{ 1, 6, 9, 5 },
|
|
|
|
{ 0, 1, 2, 3 },
|
|
|
|
{ 8, 9, 10, 11 },
|
|
|
|
{ 0, 5, 8, 4 },
|
|
|
|
{ 2, 6, 10, 7 }
|
|
|
|
};
|
|
|
|
|
|
|
|
// 3---2
|
|
|
|
// | / | {0,1,2,0,2,3}
|
|
|
|
// 0---1
|
|
|
|
//static const unsigned int g_vertex_to_corner[Voxel::SIDE_COUNT][6] = {
|
|
|
|
// { 0, 3, 7, 0, 7, 4 },
|
|
|
|
// { 2, 1, 5, 2, 5, 6 },
|
|
|
|
// { 0, 1, 2, 0, 2, 3 },
|
|
|
|
// { 7, 6, 5, 7, 5, 4 },
|
|
|
|
// { 1, 0, 4 ,1, 4, 5 },
|
|
|
|
// { 3, 2, 6, 3, 6, 7 }
|
|
|
|
//};
|
|
|
|
|
|
|
|
const Vector3i g_corner_inormals[CORNER_COUNT] = {
|
|
|
|
Vector3i(1, -1, -1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(-1, -1, -1),
|
2017-08-19 21:10:31 +02:00
|
|
|
Vector3i(-1, -1, 1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(1, -1, 1),
|
2017-08-19 21:10:31 +02:00
|
|
|
|
|
|
|
Vector3i(1, 1, -1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(-1, 1, -1),
|
|
|
|
Vector3i(-1, 1, 1),
|
|
|
|
Vector3i(1, 1, 1)
|
2017-08-19 21:10:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const Vector3i g_edge_inormals[EDGE_COUNT] = {
|
|
|
|
Vector3i(0, -1, -1),
|
|
|
|
Vector3i(-1, -1, 0),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(0, -1, 1),
|
|
|
|
Vector3i(1, -1, 0),
|
2017-08-19 21:10:31 +02:00
|
|
|
|
|
|
|
Vector3i(1, 0, -1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(-1, 0, -1),
|
2017-08-19 21:10:31 +02:00
|
|
|
Vector3i(-1, 0, 1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(1, 0, 1),
|
2017-08-19 21:10:31 +02:00
|
|
|
|
|
|
|
Vector3i(0, 1, -1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(-1, 1, 0),
|
2017-08-19 21:10:31 +02:00
|
|
|
Vector3i(0, 1, 1),
|
2018-10-06 00:51:55 +02:00
|
|
|
Vector3i(1, 1, 0)
|
2017-08-19 21:10:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned int g_edge_corners[EDGE_COUNT][2] = {
|
|
|
|
{ 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 },
|
|
|
|
{ 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 },
|
|
|
|
{ 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 }
|
|
|
|
};
|
|
|
|
|
2017-08-20 15:37:07 +02:00
|
|
|
// Order is irrelevant
|
2018-09-25 01:53:12 +02:00
|
|
|
const Vector3i g_moore_neighboring_3d[MOORE_NEIGHBORING_3D_COUNT] = {
|
2017-08-20 15:37:07 +02:00
|
|
|
Vector3i(-1, -1, -1),
|
|
|
|
Vector3i(0, -1, -1),
|
|
|
|
Vector3i(1, -1, -1),
|
|
|
|
Vector3i(-1, -1, 0),
|
|
|
|
Vector3i(0, -1, 0),
|
|
|
|
Vector3i(1, -1, 0),
|
|
|
|
Vector3i(-1, -1, 1),
|
|
|
|
Vector3i(0, -1, 1),
|
|
|
|
Vector3i(1, -1, 1),
|
|
|
|
|
|
|
|
Vector3i(-1, 0, -1),
|
|
|
|
Vector3i(0, 0, -1),
|
|
|
|
Vector3i(1, 0, -1),
|
|
|
|
Vector3i(-1, 0, 0),
|
|
|
|
//Vector3i(0,0,0),
|
|
|
|
Vector3i(1, 0, 0),
|
|
|
|
Vector3i(-1, 0, 1),
|
|
|
|
Vector3i(0, 0, 1),
|
|
|
|
Vector3i(1, 0, 1),
|
|
|
|
|
|
|
|
Vector3i(-1, 1, -1),
|
|
|
|
Vector3i(0, 1, -1),
|
|
|
|
Vector3i(1, 1, -1),
|
|
|
|
Vector3i(-1, 1, 0),
|
|
|
|
Vector3i(0, 1, 0),
|
|
|
|
Vector3i(1, 1, 0),
|
|
|
|
Vector3i(-1, 1, 1),
|
|
|
|
Vector3i(0, 1, 1),
|
|
|
|
Vector3i(1, 1, 1),
|
|
|
|
};
|
|
|
|
|
2017-08-19 21:10:31 +02:00
|
|
|
} // namespace CubeTables
|
|
|
|
|