// Copyright 2018 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_IO_GLTF_DECODER_H_
#define DRACO_IO_GLTF_DECODER_H_
#include "draco/draco_features.h"
#ifdef DRACO_TRANSCODER_SUPPORTED
#include <map>
#include <memory>
#include <string>
#include <unordered_set>
#include <vector>
#include "draco/core/decoder_buffer.h"
#include "draco/core/status.h"
#include "draco/core/status_or.h"
#include "draco/io/file_utils.h"
#include "draco/io/texture_io.h"
#include "draco/mesh/mesh.h"
#include "draco/mesh/triangle_soup_mesh_builder.h"
#include "draco/point_cloud/point_cloud_builder.h"
#include "draco/scene/scene.h"
#include "tiny_gltf.h"
namespace draco {
// Decodes a glTF file and returns a draco::Mesh. All of the |mesh|'s attributes
// will be merged into one draco::Mesh
class GltfDecoder {
public:
GltfDecoder();
// Decodes a glTF file stored in the input |file_name| or |buffer| to a Mesh.
// The second form returns a vector of files used as input to the mesh during
// the decoding process. Returns nullptr when decode fails.
StatusOr<std::unique_ptr<Mesh>> DecodeFromFile(const std::string &file_name);
StatusOr<std::unique_ptr<Mesh>> DecodeFromFile(
const std::string &file_name, std::vector<std::string> *mesh_files);
StatusOr<std::unique_ptr<Mesh>> DecodeFromBuffer(DecoderBuffer *buffer);
// Decodes a glTF file stored in the input |file_name| or |buffer| to a Scene.
// The second form returns a vector of files used as input to the scene during
// the decoding process. Returns nullptr if the decode fails.
StatusOr<std::unique_ptr<Scene>> DecodeFromFileToScene(
const std::string &file_name);
StatusOr<std::unique_ptr<Scene>> DecodeFromFileToScene(
const std::string &file_name, std::vector<std::string> *scene_files);
StatusOr<std::unique_ptr<Scene>> DecodeFromBufferToScene(
DecoderBuffer *buffer);
// Scene graph can be loaded either as a tree or a general directed acyclic
// graph (DAG) that allows multiple parent nodes. By default. we decode the
// scene graph as a tree. If the tree mode is selected and the input contains
// nodes with multiple parents, these nodes are duplicated to form a tree.
// TODO(ostava): Add support for DAG mode to other parts of the Draco
// library.
enum class GltfSceneGraphMode { TREE, DAG };
void SetSceneGraphMode(GltfSceneGraphMode mode) {
gltf_scene_graph_mode_ = mode;
}
private:
// Loads |file_name| into |gltf_model_|. Fills |input_files| with paths to all
// input files when non-null.
Status LoadFile(const std::string &file_name,
std::vector<std::string> *input_files);
// Loads |gltf_model_| from |buffer| in GLB format.
Status LoadBuffer(const DecoderBuffer &buffer);
// Builds mesh from |gltf_model_|.
StatusOr<std::unique_ptr<Mesh>> BuildMesh();
// Checks |gltf_model_| for unsupported features. If |gltf_model_| contains
// unsupported features then the function will return with a status code of
// UNSUPPORTED_FEATURE.
Status CheckUnsupportedFeatures();
// Decodes a glTF Node as well as any child Nodes. If |node| contains a mesh
// it will process all of the mesh's primitives.
Status DecodeNode(int node_index, const Eigen::Matrix4d &parent_matrix);
// Decodes the number of entries in the first attribute of a given glTF
// |primitive|. Note that all attributes have the same entry count according
// to glTF 2.0 spec.
StatusOr<int> DecodePrimitiveAttributeCount(
const tinygltf::Primitive &primitive) const;
// Decodes the number of indices in a given glTF |primitive|. If primitive's
// indices property is not defined, the index count is implied from the entry
// count of a primitive attribute.
StatusOr<int> DecodePrimitiveIndicesCount(
const tinygltf::Primitive &primitive) const;
// Decodes indices property of a given glTF |primitive|. If primitive's
// indices property is not defined, the indices are generated based on entry
// count of a primitive attribute.
StatusOr<std::vector<uint32_t>> DecodePrimitiveIndices(
const tinygltf::Primitive &primitive) const;
// Decodes a glTF Primitive. All of the |primitive|'s attributes will be
// merged into the draco::Mesh output if they are of the same type that
// already has been decoded.
Status DecodePrimitive(const tinygltf::Primitive &primitive,
const Eigen::Matrix4d &transform_matrix);
// Sums the number of elements per attribute for |node|'s mesh and any of
// |node|'s children. Fills out the material index map.
Status NodeGatherAttributeAndMaterialStats(const tinygltf::Node &node);
// Sums the number of elements per attribute for all of the meshes and
// primitives.
Status GatherAttributeAndMaterialStats();
// Sums the attribute counts into total_attribute_counts_.
void SumAttributeStats(const std::string &attribute_name, int count);
// Checks that all the same glTF attribute types in different meshes and
// primitives contain the same characteristics.
Status CheckTypes(const std::string &attribute_name, int component_type,
int type, bool normalized);
// Accumulates the number of elements per attribute for |primitive|.
Status AccumulatePrimitiveStats(const tinygltf::Primitive &primitive);
// Adds all of the attributes from the glTF file to a Draco mesh.
// GatherAttributeAndMaterialStats() must be called before this function. The
// GeometryAttribute::MATERIAL attribute will be created only if the glTF file
// contains more than one material.
template <typename BuilderT>
Status AddAttributesToDracoMesh(BuilderT *builder);
// Copies attribute data from |accessor| and adds it to a Draco mesh using the
// geometry builder |builder|.
template <typename BuilderT>
Status AddAttributeValuesToBuilder(const std::string &attribute_name,
const tinygltf::Accessor &accessor,
const std::vector<uint32_t> &indices_data,
int att_id, int number_of_elements,
const Eigen::Matrix4d &transform_matrix,
BuilderT *builder);
// Copies the tangent attribute data from |accessor| and adds it to a Draco
// mesh. This function will transform all of the data by |transform_matrix|
// and then normalize before adding the data to the Draco mesh.
// |indices_data| is the indices data from the glTF file. |att_id| is the
// attribute id of the tangent attribute in the Draco mesh.
// |number_of_elements| is the number of faces or points this function will
// process. |reverse_winding| if set will change the orientation of the data.
template <typename BuilderT>
Status AddTangentToBuilder(const tinygltf::Accessor &accessor,
const std::vector<uint32_t> &indices_data,
int att_id, int number_of_elements,
const Eigen::Matrix4d &transform_matrix,
bool reverse_winding, BuilderT *builder);
// Copies the texture coordinate attribute data from |accessor| and adds it to
// a Draco mesh. This function will flip the data on the horizontal axis as
// Draco meshes store the texture coordinates differently than glTF.
// |indices_data| is the indices data from the glTF file. |att_id| is the
// attribut
没有合适的资源?快使用搜索试试~ 我知道了~
draco编译好的程序
共239个文件
h:230个
cmake:4个
exe:3个
需积分: 0 3 下载量 136 浏览量
2023-03-22
13:44:33
上传
评论 1
收藏 29.52MB ZIP 举报
温馨提示
draco编译好的程序
资源推荐
资源详情
资源评论
收起资源包目录
draco编译好的程序 (239个子文件)
draco-targets.cmake 4KB
draco-config-version.cmake 2KB
draco-config.cmake 970B
draco-targets-debug.cmake 848B
draco_transcoder.exe 9.86MB
draco_encoder.exe 9.59MB
draco_decoder.exe 9.56MB
gltf_decoder.h 24KB
geometry_attribute.h 21KB
mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h 18KB
ans.h 15KB
mesh_prediction_scheme_tex_coords_decoder.h 14KB
corner_table.h 14KB
dynamic_integer_points_kd_tree_encoder.h 13KB
normal_compression_utils.h 13KB
mesh.h 13KB
mesh_prediction_scheme_tex_coords_encoder.h 13KB
material.h 11KB
mesh_prediction_scheme_tex_coords_portable_predictor.h 11KB
dynamic_integer_points_kd_tree_decoder.h 11KB
rans_symbol_encoder.h 11KB
point_cloud.h 10KB
point_d_vector.h 10KB
prediction_scheme_decoder_factory.h 10KB
mesh_stripifier.h 10KB
draco_options.h 10KB
scene.h 9KB
mesh_edgebreaker_decoder_impl.h 9KB
vector_d.h 9KB
corner_table_iterators.h 9KB
mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h 9KB
mesh_edgebreaker_traversal_valence_encoder.h 9KB
mesh_edgebreaker_encoder_impl.h 9KB
max_prediction_degree_traverser.h 9KB
property_table.h 8KB
point_attribute.h 8KB
mesh_attribute_corner_table.h 8KB
mesh_prediction_scheme_geometric_normal_encoder.h 7KB
metadata.h 7KB
mesh_edgebreaker_traversal_valence_decoder.h 7KB
expert_encode.h 7KB
mesh_edgebreaker_traversal_predictive_encoder.h 7KB
prediction_scheme_encoder_factory.h 7KB
decoder_buffer.h 7KB
depth_first_traverser.h 6KB
mesh_edgebreaker_traversal_decoder.h 6KB
encode.h 6KB
mesh_prediction_scheme_geometric_normal_decoder.h 6KB
scene_utils.h 6KB
texture_map.h 6KB
point_cloud_encoder.h 6KB
mesh_connected_components.h 6KB
mesh_prediction_scheme_multi_parallelogram_encoder.h 6KB
draco_compression_options.h 6KB
attributes_encoder.h 6KB
mesh_prediction_scheme_tex_coords_portable_encoder.h 6KB
mesh_prediction_scheme_tex_coords_portable_decoder.h 6KB
rans_symbol_decoder.h 6KB
valence_cache.h 5KB
gltf_encoder.h 5KB
draco_index_type.h 5KB
sequential_attribute_encoder.h 5KB
mesh_prediction_scheme_multi_parallelogram_decoder.h 5KB
ply_reader.h 5KB
mesh_edgebreaker_shared.h 5KB
compression_shared.h 5KB
encoder_buffer.h 5KB
obj_decoder.h 5KB
mesh_edgebreaker_traversal_encoder.h 5KB
triangle_soup_mesh_builder.h 5KB
prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h 5KB
options.h 5KB
gltf_utils.h 5KB
mesh_prediction_scheme_parallelogram_encoder.h 5KB
tiny_gltf_utils.h 5KB
mesh_prediction_scheme_geometric_normal_predictor_area.h 5KB
float_points_tree_decoder.h 5KB
encode_base.h 5KB
mesh_edgebreaker_traversal_predictive_decoder.h 5KB
float_points_tree_encoder.h 5KB
mesh_utils.h 5KB
animation.h 5KB
geometry_metadata.h 5KB
sequential_attribute_encoders_controller.h 5KB
mesh_splitter.h 4KB
mesh_traversal_sequencer.h 4KB
node_animation_data.h 4KB
prediction_scheme_normal_octahedron_decoding_transform.h 4KB
prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h 4KB
point_cloud_decoder.h 4KB
mesh_group.h 4KB
shannon_entropy.h 4KB
prediction_scheme_normal_octahedron_encoding_transform.h 4KB
prediction_scheme_wrap_transform_base.h 4KB
bit_utils.h 4KB
mesh_io.h 4KB
keyframe_animation.h 4KB
attribute_quantization_transform.h 4KB
macros.h 4KB
scene_node.h 4KB
共 239 条
- 1
- 2
- 3
资源评论
GIS小虫
- 粉丝: 82
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功