Go to the documentation of this file.
30 #ifndef EXOTICA_CORE_VISUALIZATION_MESHCAT_TYPES_H_
31 #define EXOTICA_CORE_VISUALIZATION_MESHCAT_TYPES_H_
33 #define MSGPACK_USE_DEFINE_MAP
36 #include <msgpack.hpp>
44 #if (MSGPACK_VERSION_MAJOR >= 2)
50 #define MSGPACK_FEATURE_NOT_SUPPORTED
55 namespace visualization
57 inline long RGB(
double R,
double G,
double B)
59 return static_cast<long>(std::min(std::max(R, 0.0), 1.0) * 255) * 65536L +
static_cast<long>(std::min(std::max(G, 0.0), 1.0) * 255) * 256L +
static_cast<long>(std::min(std::max(B, 0.0), 1.0) * 255);
64 std::random_device rd;
65 std::mt19937 gen(rd());
66 std::uniform_int_distribution<> dis(0, 255);
67 return static_cast<unsigned char>(dis(gen));
73 for (
auto i = 0; i < len; ++i)
76 std::stringstream hexstream;
77 hexstream << std::hex << int(rc);
78 auto hex = hexstream.str();
79 ss << (hex.length() < 2 ?
'0' + hex : hex);
92 Base(
const std::string& type_in,
const std::string& path_in) :
type(type_in),
path(path_in){};
101 Property(
const std::string& path_in,
const std::string& property_in,
const T& value_in) :
Base(
"set_property", path_in),
property(property_in),
value(value_in){};
118 Material(
long color_in,
double opacity_in = 1.0,
const std::string& type_in =
"MeshPhongMaterial",
const std::string& uuid_in =
"") :
color(color_in),
opacity(opacity_in),
uuid(uuid_in),
type(type_in)
124 uuid =
"0000-0000-0000-0000";
127 std::string
type =
"MeshPhongMaterial";
142 ObjectData(
const std::string& type_in,
const std::string& uuid_in,
143 const std::string& geometry_in,
const std::string& material_in) :
type(type_in),
uuid(uuid_in),
geometry(geometry_in),
material(material_in){};
148 std::vector<double>
matrix = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
152 template <
typename T>
162 template <
typename T>
172 template <
typename T>
183 template <
typename T>
192 Geometry(
const std::string& type_in,
const std::string& uuid_in =
"") :
type(type_in),
uuid(uuid_in)
203 GeometryBox(
double width_in,
double height_in,
double depth_in,
const std::string& uuid_in =
"") :
Geometry(
"BoxGeometry", uuid_in),
width(width_in),
height(height_in),
depth(depth_in){};
235 GeometryMesh(
const std::string& file_name_in,
const std::string& url_in =
"",
const std::string& format_in =
"",
const std::string& uuid_in =
"") :
Geometry(
"_meshfile_geometry", uuid_in),
format(format_in)
240 std::string::size_type pos =
file_name.rfind(
".");
241 if (pos != std::string::npos)
248 std::ifstream file(
file_name, std::ios::binary | std::ios::ate);
249 std::streamsize size = file.tellg();
250 file.seekg(0, std::ios::beg);
253 file.read(
buffer.data(), size);
293 std::vector<double>
matrix = {1.0, 0.0, 0.0, 0.0,
308 for (
unsigned int i = 0; i < size; ++i)
309 data[i] =
static_cast<float>(data_in[i]);
310 #ifdef MSGPACK_FEATURE_NOT_SUPPORTED
312 WARNING(
"MSGPACK version does not support sending this type of data. Ignoring.");
323 #ifdef MSGPACK_FEATURE_NOT_SUPPORTED
331 std::string
type =
"Float32Array";
346 for (
unsigned int i = 0; i < size; ++i)
351 std::string
type =
"Uint32Array";
363 std::shared_ptr<shapes::Mesh> shape = std::static_pointer_cast<shapes::Mesh>(shape_in);
364 attributes.insert(std::make_pair<std::string, ArrayFloat>(
"position",
ArrayFloat(shape->vertices, shape->vertex_count * 3)));
365 if (shape->vertex_normals)
366 attributes.insert(std::make_pair<std::string, ArrayFloat>(
"normal",
ArrayFloat(shape->vertex_normals, shape->vertex_count * 3)));
367 index =
ArrayInt(shape->triangles, shape->triangle_count * 3);
386 std::vector<double>
matrix = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
390 template <
typename T>
403 template <
typename T>
408 ret.
object.type =
"_meshfile_object";
425 Key(
double time_in,
const std::vector<double>& value_in) :
time(time_in),
value(value_in){};
434 Track(
const std::string& name_in,
const std::string& type_in) :
name(name_in),
type(type_in){};
444 Clip(
double fps_in,
const std::string& name_in) :
fps(fps_in),
name(name_in){};
471 std::string
type =
"set_animation";
488 #endif // EXOTICA_CORE_VISUALIZATION_MESHCAT_TYPES_H_
MSGPACK_DEFINE(type, path)
GeometryMesh(const std::string &file_name_in, const std::string &url_in="", const std::string &format_in="", const std::string &uuid_in="")
Object< T > CreateGeometryObject(const T &geometry_in, const Material &material_in=Material(), const std::string &uuid_in="")
Property(const std::string &path_in, const std::string &property_in, const T &value_in)
MSGPACK_DEFINE(type, path, animations, options)
msgpack::type::raw_ref msgpack_raw_ref
MSGPACK_DEFINE(metadata, geometries, materials, object)
MSGPACK_DEFINE(time, value)
std::vector< double > matrix
std::string generate_uuid()
GeometryMeshBuffer(shapes::ShapePtr shape_in, const std::string &uuid_in="")
ArrayInt(unsigned int *data, unsigned int size)
std::vector< Track > tracks
std::vector< float > data
unsigned char random_char()
GeometryMesh & operator=(const GeometryMesh &other)
std::shared_ptr< Shape > ShapePtr
MSGPACK_DEFINE(type, path, object)
ArrayFloat(double *data_in, unsigned int size)
std::vector< uint32_t > array
MSGPACK_DEFINE(play, repetitions)
SetObjectType< T > SetObject(const std::string &path_in, const T &object_in)
std::vector< double > matrix
Material(long color_in, double opacity_in=1.0, const std::string &type_in="MeshPhongMaterial", const std::string &uuid_in="")
MSGPACK_DEFINE(type, path, property, value)
std::string generate_hex(const unsigned int len)
MSGPACK_DEFINE(uuid, type, color, ambient, emissive, specular, shininess, opacity, transparent, wireframe)
std::vector< T > geometries
std::string ParsePath(const std::string &path)
GeometryMeshBufferData data
MSGPACK_DEFINE(path, clip)
std::vector< float > msgpack_ext
Geometry(const std::string &type_in, const std::string &uuid_in="")
std::vector< T > geometries
GeometryMeshBufferData()=default
std::vector< double > matrix
Delete(const std::string &path_in)
MeshObject< T > CreateMeshObject(const T &geometry_in, const Material &material_in=Material(), const std::string &uuid_in="")
std::vector< char > buffer
std::map< std::string, std::string > resources
std::vector< Animation > animations
#define WARNING(x)
With endline.
MSGPACK_DEFINE(name, type, keys)
Track(const std::string &name_in, const std::string &type_in)
MSGPACK_DEFINE(type, uuid, geometry, material, matrix)
std::vector< double > value
std::map< std::string, ArrayFloat > attributes
MSGPACK_DEFINE(metadata, geometries, materials, object)
ObjectData(const std::string &type_in, const std::string &uuid_in, const std::string &geometry_in, const std::string &material_in)
GeometryMesh(const GeometryMesh &other)
long RGB(double R, double G, double B)
std::vector< Material > materials
MSGPACK_DEFINE(fps, name, tracks)
GeometryMeshBufferData(shapes::ShapePtr shape_in)
AnimationOption()=default
ArrayFloat(const ArrayFloat &other)
std::vector< Material > materials
exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Sun Jun 2 2024 02:58:18