// Copyright 2016 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_ATTRIBUTES_GEOMETRY_ATTRIBUTE_H_
#define DRACO_ATTRIBUTES_GEOMETRY_ATTRIBUTE_H_
#include <algorithm>
#include <array>
#include <cmath>
#include <limits>
#include "draco/attributes/geometry_indices.h"
#include "draco/core/data_buffer.h"
#include "draco/core/hash_utils.h"
#include "draco/draco_features.h"
#ifdef DRACO_TRANSCODER_SUPPORTED
#include "draco/core/status.h"
#endif
namespace draco {
// The class provides access to a specific attribute which is stored in a
// DataBuffer, such as normals or coordinates. However, the GeometryAttribute
// class does not own the buffer and the buffer itself may store other data
// unrelated to this attribute (such as data for other attributes in which case
// we can have multiple GeometryAttributes accessing one buffer). Typically,
// all attributes for a point (or corner, face) are stored in one block, which
// is advantageous in terms of memory access. The length of the entire block is
// given by the byte_stride, the position where the attribute starts is given by
// the byte_offset, the actual number of bytes that the attribute occupies is
// given by the data_type and the number of components.
class GeometryAttribute {
public:
// Supported attribute types.
enum Type {
INVALID = -1,
// Named attributes start here. The difference between named and generic
// attributes is that for named attributes we know their purpose and we
// can apply some special methods when dealing with them (e.g. during
// encoding).
POSITION = 0,
NORMAL,
COLOR,
TEX_COORD,
// A special id used to mark attributes that are not assigned to any known
// predefined use case. Such attributes are often used for a shader specific
// data.
GENERIC,
#ifdef DRACO_TRANSCODER_SUPPORTED
// TODO(ostava): Adding a new attribute would be bit-stream change for GLTF.
// Older decoders wouldn't know what to do with this attribute type. This
// should be open-sourced only when we are ready to increase our bit-stream
// version.
TANGENT,
MATERIAL,
JOINTS,
WEIGHTS,
#endif
// Total number of different attribute types.
// Always keep behind all named attributes.
NAMED_ATTRIBUTES_COUNT,
};
GeometryAttribute();
// Initializes and enables the attribute.
void Init(Type attribute_type, DataBuffer *buffer, uint8_t num_components,
DataType data_type, bool normalized, int64_t byte_stride,
int64_t byte_offset);
bool IsValid() const { return buffer_ != nullptr; }
// Copies data from the source attribute to the this attribute.
// This attribute must have a valid buffer allocated otherwise the operation
// is going to fail and return false.
bool CopyFrom(const GeometryAttribute &src_att);
// Function for getting a attribute value with a specific format.
// Unsafe. Caller must ensure the accessed memory is valid.
// T is the attribute data type.
// att_components_t is the number of attribute components.
template <typename T, int att_components_t>
std::array<T, att_components_t> GetValue(
AttributeValueIndex att_index) const {
// Byte address of the attribute index.
const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value();
std::array<T, att_components_t> out;
buffer_->Read(byte_pos, &(out[0]), sizeof(out));
return out;
}
// Function for getting a attribute value with a specific format.
// T is the attribute data type.
// att_components_t is the number of attribute components.
template <typename T, int att_components_t>
bool GetValue(AttributeValueIndex att_index,
std::array<T, att_components_t> *out) const {
// Byte address of the attribute index.
const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value();
// Check we are not reading past end of data.
if (byte_pos + sizeof(*out) > buffer_->data_size()) {
return false;
}
buffer_->Read(byte_pos, &((*out)[0]), sizeof(*out));
return true;
}
// Returns the byte position of the attribute entry in the data buffer.
inline int64_t GetBytePos(AttributeValueIndex att_index) const {
return byte_offset_ + byte_stride_ * att_index.value();
}
inline const uint8_t *GetAddress(AttributeValueIndex att_index) const {
const int64_t byte_pos = GetBytePos(att_index);
return buffer_->data() + byte_pos;
}
inline uint8_t *GetAddress(AttributeValueIndex att_index) {
const int64_t byte_pos = GetBytePos(att_index);
return buffer_->data() + byte_pos;
}
inline bool IsAddressValid(const uint8_t *address) const {
return ((buffer_->data() + buffer_->data_size()) > address);
}
// Fills out_data with the raw value of the requested attribute entry.
// out_data must be at least byte_stride_ long.
void GetValue(AttributeValueIndex att_index, void *out_data) const {
const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value();
buffer_->Read(byte_pos, out_data, byte_stride_);
}
// Sets a value of an attribute entry. The input value must be allocated to
// cover all components of a single attribute entry.
void SetAttributeValue(AttributeValueIndex entry_index, const void *value) {
const int64_t byte_pos = entry_index.value() * byte_stride();
buffer_->Write(byte_pos, value, byte_stride());
}
#ifdef DRACO_TRANSCODER_SUPPORTED
// Sets a value of an attribute entry. The input |value| must have
// |input_num_components| entries and it will be automatically converted to
// the internal format used by the geometry attribute. If the conversion is
// not possible, an error status will be returned.
template <typename InputT>
Status ConvertAndSetAttributeValue(AttributeValueIndex avi,
int input_num_components,
const InputT *value);
#endif
// DEPRECATED: Use
// ConvertValue(AttributeValueIndex att_id,
// int out_num_components,
// OutT *out_val);
//
// Function for conversion of a attribute to a specific output format.
// OutT is the desired data type of the attribute.
// out_att_components_t is the number of components of the output format.
// Returns false when the conversion failed.
template <typename OutT, int out_att_components_t>
bool ConvertValue(AttributeValueIndex att_id, OutT *out_val) const {
return ConvertValue(att_id, out_att_components_t, out_val);
}
// Function for conversion of a attribute to a specific output format.
// |out_val| needs to be able to store |out_num_components| values.
// OutT is the desired data type of the attribute.
// Returns false when the conversion failed.
template <typename OutT>
bool ConvertValue(AttributeValueIndex att_id, int8_t out_num_components,
OutT *out_val) const {
if (out_val == nullptr) {
return false;
}
switch (data_type_) {
case DT_INT8:
return ConvertTypedValue<int8_t, OutT>(att_id, out_num_components,
out_val);
case DT_UINT8:
return ConvertTypedValue<uint8_t, OutT>(att_id, out_num_components,
没有合适的资源?快使用搜索试试~ 我知道了~
DRACO编译完成的库(win10+MSVC2019-64)
共418个文件
h:402个
cmake:8个
exe:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 119 浏览量
2024-03-26
14:13:07
上传
评论
收藏 7.41MB 7Z 举报
温馨提示
https://blog.csdn.net/aggs1990/article/details/137043654 DRACO编译完成的库(win10+MSVC2019_64) CSDN审核可能较慢,如无法下载,可以过段时间再回来看下 仅供相关爱好者交流使用,请于下载24小时内删除
资源推荐
资源详情
资源评论
收起资源包目录
DRACO编译完成的库(win10+MSVC2019-64) (418个子文件)
draco-targets.cmake 4KB
draco-targets.cmake 4KB
draco-config-version.cmake 2KB
draco-config-version.cmake 2KB
draco-config.cmake 970B
draco-config.cmake 970B
draco-targets-release.cmake 848B
draco-targets-debug.cmake 838B
draco_encoder.exe 2.5MB
draco_decoder.exe 1.67MB
draco_encoder.exe 494KB
draco_decoder.exe 252KB
geometry_attribute.h 22KB
geometry_attribute.h 22KB
mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h 18KB
mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h 18KB
ans.h 16KB
ans.h 16KB
mesh.h 15KB
mesh.h 15KB
mesh_prediction_scheme_tex_coords_decoder.h 15KB
mesh_prediction_scheme_tex_coords_decoder.h 15KB
corner_table.h 14KB
corner_table.h 14KB
dynamic_integer_points_kd_tree_encoder.h 14KB
dynamic_integer_points_kd_tree_encoder.h 14KB
normal_compression_utils.h 14KB
normal_compression_utils.h 14KB
mesh_prediction_scheme_tex_coords_encoder.h 13KB
mesh_prediction_scheme_tex_coords_encoder.h 13KB
dynamic_integer_points_kd_tree_decoder.h 12KB
dynamic_integer_points_kd_tree_decoder.h 12KB
mesh_prediction_scheme_tex_coords_portable_predictor.h 12KB
mesh_prediction_scheme_tex_coords_portable_predictor.h 12KB
point_cloud.h 11KB
point_cloud.h 11KB
rans_symbol_encoder.h 11KB
rans_symbol_encoder.h 11KB
point_d_vector.h 10KB
point_d_vector.h 10KB
corner_table_iterators.h 10KB
corner_table_iterators.h 10KB
mesh_stripifier.h 10KB
mesh_stripifier.h 10KB
draco_options.h 10KB
draco_options.h 10KB
prediction_scheme_decoder_factory.h 10KB
prediction_scheme_decoder_factory.h 10KB
vector_d.h 10KB
vector_d.h 10KB
mesh_edgebreaker_decoder_impl.h 10KB
mesh_edgebreaker_decoder_impl.h 10KB
mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h 9KB
mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h 9KB
mesh_edgebreaker_traversal_valence_encoder.h 9KB
mesh_edgebreaker_traversal_valence_encoder.h 9KB
mesh_edgebreaker_encoder_impl.h 9KB
mesh_edgebreaker_encoder_impl.h 9KB
max_prediction_degree_traverser.h 9KB
max_prediction_degree_traverser.h 9KB
point_attribute.h 8KB
point_attribute.h 8KB
mesh_attribute_corner_table.h 8KB
mesh_attribute_corner_table.h 8KB
property_table.h 8KB
property_table.h 8KB
mesh_prediction_scheme_geometric_normal_encoder.h 8KB
mesh_prediction_scheme_geometric_normal_encoder.h 8KB
metadata.h 7KB
metadata.h 7KB
expert_encode.h 7KB
expert_encode.h 7KB
mesh_edgebreaker_traversal_valence_decoder.h 7KB
mesh_edgebreaker_traversal_valence_decoder.h 7KB
mesh_edgebreaker_traversal_predictive_encoder.h 7KB
mesh_edgebreaker_traversal_predictive_encoder.h 7KB
prediction_scheme_encoder_factory.h 7KB
prediction_scheme_encoder_factory.h 7KB
decoder_buffer.h 7KB
decoder_buffer.h 7KB
mesh_edgebreaker_traversal_decoder.h 7KB
mesh_edgebreaker_traversal_decoder.h 7KB
depth_first_traverser.h 7KB
depth_first_traverser.h 7KB
encode.h 7KB
encode.h 7KB
mesh_prediction_scheme_geometric_normal_decoder.h 6KB
mesh_prediction_scheme_geometric_normal_decoder.h 6KB
point_cloud_encoder.h 6KB
point_cloud_encoder.h 6KB
mesh_prediction_scheme_multi_parallelogram_encoder.h 6KB
mesh_prediction_scheme_multi_parallelogram_encoder.h 6KB
draco_compression_options.h 6KB
draco_compression_options.h 6KB
attributes_encoder.h 6KB
attributes_encoder.h 6KB
mesh_prediction_scheme_tex_coords_portable_encoder.h 6KB
mesh_prediction_scheme_tex_coords_portable_encoder.h 6KB
rans_symbol_decoder.h 6KB
rans_symbol_decoder.h 6KB
共 418 条
- 1
- 2
- 3
- 4
- 5
资源评论
꧁白杨树下꧂
- 粉丝: 688
- 资源: 192
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于opencv的人脸识别考勤系统python源码+数据.zip
- IOT安装包 iotech-iot-1.5-dev-1.5.0-amd64.deb
- 基于物品的协同过滤算法(推荐视频)工具类(见仁见智)
- 21信管2班 武学芹组+独立样本T检验数据分析案例.zip
- demo_ccms_global_open_wlan.py
- 小程序项目源码-小契约(交友互动小程序).zip
- 小程序项目源码-健身房预约课程小程序.zip
- 小程序项目源码-wechat-app-xiaoyima-master小程序.zip
- 小程序项目源码-滑动选项卡小程序.zip
- 小程序项目源码-学习Demo影视推荐、音乐播放、地图小程序.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功