| 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_ASSET_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 VEC2, | 22 VEC2, |
| 23 VEC3, | 23 VEC3, |
| 24 VEC4, | 24 VEC4, |
| 25 MAT2, | 25 MAT2, |
| 26 MAT3, | 26 MAT3, |
| 27 MAT4, | 27 MAT4, |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 Type GetType(const std::string& type); | 30 Type GetType(const std::string& type); |
| 31 | 31 |
| 32 GLint GetTypeComponents(Type type); |
| 33 |
| 32 // A Buffer is data stored as binary blob in little-endian format. | 34 // A Buffer is data stored as binary blob in little-endian format. |
| 33 using Buffer = std::string; | 35 using Buffer = std::string; |
| 34 | 36 |
| 35 // The following structures match the objects defined in glTF 1.0 standard. | 37 // 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 | 38 // https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#properties
-reference |
| 37 | 39 |
| 38 // A BufferView is subset of data in a buffer. | 40 // A BufferView is subset of data in a buffer. |
| 39 struct BufferView { | 41 struct BufferView { |
| 40 const Buffer* buffer; | 42 int buffer; |
| 41 int byte_length = 0; | 43 int byte_length = 0; |
| 42 int byte_offset; | 44 int byte_offset; |
| 43 int target = GL_ARRAY_BUFFER; | 45 int target = GL_ARRAY_BUFFER; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 // An Accessor is a typed view into a BufferView. | 48 // An Accessor is a typed view into a BufferView. |
| 47 struct Accessor { | 49 struct Accessor { |
| 48 const BufferView* buffer_view; | 50 const BufferView* buffer_view; |
| 49 int byte_offset; | 51 int byte_offset; |
| 50 // TODO(acondor): byte_stride is on BufferView in glTF 2.0. | 52 // TODO(acondor): byte_stride is on BufferView in glTF 2.0. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 std::vector<const Node*> nodes; | 86 std::vector<const Node*> nodes; |
| 85 Scene(); | 87 Scene(); |
| 86 ~Scene(); | 88 ~Scene(); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 class Asset { | 91 class Asset { |
| 90 public: | 92 public: |
| 91 Asset(); | 93 Asset(); |
| 92 virtual ~Asset(); | 94 virtual ~Asset(); |
| 93 | 95 |
| 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 AddBufferView(std::unique_ptr<BufferView> buffer_view); |
| 96 std::size_t AddAccessor(std::unique_ptr<Accessor> accessor); | 97 std::size_t AddAccessor(std::unique_ptr<Accessor> accessor); |
| 97 std::size_t AddMesh(std::unique_ptr<Mesh> mesh); | 98 std::size_t AddMesh(std::unique_ptr<Mesh> mesh); |
| 98 std::size_t AddNode(std::unique_ptr<Node> node); | 99 std::size_t AddNode(std::unique_ptr<Node> node); |
| 99 std::size_t AddScene(std::unique_ptr<Scene> scene); | 100 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; | 101 const BufferView* GetBufferView(std::size_t id) const; |
| 102 const Accessor* GetAccessor(std::size_t id) const; | 102 const Accessor* GetAccessor(std::size_t id) const; |
| 103 const Mesh* GetMesh(std::size_t id) const; | 103 const Mesh* GetMesh(std::size_t id) const; |
| 104 const Node* GetNode(std::size_t id) const; | 104 const Node* GetNode(std::size_t id) const; |
| 105 const Scene* GetScene(std::size_t id) const; | 105 const Scene* GetScene(std::size_t id) const; |
| 106 | 106 |
| 107 const Scene* GetMainScene() const { return scene_; } | 107 const Scene* GetMainScene() const { return scene_; } |
| 108 | 108 |
| 109 void SetMainScene(const Scene* scene) { scene_ = scene; } | 109 void SetMainScene(const Scene* scene) { scene_ = scene; } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 std::vector<std::unique_ptr<Buffer>> buffers_; | |
| 113 std::vector<std::unique_ptr<BufferView>> buffer_views_; | 112 std::vector<std::unique_ptr<BufferView>> buffer_views_; |
| 114 std::vector<std::unique_ptr<Accessor>> accessors_; | 113 std::vector<std::unique_ptr<Accessor>> accessors_; |
| 115 std::vector<std::unique_ptr<Mesh>> meshes_; | 114 std::vector<std::unique_ptr<Mesh>> meshes_; |
| 116 std::vector<std::unique_ptr<Node>> nodes_; | 115 std::vector<std::unique_ptr<Node>> nodes_; |
| 117 std::vector<std::unique_ptr<Scene>> scenes_; | 116 std::vector<std::unique_ptr<Scene>> scenes_; |
| 118 const Scene* scene_; | 117 const Scene* scene_; |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 } // namespace gltf | 120 } // namespace gltf |
| 122 | 121 |
| 123 } // namespace vr_shell | 122 } // namespace vr_shell |
| 124 | 123 |
| 125 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_ | 124 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_GLTF_ASSET_H_ |
| OLD | NEW |