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

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

Issue 2757213003: Implementing glTF 1.0 parser (Closed)
Patch Set: Resolving merge. 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
« no previous file with comments | « chrome/browser/android/vr_shell/BUILD.gn ('k') | chrome/browser/android/vr_shell/gltf_asset.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <vector>
12
13 #include "ui/gl/gl_bindings.h"
14
15 namespace vr_shell {
16
17 namespace gltf {
18
19 enum Type {
20 UNKNOWN = 0,
21 SCALAR,
22 VEC2,
23 VEC3,
24 VEC4,
25 MAT2,
26 MAT3,
27 MAT4,
28 };
29
30 Type GetType(const std::string& type);
31
32 // A Buffer is data stored as binary blob in little-endian format.
33 using Buffer = std::string;
34
35 // The following structures match the objects defined in glTF 1.0 standard.
36 // https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#properties -reference
37
38 // A BufferView is subset of data in a buffer.
39 struct BufferView {
40 const Buffer* buffer;
41 int byte_length = 0;
42 int byte_offset;
43 int target = GL_ARRAY_BUFFER;
44 };
45
46 // An Accessor is a typed view into a BufferView.
47 struct Accessor {
48 const BufferView* buffer_view;
49 int byte_offset;
50 // TODO(acondor): byte_stride is on BufferView in glTF 2.0.
51 int byte_stride = 0;
52 int component_type;
53 int count;
54 Type type;
55 };
56
57 // A Mesh is a set of primitives to be rendered.
58 struct Mesh {
59 // A Primitive describes a geometry to be rendered.
60 struct Primitive {
61 std::map<std::string, const Accessor*> attributes;
62 const Accessor* indices;
63 int mode;
64 Primitive();
65 ~Primitive();
66 };
67
68 std::vector<std::unique_ptr<Primitive>> primitives;
69 Mesh();
70 ~Mesh();
71 };
72
73 // A Node in the node hierarchy.
74 struct Node {
75 std::vector<const Node*> children;
76 // TODO(acondor): There is only one mesh per node in glTF 2.0.
77 std::vector<const Mesh*> meshes;
78 Node();
79 ~Node();
80 };
81
82 // The root nodes of a scene.
83 struct Scene {
84 std::vector<const Node*> nodes;
85 Scene();
86 ~Scene();
87 };
88
89 class Asset {
90 public:
91 Asset();
92 virtual ~Asset();
93
94 std::size_t AddBuffer(std::unique_ptr<Buffer> buffer);
95 std::size_t AddBufferView(std::unique_ptr<BufferView> buffer_view);
96 std::size_t AddAccessor(std::unique_ptr<Accessor> accessor);
97 std::size_t AddMesh(std::unique_ptr<Mesh> mesh);
98 std::size_t AddNode(std::unique_ptr<Node> node);
99 std::size_t AddScene(std::unique_ptr<Scene> scene);
100 const Buffer* GetBuffer(std::size_t id) const;
101 const BufferView* GetBufferView(std::size_t id) const;
102 const Accessor* GetAccessor(std::size_t id) const;
103 const Mesh* GetMesh(std::size_t id) const;
104 const Node* GetNode(std::size_t id) const;
105 const Scene* GetScene(std::size_t id) const;
106
107 const Scene* GetMainScene() const { return scene_; }
108
109 void SetMainScene(const Scene* scene) { scene_ = scene; }
110
111 private:
112 std::vector<std::unique_ptr<Buffer>> buffers_;
113 std::vector<std::unique_ptr<BufferView>> buffer_views_;
114 std::vector<std::unique_ptr<Accessor>> accessors_;
115 std::vector<std::unique_ptr<Mesh>> meshes_;
116 std::vector<std::unique_ptr<Node>> nodes_;
117 std::vector<std::unique_ptr<Scene>> scenes_;
118 const Scene* scene_;
119 };
120
121 } // namespace gltf
122
123 } // namespace vr_shell
124
125 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/BUILD.gn ('k') | chrome/browser/android/vr_shell/gltf_asset.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698