|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
A vector 3D class used for defining coordinates in the MMORoom virtual world. More...
#include <Vec3D.h>
Public Member Functions | |
| bool | isFloat () const |
| Detects whether this object uses floating point numbers or integers. | |
| int32_t | intX () const |
| Gets the X coordinate as integer; a float coordinate is truncated towards zero. | |
| int32_t | intY () const |
| Gets the Y coordinate as integer; a float coordinate is truncated towards zero. | |
| int32_t | intZ () const |
| Gets the Z coordinate as integer; a float coordinate is truncated towards zero. | |
| float | floatX () const |
| Gets the X coordinate as float. | |
| float | floatY () const |
| Gets the Y coordinate as float. | |
| float | floatZ () const |
| Gets the Z coordinate as float. | |
| SFSVector3 | toVector3 () const |
| Converts this coordinate to an SFSVector3, the float-only vector carrying the geometry operations (length, dot, cross, lerp, ...). | |
Static Public Member Functions | |
| static Vec3D | ofInt (int32_t x, int32_t y, int32_t z) |
| Builds an integer-based 3D coordinate. | |
| static Vec3D | ofInt (int32_t x, int32_t y) |
| Builds an integer-based 2D coordinate, with Z set to 0. | |
| static Vec3D | ofFloat (float x, float y, float z) |
| Builds a float-based 3D coordinate. | |
| static Vec3D | ofFloat (float x, float y) |
| Builds a float-based 2D coordinate, with Z set to 0. | |
| static Vec3D | fromVector3 (const SFSVector3 &vec) |
| Builds a float-based coordinate out of an SFSVector3. | |
A vector 3D class used for defining coordinates in the MMORoom virtual world.
The class supports either integers or floats, in 2D or 3D coordinates systems (in 2D, Z == 0).
The numeric mode is not a display detail: it decides how the coordinates travel on the wire (as an int array or as a float array) and the server picks the coordinates system of an MMORoom from the mode of the Room's area of interest. Two vectors holding the same numbers in different modes are therefore not equal.
Instances are immutable and are built through the ofInt() / ofFloat() factories rather than through constructors: in C++ the two would be ambiguous overloads for the most natural call of all, Vec3D(1.5, 2.5, 3.5).
auto aoi = entities::Vec3D::ofInt(50, 50); // 2D, integer coordinates auto pos = entities::Vec3D::ofFloat(1.5, 2.5, 0.0); // 3D, float coordinates
|
inline |
Detects whether this object uses floating point numbers or integers.
|
inline |
Converts this coordinate to an SFSVector3, the float-only vector carrying the geometry operations (length, dot, cross, lerp, ...).
An integer coordinate is widened to float.