-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller Scene] Parse GLTF primitives #38064
Changes from 3 commits
dce50b1
09bb019
a9d668e
c34e192
ab0bb2f
8e807cb
c917e70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
|
|
||
|
||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "impeller/scene/importer/conversions.h" | ||
|
|
||
| #include <cstring> | ||
|
|
||
| #include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
|
||
| namespace impeller { | ||
| namespace scene { | ||
| namespace importer { | ||
|
|
||
| Matrix ToMatrix(const std::vector<double>& m) { | ||
| return Matrix(m[0], m[1], m[2], m[3], // | ||
| m[4], m[5], m[6], m[7], // | ||
| m[8], m[9], m[10], m[11], // | ||
| m[12], m[13], m[14], m[15]); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// Flatbuffers -> Impeller | ||
| /// | ||
|
|
||
| Matrix ToMatrix(const fb::Matrix& m) { | ||
| auto& a = *m.m(); | ||
| return Matrix(a[0], a[1], a[2], a[3], // | ||
| a[4], a[5], a[6], a[7], // | ||
| a[8], a[9], a[10], a[11], // | ||
| a[12], a[13], a[14], a[15]); | ||
| } | ||
|
|
||
| Vector2 ToVector2(const fb::Vec2& v) { | ||
| return Vector2(v.x(), v.y()); | ||
| } | ||
|
|
||
| Vector3 ToVector3(const fb::Vec3& v) { | ||
| return Vector3(v.x(), v.y(), v.z()); | ||
| } | ||
|
|
||
| Vector4 ToVector4(const fb::Vec4& v) { | ||
| return Vector4(v.x(), v.y(), v.z(), v.w()); | ||
| } | ||
|
|
||
| Color ToColor(const fb::Color& c) { | ||
| return Color(c.r(), c.g(), c.b(), c.a()); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// Impeller -> Flatbuffers | ||
| /// | ||
|
|
||
| std::unique_ptr<fb::Matrix> ToFBMatrix(const Matrix& m) { | ||
| auto array = std::array<Scalar, 16>{m.m[0], m.m[1], m.m[2], m.m[3], // | ||
| m.m[4], m.m[5], m.m[6], m.m[7], // | ||
| m.m[8], m.m[9], m.m[10], m.m[11], // | ||
| m.m[12], m.m[13], m.m[14], m.m[15]}; | ||
| return std::make_unique<fb::Matrix>(array); | ||
| } | ||
|
|
||
| fb::Vec2 ToFBVec2(const Vector2 v) { | ||
| return fb::Vec2(v.x, v.y); | ||
| } | ||
|
|
||
| fb::Vec3 ToFBVec3(const Vector3 v) { | ||
| return fb::Vec3(v.x, v.y, v.z); | ||
| } | ||
|
|
||
| fb::Vec4 ToFBVec4(const Vector4 v) { | ||
| return fb::Vec4(v.x, v.y, v.z, v.w); | ||
| } | ||
|
|
||
| fb::Color ToFBColor(const Color c) { | ||
| return fb::Color(c.red, c.green, c.blue, c.alpha); | ||
| } | ||
|
|
||
| } // namespace importer | ||
| } // namespace scene | ||
| } // namespace impeller | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto question about include guards in this file.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <cstddef> | ||
| #include <map> | ||
|
|
||
| #include "impeller/geometry/matrix.h" | ||
| #include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
|
||
| namespace impeller { | ||
| namespace scene { | ||
| namespace importer { | ||
|
|
||
| Matrix ToMatrix(const std::vector<double>& m); | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// Flatbuffers -> Impeller | ||
| /// | ||
|
|
||
| Matrix ToMatrix(const fb::Matrix& m); | ||
|
|
||
| Vector2 ToVector2(const fb::Vec2& c); | ||
|
|
||
| Vector3 ToVector3(const fb::Vec3& c); | ||
|
|
||
| Vector4 ToVector4(const fb::Vec4& c); | ||
|
|
||
| Color ToColor(const fb::Color& c); | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// Impeller -> Flatbuffers | ||
| /// | ||
|
|
||
| std::unique_ptr<fb::Matrix> ToFBMatrix(const Matrix& m); | ||
|
|
||
| fb::Vec2 ToFBVec2(const Vector2 v); | ||
|
|
||
| fb::Vec3 ToFBVec3(const Vector3 v); | ||
|
|
||
| fb::Vec4 ToFBVec4(const Vector4 v); | ||
|
|
||
| fb::Color ToFBColor(const Color c); | ||
|
|
||
| } // namespace importer | ||
| } // namespace scene | ||
| } // namespace impeller | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,13 @@ | |
| #include <memory> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto question about include guards in this file
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
|
||
| #include "flutter/fml/mapping.h" | ||
| #include "impeller/scene/importer/mesh_flatbuffers.h" | ||
| #include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
|
||
| namespace impeller { | ||
| namespace scene { | ||
| namespace importer { | ||
|
|
||
| bool ParseGLTF(const fml::Mapping& source_mapping, fb::MeshT& out_mesh); | ||
| bool ParseGLTF(const fml::Mapping& source_mapping, fb::SceneT& out_scene); | ||
|
|
||
| } | ||
| } // namespace scene | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this based off of an old commit? I thought scenec was the name we settled on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it would make sense to call the frontend/executable name "scenec" and the namespace/library with the importing utilities "importer", similar to how "impellerc" is the frontend for the "compiler" lib. Perhaps I should use the
scenecname all around?