GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
mesh_prediction_scheme_geometric_normal_predictor_base.h
Go to the documentation of this file.
1// Copyright 2017 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_
17
18#include <math.h>
19
24#include "draco/core/vector_d.h"
27
28namespace draco {
29
30// Base class for geometric normal predictors using position attribute.
31template <typename DataTypeT, class TransformT, class MeshDataT>
33 protected:
35 : pos_attribute_(nullptr),
37 mesh_data_(md) {}
39
40 public:
41 void SetPositionAttribute(const PointAttribute &position_attribute) {
42 pos_attribute_ = &position_attribute;
43 }
46 }
47 bool IsInitialized() const {
48 if (pos_attribute_ == nullptr) {
49 return false;
50 }
51 if (entry_to_point_id_map_ == nullptr) {
52 return false;
53 }
54 return true;
55 }
56
61
62 protected:
65 const auto point_id = entry_to_point_id_map_[data_id];
66 const auto pos_val_id = pos_attribute_->mapped_index(point_id);
68 pos_attribute_->ConvertValue(pos_val_id, &pos[0]);
69 return pos;
70 }
73 const auto corner_table = mesh_data_.corner_table();
74 const auto vert_id = corner_table->Vertex(ci).value();
75 const auto data_id = mesh_data_.vertex_to_data_map()->at(vert_id);
76 return GetPositionForDataId(data_id);
77 }
79 const DataTypeT *data) const {
81 const int data_offset = data_id * 2;
82 return VectorD<int32_t, 2>(data[data_offset], data[data_offset + 1]);
83 }
84 // Computes predicted octahedral coordinates on a given corner.
85 virtual void ComputePredictedValue(CornerIndex corner_id,
86 DataTypeT *prediction) = 0;
87
90 MeshDataT mesh_data_;
92};
93
94} // namespace draco
95
96#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_
MeshDataT mesh_data_
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:90
void SetPositionAttribute(const PointAttribute &position_attribute)
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:41
VectorD< int64_t, 3 > GetPositionForCorner(CornerIndex ci) const
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:71
NormalPredictionMode normal_prediction_mode_
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:91
const PointAttribute * pos_attribute_
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:88
VectorD< int64_t, 3 > GetPositionForDataId(int data_id) const
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:63
bool IsInitialized() const
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:47
virtual NormalPredictionMode GetNormalPredictionMode() const
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:58
virtual ~MeshPredictionSchemeGeometricNormalPredictorBase()
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:38
void SetEntryToPointIdMap(const PointIndex *map)
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:44
VectorD< int32_t, 2 > GetOctahedralCoordForDataId(int data_id, const DataTypeT *data) const
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:78
virtual bool SetNormalPredictionMode(NormalPredictionMode mode)=0
const PointIndex * entry_to_point_id_map_
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:89
MeshPredictionSchemeGeometricNormalPredictorBase(const MeshDataT &md)
Definition mesh_prediction_scheme_geometric_normal_predictor_base.h:34
virtual void ComputePredictedValue(CornerIndex corner_id, DataTypeT *prediction)=0
Definition point_attribute.h:33
Definition vector_d.h:30
#define DRACO_DCHECK(x)
Definition macros.h:80
lazy data
Definition meshpage.php:1583
Definition attribute_octahedron_transform.cc:21
NormalPredictionMode
Definition compression_shared.h:138
CornerIndex CornerIndex
Definition mesh_edgebreaker_encoder_impl.cc:35
Definition GameApi_pl.cc:29382