HighMap library (C++)
Loading...
Searching...
No Matches
asset.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
16#pragma once
17#include <filesystem>
18#include <map>
19#include <string>
20#include <vector>
21
22#include "highmap/array.hpp"
23
24namespace hmap
25{
26
34enum MeshType : int
35{
38};
39
48static std::map<MeshType, std::string> mesh_type_as_string = {
49 {TRI_OPTIMIZED, "triangles (optimized)"},
50 {TRI, "triangles"}};
51
81
101// clang-format off
102static std::map<AssetExportFormat, std::vector<std::string> >
103asset_export_format_as_string = {
104 {_3DS, {"Autodesk 3DS (legacy) - *.3ds", "3ds", "3ds"}},
105 {_3MF, {"The 3MF-File-Format - *.3mf", "3mf", "3mf"}},
106 {ASSBIN, {"Assimp Binary - *.assbin", "assbin", "assbin"}},
107 {ASSXML, {"Assxml Document - *.assxml", "assxml", "assxml"}},
108 {FXBA, {"Autodesk FBX (ascii) - *.fbx", "fbxa", "fbx"}},
109 {FBX, {"Autodesk FBX (binary) - *.fbx", "fbx", "fbx"}},
110 {COLLADA, {"COLLADA - Digital Asset Exchange Schema - *.dae", "collada", "dae"}},
111 {X3D, {"Extensible 3D - *.x3d", "x3d", "x3d"}},
112 {GLTF, {"GL Transmission Format - *.gltf", "gltf", "gltf"}},
113 {GLB, {"GL Transmission Format (binary) - *.glb", "glb", "glb"}},
114 {GTLF2, {"GL Transmission Format v. 2 - *.gltf", "gltf2", "gltf"}},
115 {GLB2, {"GL Transmission Format v. 2 (binary) - *.glb", "glb2", "glb"}},
116 {PLY, {"Stanford Polygon Library - *.ply", "ply", "ply"}},
117 {PLYB, {"Stanford Polygon Library (binary) - *.ply", "plyb", "ply"}},
118 {STP, {"Step Files - *.stp", "stp", "stp"}},
119 {STL, {"Stereolithography - *.stl", "stl", "stl"}},
120 {STLB, {"Stereolithography (binary) - *.stl", "stlb", "stl"}},
121 {OBJ, {"Wavefront OBJ format - *.obj", "obj", "obj"}},
122 {OBJNOMTL, {"Wavefront OBJ format without material file - *.obj", "objnomtl", "obj"}},
123};
124// clang-format on
125
158bool export_asset(const std::string &fname,
159 const Array &array,
160 MeshType mesh_type = MeshType::TRI,
162 float elevation_scaling = 0.2f,
163 const std::string &texture_fname = "",
164 const std::string &normal_map_fname = "",
165 float max_error = 5e-4f,
166 bool fit_boundaries = false);
167
168bool export_asset(const std::string &fname,
169 const Array &array,
170 const Array &mask,
172 float elevation_scaling = 0.2f,
173 const std::string &texture_fname = "",
174 const std::string &normal_map_fname = "",
175 bool fit_boundaries = false);
176
196 const std::string &fname,
197 const std::vector<float> &x,
198 const std::vector<float> &y,
199 const std::vector<float> &z,
200 const std::map<std::string, std::vector<float>> &custom_fields = {});
201
214void write_raw_16bit(const std::string &fname, const Array &array);
215
216} // namespace hmap
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Definition opencv.hpp:20
bool export_asset(const std::string &fname, const Array &array, MeshType mesh_type=MeshType::TRI, AssetExportFormat export_format=AssetExportFormat::GLB2, float elevation_scaling=0.2f, const std::string &texture_fname="", const std::string &normal_map_fname="", float max_error=5e-4f, bool fit_boundaries=false)
Exports a heightmap to various 3D file formats.
Definition export_asset.cpp:268
void write_raw_16bit(const std::string &fname, const Array &array)
Exports an array to a 16-bit 'raw' file format, commonly used for Unity terrain imports.
Definition format_raw.cpp:15
AssetExportFormat
Enumeration for asset export formats supported by Assimp.
Definition asset.hpp:60
@ FBX
Autodesk FBX (binary) - *.fbx.
Definition asset.hpp:66
@ PLY
Stanford Polygon Library - *.ply.
Definition asset.hpp:73
@ GLB2
GL Transmission Format v. 2 (binary) - *.glb.
Definition asset.hpp:72
@ STL
Stereolithography - *.stl.
Definition asset.hpp:76
@ _3MF
The 3MF-File-Format - *.3mf.
Definition asset.hpp:62
@ ASSBIN
Assimp Binary - *.assbin.
Definition asset.hpp:63
@ GTLF2
GL Transmission Format v. 2 - *.gltf.
Definition asset.hpp:71
@ X3D
Extensible 3D - *.x3d.
Definition asset.hpp:68
@ COLLADA
COLLADA - Digital Asset Exchange Schema - *.dae.
Definition asset.hpp:67
@ STP
Step Files - *.stp.
Definition asset.hpp:75
@ GLB
GL Transmission Format (binary) - *.glb.
Definition asset.hpp:70
@ ASSXML
Assxml Document - *.assxml.
Definition asset.hpp:64
@ FXBA
Autodesk FBX (ascii) - *.fbx.
Definition asset.hpp:65
@ GLTF
GL Transmission Format - *.gltf.
Definition asset.hpp:69
@ STLB
Stereolithography (binary) - *.stl.
Definition asset.hpp:77
@ OBJ
Wavefront OBJ format - *.obj.
Definition asset.hpp:78
@ PLYB
Stanford Polygon Library (binary) - *.ply.
Definition asset.hpp:74
@ _3DS
Autodesk 3DS (legacy) - *.3ds.
Definition asset.hpp:61
@ OBJNOMTL
Wavefront OBJ format without material file - *.obj.
Definition asset.hpp:79
MeshType
Enumeration for different mesh types.
Definition asset.hpp:35
@ TRI_OPTIMIZED
Triangles with optimized Delaunay triangulation.
Definition asset.hpp:36
@ TRI
Triangle elements.
Definition asset.hpp:37
void export_points_to_ply(const std::string &fname, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &z, const std::map< std::string, std::vector< float > > &custom_fields={})
Exports 3D points with optional custom fields to an ASCII PLY file.
Definition export_points_to_ply.cpp:16