Botcraft 1.21.4
Loading...
Searching...
No Matches
Transformation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <string>
5#include <memory>
6
7namespace Botcraft
8{
9 namespace Renderer
10 {
11 struct IMatrix;
12
14 {
15 public:
16 virtual void ApplyTransformation(IMatrix& m) const = 0;
17 virtual const std::string Print() const = 0;
18 };
19
21 {
22 public:
23 Translation(const float x_ = 0.0f, const float y_ = 0.0f, const float z_ = 0.0f);
24 virtual void ApplyTransformation(IMatrix& m) const override;
25
26 const virtual std::string Print() const override;
27
28 float x;
29 float y;
30 float z;
31 };
32
33 class Rotation : public Transformation
34 {
35 public:
36 Rotation(const float axis_x_ = 0.0f, const float axis_y_ = 0.0f, const float axis_z_ = 0.0f, const float deg_angle_ = 0.0f);
37 virtual void ApplyTransformation(IMatrix& m) const override;
38
39 const virtual std::string Print() const override;
40
41 float axis_x;
42 float axis_y;
43 float axis_z;
44 float deg_angle;
45 };
46
47 class Scale : public Transformation
48 {
49 public:
50 Scale(const float axis_x_ = 1.0f, const float axis_y_ = 1.0f, const float axis_z_ = 1.0f);
51 virtual void ApplyTransformation(IMatrix& m) const override;
52
53 const virtual std::string Print() const override;
54
55 float axis_x;
56 float axis_y;
57 float axis_z;
58 };
59
60 typedef std::shared_ptr<Transformation> TransformationPtr;
61 typedef std::shared_ptr<Scale> ScalePtr;
62
64 {
65 std::vector<ScalePtr> scales;
66 std::vector<TransformationPtr> rotations;
67 std::vector<TransformationPtr> translations;
68
69 //Textures transformations
70 //Steps of 90° (0, 90°, 180°, 270°)
71 unsigned char rotation = 0;
72
73 //In 1/16th of the image
74 float offset_x1 = 0;
75 float offset_y1 = 0;
76 float offset_x2 = 16;
77 float offset_y2 = 16;
78 };
79 } // Renderer
80} // Botcraft
virtual void ApplyTransformation(IMatrix &m) const override
virtual const std::string Print() const override
virtual void ApplyTransformation(IMatrix &m) const override
virtual const std::string Print() const override
virtual const std::string Print() const =0
virtual void ApplyTransformation(IMatrix &m) const =0
virtual void ApplyTransformation(IMatrix &m) const override
virtual const std::string Print() const override
std::shared_ptr< Scale > ScalePtr
std::shared_ptr< Transformation > TransformationPtr
std::vector< TransformationPtr > rotations
std::vector< TransformationPtr > translations