19 #if !defined(__NORI_COMMON_H)
20 #define __NORI_COMMON_H
24 #pragma warning(disable : 4127 4702 4100 4515 4800 4146 4512)
25 #define WIN32_LEAN_AND_MEAN
35 #include <ImathPlatform.h>
36 #include <tinyformat.h>
39 #define NORI_NAMESPACE_BEGIN namespace nori {
40 #define NORI_NAMESPACE_END }
42 #if defined(__NORI_APPLE__NORI_)
43 #define PLATFORM_MACOS
44 #elif defined(__NORI_linux__NORI_)
45 #define PLATFORM_LINUX
47 #define PLATFORM_WINDOWS
56 #define M_PI 3.14159265358979323846f
57 #define INV_PI 0.31830988618379067154f
58 #define INV_TWOPI 0.15915494309189533577f
59 #define INV_FOURPI 0.07957747154594766788f
60 #define SQRT_TWO 1.41421356237309504880f
61 #define INV_SQRT_TWO 0.70710678118654752440f
64 namespace filesystem {
72 template <
typename Scalar,
int Dimension>
struct TVector;
73 template <
typename Scalar,
int Dimension>
struct TPoint;
74 template <
typename Po
int,
typename Vector>
struct TRay;
144 typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> MatrixXf;
145 typedef Eigen::Matrix<uint32_t, Eigen::Dynamic, Eigen::Dynamic> MatrixXu;
151 template <
typename... Args>
NoriException(
const char *fmt,
const Args &... args)
152 : std::runtime_error(tfm::format(fmt, args...)) { }
156 extern int getCoreCount();
159 extern std::string indent(
const std::string &
string,
int amount = 2);
162 extern std::string toLower(
const std::string &value);
165 extern bool toBool(
const std::string &str);
168 extern int toInt(
const std::string &str);
171 extern unsigned int toUInt(
const std::string &str);
174 extern float toFloat(
const std::string &str);
177 extern size_t vectorSize(
const std::string &str);
180 extern Eigen::Vector2f toVector2f(
const std::string &str);
182 extern Eigen::Vector3f toVector3f(
const std::string &str);
185 extern std::vector<std::string> tokenize(
const std::string &s,
const std::string &delim =
", ",
bool includeEmpty =
false);
188 extern bool endsWith(
const std::string &value,
const std::string &ending);
191 extern std::string timeString(
double time,
bool precise =
false);
194 extern std::string memString(
size_t size,
bool precise =
false);
204 inline float radToDeg(
float value) {
return value * (180.0f / M_PI); }
207 inline float degToRad(
float value) {
return value * (M_PI / 180.0f); }
209 #if !defined(_GNU_SOURCE)
211 inline void sincosf(
float theta,
float *_sin,
float *_cos) {
218 inline float clamp(
float value,
float min,
float max) {
221 else if (value > max)
227 inline int clamp(
int value,
int min,
int max) {
230 else if (value > max)
236 inline float lerp(
float t,
float v1,
float v2) {
237 return ((
float) 1 - t) * v1 + t * v2;
241 inline int mod(
int a,
int b) {
243 return (r < 0) ? r+b : r;
247 extern Vector3f sphericalDirection(
float theta,
float phi);
265 extern float fresnel(
float cosThetaI,
float extIOR,
float intIOR);
273 extern filesystem::resolver *getFileResolver();
Superclass of all bidirectional scattering distribution functions.
Stores a RGB high dynamic-range bitmap.
Spiraling block generator.
Generic camera interface.
Superclass of all emitters.
Weighted pixel storage for a rectangular subregion of an image.
Abstract integrator (i.e. a rendering technique)
Simple exception class, which stores a human-readable error description.
NoriException(const char *fmt, const Args &... args)
Variadic template constructor to support printf-style arguments.
Factory for Nori objects.
Base class of all objects.
Generic radially symmetric image reconstruction filter.
Abstract sample generator.
Main scene data structure.
Superclass of all shapes.
Data record for conveniently querying and sampling the direct illumination technique implemented by a...
Generic n-dimensional bounding box data structure.
Generic N-dimensional point data structure based on Eigen::Matrix.
Simple n-dimensional ray segment data structure.
Generic N-dimensional vector data structure based on Eigen::Matrix.