scenepic 1.1.0
3D Visualization Made Easy
mesh_update.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#ifndef _SCENEPIC_MESH_UPDATE_H_
5#define _SCENEPIC_MESH_UPDATE_H_
6
7#include "json_value.h"
8#include "matrix.h"
9
10#include <cstdint>
11#include <limits>
12#include <string>
13#include <vector>
14
15namespace scenepic
16{
19 {
20 None = 0,
21 Positions = 1,
22 Normals = 2,
23 Colors = 4,
24 Rotations = 8
25 };
26
28 {
29 return (VertexBufferType)((int)a | (int)b);
30 }
31
33 {
34 return (VertexBufferType)((int)a & (int)b);
35 }
36
38 {
39 return (VertexBufferType&)((int&)a |= (int)b);
40 }
41
48 {
49 public:
51 const std::string& base_mesh_id() const;
52
54 const std::string& mesh_id() const;
55
57 VertexBufferRef vertex_buffer();
58
60 std::string to_string() const;
61
66
69 std::uint32_t frame_index() const;
70
72 bool is_quantized() const;
73
81 std::uint32_t keyframe_index,
82 float fixed_point_range,
83 const ConstVertexBufferRef& keyframe_vertex_buffer);
84
86 VertexBuffer unquantize() const;
87
92 float difference_range(const ConstVertexBufferRef& vertex_buffer) const;
93
95 static const std::size_t QuantizationBinCount =
96 std::numeric_limits<FixedPointVertexBuffer::Scalar>::max();
97
98 private:
99 friend class Scene;
100
111 const std::string& base_mesh_id,
112 const std::string& mesh_id,
113 const std::vector<ConstVertexBufferRef>& buffers,
114 const std::vector<VertexBufferType>& buffer_types,
115 std::uint32_t frame_index);
116
117 std::string m_base_mesh_id;
118 std::string m_mesh_id;
119 VertexBuffer m_vertex_buffer;
120 FixedPointVertexBuffer m_fp_vertex_buffer;
121 float m_min;
122 float m_max;
123 std::uint32_t m_frame_index;
124 std::uint32_t m_keyframe_index;
125 VertexBufferType m_update_flags;
126 };
127} // namespace scenepic
128
129#endif
Representation of a JSON value according to the specification at https://www.json....
Definition: json_value.h:30
Class which represents an update to an existing mesh in which only the vertex buffer is changed.
Definition: mesh_update.h:48
const std::string & base_mesh_id() const
The unique identifier of the original base mesh.
const std::string & mesh_id() const
The unique identifier of the newly updated mesh.
VertexBufferRef vertex_buffer()
The updated vertex buffer.
JsonValue to_json() const
Convert this object into ScenePic json.
bool is_quantized() const
Whether this update is quantized.
std::string to_string() const
Return a JSON string representing the object.
void quantize(std::uint32_t keyframe_index, float fixed_point_range, const ConstVertexBufferRef &keyframe_vertex_buffer)
Quantize the mesh update in reference to a keyframe.
static const std::size_t QuantizationBinCount
The number of quantization bins.
Definition: mesh_update.h:95
float difference_range(const ConstVertexBufferRef &vertex_buffer) const
The range of differences between this frame and the current keyframe.
std::uint32_t frame_index() const
The unique index of the frame or the index of its keyframe (if quantized).
VertexBuffer unquantize() const
Unquantize the buffer (for testing purposes)
Top level container representing an entire ScenePic.
Definition: scene.h:58
Definition: audio_track.h:14
VertexBufferType & operator|=(VertexBufferType &a, VertexBufferType b)
Definition: mesh_update.h:37
VertexBufferType operator&(VertexBufferType a, VertexBufferType b)
Definition: mesh_update.h:32
VertexBufferType operator|(VertexBufferType a, VertexBufferType b)
Definition: mesh_update.h:27
VertexBufferType
Flags indicating what aspect of the vertex buffer is updated.
Definition: mesh_update.h:19