2010-04-21 07:48:36 -07:00
|
|
|
#ifndef UTILS_H
|
|
|
|
#define UTILS_H
|
|
|
|
|
2019-03-07 08:12:09 -08:00
|
|
|
#include <irrlicht/irrlicht.h>
|
2010-04-21 07:48:36 -07:00
|
|
|
|
2019-05-16 09:33:53 -07:00
|
|
|
#include <ctime>
|
|
|
|
#include <string>
|
|
|
|
|
2019-04-11 01:31:04 -07:00
|
|
|
class Utility {
|
2010-04-23 00:28:59 -07:00
|
|
|
public:
|
2019-04-11 01:31:04 -07:00
|
|
|
static void dumpVectorToConsole(const irr::core::vector3df& vector);
|
|
|
|
static void dumpMeshInfoToConsole(irr::scene::IAnimatedMeshSceneNode* node);
|
|
|
|
static std::wstring parentOfPath(const std::wstring& path);
|
|
|
|
static std::wstring basename(const std::wstring& path);
|
|
|
|
static std::wstring withoutExtension(const std::wstring& path);
|
|
|
|
static std::wstring extensionOf(const std::wstring& path);
|
|
|
|
static std::wstring delimiter(const std::wstring& path);
|
|
|
|
static bool isFile(const std::string& name);
|
|
|
|
static bool isFile(const std::wstring& name);
|
2019-04-03 07:35:27 -07:00
|
|
|
static std::string toString(irr::f32 val);
|
2019-04-11 01:31:04 -07:00
|
|
|
static std::string toString(const std::wstring& name);
|
|
|
|
static std::string toLower(const std::string& s);
|
|
|
|
static std::wstring toLower(const std::wstring& s);
|
2019-04-03 07:35:27 -07:00
|
|
|
static std::wstring toWstring(irr::f32 val);
|
|
|
|
static std::wstring toWstring(int val);
|
2019-04-11 01:31:04 -07:00
|
|
|
static std::wstring toWstring(const std::string& str);
|
2019-05-16 09:33:53 -07:00
|
|
|
static std::string dateTimePathString(const time_t& rawtime);
|
|
|
|
static std::string dateTimeNowPathString();
|
2019-04-03 07:35:27 -07:00
|
|
|
static irr::f32 toF32(std::wstring val);
|
2019-04-19 12:29:30 -07:00
|
|
|
static irr::f32 distance(const irr::core::vector3df& start, const irr::core::vector3df& end);
|
2019-03-10 06:55:31 -07:00
|
|
|
// compiler doesn't like template function when class is not a template--instantiate immediately
|
|
|
|
// see http://processors.wiki.ti.com/index.php/C%2B%2B_Template_Instantiation_Issues
|
|
|
|
template <typename T>
|
2019-04-11 01:31:04 -07:00
|
|
|
static bool equalsApprox(T f1, T f2)
|
|
|
|
{
|
|
|
|
return abs(f2 - f1) < .00000001; // TODO: kEpsilon? (see also <https://en.wikipedia.org/wiki/Machine_epsilon#How_to_determine_machine_epsilon>)
|
2019-03-10 06:55:31 -07:00
|
|
|
}
|
2010-04-23 00:28:59 -07:00
|
|
|
};
|
2010-04-21 07:48:36 -07:00
|
|
|
|
|
|
|
#endif // UTILS_H
|