Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/browser/android/vr_shell/gltf_parser.h

Issue 2774653002: Support for parsing external file references in a glTF resource. (Closed)
Patch Set: Scoping Clean call. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/files/file_path.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/android/vr_shell/gltf_asset.h" 14 #include "chrome/browser/android/vr_shell/gltf_asset.h"
14 15
15 namespace vr_shell { 16 namespace vr_shell {
16 17
17 // Parser for glTF 1.0 specification 18 // Parser for glTF 1.0 specification
18 // https://github.com/KhronosGroup/glTF/tree/master/specification/1.0 19 // https://github.com/KhronosGroup/glTF/tree/master/specification/1.0
19 // Supported objects are limited to: buffers, bufferViews, accessors, 20 // Supported objects are limited to: buffers, bufferViews, accessors,
20 // meshes (limited), nodes (limited), scenes (limited). 21 // meshes (limited), nodes (limited), scenes (limited).
21 // Non-supported objects include: materials, techniques, skins, shaders, 22 // Non-supported objects include: materials, techniques, skins, shaders,
22 // programs, animations, cameras, images, textures, extensions. 23 // programs, animations, cameras, images, textures, extensions.
23 // This parser is not intended to be used on user or third-party data, 24 // This parser is not intended to be used on user or third-party data,
24 // but only on thoroughly tested Chromium resource files. 25 // but only on thoroughly tested Chromium resource files.
25 // 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
26 // agnostic. 27 // agnostic.
27 class GltfParser { 28 class GltfParser {
28 public: 29 public:
29 GltfParser(); 30 GltfParser();
30 ~GltfParser(); 31 ~GltfParser();
31 std::unique_ptr<gltf::Asset> Parse(const base::DictionaryValue& dict); 32 // Note: If your glTF references external files, this function will perform
33 // IO, and a base path must be specified.
34 std::unique_ptr<gltf::Asset> Parse(
35 const base::DictionaryValue& dict,
36 const base::FilePath& path = base::FilePath());
37 // Note: This function will perform IO.
38 std::unique_ptr<gltf::Asset> Parse(const base::FilePath& gltf_path);
32 39
33 private: 40 private:
34 bool ParseInternal(const base::DictionaryValue& dict); 41 bool ParseInternal(const base::DictionaryValue& dict);
35 bool SetBuffers(const base::DictionaryValue& dict); 42 bool SetBuffers(const base::DictionaryValue& dict);
36 bool SetBufferViews(const base::DictionaryValue& dict); 43 bool SetBufferViews(const base::DictionaryValue& dict);
37 bool SetAccessors(const base::DictionaryValue& dict); 44 bool SetAccessors(const base::DictionaryValue& dict);
38 bool SetMeshes(const base::DictionaryValue& dict); 45 bool SetMeshes(const base::DictionaryValue& dict);
39 bool SetNodes(const base::DictionaryValue& dict); 46 bool SetNodes(const base::DictionaryValue& dict);
40 bool SetScenes(const base::DictionaryValue& dict); 47 bool SetScenes(const base::DictionaryValue& dict);
41 std::unique_ptr<gltf::Mesh::Primitive> ProcessPrimitive( 48 std::unique_ptr<gltf::Mesh::Primitive> ProcessPrimitive(
42 const base::DictionaryValue& dict); 49 const base::DictionaryValue& dict);
50 std::unique_ptr<gltf::Buffer> ProcessUri(const std::string& uri_str);
51 void Clear();
43 52
44 std::unique_ptr<gltf::Asset> asset_; 53 std::unique_ptr<gltf::Asset> asset_;
54 base::FilePath path_;
45 std::unordered_map<std::string, std::size_t> buffer_ids_; 55 std::unordered_map<std::string, std::size_t> buffer_ids_;
46 std::unordered_map<std::string, std::size_t> buffer_view_ids_; 56 std::unordered_map<std::string, std::size_t> buffer_view_ids_;
47 std::unordered_map<std::string, std::size_t> accessor_ids_; 57 std::unordered_map<std::string, std::size_t> accessor_ids_;
48 std::unordered_map<std::string, std::size_t> node_ids_; 58 std::unordered_map<std::string, std::size_t> node_ids_;
49 std::unordered_map<std::string, std::size_t> mesh_ids_; 59 std::unordered_map<std::string, std::size_t> mesh_ids_;
50 std::unordered_map<std::string, std::size_t> scene_ids_; 60 std::unordered_map<std::string, std::size_t> scene_ids_;
51 61
52 DISALLOW_COPY_AND_ASSIGN(GltfParser); 62 DISALLOW_COPY_AND_ASSIGN(GltfParser);
53 }; 63 };
54 64
55 } // namespace vr_shell 65 } // namespace vr_shell
56 66
57 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_ 67 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_PARSER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/BUILD.gn ('k') | chrome/browser/android/vr_shell/gltf_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698