OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 15 matching lines...) Expand all Loading... |
26 // TODO(acondor): Implement glTF 2.0 parser. gltf::Asset is mostly version | 26 // TODO(acondor): Implement glTF 2.0 parser. gltf::Asset is mostly version |
27 // agnostic. | 27 // agnostic. |
28 class GltfParser { | 28 class GltfParser { |
29 public: | 29 public: |
30 GltfParser(); | 30 GltfParser(); |
31 ~GltfParser(); | 31 ~GltfParser(); |
32 // Note: If your glTF references external files, this function will perform | 32 // Note: If your glTF references external files, this function will perform |
33 // IO, and a base path must be specified. | 33 // IO, and a base path must be specified. |
34 std::unique_ptr<gltf::Asset> Parse( | 34 std::unique_ptr<gltf::Asset> Parse( |
35 const base::DictionaryValue& dict, | 35 const base::DictionaryValue& dict, |
| 36 std::vector<std::unique_ptr<gltf::Buffer>>* buffers, |
36 const base::FilePath& path = base::FilePath()); | 37 const base::FilePath& path = base::FilePath()); |
37 // Note: This function will perform IO. | 38 // Note: This function will perform IO. |
38 std::unique_ptr<gltf::Asset> Parse(const base::FilePath& gltf_path); | 39 std::unique_ptr<gltf::Asset> Parse( |
| 40 const base::FilePath& gltf_path, |
| 41 std::vector<std::unique_ptr<gltf::Buffer>>* buffers); |
39 | 42 |
40 private: | 43 private: |
41 bool ParseInternal(const base::DictionaryValue& dict); | 44 bool ParseInternal(const base::DictionaryValue& dict, |
42 bool SetBuffers(const base::DictionaryValue& dict); | 45 std::vector<std::unique_ptr<gltf::Buffer>>* buffers); |
| 46 bool SetBuffers(const base::DictionaryValue& dict, |
| 47 std::vector<std::unique_ptr<gltf::Buffer>>* buffers); |
43 bool SetBufferViews(const base::DictionaryValue& dict); | 48 bool SetBufferViews(const base::DictionaryValue& dict); |
44 bool SetAccessors(const base::DictionaryValue& dict); | 49 bool SetAccessors(const base::DictionaryValue& dict); |
45 bool SetMeshes(const base::DictionaryValue& dict); | 50 bool SetMeshes(const base::DictionaryValue& dict); |
46 bool SetNodes(const base::DictionaryValue& dict); | 51 bool SetNodes(const base::DictionaryValue& dict); |
47 bool SetScenes(const base::DictionaryValue& dict); | 52 bool SetScenes(const base::DictionaryValue& dict); |
48 std::unique_ptr<gltf::Mesh::Primitive> ProcessPrimitive( | 53 std::unique_ptr<gltf::Mesh::Primitive> ProcessPrimitive( |
49 const base::DictionaryValue& dict); | 54 const base::DictionaryValue& dict); |
50 std::unique_ptr<gltf::Buffer> ProcessUri(const std::string& uri_str); | 55 std::unique_ptr<gltf::Buffer> ProcessUri(const std::string& uri_str); |
51 void Clear(); | 56 void Clear(); |
52 | 57 |
53 std::unique_ptr<gltf::Asset> asset_; | 58 std::unique_ptr<gltf::Asset> asset_; |
54 base::FilePath path_; | 59 base::FilePath path_; |
55 std::unordered_map<std::string, std::size_t> buffer_ids_; | 60 std::unordered_map<std::string, std::size_t> buffer_ids_; |
56 std::unordered_map<std::string, std::size_t> buffer_view_ids_; | 61 std::unordered_map<std::string, std::size_t> buffer_view_ids_; |
57 std::unordered_map<std::string, std::size_t> accessor_ids_; | 62 std::unordered_map<std::string, std::size_t> accessor_ids_; |
58 std::unordered_map<std::string, std::size_t> node_ids_; | 63 std::unordered_map<std::string, std::size_t> node_ids_; |
59 std::unordered_map<std::string, std::size_t> mesh_ids_; | 64 std::unordered_map<std::string, std::size_t> mesh_ids_; |
60 std::unordered_map<std::string, std::size_t> scene_ids_; | 65 std::unordered_map<std::string, std::size_t> scene_ids_; |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(GltfParser); | 67 DISALLOW_COPY_AND_ASSIGN(GltfParser); |
63 }; | 68 }; |
64 | 69 |
65 } // namespace vr_shell | 70 } // namespace vr_shell |
66 | 71 |
67 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ | 72 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ |
OLD | NEW |