scenepic 1.1.0
3D Visualization Made Easy
frame3d.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#ifndef _SCENEPIC_FRAME3D_H_
5#define _SCENEPIC_FRAME3D_H_
6
7#include "camera.h"
8#include "focus_point.h"
9#include "json_value.h"
10#include "label.h"
11#include "layer_settings.h"
12#include "matrix.h"
13#include "mesh.h"
14#include "mesh_update.h"
15
16#include <algorithm>
17#include <string>
18#include <vector>
19
20namespace scenepic
21{
25 class Frame3D
26 {
27 public:
33 const std::vector<std::string>& mesh_ids,
34 const Transform& transform = Transform::Identity());
35
41 template<typename MeshType>
43 const std::vector<std::shared_ptr<MeshType>>& meshes,
44 const Transform& transform = Transform::Identity())
45 {
46 std::vector<std::string> mesh_ids;
47 std::transform(
48 meshes.begin(),
49 meshes.end(),
50 std::back_inserter(mesh_ids),
51 [](const std::shared_ptr<MeshType>& mesh) { mesh->mesh_id(); });
52 this->add_meshes_by_id(mesh_ids, transform);
53 }
54
60 const std::string& mesh_id,
61 const Transform& transform = Transform::Identity());
62
68 template<typename MeshType>
70 const std::shared_ptr<MeshType>& mesh,
71 const Transform& transform = Transform::Identity())
72 {
73 this->add_mesh_by_id(mesh->mesh_id(), transform);
74 }
75
80 void add_label(const std::shared_ptr<Label>& label, const Vector& position);
81
96 const std::map<std::string, LayerSettings> layer_settings);
97
99 const Camera& camera() const;
100
105
107 const FocusPoint& focus_point() const;
108
111
113 std::string to_string() const;
114
119
120 private:
121 friend class Canvas3D;
122
128 Frame3D(
129 const std::string& frame_id,
131 const Camera& camera = Camera::None());
132
133 std::string m_frame_id;
134 FocusPoint m_focus_point;
135 Camera m_camera;
136 std::vector<JsonValue> m_frame_commands;
137 std::map<std::string, LayerSettings> m_layer_settings;
138 };
139} // namespace scenepic
140
141#endif
A camera type.
Definition: camera.h:15
static Camera None()
A value indicating "no camera".
Represents a ScenePic Canvas3D - a 3D viewport that can contain a number of Frame3Ds.
Definition: canvas3d.h:26
3D focus point for this frame (with optional 3D rotation for orientation lock), used in the ScenePic ...
Definition: focus_point.h:16
static FocusPoint None()
A value indicating "no focus point".
Represents a frame of an animation which contains a number of transformed Mesh objects.
Definition: frame3d.h:26
const Camera & camera() const
The default camera parameters for this frame.
void add_mesh_by_id(const std::string &mesh_id, const Transform &transform=Transform::Identity())
Add a mesh to the frame.
void add_label(const std::shared_ptr< Label > &label, const Vector &position)
Add a label to the frame.
void add_meshes(const std::vector< std::shared_ptr< MeshType > > &meshes, const Transform &transform=Transform::Identity())
Add meshes to the frame.
Definition: frame3d.h:42
const FocusPoint & focus_point() const
The focus point of the frame.
void add_meshes_by_id(const std::vector< std::string > &mesh_ids, const Transform &transform=Transform::Identity())
Add meshes to the frame.
Frame3D & focus_point(const FocusPoint &focus_point)
Set the focus point of the frame.
Frame3D & camera(const Camera &camera)
Set the default camera parameters for this frame.
JsonValue to_json() const
Convert this object into ScenePic json.
void set_layer_settings(const std::map< std::string, LayerSettings > layer_settings)
Specify the visibilities and opacities of certain mesh layers.
std::string to_string() const
Return a JSON string representing the object.
void add_mesh(const std::shared_ptr< MeshType > &mesh, const Transform &transform=Transform::Identity())
Add a mesh to the frame.
Definition: frame3d.h:69
Representation of a JSON value according to the specification at https://www.json....
Definition: json_value.h:30
Definition: audio_track.h:14