GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
texture_transform.h
Go to the documentation of this file.
1// Copyright 2021 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_TEXTURE_TEXTURE_TRANSFORM_H_
16#define DRACO_TEXTURE_TEXTURE_TRANSFORM_H_
17
19
20#ifdef DRACO_TRANSCODER_SUPPORTED
21#include <array>
22#include <memory>
23
24namespace draco {
25
26// Class to hold texture transformations. Parameters are based on the glTF 2.0
27// extension KHR_texture_transform:
28// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
29class TextureTransform {
30 public:
31 TextureTransform();
32
33 // Resets the values back to defaults.
34 void Clear();
35
36 // Copies texture transform data from the |src| texture transform to this
37 // texture transform.
38 void Copy(const TextureTransform &src);
39
40 // Returns true if |tt| contains all default values.
41 static bool IsDefault(const TextureTransform &tt);
42
43 bool IsOffsetSet() const;
44 bool IsRotationSet() const;
45 bool IsScaleSet() const;
46 bool IsTexCoordSet() const;
47
48 void set_offset(const std::array<double, 2> &offset) { offset_ = offset; }
49 const std::array<double, 2> &offset() const { return offset_; }
50 void set_scale(const std::array<double, 2> &scale) { scale_ = scale; }
51 const std::array<double, 2> &scale() const { return scale_; }
52
53 void set_rotation(double rotation) { rotation_ = rotation; }
54 double rotation() const { return rotation_; }
55 void set_tex_coord(int tex_coord) { tex_coord_ = tex_coord; }
56 int tex_coord() const { return tex_coord_; }
57
58 bool operator==(const TextureTransform &tt) const;
59
60 private:
61 static std::array<double, 2> GetDefaultOffset() { return {0.0, 0.0}; }
62 static float GetDefaultRotation() { return 0.0; }
63 static std::array<double, 2> GetDefaultScale() { return {0.0, 0.0}; }
64 static int GetDefaultTexCoord() { return -1; }
65
66 std::array<double, 2> offset_;
67 double rotation_;
68 std::array<double, 2> scale_;
69 int tex_coord_;
70};
71
72} // namespace draco
73
74#endif // DRACO_TRANSCODER_SUPPORTED
75#endif // DRACO_TEXTURE_TEXTURE_TRANSFORM_H_
tag src
Definition meshpage.php:1786
Definition attribute_octahedron_transform.cc:21
bool operator==(const short_alloc< T, N, A1 > &x, const short_alloc< U, M, A2 > &y) noexcept
Definition short_alloc.hpp:145