-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Eigen - Draco - Python
- Loading branch information
0 parents
commit 8dca0d7
Showing
857 changed files
with
244,410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.p4* | ||
.DS_Store | ||
.AppleDouble | ||
.build | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// swift-tools-version: 5.9 | ||
|
||
import PackageDescription | ||
|
||
/* --------------------------------------------------------------------------------------------- * | ||
* We will need to migrate these include paths once we provide each of Pixar's USD dependencies, * | ||
* we are also looking to the industry & community for guidance as to which versions we support. * | ||
* --------------------------------------------------------------------------------------------- */ | ||
|
||
#if os(macOS) | ||
let platformIncludes: [String] = [] | ||
let platformExcludes: [String] = [] | ||
#elseif os(Linux) | ||
let platformIncludes: [String] = [] | ||
let platformExcludes: [String] = [] | ||
#else /* os(Windows) */ | ||
let platformIncludes: [String] = [] | ||
let platformExcludes: [String] = [] | ||
#endif /* os(Windows) */ | ||
|
||
let package = Package( | ||
name: "MetaverseKit", | ||
products: [ | ||
.library( | ||
name: "Eigen", | ||
targets: ["Eigen"] | ||
), | ||
.library( | ||
name: "Draco", | ||
targets: ["Draco"] | ||
), | ||
.library( | ||
name: "Python", | ||
targets: ["Python"] | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "Eigen", | ||
dependencies: [], | ||
exclude: [], | ||
publicHeadersPath: "include", | ||
cxxSettings: [], | ||
swiftSettings: [ | ||
.interoperabilityMode(.Cxx), | ||
] | ||
), | ||
.target( | ||
name: "Draco", | ||
dependencies: [ | ||
"Eigen" | ||
], | ||
exclude: [ | ||
"include/draco/animation/keyframe_animation_encoding_test.cc", | ||
"include/draco/animation/keyframe_animation_test.cc", | ||
"include/draco/attributes/point_attribute_test.cc", | ||
"include/draco/point_cloud/point_cloud_test.cc", | ||
"include/draco/metadata/metadata_test.cc", | ||
"include/draco/metadata/metadata_encoder_test.cc", | ||
"include/draco/point_cloud/point_cloud_builder_test.cc", | ||
"include/draco/unity/draco_unity_plugin_test.cc", | ||
"include/draco/mesh/mesh_test.cc", | ||
"include/draco/mesh/triangle_soup_mesh_builder_test.cc", | ||
"include/draco/mesh/mesh_are_equivalent_test.cc", | ||
"include/draco/mesh/corner_table_test.cc", | ||
"include/draco/mesh/mesh_cleanup_test.cc", | ||
"include/draco/io/stdio_file_writer_test.cc", | ||
"include/draco/io/stdio_file_reader_test.cc", | ||
"include/draco/io/stl_decoder_test.cc", | ||
"include/draco/io/ply_reader_test.cc", | ||
"include/draco/io/point_cloud_io_test.cc", | ||
"include/draco/io/stl_encoder_test.cc", | ||
"include/draco/io/obj_decoder_test.cc", | ||
"include/draco/io/obj_encoder_test.cc", | ||
"include/draco/io/ply_decoder_test.cc", | ||
"include/draco/io/file_reader_factory_test.cc", | ||
"include/draco/io/file_writer_factory_test.cc", | ||
"include/draco/io/file_utils_test.cc", | ||
"include/draco/io/file_writer_utils_test.cc", | ||
"include/draco/core/status_test.cc", | ||
"include/draco/core/vector_d_test.cc", | ||
"include/draco/core/math_utils_test.cc", | ||
"include/draco/core/quantization_utils_test.cc", | ||
"include/draco/core/buffer_bit_coding_test.cc", | ||
"include/draco/core/draco_test_utils.cc", | ||
"include/draco/compression/point_cloud/point_cloud_kd_tree_encoding_test.cc", | ||
"include/draco/compression/point_cloud/point_cloud_sequential_encoding_test.cc", | ||
"include/draco/compression/mesh/mesh_encoder_test.cc", | ||
"include/draco/compression/mesh/mesh_edgebreaker_encoding_test.cc", | ||
"include/draco/compression/entropy/symbol_coding_test.cc", | ||
"include/draco/compression/entropy/shannon_entropy_test.cc", | ||
"include/draco/compression/encode_test.cc", | ||
"include/draco/compression/decode_test.cc", | ||
"include/draco/compression/config/decoder_options_test.cc", | ||
"include/draco/compression/bit_coders/rans_coding_test.cc", | ||
"include/draco/compression/attributes/sequential_integer_attribute_encoding_test.cc", | ||
"include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_test.cc", | ||
"include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_test.cc", | ||
"include/draco/compression/attributes/point_d_vector_test.cc", | ||
"include/draco/javascript", | ||
"include/draco/tools" | ||
], | ||
publicHeadersPath: "include", | ||
cxxSettings: [], | ||
swiftSettings: [ | ||
.interoperabilityMode(.Cxx), | ||
] | ||
), | ||
|
||
.binaryTarget( | ||
name: "Python", | ||
url: "https://github.com/wabiverse/Kraken/releases/download/1.50a/Python.xcframework.zip", | ||
checksum: "11c2238d09cf559340ce3fd240235b08f227e8b9c6e60f48d4187cd6de52fa7a" | ||
), | ||
], | ||
cxxLanguageStandard: .cxx17 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2019 The Draco Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "draco/animation/animation.h" | ||
|
||
#ifdef DRACO_TRANSCODER_SUPPORTED | ||
|
||
namespace draco { | ||
|
||
void Animation::Copy(const Animation &src) { | ||
name_ = src.name_; | ||
channels_.clear(); | ||
for (int i = 0; i < src.NumChannels(); ++i) { | ||
std::unique_ptr<AnimationChannel> new_channel(new AnimationChannel()); | ||
new_channel->Copy(*src.GetChannel(i)); | ||
channels_.push_back(std::move(new_channel)); | ||
} | ||
|
||
samplers_.clear(); | ||
for (int i = 0; i < src.NumSamplers(); ++i) { | ||
std::unique_ptr<AnimationSampler> new_sampler(new AnimationSampler()); | ||
new_sampler->Copy(*src.GetSampler(i)); | ||
samplers_.push_back(std::move(new_sampler)); | ||
} | ||
|
||
node_animation_data_.clear(); | ||
for (int i = 0; i < src.NumNodeAnimationData(); ++i) { | ||
std::unique_ptr<NodeAnimationData> new_data(new NodeAnimationData()); | ||
new_data->Copy(*src.GetNodeAnimationData(i)); | ||
node_animation_data_.push_back(std::move(new_data)); | ||
} | ||
} | ||
|
||
} // namespace draco | ||
|
||
#endif // DRACO_TRANSCODER_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// Copyright 2019 The Draco Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#ifndef DRACO_ANIMATION_ANIMATION_H_ | ||
#define DRACO_ANIMATION_ANIMATION_H_ | ||
|
||
#include "draco/draco_features.h" | ||
|
||
#ifdef DRACO_TRANSCODER_SUPPORTED | ||
#include <memory> | ||
#include <vector> | ||
|
||
#include "draco/animation/node_animation_data.h" | ||
#include "draco/core/status.h" | ||
|
||
namespace draco { | ||
|
||
// Struct to hold information about an animation's sampler. | ||
struct AnimationSampler { | ||
enum class SamplerInterpolation { LINEAR, STEP, CUBICSPLINE }; | ||
|
||
static std::string InterpolationToString(SamplerInterpolation value) { | ||
switch (value) { | ||
case SamplerInterpolation::STEP: | ||
return "STEP"; | ||
case SamplerInterpolation::CUBICSPLINE: | ||
return "CUBICSPLINE"; | ||
default: | ||
return "LINEAR"; | ||
} | ||
} | ||
|
||
AnimationSampler() | ||
: input_index(-1), | ||
interpolation_type(SamplerInterpolation::LINEAR), | ||
output_index(-1) {} | ||
|
||
void Copy(const AnimationSampler &src) { | ||
input_index = src.input_index; | ||
interpolation_type = src.interpolation_type; | ||
output_index = src.output_index; | ||
} | ||
|
||
int input_index; | ||
SamplerInterpolation interpolation_type; | ||
int output_index; | ||
}; | ||
|
||
// Struct to hold information about an animation's channel. | ||
struct AnimationChannel { | ||
enum class ChannelTransformation { TRANSLATION, ROTATION, SCALE, WEIGHTS }; | ||
|
||
static std::string TransformationToString(ChannelTransformation value) { | ||
switch (value) { | ||
case ChannelTransformation::ROTATION: | ||
return "rotation"; | ||
case ChannelTransformation::SCALE: | ||
return "scale"; | ||
case ChannelTransformation::WEIGHTS: | ||
return "weights"; | ||
default: | ||
return "translation"; | ||
} | ||
} | ||
|
||
AnimationChannel() | ||
: target_index(-1), | ||
transformation_type(ChannelTransformation::TRANSLATION), | ||
sampler_index(-1) {} | ||
|
||
void Copy(const AnimationChannel &src) { | ||
target_index = src.target_index; | ||
transformation_type = src.transformation_type; | ||
sampler_index = src.sampler_index; | ||
} | ||
|
||
int target_index; | ||
ChannelTransformation transformation_type; | ||
int sampler_index; | ||
}; | ||
|
||
// This class is used to hold data and information of glTF animations. | ||
class Animation { | ||
public: | ||
Animation() {} | ||
|
||
void Copy(const Animation &src); | ||
|
||
const std::string &GetName() const { return name_; } | ||
void SetName(const std::string &name) { name_ = name; } | ||
|
||
// Returns the number of channels in an animation. | ||
int NumChannels() const { return channels_.size(); } | ||
// Returns the number of samplers in an animation. | ||
int NumSamplers() const { return samplers_.size(); } | ||
// Returns the number of accessors in an animation. | ||
int NumNodeAnimationData() const { return node_animation_data_.size(); } | ||
|
||
// Returns a channel in the animation. | ||
AnimationChannel *GetChannel(int index) { return channels_[index].get(); } | ||
const AnimationChannel *GetChannel(int index) const { | ||
return channels_[index].get(); | ||
} | ||
// Returns a sampler in the animation. | ||
AnimationSampler *GetSampler(int index) { return samplers_[index].get(); } | ||
const AnimationSampler *GetSampler(int index) const { | ||
return samplers_[index].get(); | ||
} | ||
// Returns an accessor in the animation. | ||
NodeAnimationData *GetNodeAnimationData(int index) { | ||
return node_animation_data_[index].get(); | ||
} | ||
const NodeAnimationData *GetNodeAnimationData(int index) const { | ||
return node_animation_data_[index].get(); | ||
} | ||
|
||
void AddNodeAnimationData( | ||
std::unique_ptr<NodeAnimationData> node_animation_data) { | ||
node_animation_data_.push_back(std::move(node_animation_data)); | ||
} | ||
void AddSampler(std::unique_ptr<AnimationSampler> sampler) { | ||
samplers_.push_back(std::move(sampler)); | ||
} | ||
void AddChannel(std::unique_ptr<AnimationChannel> channel) { | ||
channels_.push_back(std::move(channel)); | ||
} | ||
|
||
private: | ||
std::string name_; | ||
std::vector<std::unique_ptr<AnimationSampler>> samplers_; | ||
std::vector<std::unique_ptr<AnimationChannel>> channels_; | ||
std::vector<std::unique_ptr<NodeAnimationData>> node_animation_data_; | ||
}; | ||
|
||
} // namespace draco | ||
|
||
#endif // DRACO_TRANSCODER_SUPPORTED | ||
#endif // DRACO_ANIMATION_ANIMATION_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2021 The Draco Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "draco/animation/animation.h" | ||
|
||
#include "draco/core/draco_test_base.h" | ||
#include "draco/draco_features.h" | ||
|
||
namespace { | ||
|
||
#ifdef DRACO_TRANSCODER_SUPPORTED | ||
TEST(AnimationTest, TestCopy) { | ||
// Test copying of animation data. | ||
draco::Animation src_anim; | ||
ASSERT_TRUE(src_anim.GetName().empty()); | ||
src_anim.SetName("Walking"); | ||
ASSERT_EQ(src_anim.GetName(), "Walking"); | ||
|
||
std::unique_ptr<draco::AnimationSampler> src_sampler_0( | ||
new draco::AnimationSampler()); | ||
src_sampler_0->interpolation_type = | ||
draco::AnimationSampler::SamplerInterpolation::CUBICSPLINE; | ||
std::unique_ptr<draco::AnimationSampler> src_sampler_1( | ||
new draco::AnimationSampler()); | ||
src_sampler_1->Copy(*src_sampler_0); | ||
|
||
ASSERT_EQ(src_sampler_0->interpolation_type, | ||
src_sampler_1->interpolation_type); | ||
|
||
src_sampler_1->interpolation_type = | ||
draco::AnimationSampler::SamplerInterpolation::STEP; | ||
|
||
src_anim.AddSampler(std::move(src_sampler_0)); | ||
src_anim.AddSampler(std::move(src_sampler_1)); | ||
ASSERT_EQ(src_anim.NumSamplers(), 2); | ||
|
||
std::unique_ptr<draco::AnimationChannel> src_channel( | ||
new draco::AnimationChannel()); | ||
src_channel->transformation_type = | ||
draco::AnimationChannel::ChannelTransformation::WEIGHTS; | ||
src_anim.AddChannel(std::move(src_channel)); | ||
ASSERT_EQ(src_anim.NumChannels(), 1); | ||
|
||
draco::Animation dst_anim; | ||
dst_anim.Copy(src_anim); | ||
|
||
ASSERT_EQ(dst_anim.GetName(), src_anim.GetName()); | ||
ASSERT_EQ(dst_anim.NumSamplers(), 2); | ||
ASSERT_EQ(dst_anim.NumChannels(), 1); | ||
|
||
ASSERT_EQ(dst_anim.GetSampler(0)->interpolation_type, | ||
src_anim.GetSampler(0)->interpolation_type); | ||
ASSERT_EQ(dst_anim.GetSampler(1)->interpolation_type, | ||
src_anim.GetSampler(1)->interpolation_type); | ||
ASSERT_EQ(dst_anim.GetChannel(0)->transformation_type, | ||
src_anim.GetChannel(0)->transformation_type); | ||
} | ||
#endif // DRACO_TRANSCODER_SUPPORTED | ||
|
||
} // namespace |
Oops, something went wrong.