feature: vertex and triangle index storage
This commit is contained in:
52
src/main.cpp
52
src/main.cpp
@@ -151,10 +151,54 @@ int main(int argc, char** argv) {
|
||||
|
||||
auto coordinate_storage = compile_coordinate_storage(coordinate_index_data);
|
||||
|
||||
auto coordinate_storage_index = compile_coordinate_storage_line_mapping(coordinate_index_data, coordinate_storage);
|
||||
if (std::get<1>(coordinate_storage).size() > 0) {
|
||||
std::cerr << "Indexed " << 1 << "D coordinates: " << std::get<1>(coordinate_storage).size() << std::endl;
|
||||
}
|
||||
|
||||
if (std::get<2>(coordinate_storage).size() > 0) {
|
||||
std::cerr << "Indexed " << 2 << "D coordinates: " << std::get<2>(coordinate_storage).size() << std::endl;
|
||||
}
|
||||
|
||||
if (std::get<3>(coordinate_storage).size() > 0) {
|
||||
std::cerr << "Indexed " << 3 << "D coordinates: " << std::get<3>(coordinate_storage).size() << std::endl;
|
||||
}
|
||||
|
||||
auto coordinate_storage_index = compile_coordinate_storage_line_mapping<IndexType>(coordinate_index_data, coordinate_storage);
|
||||
|
||||
auto index_storage = compile_vertex_storage<IndexType>(scan_data, face_data, coordinate_storage_index);
|
||||
|
||||
std::visit([&](const auto &vertex_storage) {
|
||||
std::cerr << "Compiled " << vertex_storage.size() << " vertices" << std::endl;
|
||||
}, index_storage.vertices);
|
||||
|
||||
std::cerr << "Compiled " << index_storage.triangles.size() << " triangles" << std::endl;
|
||||
|
||||
// TODO: We need to output:
|
||||
// 1. Some kind of singature;
|
||||
// 2. A version number;
|
||||
// 3. Flags describing the data:
|
||||
// 3.1. position: required, always 3 coordinates (no flag needed)
|
||||
// 3.2. normal: optional, always 3 coordinates (single flag needed)
|
||||
// 3.3. texcoord: optional, up to 3 coordinates (two flags needed, 0 = none, 1 = 1D, 2 = 2D, 3 = 3D)
|
||||
// 3.4. type of number data: 0 = float, 1 = double
|
||||
// 3.5. vertices: 0 = never used, 1 = one attribute per vertex, 2 = two attributes per vertex, 3 = three attributes per vertex
|
||||
// Flags: (0 = number type, 1 = normals present, 2-3 = texture_coordinate size, 4-7 = number of vertex attributes (up to 16), only 3 supported for now)
|
||||
// 4. Data order: up to attribute_count attributes, 1-byte each, specifying an index of map in file order. 0 is the number_list and therefore reserved.
|
||||
// 5. Sizes:
|
||||
// 5.1. Size of the number list (in items): 1 item = 1 float/double (depending on number_type)
|
||||
// 5.2. Size of the position list (in items): 1 item = 3 indices into the float_list
|
||||
// 5.3. Size of the normal list (in items, only if normal flag is set): 1 item = 3 indices into the float_list
|
||||
// 5.4. Size of the texcoord list (in items, only if texcoord_size is not 0): 1 item = 1-3 indices into the float_list (depending on texcoord_size)
|
||||
// 5.5. Size of the vertex list (in items): 1 item = 1-attribute_count indices into different maps.
|
||||
// 5.6. Size of the triangle list (in items): 1 item = 3 triangle vertex indices into the vertex list.
|
||||
// Special references: number_list, triangle_list, vertex_list, position_list
|
||||
// All other references are additional attributes.
|
||||
// In order for quick load into GPU buffer we want:
|
||||
// - each map start file pos to be known
|
||||
// - each map size in bytes to be known
|
||||
// - each map type (float32, float64, int8, int16, int32, int64)
|
||||
// - number of elements per item (or stride, i.e. number of bytes per item)
|
||||
// - each map file pos aligned to 16-bytes (assuming file is loaded aligned to 16-bytes). Elements within the map do not need to be aligned.
|
||||
|
||||
// Form coordinate_list_data : std::vector variant of coordinate_index_data. Internally, it creates std::set initially, stores everything in the set and then convert to vector.
|
||||
// Then we can form coordinate_line_mapping : std::map<file_line_t, std::size_t> pointing for each entry to entry in coordinate_list_data.
|
||||
// Then using face_data.triangle_list and scan_data.category_map[v/vn/vt], coordinate_line_mapping, we can form vertex_list_data. The vertex here is 1-3 IndexType numbers pointing to coordinate_list_data.
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user