ScummVM API documentation
te_vector3f32.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_VECTOR3F32_H
23 #define TETRAEDGE_TE_TE_VECTOR3F32_H
24 
25 #include "common/str.h"
26 #include "math/vector2d.h"
27 #include "tetraedge/te/te_vector2s32.h"
28 
29 namespace Tetraedge {
30 
31 class TeQuaternion;
32 
33 class TeVector3f32 : public Math::Vector3d {
34 
35 public:
36  TeVector3f32() { }; // Note: vector3d constructor sets 0, 0, 0
37  TeVector3f32(float x_, float y_, float z_) {
38  set(x_, y_, z_);
39  }
40  TeVector3f32(const TeVector3f32 &other) : Math::Vector3d(other) {}
41  TeVector3f32(const Math::Vector3d &v) : Math::Vector3d(v) {}
42  TeVector3f32 &operator=(const TeVector3f32 &other) {
43  Math::Vector3d::operator=(other);
44  return *this;
45  }
46 
47  //TeVector3f32 operator*(const TeVector3f32 &other) const {
48  // return TeVector3f32(x() * other.x(), y() * other.y(), z() * other.z());
49  //}
50 
51  explicit TeVector3f32(const TeVector2s32 &vec2d) {
52  set(vec2d._x, vec2d._y, 0.0);
53  }
54 
55  static void deserialize(Common::ReadStream &stream, TeVector3f32 &dest) {
56  dest.x() = stream.readFloatLE();
57  dest.y() = stream.readFloatLE();
58  dest.z() = stream.readFloatLE();
59  }
60 
61  static void serialize(Common::WriteStream &stream, const TeVector3f32 &src) {
62  stream.writeFloatLE(src.x());
63  stream.writeFloatLE(src.y());
64  stream.writeFloatLE(src.z());
65  }
66 
67  float squaredLength() const {
68  return (x() * x() + y() * y() + z() * z());
69  }
70 
72  bool parse(const Common::String &val);
73 
74  Common::String dump() const {
75  return Common::String::format("Vec3f(%.02f %.02f %.02f)", x(), y(), z());
76  }
77 
78  void rotate(const TeQuaternion &rot);
79 
80  TeVector3f32 operator-() { return TeVector3f32(-x(), -y(), -z()); }
81 };
82 
83 TeVector3f32 operator^(const TeVector3f32 &left, const TeVector3f32 &right);
84 
85 } // end namespace Tetraedge
86 
87 #endif // TETRAEDGE_TE_TE_VECTOR3F32_H
Definition: str.h:59
Definition: detection.h:27
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: stream.h:77
Definition: te_quaternion.h:32
FORCEINLINE void writeFloatLE(float value)
Definition: stream.h:233
FORCEINLINE float readFloatLE()
Definition: stream.h:615
Definition: te_vector2s32.h:31
Definition: te_vector3f32.h:33
Definition: stream.h:385
bool parse(const Common::String &val)