Welcome to mirror list, hosted at ThFree Co, Russian Federation.

obj_import_file_reader.hh « importer « wavefront_obj « io « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8093417fcda611ad96be03ee3df348d39b3d99eb (plain)
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
/* SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup obj
 */

#pragma once

#include "BLI_fileops.hh"
#include "IO_wavefront_obj.h"
#include "obj_import_mtl.hh"
#include "obj_import_objects.hh"

namespace blender::io::obj {

/* Note: the OBJ parser implementation is planned to get fairly large changes "soon",
 * so don't read too much into current implementation... */
class OBJParser {
 private:
  const OBJImportParams &import_params_;
  FILE *obj_file_;
  Vector<std::string> mtl_libraries_;
  size_t read_buffer_size_;

 public:
  /**
   * Open OBJ file at the path given in import parameters.
   */
  OBJParser(const OBJImportParams &import_params, size_t read_buffer_size);
  ~OBJParser();

  /**
   * Read the OBJ file line by line and create OBJ Geometry instances. Also store all the vertex
   * and UV vertex coordinates in a struct accessible by all objects.
   */
  void parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries,
             GlobalVertices &r_global_vertices);
  /**
   * Return a list of all material library filepaths referenced by the OBJ file.
   */
  Span<std::string> mtl_libraries() const;
};

class MTLParser {
 private:
  char mtl_file_path_[FILE_MAX];
  /**
   * Directory in which the MTL file is found.
   */
  char mtl_dir_path_[FILE_MAX];

 public:
  /**
   * Open material library file.
   */
  MTLParser(StringRef mtl_library_, StringRefNull obj_filepath);

  /**
   * Read MTL file(s) and add MTLMaterial instances to the given Map reference.
   */
  void parse_and_store(Map<std::string, std::unique_ptr<MTLMaterial>> &r_materials);
};
}  // namespace blender::io::obj