File: yocto_sceneio.h

package info (click to toggle)
goxel 0.10.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,076 kB
  • sloc: ansic: 97,667; cpp: 52,249; python: 132; makefile: 81; xml: 55
file content (102 lines) | stat: -rw-r--r-- 3,958 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// # Yocto/SceneIO: Tiny library for Yocto/Scene input and output
//
// Yocto/SceneIO provides loading and saving functionality for scenes
// in Yocto/GL. We support a simple to use YAML format, PLY, OBJ and glTF.
// The YAML serialization is a straight copy of the in-memory scene data.
// To speed up testing, we also support a binary format that is a dump of
// the current scene. This format should not be use for archival though.
//
// Error reporting is done through exceptions using the `io_error` exception.
//
// ## Scene Loading and Saving
//
// 1. load a scene with `load_scene()` and save it with `save_scene()`
//
//

//
// LICENSE:
//
// Copyright (c) 2016 -- 2019 Fabio Pellacini
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

#ifndef _YOCTO_SCENEIO_H_
#define _YOCTO_SCENEIO_H_

// -----------------------------------------------------------------------------
// INCLUDES
// -----------------------------------------------------------------------------

#include <atomic>
#include "yocto_scene.h"

// -----------------------------------------------------------------------------
// SCENE IO FUNCTIONS
// -----------------------------------------------------------------------------

namespace yocto {

// Scene load params
struct load_params {
  bool               notextures  = false;
  bool               facevarying = false;
  std::atomic<bool>* cancel      = nullptr;
  bool               noparallel  = false;
};

// Scene save params
struct save_params {
  bool               notextures   = false;
  bool               objinstances = false;
  std::atomic<bool>* cancel       = nullptr;
  bool               noparallel   = false;
};

// Load/save a scene in the supported formats.
void load_scene(
    const string& filename, yocto_scene& scene, const load_params& params = {});
void save_scene(const string& filename, const yocto_scene& scene,
    const save_params& params = {});

// Load/save scene textures
void load_texture(yocto_texture& texture, const string& dirname);
void save_texture(const yocto_texture& texture, const string& dirname);
void load_voltexture(yocto_voltexture& texture, const string& dirname);
void save_voltexture(const yocto_voltexture& texture, const string& dirname);
void load_textures(
    yocto_scene& scene, const string& dirname, const load_params& params);
void save_textures(
    const yocto_scene& scene, const string& dirname, const save_params& params);

// Load/save scene shapes
void load_shape(yocto_shape& shape, const string& dirname);
void save_shape(const yocto_shape& shape, const string& dirname);
void load_subdiv(yocto_subdiv& subdiv, const string& dirname);
void save_subdiv(const yocto_subdiv& subdiv, const string& dirname);
void load_shapes(
    yocto_scene& scene, const string& dirname, const load_params& params);
void save_shapes(
    const yocto_scene& scene, const string& dirname, const save_params& params);

}  // namespace yocto

#endif