Big skeletal animation update
Added MeshInfos demo Added MD5Mesh/MD5Anim loader support Added Node class Fixed ResourceParams not being exported Added support for skeletal animation (Animation/Mesh/Joint/SkeletalMesh/Skeleton) Meshes are now only stored with VertexStruct_XYZ_Normal_UV_Tangent type Moved Sequence declaration to Sequence.hpp -Animation: Renamed Create to Create[Keyframe|Skeletal] -AxisAlignedBox: Added Contains method Added GetCorner method Added GetCube method Added Transform method -Cube/Rect: Added GetPosition method Added GetSize method (Almost) Fixed ExtendTo method Fixed GetCenter method -File: Added GetDirectory static function Added GetPath method Renamed GetDirectoryPath method to GetDirectory -Math module: Fixed constructor/methods taking a non-const array GetNormal/Normalize methods now takes an optionnal integer pointer (returning length) Made all classes default constructor trivial Inverse, MakeIdentity, MakeZero, Normalize, Set methods now returns reference to object -Matrix4: Modified methods to avoid copies Removed COW (Too much overhead) Removed Concatenate[Affine] static function -Mesh: Renamed Create to Create[Keyframe|Skeletal|Static] Renamed Skin to Material -MeshParams: No longer takes declaration argument Renamed loadAnimations to animated Storage default to BufferStorage_Hardware if supported and BufferStorage_Software otherwise -OpenGL: Added glGetBooleanv function Added glIsEnabled function -Quaternion: Added ComputeW method Added Conjugate method -Renderer: Added IsEnabled static function Fixed GetLineWidth function not being static Removed SetVertexDeclaration -RenderWindow: Made CopyTo[Image|Texture] method constant -Resource Fixed RemoveResourceListener crash -ResourceLoader: Loaders are now used in a LIFO context -Stream: Renamed GetLine method to ReadLine -String: Fixed Simplified -Utility module Added configuration define for strict resource parsing -VertexBuffer Now takes a VertexDeclaration pointer -VertexDeclaration No longer throw an error when getting a non-existing element Former-commit-id: f7358c1231d6af48b799d2f24f077a001e16785b
This commit is contained in:
@@ -26,9 +26,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_AUDIO_HPP
|
||||
#define NAZARA_GLOBAL_AUDIO_HPP
|
||||
|
||||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Audio/Sound.hpp>
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_AUDIO_HPP
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_CORE_HPP
|
||||
#define NAZARA_GLOBAL_CORE_HPP
|
||||
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
@@ -61,3 +64,5 @@
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/Tuple.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_CORE_HPP
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -27,39 +27,36 @@
|
||||
#ifndef NAZARA_CONFIG_CORE_HPP
|
||||
#define NAZARA_CONFIG_CORE_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Appelle exit dès qu'une assertion est invalide
|
||||
// Appelle exit dès qu'une assertion est invalide
|
||||
#define NAZARA_CORE_EXIT_ON_ASSERT_FAILURE 1
|
||||
|
||||
// Teste les assertions
|
||||
#define NAZARA_CORE_ENABLE_ASSERTS 0
|
||||
|
||||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
#define NAZARA_CORE_FILE_BUFFERSIZE 4096
|
||||
|
||||
// Le moteur doit-il incorporer les Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
// Incorpore la table Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_CORE_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Standardise les séparateurs des dossiers selon le système d'exploitation courant (Léger coût à l'exécution)
|
||||
#define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1
|
||||
|
||||
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
|
||||
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
|
||||
#define NAZARA_CORE_REAL_PRECISION 6
|
||||
|
||||
// Duplique la sortie du log sur le flux de sortie standard (cout)
|
||||
#define NAZARA_CORE_DUPLICATE_TO_COUT 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_CORE_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW)
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
|
||||
@@ -71,14 +68,14 @@
|
||||
#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW)
|
||||
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
||||
|
||||
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
|
||||
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
|
||||
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
|
||||
|
||||
// Optimise certaines parties du code avec certaines avancées venues de Windows Vista (Casse la compatibilité XP mais n'affecte pas les autres OS)
|
||||
// Optimise l'implémentation Windows avec certaines avancées de Windows vista (Casse la compatibilité XP)
|
||||
#define NAZARA_CORE_WINDOWS_VISTA 0
|
||||
|
||||
/*
|
||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
||||
*/
|
||||
|
||||
|
||||
@@ -67,11 +67,11 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
nzUInt64 GetCursorPos() const;
|
||||
NzString GetDirectoryPath() const;
|
||||
NzString GetFilePath() const;
|
||||
NzString GetDirectory() const;
|
||||
NzString GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
NzString GetPath() const;
|
||||
nzUInt64 GetSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
@@ -99,12 +99,13 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||
static bool Delete(const NzString& filePath);
|
||||
static bool Exists(const NzString& filePath);
|
||||
static time_t GetCreationTime(const NzString& filePath);
|
||||
static NzString GetDirectory(const NzString& filePath);
|
||||
static time_t GetLastAccessTime(const NzString& filePath);
|
||||
static time_t GetLastWriteTime(const NzString& filePath);
|
||||
static NzHashDigest GetHash(const NzString& filePath, nzHash hash);
|
||||
static NzHashDigest GetHash(const NzString& filePath, NzHashImpl* hash);
|
||||
static nzUInt64 GetSize(const NzString& filePath);
|
||||
static bool IsAbsolute(const NzString& path);
|
||||
static bool IsAbsolute(const NzString& filePath);
|
||||
static NzString NormalizePath(const NzString& filePath);
|
||||
static NzString NormalizeSeparators(const NzString& filePath);
|
||||
static bool Rename(const NzString& sourcePath, const NzString& targetPath);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
class NzString;
|
||||
|
||||
class NAZARA_API NzInputStream : public NzStream
|
||||
{
|
||||
public:
|
||||
@@ -19,10 +17,10 @@ class NAZARA_API NzInputStream : public NzStream
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
virtual NzString GetLine(unsigned int lineSize = 0);
|
||||
virtual nzUInt64 GetSize() const = 0;
|
||||
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
virtual NzString ReadLine(unsigned int lineSize = 0);
|
||||
};
|
||||
|
||||
#endif // NAZARA_INPUTSTREAM_HPP
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_RESOURCELOADER_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
|
||||
@@ -28,7 +29,7 @@ class NzResourceLoader
|
||||
static void UnregisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadfunc);
|
||||
|
||||
using Loader = std::tuple<std::set<NzString>, CheckFunction, LoadFunction>;
|
||||
using LoaderList = std::set<Loader>;
|
||||
using LoaderList = std::list<Loader>;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/ResourceLoader.inl>
|
||||
|
||||
@@ -124,7 +124,7 @@ void NzResourceLoader<Type, Parameters>::RegisterLoader(const NzString& fileExte
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.insert(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
Type::s_loaders.push_front(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
@@ -136,7 +136,7 @@ void NzResourceLoader<Type, Parameters>::UnregisterLoader(const NzString& fileEx
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.erase(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
Type::s_loaders.remove(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
class NAZARA_API NzStream
|
||||
{
|
||||
@@ -17,6 +18,8 @@ class NAZARA_API NzStream
|
||||
virtual ~NzStream();
|
||||
|
||||
virtual nzUInt64 GetCursorPos() const = 0;
|
||||
virtual NzString GetDirectory() const;
|
||||
virtual NzString GetPath() const;
|
||||
unsigned int GetStreamOptions() const;
|
||||
|
||||
virtual bool SetCursorPos(nzUInt64 offset) = 0;
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_MATH_HPP
|
||||
#define NAZARA_GLOBAL_MATH_HPP
|
||||
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
@@ -37,3 +40,5 @@
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_MATH_HPP
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592653589793238462643
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
@@ -73,7 +72,7 @@ unsigned int NzGetNumberLength(signed char number)
|
||||
unsigned int NzGetNumberLength(unsigned char number)
|
||||
{
|
||||
// Le standard définit le char comme étant codé sur un octet
|
||||
static_assert(sizeof(number) == 1, "Signed char must be one byte-sized");
|
||||
static_assert(sizeof(number) == 1, "Unsigned char must be one byte-sized");
|
||||
|
||||
if (number >= 100)
|
||||
return 3;
|
||||
@@ -204,7 +203,7 @@ NzString NzNumberToString(long long number, nzUInt8 radix)
|
||||
negative = false;
|
||||
|
||||
NzString str;
|
||||
str.Reserve(NzGetNumberLength(number));
|
||||
str.Reserve(NzGetNumberLength(number)); // Prends en compte le signe négatif
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -33,17 +33,10 @@
|
||||
// Définit le radian comme l'unité utilisée pour les angles
|
||||
#define NAZARA_MATH_ANGLE_RADIAN 0
|
||||
|
||||
// Optimise les opérations entre matrices affines (Demande plusieurs comparaisons pour déterminer si une matrice est affine)
|
||||
// Optimise automatiquement les opérations entre matrices affines (Demande plusieurs comparaisons pour déterminer si une matrice est affine)
|
||||
#define NAZARA_MATH_MATRIX4_CHECK_AFFINE 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_MATH_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_MATH_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_MATRIX3 1 // NzMatrix3 (COW)
|
||||
#define NAZARA_THREADSAFETY_MATRIX4 1 // NzMatrix4 (COW)
|
||||
|
||||
#endif // NAZARA_CONFIG_MATH_HPP
|
||||
|
||||
@@ -15,7 +15,7 @@ template<typename T>
|
||||
class NzCube
|
||||
{
|
||||
public:
|
||||
NzCube();
|
||||
NzCube() = default;
|
||||
NzCube(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzCube(const T cube[6]);
|
||||
NzCube(const NzRect<T>& rect);
|
||||
@@ -28,22 +28,24 @@ class NzCube
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
bool Contains(const NzCube& cube) const;
|
||||
|
||||
void ExtendTo(const NzVector3<T>& point);
|
||||
void ExtendTo(const NzCube& cube);
|
||||
NzCube& ExtendTo(const NzVector3<T>& point);
|
||||
NzCube& ExtendTo(const NzCube& cube);
|
||||
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetSize() const;
|
||||
|
||||
bool Intersect(const NzCube& cube, NzCube* intersection = nullptr) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void MakeZero();
|
||||
NzCube& MakeZero();
|
||||
|
||||
void Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
void Set(const T cube[6]);
|
||||
void Set(const NzRect<T>& rect);
|
||||
void Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> void Set(const NzCube<U>& cube);
|
||||
NzCube& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzCube& Set(const T cube[6]);
|
||||
NzCube& Set(const NzRect<T>& rect);
|
||||
NzCube& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzCube& Set(const NzCube<U>& cube);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
|
||||
@@ -8,23 +8,12 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
Set(X, Y, Z, Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const T vec[6])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const NzRect<T>& rect)
|
||||
{
|
||||
@@ -37,6 +26,12 @@ NzCube<T>::NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
Set(vec1, vec2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const T vec[6])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzCube<T>::NzCube(const NzCube<U>& cube)
|
||||
@@ -66,42 +61,58 @@ bool NzCube<T>::Contains(const NzCube<T>& cube) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||
{
|
||||
x = std::min(x, point.x);
|
||||
y = std::min(y, point.y);
|
||||
z = std::min(z, point.z);
|
||||
width = std::max(x+width, point.x)-x;
|
||||
height = std::max(y+height, point.x)-y;
|
||||
depth = std::max(z+depth, point.x)-z;
|
||||
width = std::max(x + width, point.x) - x;
|
||||
height = std::max(y + height, point.y) - y;
|
||||
depth = std::max(z + depth, point.z) - z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::ExtendTo(const NzCube& cube)
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzCube& cube)
|
||||
{
|
||||
x = std::min(x, cube.x);
|
||||
y = std::min(y, cube.y);
|
||||
z = std::min(y, cube.z);
|
||||
width = std::max(x+width, cube.x+cube.width)-x;
|
||||
height = std::max(x+height, cube.y+cube.height)-y;
|
||||
depth = std::max(x+depth, cube.z+cube.depth)-z;
|
||||
z = std::min(z, cube.z);
|
||||
width = std::max(x + width, cube.x + cube.width) - x;
|
||||
height = std::max(y + height, cube.y + cube.height) - y;
|
||||
depth = std::max(z + depth, cube.z + cube.depth) - z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetCenter() const
|
||||
{
|
||||
return NzVector3<T>((x+width)/F(2.0), (y+height)/F(2.0), (z+depth)/F(2.0));
|
||||
return NzVector3<T>(x + width/F(2.0), y + height/F(2.0), z + depth/F(2.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetPosition() const
|
||||
{
|
||||
return NzVector3<T>(x, y, z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetSize() const
|
||||
{
|
||||
return NzVector3<T>(width, height, depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::Intersect(const NzCube& cube, NzCube* intersection) const
|
||||
{
|
||||
T left = std::max(x, cube.x);
|
||||
T right = std::min(x+width, cube.x+cube.width);
|
||||
T right = std::min(x + width, cube.x + cube.width);
|
||||
T top = std::max(y, cube.y);
|
||||
T bottom = std::min(y+height, cube.y+cube.height);
|
||||
T bottom = std::min(y + height, cube.y + cube.height);
|
||||
T up = std::max(z, cube.z);
|
||||
T down = std::min(z+depth, cube.z+cube.depth);
|
||||
T down = std::min(z + depth, cube.z + cube.depth);
|
||||
|
||||
if (left < right && top < bottom && up < down)
|
||||
{
|
||||
@@ -110,9 +121,9 @@ bool NzCube<T>::Intersect(const NzCube& cube, NzCube* intersection) const
|
||||
intersection->x = left;
|
||||
intersection->y = top;
|
||||
intersection->z = up;
|
||||
intersection->width = right-left;
|
||||
intersection->height = bottom-top;
|
||||
intersection->depth = down-up;
|
||||
intersection->width = right - left;
|
||||
intersection->height = bottom - top;
|
||||
intersection->depth = down - up;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -128,7 +139,7 @@ bool NzCube<T>::IsValid() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::MakeZero()
|
||||
NzCube<T>& NzCube<T>::MakeZero()
|
||||
{
|
||||
x = F(0.0);
|
||||
y = F(0.0);
|
||||
@@ -136,10 +147,12 @@ void NzCube<T>::MakeZero()
|
||||
width = F(0.0);
|
||||
height = F(0.0);
|
||||
depth = F(0.0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
NzCube<T>& NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
@@ -147,10 +160,12 @@ void NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
width = Width;
|
||||
height = Height;
|
||||
depth = Depth;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::Set(const T cube[6])
|
||||
NzCube<T>& NzCube<T>::Set(const T cube[6])
|
||||
{
|
||||
x = cube[0];
|
||||
y = cube[1];
|
||||
@@ -158,21 +173,25 @@ void NzCube<T>::Set(const T cube[6])
|
||||
width = cube[3];
|
||||
height = cube[4];
|
||||
depth = cube[5];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::Set(const NzRect<T>& rect)
|
||||
NzCube<T>& NzCube<T>::Set(const NzRect<T>& rect)
|
||||
{
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
z = 0;
|
||||
z = F(0.0);
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
depth = 1;
|
||||
depth = F(1.0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
NzCube<T>& NzCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
x = std::min(vec1.x, vec2.x);
|
||||
y = std::min(vec1.y, vec2.y);
|
||||
@@ -180,11 +199,13 @@ void NzCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
width = (vec2.x > vec1.x) ? vec2.x-vec1.x : vec1.x-vec2.x;
|
||||
height = (vec2.y > vec1.y) ? vec2.y-vec1.y : vec1.y-vec2.y;
|
||||
depth = (vec2.z > vec1.z) ? vec2.z-vec1.z : vec1.z-vec2.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzCube<T>::Set(const NzCube<U>& cube)
|
||||
NzCube<T>& NzCube<T>::Set(const NzCube<U>& cube)
|
||||
{
|
||||
x = F(cube.x);
|
||||
y = F(cube.y);
|
||||
@@ -192,6 +213,8 @@ void NzCube<T>::Set(const NzCube<U>& cube)
|
||||
width = F(cube.width);
|
||||
height = F(cube.height);
|
||||
depth = F(cube.depth);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -215,8 +238,9 @@ T& NzCube<T>::operator[](unsigned int i)
|
||||
if (i >= 6)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 6)";
|
||||
ss << "Index out of range: (" << i << " >= 6)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -231,8 +255,9 @@ T NzCube<T>::operator[](unsigned int i) const
|
||||
if (i >= 6)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 6)";
|
||||
ss << "Index out of range: (" << i << " >= 6)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
template<typename T> class NzEulerAngles
|
||||
{
|
||||
public:
|
||||
NzEulerAngles();
|
||||
NzEulerAngles() = default;
|
||||
NzEulerAngles(T P, T Y, T R);
|
||||
NzEulerAngles(T angles[3]);
|
||||
NzEulerAngles(const T angles[3]);
|
||||
//NzEulerAngles(const NzMatrix3<T>& mat);
|
||||
NzEulerAngles(const NzQuaternion<T>& quat);
|
||||
template<typename U> explicit NzEulerAngles(const NzEulerAngles<U>& angles);
|
||||
@@ -28,7 +28,7 @@ template<typename T> class NzEulerAngles
|
||||
void Normalize();
|
||||
|
||||
void Set(T P, T Y, T R);
|
||||
void Set(T angles[3]);
|
||||
void Set(const T angles[3]);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion<T>& quat);
|
||||
|
||||
@@ -11,11 +11,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles(T P, T Y, T R)
|
||||
{
|
||||
@@ -23,7 +18,7 @@ NzEulerAngles<T>::NzEulerAngles(T P, T Y, T R)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles(T angles[3])
|
||||
NzEulerAngles<T>::NzEulerAngles(const T angles[3])
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
@@ -64,7 +59,7 @@ void NzEulerAngles<T>::Set(T P, T Y, T R)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Set(T angles[3])
|
||||
void NzEulerAngles<T>::Set(const T angles[3])
|
||||
{
|
||||
pitch = angles[0];
|
||||
yaw = angles[1];
|
||||
@@ -97,9 +92,9 @@ void NzEulerAngles<T>::Set(const NzEulerAngles<U>& angles)
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzEulerAngles<T>::ToQuaternion() const
|
||||
{
|
||||
NzQuaternion<T> rotX(pitch, NzVector3<T>(F(1.0), F(0.0), F(0.0)));
|
||||
NzQuaternion<T> rotY(yaw, NzVector3<T>(F(0.0), F(1.0), F(0.0)));
|
||||
NzQuaternion<T> rotZ(roll, NzVector3<T>(F(0.0), F(0.0), F(1.0)));
|
||||
NzQuaternion<T> rotX(pitch, NzVector3<T>::UnitX());
|
||||
NzQuaternion<T> rotY(yaw, NzVector3<T>::UnitY());
|
||||
NzQuaternion<T> rotZ(roll, NzVector3<T>::UnitZ());
|
||||
|
||||
return rotY * rotX * rotZ;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
#if NAZARA_MATH_THREADSAFE && NAZARA_THREADSAFETY_MATRIX4
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzQuaternion;
|
||||
template<typename T> class NzVector2;
|
||||
@@ -26,31 +20,30 @@ template<typename T>
|
||||
class NzMatrix4
|
||||
{
|
||||
public:
|
||||
NzMatrix4();
|
||||
NzMatrix4() = default;
|
||||
NzMatrix4(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
NzMatrix4(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
NzMatrix4(const T matrix[16]);
|
||||
template<typename U> explicit NzMatrix4(const NzMatrix4<U>& matrix);
|
||||
NzMatrix4(const NzMatrix4& matrix);
|
||||
NzMatrix4(NzMatrix4&& matrix) noexcept;
|
||||
~NzMatrix4();
|
||||
NzMatrix4(const NzMatrix4& matrix) = default;
|
||||
~NzMatrix4() = default;
|
||||
|
||||
NzMatrix4& ApplyScale(const NzVector3<T>& scale);
|
||||
|
||||
NzMatrix4 Concatenate(const NzMatrix4& matrix) const;
|
||||
NzMatrix4 ConcatenateAffine(const NzMatrix4& matrix) const;
|
||||
NzMatrix4& Concatenate(const NzMatrix4& matrix);
|
||||
NzMatrix4& ConcatenateAffine(const NzMatrix4& matrix);
|
||||
|
||||
T GetDeterminant() const;
|
||||
NzMatrix4 GetInverse(bool* succeeded = nullptr) const;
|
||||
NzMatrix4 GetInverseAffine(bool* succeeded = nullptr) const;
|
||||
bool GetInverse(NzMatrix4* dest) const;
|
||||
bool GetInverseAffine(NzMatrix4* dest) const;
|
||||
NzQuaternion<T> GetRotation() const;
|
||||
//NzMatrix3 GetRotationMatrix() const;
|
||||
NzVector3<T> GetScale() const;
|
||||
NzVector3<T> GetTranslation() const;
|
||||
NzMatrix4 GetTransposed() const;
|
||||
void GetTransposed(NzMatrix4* dest) const;
|
||||
|
||||
bool HasNegativeScale() const;
|
||||
bool HasScale() const;
|
||||
@@ -59,7 +52,6 @@ class NzMatrix4
|
||||
NzMatrix4& InverseAffine(bool* succeeded = nullptr);
|
||||
|
||||
bool IsAffine() const;
|
||||
bool IsDefined() const;
|
||||
|
||||
NzMatrix4& MakeIdentity();
|
||||
NzMatrix4& MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
@@ -72,9 +64,9 @@ class NzMatrix4
|
||||
NzMatrix4& MakeZero();
|
||||
|
||||
NzMatrix4& Set(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
NzMatrix4& Set(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
NzMatrix4& Set(const NzMatrix4& matrix);
|
||||
@@ -92,8 +84,6 @@ class NzMatrix4
|
||||
|
||||
NzMatrix4& Transpose();
|
||||
|
||||
NzMatrix4& Undefine();
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
@@ -102,8 +92,7 @@ class NzMatrix4
|
||||
T& operator()(unsigned int x, unsigned int y);
|
||||
const T& operator()(unsigned int x, unsigned int y) const;
|
||||
|
||||
NzMatrix4& operator=(const NzMatrix4& matrix);
|
||||
NzMatrix4& operator=(NzMatrix4&& matrix) noexcept;
|
||||
NzMatrix4& operator=(const NzMatrix4& matrix) = default;
|
||||
|
||||
NzMatrix4 operator*(const NzMatrix4& matrix) const;
|
||||
NzVector2<T> operator*(const NzVector2<T>& vector) const;
|
||||
@@ -117,8 +106,6 @@ class NzMatrix4
|
||||
bool operator==(const NzMatrix4& mat) const;
|
||||
bool operator!=(const NzMatrix4& mat) const;
|
||||
|
||||
static NzMatrix4 Concatenate(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 ConcatenateAffine(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 Identity();
|
||||
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||
@@ -129,22 +116,10 @@ class NzMatrix4
|
||||
static NzMatrix4 Transform(const NzVector3<T>& translation, const NzVector3<T>& scale, const NzQuaternion<T>& rotation);
|
||||
static NzMatrix4 Zero();
|
||||
|
||||
struct SharedMatrix
|
||||
{
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
void ReleaseMatrix();
|
||||
|
||||
SharedMatrix* m_sharedMatrix = nullptr;
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4<T>& matrix);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,9 @@ template<typename T> class NzVector3;
|
||||
template<typename T> class NzQuaternion
|
||||
{
|
||||
public:
|
||||
NzQuaternion();
|
||||
NzQuaternion() = default;
|
||||
NzQuaternion(T W, T X, T Y, T Z);
|
||||
NzQuaternion(T quat[4]);
|
||||
NzQuaternion(const T quat[4]);
|
||||
NzQuaternion(T angle, const NzVector3<T>& axis);
|
||||
NzQuaternion(const NzEulerAngles<T>& angles);
|
||||
//NzQuaternion(const NzMatrix3<T>& mat);
|
||||
@@ -25,28 +25,31 @@ template<typename T> class NzQuaternion
|
||||
NzQuaternion(const NzQuaternion& quat) = default;
|
||||
~NzQuaternion() = default;
|
||||
|
||||
NzQuaternion& ComputeW();
|
||||
NzQuaternion& Conjugate();
|
||||
|
||||
T DotProduct(const NzQuaternion& vec) const;
|
||||
|
||||
NzQuaternion GetConjugate() const;
|
||||
NzQuaternion GetInverse() const;
|
||||
NzQuaternion GetNormal() const;
|
||||
NzQuaternion GetNormal(T* length = nullptr) const;
|
||||
|
||||
void Inverse();
|
||||
NzQuaternion& Inverse();
|
||||
|
||||
void MakeIdentity();
|
||||
void MakeZero();
|
||||
NzQuaternion& MakeIdentity();
|
||||
NzQuaternion& MakeZero();
|
||||
|
||||
T Magnitude() const;
|
||||
|
||||
T Normalize();
|
||||
NzQuaternion& Normalize(T* length = nullptr);
|
||||
|
||||
void Set(T W, T X, T Y, T Z);
|
||||
void Set(T quat[4]);
|
||||
void Set(T angle, const NzVector3<T>& normalizedAxis);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion& quat);
|
||||
template<typename U> void Set(const NzQuaternion<U>& quat);
|
||||
NzQuaternion& Set(T W, T X, T Y, T Z);
|
||||
NzQuaternion& Set(const T quat[4]);
|
||||
NzQuaternion& Set(T angle, const NzVector3<T>& normalizedAxis);
|
||||
NzQuaternion& Set(const NzEulerAngles<T>& angles);
|
||||
//NzQuaternion& Set(const NzMatrix3<T>& mat);
|
||||
NzQuaternion& Set(const NzQuaternion& quat);
|
||||
template<typename U> NzQuaternion& Set(const NzQuaternion<U>& quat);
|
||||
|
||||
T SquaredMagnitude() const;
|
||||
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T W, T X, T Y, T Z)
|
||||
{
|
||||
@@ -24,7 +19,7 @@ NzQuaternion<T>::NzQuaternion(T W, T X, T Y, T Z)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T quat[4])
|
||||
NzQuaternion<T>::NzQuaternion(const T quat[4])
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
@@ -54,6 +49,29 @@ NzQuaternion<T>::NzQuaternion(const NzQuaternion<U>& quat)
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::ComputeW()
|
||||
{
|
||||
T t = F(1.0) - SquaredMagnitude();
|
||||
|
||||
if (t < F(0.0))
|
||||
w = F(0.0);
|
||||
else
|
||||
w = -std::sqrt(t);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::Conjugate()
|
||||
{
|
||||
x = -x;
|
||||
y = -y;
|
||||
z = -z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::DotProduct(const NzQuaternion& quat) const
|
||||
{
|
||||
@@ -63,7 +81,10 @@ T NzQuaternion<T>::DotProduct(const NzQuaternion& quat) const
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetConjugate() const
|
||||
{
|
||||
return NzQuaternion(w, -x, -y, -z);
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Conjugate();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -76,16 +97,16 @@ NzQuaternion<T> NzQuaternion<T>::GetInverse() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetNormal() const
|
||||
NzQuaternion<T> NzQuaternion<T>::GetNormal(T* length) const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Normalize();
|
||||
quat.Normalize(length);
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Inverse()
|
||||
NzQuaternion<T>& NzQuaternion<T>::Inverse()
|
||||
{
|
||||
T norm = SquaredMagnitude();
|
||||
if (norm > F(0.0))
|
||||
@@ -97,18 +118,20 @@ void NzQuaternion<T>::Inverse()
|
||||
y *= -invNorm;
|
||||
z *= -invNorm;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeIdentity()
|
||||
NzQuaternion<T>& NzQuaternion<T>::MakeIdentity()
|
||||
{
|
||||
Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
||||
return Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeZero()
|
||||
NzQuaternion<T>& NzQuaternion<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
return Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -118,49 +141,48 @@ T NzQuaternion<T>::Magnitude() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::Normalize()
|
||||
NzQuaternion<T>& NzQuaternion<T>::Normalize(T* length)
|
||||
{
|
||||
T squaredMagnitude = SquaredMagnitude();
|
||||
T norm = std::sqrt(SquaredMagnitude());
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
// Inutile de vérifier si la magnitude au carrée est négative (Elle ne peut pas l'être)
|
||||
if (!NzNumberEquals(squaredMagnitude, F(1.0)))
|
||||
{
|
||||
T norm = std::sqrt(squaredMagnitude);
|
||||
T invNorm = F(1.0) / norm;
|
||||
w *= invNorm;
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
z *= invNorm;
|
||||
|
||||
w *= invNorm;
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
z *= invNorm;
|
||||
if (length)
|
||||
*length = norm;
|
||||
|
||||
return norm;
|
||||
}
|
||||
else
|
||||
return F(1.0); // Le quaternion est déjà normalisé
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T W, T X, T Y, T Z)
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(T W, T X, T Y, T Z)
|
||||
{
|
||||
w = W;
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T quat[4])
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(const T quat[4])
|
||||
{
|
||||
w = quat[0];
|
||||
x = quat[1];
|
||||
y = quat[2];
|
||||
z = quat[3];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T angle, const NzVector3<T>& axis)
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
angle /= F(2.0);
|
||||
angle *= F(0.5);
|
||||
|
||||
#if !NAZARA_MATH_ANGLE_RADIAN
|
||||
angle = NzDegreeToRadian(angle);
|
||||
@@ -175,32 +197,36 @@ void NzQuaternion<T>::Set(T angle, const NzVector3<T>& axis)
|
||||
y = normalizedAxis.y * sinAngle;
|
||||
z = normalizedAxis.z * sinAngle;
|
||||
|
||||
Normalize();
|
||||
return Normalize();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzEulerAngles<T>& angles)
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles.ToQuaternion());
|
||||
return Set(angles.ToQuaternion());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
|
||||
{
|
||||
w = static_cast<T>(quat.w);
|
||||
x = static_cast<T>(quat.x);
|
||||
y = static_cast<T>(quat.y);
|
||||
z = static_cast<T>(quat.z);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion& quat)
|
||||
NzQuaternion<T>& NzQuaternion<T>::Set(const NzQuaternion& quat)
|
||||
{
|
||||
w = quat.w;
|
||||
x = quat.x;
|
||||
y = quat.y;
|
||||
z = quat.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -242,27 +268,31 @@ NzQuaternion<T>::operator NzString() const
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator=(const NzQuaternion& quat)
|
||||
{
|
||||
Set(quat);
|
||||
|
||||
return *this;
|
||||
return Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator+(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w + quat.w,
|
||||
x + quat.x,
|
||||
y + quat.y,
|
||||
z + quat.z);
|
||||
NzQuaternion result;
|
||||
result.w = w + quat.w;
|
||||
result.x = x + quat.x;
|
||||
result.y = y + quat.y;
|
||||
result.z = z + quat.z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w*quat.w - x*quat.x - y*quat.y - z*quat.z,
|
||||
w*quat.x + x*quat.w + y*quat.z - z*quat.y,
|
||||
w*quat.y + y*quat.w + z*quat.x - x*quat.z,
|
||||
w*quat.z + z*quat.w + x*quat.y - y*quat.x);
|
||||
NzQuaternion result;
|
||||
result.w = w*quat.w - x*quat.x - y*quat.y - z*quat.z;
|
||||
result.x = w*quat.x + x*quat.w + y*quat.z - z*quat.y;
|
||||
result.y = w*quat.y + y*quat.w + z*quat.x - x*quat.z;
|
||||
result.z = w*quat.z + z*quat.w + x*quat.y - y*quat.x;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -14,7 +14,7 @@ template<typename T>
|
||||
class NzRect
|
||||
{
|
||||
public:
|
||||
NzRect();
|
||||
NzRect() = default;
|
||||
NzRect(T X, T Y, T Width, T Height);
|
||||
NzRect(const T rect[4]);
|
||||
NzRect(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
|
||||
@@ -26,21 +26,23 @@ class NzRect
|
||||
bool Contains(const NzVector2<T>& point) const;
|
||||
bool Contains(const NzRect& rect) const;
|
||||
|
||||
void ExtendTo(const NzVector2<T>& point);
|
||||
void ExtendTo(const NzRect& rect);
|
||||
NzRect& ExtendTo(const NzVector2<T>& point);
|
||||
NzRect& ExtendTo(const NzRect& rect);
|
||||
|
||||
NzVector2<T> GetCenter() const;
|
||||
NzVector2<T> GetPosition() const;
|
||||
NzVector2<T> GetSize() const;
|
||||
|
||||
bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void MakeZero();
|
||||
NzRect& MakeZero();
|
||||
|
||||
void Set(T X, T Y, T Width, T Height);
|
||||
void Set(const T rect[4]);
|
||||
void Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
|
||||
template<typename U> void Set(const NzRect<U>& rect);
|
||||
NzRect& Set(T X, T Y, T Width, T Height);
|
||||
NzRect& Set(const T rect[4]);
|
||||
NzRect& Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
|
||||
template<typename U> NzRect& Set(const NzRect<U>& rect);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::NzRect()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::NzRect(T X, T Y, T Width, T Height)
|
||||
{
|
||||
@@ -59,27 +54,43 @@ bool NzRect<T>::Contains(const NzRect<T>& rect) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
||||
NzRect<T>& NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
||||
{
|
||||
x = std::min(x, point.x);
|
||||
y = std::min(y, point.y);
|
||||
width = std::max(x+width, point.x)-x;
|
||||
height = std::max(y+height, point.y)-y;
|
||||
width = std::max(x + width, point.x) - x;
|
||||
height = std::max(y + height, point.y) - y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::ExtendTo(const NzRect& rect)
|
||||
NzRect<T>& NzRect<T>::ExtendTo(const NzRect& rect)
|
||||
{
|
||||
x = std::min(x, rect.x);
|
||||
y = std::min(y, rect.y);
|
||||
width = std::max(x+width, rect.x+rect.width)-x;
|
||||
height = std::max(x+height, rect.y+rect.height)-y;
|
||||
width = std::max(x + width, rect.x + rect.width) - x;
|
||||
height = std::max(x + height, rect.y + rect.height) - y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetCenter() const
|
||||
{
|
||||
return NzVector2<T>((x+width)/F(2.0), (y+height)/F(2.0));
|
||||
return NzVector2<T>(x + width/F(2.0), y + height/F(2.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetPosition() const
|
||||
{
|
||||
return NzVector2<T>(x, y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetSize() const
|
||||
{
|
||||
return NzVector2<T>(width, height);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -113,49 +124,59 @@ bool NzRect<T>::IsValid() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::MakeZero()
|
||||
NzRect<T>& NzRect<T>::MakeZero()
|
||||
{
|
||||
x = F(0.0);
|
||||
y = F(0.0);
|
||||
width = F(0.0);
|
||||
height = F(0.0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::Set(T X, T Y, T Width, T Height)
|
||||
NzRect<T>& NzRect<T>::Set(T X, T Y, T Width, T Height)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
width = Width;
|
||||
height = Height;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::Set(const T rect[4])
|
||||
NzRect<T>& NzRect<T>::Set(const T rect[4])
|
||||
{
|
||||
x = rect[0];
|
||||
y = rect[1];
|
||||
width = rect[2];
|
||||
height = rect[3];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2)
|
||||
NzRect<T>& NzRect<T>::Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2)
|
||||
{
|
||||
x = std::min(vec1.x, vec2.x);
|
||||
y = std::min(vec1.y, vec2.y);
|
||||
width = (vec2.x > vec1.x) ? vec2.x-vec1.x : vec1.x-vec2.x;
|
||||
height = (vec2.y > vec1.y) ? vec2.y-vec1.y : vec1.y-vec2.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzRect<T>::Set(const NzRect<U>& rect)
|
||||
NzRect<T>& NzRect<T>::Set(const NzRect<U>& rect)
|
||||
{
|
||||
x = F(rect.x);
|
||||
y = F(rect.y);
|
||||
width = F(rect.width);
|
||||
height = F(rect.height);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -179,8 +200,9 @@ T& NzRect<T>::operator[](unsigned int i)
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
ss << "Index out of range: (" << i << " >= 4)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -195,8 +217,9 @@ T NzRect<T>::operator[](unsigned int i) const
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
ss << "Index out of range: (" << i << " >= 4)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector2
|
||||
template<typename T>
|
||||
class NzVector2
|
||||
{
|
||||
public:
|
||||
NzVector2();
|
||||
NzVector2() = default;
|
||||
NzVector2(T X, T Y);
|
||||
explicit NzVector2(T scale);
|
||||
NzVector2(T vec[2]);
|
||||
NzVector2(const T vec[2]);
|
||||
template<typename U> explicit NzVector2(const NzVector2<U>& vec);
|
||||
NzVector2(const NzVector2& vec) = default;
|
||||
~NzVector2() = default;
|
||||
@@ -32,19 +33,19 @@ template<typename T> class NzVector2
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeZero();
|
||||
NzVector2& MakeUnitX();
|
||||
NzVector2& MakeUnitY();
|
||||
NzVector2& MakeZero();
|
||||
|
||||
void Maximize(const NzVector2& vec);
|
||||
void Minimize(const NzVector2& vec);
|
||||
NzVector2& Maximize(const NzVector2& vec);
|
||||
NzVector2& Minimize(const NzVector2& vec);
|
||||
|
||||
void Normalize();
|
||||
NzVector2& Normalize(T* length = nullptr);
|
||||
|
||||
void Set(T X, T Y);
|
||||
void Set(T scale);
|
||||
void Set(T vec[2]);
|
||||
template<typename U> void Set(const NzVector2<U>& vec);
|
||||
NzVector2& Set(T X, T Y);
|
||||
NzVector2& Set(T scale);
|
||||
NzVector2& Set(const T vec[2]);
|
||||
template<typename U> NzVector2& Set(const NzVector2<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector2& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T X, T Y)
|
||||
{
|
||||
@@ -30,7 +25,7 @@ NzVector2<T>::NzVector2(T scale)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T vec[2])
|
||||
NzVector2<T>::NzVector2(const T vec[2])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
@@ -100,83 +95,96 @@ float NzVector2<T>::Lengthf() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitX()
|
||||
NzVector2<T>& NzVector2<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitY()
|
||||
NzVector2<T>& NzVector2<T>::MakeUnitY()
|
||||
{
|
||||
Set(F(0.0), F(1.0));
|
||||
return Set(F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeZero()
|
||||
NzVector2<T>& NzVector2<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0));
|
||||
return Set(F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Maximize(const NzVector2& vec)
|
||||
NzVector2<T>& NzVector2<T>::Maximize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Minimize(const NzVector2& vec)
|
||||
NzVector2<T>& NzVector2<T>::Minimize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Normalize()
|
||||
NzVector2<T>& NzVector2<T>::Normalize(T* length)
|
||||
{
|
||||
T squaredLength = SquaredLength();
|
||||
T norm = std::sqrt(SquaredLength());
|
||||
T invNorm = F(1.0) / length;
|
||||
|
||||
if (squaredLength-F(1.0) > std::numeric_limits<T>::epsilon())
|
||||
{
|
||||
T length = std::sqrt(squaredLength);
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
|
||||
x /= length;
|
||||
y /= length;
|
||||
}
|
||||
if (length)
|
||||
*length = norm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T X, T Y)
|
||||
NzVector2<T>& NzVector2<T>::Set(T X, T Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T scale)
|
||||
NzVector2<T>& NzVector2<T>::Set(T scale)
|
||||
{
|
||||
x = scale;
|
||||
y = scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T vec[2])
|
||||
NzVector2<T>& NzVector2<T>::Set(const T vec[2])
|
||||
{
|
||||
std::memcpy(&x, vec, 2*sizeof(T));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzVector2<T>::Set(const NzVector2<U>& vec)
|
||||
NzVector2<T>& NzVector2<T>::Set(const NzVector2<U>& vec)
|
||||
{
|
||||
x = F(vec.x);
|
||||
y = F(vec.y);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -224,8 +232,9 @@ T& NzVector2<T>::operator[](unsigned int i)
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
ss << "Index out of range: (" << i << " >= 2)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -240,8 +249,9 @@ T NzVector2<T>::operator[](unsigned int i) const
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
ss << "Index out of range: (" << i << " >= 2)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -291,10 +301,10 @@ NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -307,10 +317,10 @@ NzVector2<T> NzVector2<T>::operator/(T scale) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -359,10 +369,10 @@ NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -378,10 +388,10 @@ NzVector2<T>& NzVector2<T>::operator/=(T scale)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -479,10 +489,10 @@ NzVector2<T> operator/(T scale, const NzVector2<T>& vec)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
template<typename T> class NzVector3
|
||||
{
|
||||
public:
|
||||
NzVector3();
|
||||
NzVector3() = default;
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
NzVector3(const T vec[3]);
|
||||
NzVector3(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||
NzVector3(const NzVector3& vec) = default;
|
||||
@@ -36,24 +36,24 @@ template<typename T> class NzVector3
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeForward();
|
||||
void MakeLeft();
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeUp();
|
||||
void MakeZero();
|
||||
NzVector3& MakeForward();
|
||||
NzVector3& MakeLeft();
|
||||
NzVector3& MakeUnitX();
|
||||
NzVector3& MakeUnitY();
|
||||
NzVector3& MakeUnitZ();
|
||||
NzVector3& MakeUp();
|
||||
NzVector3& MakeZero();
|
||||
|
||||
void Maximize(const NzVector3& vec);
|
||||
void Minimize(const NzVector3& vec);
|
||||
NzVector3& Maximize(const NzVector3& vec);
|
||||
NzVector3& Minimize(const NzVector3& vec);
|
||||
|
||||
void Normalize();
|
||||
NzVector3& Normalize(T* length = nullptr);
|
||||
|
||||
void Set(T X, T Y, T Z);
|
||||
void Set(T scale);
|
||||
void Set(T vec[3]);
|
||||
void Set(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> void Set(const NzVector3<U>& vec);
|
||||
NzVector3& Set(T X, T Y, T Z);
|
||||
NzVector3& Set(T scale);
|
||||
NzVector3& Set(const T vec[3]);
|
||||
NzVector3& Set(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> NzVector3& Set(const NzVector3<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector3& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(T X, T Y, T Z)
|
||||
{
|
||||
@@ -30,7 +25,7 @@ NzVector3<T>::NzVector3(T scale)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(T vec[3])
|
||||
NzVector3<T>::NzVector3(const T vec[3])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
@@ -112,49 +107,49 @@ float NzVector3<T>::Lengthf() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeForward()
|
||||
NzVector3<T>& NzVector3<T>::MakeForward()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(-1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeLeft()
|
||||
NzVector3<T>& NzVector3<T>::MakeLeft()
|
||||
{
|
||||
Set(F(-1.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeUnitX()
|
||||
NzVector3<T>& NzVector3<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0), F(0.0));
|
||||
return Set(F(1.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeUnitY()
|
||||
NzVector3<T>& NzVector3<T>::MakeUnitY()
|
||||
{
|
||||
Set(F(0.0), F(1.0), F(0.0));
|
||||
return Set(F(0.0), F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeUnitZ()
|
||||
NzVector3<T>& NzVector3<T>::MakeUnitZ()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(1.0));
|
||||
return Set(F(0.0), F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeUp()
|
||||
NzVector3<T>& NzVector3<T>::MakeUp()
|
||||
{
|
||||
Set(F(0.0), F(1.0), F(0.0));
|
||||
return Set(F(0.0), F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeZero()
|
||||
NzVector3<T>& NzVector3<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(0.0));
|
||||
return Set(F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Maximize(const NzVector3& vec)
|
||||
NzVector3<T>& NzVector3<T>::Maximize(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
@@ -164,10 +159,12 @@ void NzVector3<T>::Maximize(const NzVector3& vec)
|
||||
|
||||
if (vec.z > z)
|
||||
z = vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Minimize(const NzVector3& vec)
|
||||
NzVector3<T>& NzVector3<T>::Minimize(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
@@ -177,60 +174,73 @@ void NzVector3<T>::Minimize(const NzVector3& vec)
|
||||
|
||||
if (vec.z < z)
|
||||
z = vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Normalize()
|
||||
NzVector3<T>& NzVector3<T>::Normalize(T* length)
|
||||
{
|
||||
T squaredLength = SquaredLength();
|
||||
T norm = std::sqrt(SquaredLength());
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
if (!NzNumberEquals(squaredLength, F(1.0)))
|
||||
{
|
||||
T invLength = F(1.0) / std::sqrt(squaredLength);
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
z *= invNorm;
|
||||
|
||||
x *= invLength;
|
||||
y *= invLength;
|
||||
z *= invLength;
|
||||
}
|
||||
if (length)
|
||||
*length = norm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Set(T X, T Y, T Z)
|
||||
NzVector3<T>& NzVector3<T>::Set(T X, T Y, T Z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Set(T scale)
|
||||
NzVector3<T>& NzVector3<T>::Set(T scale)
|
||||
{
|
||||
x = scale;
|
||||
y = scale;
|
||||
z = scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Set(T vec[3])
|
||||
NzVector3<T>& NzVector3<T>::Set(const T vec[3])
|
||||
{
|
||||
std::memcpy(&x, vec, 3*sizeof(T));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Set(const NzVector2<T>& vec, T Z)
|
||||
NzVector3<T>& NzVector3<T>::Set(const NzVector2<T>& vec, T Z)
|
||||
{
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = Z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzVector3<T>::Set(const NzVector3<U>& vec)
|
||||
NzVector3<T>& NzVector3<T>::Set(const NzVector3<U>& vec)
|
||||
{
|
||||
x = F(vec.x);
|
||||
y = F(vec.y);
|
||||
z = F(vec.z);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -278,8 +288,9 @@ T& NzVector3<T>::operator[](unsigned int i)
|
||||
if (i >= 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)";
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -294,8 +305,9 @@ T NzVector3<T>::operator[](unsigned int i) const
|
||||
if (i >= 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)";
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -345,10 +357,10 @@ NzVector3<T> NzVector3<T>::operator/(const NzVector3& vec) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -361,10 +373,10 @@ NzVector3<T> NzVector3<T>::operator/(T scale) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -416,10 +428,10 @@ NzVector3<T>& NzVector3<T>::operator/=(const NzVector3& vec)
|
||||
{
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
|
||||
x /= vec.x;
|
||||
@@ -434,10 +446,10 @@ NzVector3<T>& NzVector3<T>::operator/=(T scale)
|
||||
{
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
|
||||
x /= scale;
|
||||
@@ -590,10 +602,10 @@ NzVector3<T> operator/(T scale, const NzVector3<T>& vec)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
template<typename T> class NzVector4
|
||||
{
|
||||
public:
|
||||
NzVector4();
|
||||
NzVector4() = default;
|
||||
NzVector4(T X, T Y, T Z, T W = 1.0);
|
||||
explicit NzVector4(T scale);
|
||||
NzVector4(T vec[4]);
|
||||
NzVector4(const T vec[4]);
|
||||
NzVector4(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> explicit NzVector4(const NzVector4<U>& vec);
|
||||
NzVector4(const NzVector4& vec) = default;
|
||||
@@ -26,21 +26,21 @@ template<typename T> class NzVector4
|
||||
|
||||
T DotProduct(const NzVector4& vec) const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeZero();
|
||||
NzVector4& MakeUnitX();
|
||||
NzVector4& MakeUnitY();
|
||||
NzVector4& MakeUnitZ();
|
||||
NzVector4& MakeZero();
|
||||
|
||||
void Maximize(const NzVector4& vec);
|
||||
void Minimize(const NzVector4& vec);
|
||||
NzVector4& Maximize(const NzVector4& vec);
|
||||
NzVector4& Minimize(const NzVector4& vec);
|
||||
|
||||
void Normalize();
|
||||
NzVector4& Normalize(T* length = nullptr);
|
||||
|
||||
void Set(T X, T Y, T Z, T W = 1.0);
|
||||
void Set(T scale);
|
||||
void Set(T vec[4]);
|
||||
void Set(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> void Set(const NzVector4<U>& vec);
|
||||
NzVector4& Set(T X, T Y, T Z, T W = 1.0);
|
||||
NzVector4& Set(T scale);
|
||||
NzVector4& Set(const T vec[4]);
|
||||
NzVector4& Set(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> NzVector4& Set(const NzVector4<U>& vec);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(T X, T Y, T Z, T W)
|
||||
{
|
||||
@@ -31,7 +26,7 @@ NzVector4<T>::NzVector4(T scale)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(T vec[4])
|
||||
NzVector4<T>::NzVector4(const T vec[4])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
@@ -74,31 +69,31 @@ T NzVector4<T>::DotProduct(const NzVector4& vec) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeUnitX()
|
||||
NzVector4<T>& NzVector4<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0), F(0.0), F(1.0));
|
||||
return Set(F(1.0), F(0.0), F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeUnitY()
|
||||
NzVector4<T>& NzVector4<T>::MakeUnitY()
|
||||
{
|
||||
Set(F(0.0), F(1.0), F(0.0), F(1.0));
|
||||
return Set(F(0.0), F(1.0), F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeUnitZ()
|
||||
NzVector4<T>& NzVector4<T>::MakeUnitZ()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(1.0), F(1.0));
|
||||
return Set(F(0.0), F(0.0), F(1.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeZero()
|
||||
NzVector4<T>& NzVector4<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
return Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Maximize(const NzVector4& vec)
|
||||
NzVector4<T>& NzVector4<T>::Maximize(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
@@ -111,10 +106,12 @@ void NzVector4<T>::Maximize(const NzVector4& vec)
|
||||
|
||||
if (vec.w > w)
|
||||
w = vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Minimize(const NzVector4& vec)
|
||||
NzVector4<T>& NzVector4<T>::Minimize(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
@@ -127,60 +124,76 @@ void NzVector4<T>::Minimize(const NzVector4& vec)
|
||||
|
||||
if (vec.w < w)
|
||||
w = vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Normalize()
|
||||
NzVector4<T>& NzVector4<T>::Normalize(T* length)
|
||||
{
|
||||
if (!NzNumberEquals(w, F(0.0)))
|
||||
{
|
||||
x /= w;
|
||||
y /= w;
|
||||
z /= w;
|
||||
}
|
||||
x /= w;
|
||||
y /= w;
|
||||
z /= w;
|
||||
|
||||
w = F(1.0);
|
||||
|
||||
if (length)
|
||||
*length = w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Set(T X, T Y, T Z, T W)
|
||||
NzVector4<T>& NzVector4<T>::Set(T X, T Y, T Z, T W)
|
||||
{
|
||||
w = W;
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Set(T scale)
|
||||
NzVector4<T>& NzVector4<T>::Set(T scale)
|
||||
{
|
||||
w = scale;
|
||||
x = scale;
|
||||
y = scale;
|
||||
z = scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Set(T vec[4])
|
||||
NzVector4<T>& NzVector4<T>::Set(const T vec[4])
|
||||
{
|
||||
std::memcpy(&x, vec, 4*sizeof(T));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Set(const NzVector3<T>& vec, T W)
|
||||
NzVector4<T>& NzVector4<T>::Set(const NzVector3<T>& vec, T W)
|
||||
{
|
||||
w = W;
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = vec.z;
|
||||
w = W;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzVector4<T>::Set(const NzVector4<U>& vec)
|
||||
NzVector4<T>& NzVector4<T>::Set(const NzVector4<U>& vec)
|
||||
{
|
||||
w = F(vec.w);
|
||||
x = F(vec.x);
|
||||
y = F(vec.y);
|
||||
z = F(vec.z);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -216,8 +229,9 @@ T& NzVector4<T>::operator[](unsigned int i)
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
ss << "Index out of range: (" << i << " >= 4)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -232,8 +246,9 @@ T NzVector4<T>::operator[](unsigned int i) const
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
ss << "Index out of range: (" << i << " >= 4)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -283,10 +298,10 @@ NzVector4<T> NzVector4<T>::operator/(const NzVector4& vec) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -299,10 +314,10 @@ NzVector4<T> NzVector4<T>::operator/(T scale) const
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -359,10 +374,10 @@ NzVector4<T>& NzVector4<T>::operator/=(const NzVector4& vec)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -380,10 +395,10 @@ NzVector4<T>& NzVector4<T>::operator/=(T scale)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -488,10 +503,10 @@ NzVector4<T> operator/(T scale, const NzVector4<T>& vec)
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
NzString error("Division by zero");
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
NazaraError(error);
|
||||
throw std::domain_error(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_NOISE_HPP
|
||||
#define NAZARA_GLOBAL_NOISE_HPP
|
||||
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Config.hpp>
|
||||
#include <Nazara/Noise/Noise.hpp>
|
||||
@@ -37,3 +40,5 @@
|
||||
#include <Nazara/Noise/Simplex2D.hpp>
|
||||
#include <Nazara/Noise/Simplex3D.hpp>
|
||||
#include <Nazara/Noise/Simplex4D.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_NOISE_HPP
|
||||
|
||||
@@ -26,9 +26,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_RENDERER_HPP
|
||||
#define NAZARA_GLOBAL_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Context.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/DebugDrawer.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/OcclusionQuery.hpp>
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
@@ -39,3 +43,5 @@
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_RENDERER_HPP
|
||||
|
||||
44
include/Nazara/Renderer/DebugDrawer.hpp
Normal file
44
include/Nazara/Renderer/DebugDrawer.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DEBUGDRAWER_HPP
|
||||
#define NAZARA_DEBUGDRAWER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
|
||||
class NzAxisAlignedBox;
|
||||
class NzSkeleton;
|
||||
|
||||
class NAZARA_API NzDebugDrawer
|
||||
{
|
||||
public:
|
||||
static void Draw(const NzAxisAlignedBox& aabb);
|
||||
static void Draw(const NzCubef& cube);
|
||||
static void Draw(const NzCubei& cube);
|
||||
static void Draw(const NzCubeui& cube);
|
||||
static void Draw(const NzSkeleton* skeleton);
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static bool GetDepthTest();
|
||||
static float GetLineWidth();
|
||||
static float GetPointSize();
|
||||
static NzColor GetPrimaryColor();
|
||||
static NzColor GetSecondaryColor();
|
||||
|
||||
static void SetDepthTest(bool shouldTest);
|
||||
static void SetLineWidth(float width);
|
||||
static void SetPointSize(float size);
|
||||
static void SetPrimaryColor(const NzColor& color);
|
||||
static void SetSecondaryColor(const NzColor& color);
|
||||
|
||||
static void Uninitialize();
|
||||
};
|
||||
|
||||
#endif // NAZARA_DEBUG_DRAWER_HPP
|
||||
@@ -131,6 +131,8 @@ NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
|
||||
NAZARA_API extern PFNGLENABLEPROC glEnable;
|
||||
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
|
||||
NAZARA_API extern PFNGLFLUSHPROC glFlush;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
@@ -139,8 +141,6 @@ NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
|
||||
NAZARA_API extern PFNGLENABLEPROC glEnable;
|
||||
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
@@ -148,6 +148,7 @@ NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
|
||||
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
|
||||
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
NAZARA_API extern PFNGLGETBOOLEANVPROC glGetBooleanv;
|
||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
||||
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
||||
@@ -169,6 +170,7 @@ NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
||||
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
NAZARA_API extern PFNGLISENABLEDPROC glIsEnabled;
|
||||
NAZARA_API extern PFNGLLINEWIDTHPROC glLineWidth;
|
||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
|
||||
@@ -29,8 +29,8 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
virtual ~NzRenderWindow();
|
||||
|
||||
bool CopyToImage(NzImage* image); ///TODO: Const
|
||||
bool CopyToTexture(NzTexture* texture); ///TODO: Const
|
||||
bool CopyToImage(NzImage* image) const;
|
||||
bool CopyToTexture(NzTexture* texture) const;
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
@@ -61,7 +61,7 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
|
||||
NzClock m_clock;
|
||||
NzContextParameters m_parameters;
|
||||
NzContext* m_context = nullptr;
|
||||
mutable NzContext* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class NAZARA_API NzRenderer
|
||||
|
||||
static void Enable(nzRendererParameter parameter, bool enable);
|
||||
|
||||
float GetLineWidth();
|
||||
static float GetLineWidth();
|
||||
//static NzMatrix4f GetMatrix(nzMatrixCombination combination);
|
||||
static NzMatrix4f GetMatrix(nzMatrixType type);
|
||||
static unsigned int GetMaxAnisotropyLevel();
|
||||
@@ -51,6 +51,7 @@ class NAZARA_API NzRenderer
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsEnabled(nzRendererParameter parameter);
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetBlendFunc(nzBlendFunc src, nzBlendFunc dest);
|
||||
@@ -73,7 +74,6 @@ class NAZARA_API NzRenderer
|
||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
||||
static bool SetTarget(NzRenderTarget* target);
|
||||
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
static bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration);
|
||||
static void SetViewport(const NzRectui& viewport);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_UTILITY_HPP
|
||||
#define NAZARA_GLOBAL_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
@@ -37,16 +40,25 @@
|
||||
#include <Nazara/Utility/Icon.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/KeyframeMesh.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/Mouse.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Utility/Sequence.hpp>
|
||||
#include <Nazara/Utility/SkeletalMesh.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <Nazara/Utility/Vertex.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_UTILITY_HPP
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Sequence.hpp>
|
||||
|
||||
struct NzAnimationParams
|
||||
struct NAZARA_API NzAnimationParams
|
||||
{
|
||||
unsigned int endFrame = static_cast<unsigned int>(-1);
|
||||
unsigned int startFrame = 0;
|
||||
@@ -21,15 +22,8 @@ struct NzAnimationParams
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
struct NzSequence
|
||||
{
|
||||
NzString name;
|
||||
unsigned int firstFrame;
|
||||
unsigned int lastFrame;
|
||||
unsigned int framePerSecond;
|
||||
};
|
||||
|
||||
class NzAnimation;
|
||||
class NzSkeleton;
|
||||
|
||||
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||
|
||||
@@ -44,8 +38,10 @@ class NAZARA_API NzAnimation : public NzResource
|
||||
~NzAnimation();
|
||||
|
||||
bool AddSequence(const NzSequence& sequence);
|
||||
void AnimateSkeleton(NzSkeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
|
||||
|
||||
bool Create(nzAnimationType type, unsigned int frameCount);
|
||||
bool CreateKeyframe(unsigned int frameCount);
|
||||
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
|
||||
void Destroy();
|
||||
|
||||
unsigned int GetFrameCount() const;
|
||||
@@ -55,6 +51,8 @@ class NAZARA_API NzAnimation : public NzResource
|
||||
const NzSequence* GetSequence(unsigned int index) const;
|
||||
unsigned int GetSequenceCount() const;
|
||||
int GetSequenceIndex(const NzString& sequenceName) const;
|
||||
NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
|
||||
const NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
|
||||
nzAnimationType GetType() const;
|
||||
|
||||
bool HasSequence(const NzString& sequenceName) const;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
@@ -20,10 +21,13 @@ class NAZARA_API NzAxisAlignedBox
|
||||
NzAxisAlignedBox(nzExtend extend);
|
||||
|
||||
bool Contains(const NzAxisAlignedBox& box);
|
||||
bool Contains(const NzVector3f& vector);
|
||||
|
||||
void ExtendTo(const NzAxisAlignedBox& box);
|
||||
void ExtendTo(const NzVector3f& vector);
|
||||
|
||||
NzVector3f GetCorner(nzCorner corner) const;
|
||||
NzCubef GetCube() const;
|
||||
nzExtend GetExtend() const;
|
||||
NzVector3f GetMaximum() const;
|
||||
NzVector3f GetMinimum() const;
|
||||
@@ -38,6 +42,8 @@ class NAZARA_API NzAxisAlignedBox
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
void Transform(const NzMatrix4f& matrix);
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
static NzAxisAlignedBox Lerp(const NzAxisAlignedBox& from, const NzAxisAlignedBox& to, float interpolation);
|
||||
|
||||
@@ -38,8 +38,11 @@
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_UTILITY_SAFE 1
|
||||
|
||||
// Lors du parsage d'une ressource, déclenche un avertissement si une erreur non-critique est repérée dans une ressource (Plus lent)
|
||||
#define NAZARA_UTILITY_STRICT_RESOURCE_PARSING 1
|
||||
|
||||
// Fait tourner chaque fenêtre dans un thread séparé si le système le supporte
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7 avec certains ordinateurs
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_UTILITY_THREADSAFE 1
|
||||
|
||||
@@ -51,6 +51,28 @@ enum nzBufferUsage
|
||||
nzBufferUsage_Max = nzBufferUsage_Static
|
||||
};
|
||||
|
||||
enum nzCoordSys
|
||||
{
|
||||
nzCoordSys_Global,
|
||||
nzCoordSys_Local,
|
||||
|
||||
nzCoordSys_Max = nzCoordSys_Local
|
||||
};
|
||||
|
||||
enum nzCorner
|
||||
{
|
||||
nzCorner_FarLeftBottom,
|
||||
nzCorner_FarLeftTop,
|
||||
nzCorner_FarRightBottom,
|
||||
nzCorner_FarRightTop,
|
||||
nzCorner_NearLeftBottom,
|
||||
nzCorner_NearLeftTop,
|
||||
nzCorner_NearRightBottom,
|
||||
nzCorner_NearRightTop,
|
||||
|
||||
nzCorner_Max = nzCorner_FarRightTop
|
||||
};
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
///TODO: Filtres
|
||||
|
||||
struct NzImageParams
|
||||
struct NAZARA_API NzImageParams
|
||||
{
|
||||
nzPixelFormat loadFormat = nzPixelFormat_Undefined;
|
||||
nzUInt8 levelCount = 0;
|
||||
|
||||
38
include/Nazara/Utility/Joint.hpp
Normal file
38
include/Nazara/Utility/Joint.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_JOINT_HPP
|
||||
#define NAZARA_JOINT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
|
||||
class NzSkeleton;
|
||||
|
||||
class NAZARA_API NzJoint : public NzNode
|
||||
{
|
||||
public:
|
||||
NzJoint(NzSkeleton* skeleton);
|
||||
NzJoint(const NzJoint& joint);
|
||||
~NzJoint() = default;
|
||||
|
||||
NzMatrix4f GetInverseBindMatrix() const;
|
||||
NzString GetName() const;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
|
||||
void SetInverseBindMatrix(const NzMatrix4f& matrix);
|
||||
void SetName(const NzString& name);
|
||||
|
||||
private:
|
||||
NzMatrix4f m_inverseBindMatrix;
|
||||
NzString m_name;
|
||||
NzSkeleton* m_skeleton;
|
||||
};
|
||||
|
||||
#endif // NAZARA_JOINT_HPP
|
||||
@@ -8,15 +8,48 @@
|
||||
#define NAZARA_KEYFRAMEMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzMesh;
|
||||
struct NzKeyframeMeshImpl;
|
||||
|
||||
class NAZARA_API NzKeyframeMesh : public NzSubMesh
|
||||
class NAZARA_API NzKeyframeMesh final : public NzSubMesh
|
||||
{
|
||||
friend NzMesh;
|
||||
|
||||
public:
|
||||
NzKeyframeMesh(const NzMesh* parent);
|
||||
virtual ~NzKeyframeMesh();
|
||||
|
||||
bool Create(NzVertexBuffer* vertexBuffer, unsigned int frameCount, bool lock = true);
|
||||
void Destroy();
|
||||
|
||||
void Finish();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const override;
|
||||
nzAnimationType GetAnimationType() const override;
|
||||
unsigned int GetFrameCount() const;
|
||||
const NzIndexBuffer* GetIndexBuffer() const override;
|
||||
bool GetVertex(NzMeshVertex* dest, unsigned int frameIndex, unsigned int vertexIndex, bool queryUV = true) const;
|
||||
const NzVertexBuffer* GetVertexBuffer() const override;
|
||||
|
||||
void Interpolate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
bool IsAnimated() const override;
|
||||
bool IsValid();
|
||||
|
||||
bool Lock(nzBufferAccess access) const;
|
||||
|
||||
void SetAABB(unsigned int frameIndex, const NzAxisAlignedBox& aabb);
|
||||
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
bool SetVertex(const NzMeshVertex& source, unsigned int frameIndex, unsigned int vertexIndex, bool setUV = true);
|
||||
|
||||
void Unlock() const;
|
||||
|
||||
private:
|
||||
void InterpolateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
NzKeyframeMeshImpl* m_impl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_KEYFRAMEMESH_HPP
|
||||
|
||||
@@ -15,22 +15,27 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
|
||||
class NzVertexDeclaration;
|
||||
|
||||
struct NzMeshParams
|
||||
struct NAZARA_API NzMeshParams
|
||||
{
|
||||
NzMeshParams(); // Vérifie que le storage indiqué un peu plus bas est supporté
|
||||
|
||||
NzAnimationParams animation;
|
||||
//const NzVertexDeclaration* declaration = nullptr;
|
||||
nzBufferStorage storage = nzBufferStorage_Hardware;
|
||||
bool loadAnimations = true;
|
||||
bool animated = true;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMesh;
|
||||
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
||||
|
||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
|
||||
struct NzMeshImpl;
|
||||
@@ -43,21 +48,26 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
NzMesh() = default;
|
||||
~NzMesh();
|
||||
|
||||
bool AddSkin(const NzString& skin, bool setDefault = false);
|
||||
bool AddMaterial(const NzString& matPath, unsigned int* matIndex = nullptr);
|
||||
bool AddSubMesh(NzSubMesh* subMesh);
|
||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
bool Create(nzAnimationType type);
|
||||
bool CreateKeyframe();
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
bool CreateStatic();
|
||||
void Destroy();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
const NzAnimation* GetAnimation() const;
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetFrameCount() const;
|
||||
NzString GetSkin(unsigned int index = 0) const;
|
||||
unsigned int GetSkinCount() const;
|
||||
unsigned int GetJointCount() const;
|
||||
NzString GetMaterial(unsigned int index) const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
NzSubMesh* GetSubMesh(const NzString& identifier);
|
||||
NzSubMesh* GetSubMesh(unsigned int index);
|
||||
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
|
||||
@@ -67,7 +77,7 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
bool HasSkin(unsigned int index = 0) const;
|
||||
bool HasMaterial(unsigned int index) const;
|
||||
bool HasSubMesh(const NzString& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
|
||||
@@ -80,11 +90,14 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzMeshParams& params = NzMeshParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzMeshParams& params = NzMeshParams());
|
||||
|
||||
void RemoveSkin(unsigned int index = 0);
|
||||
void RemoveMaterial(unsigned int index);
|
||||
void RemoveSubMesh(const NzString& identifier);
|
||||
void RemoveSubMesh(unsigned int index = 0);
|
||||
void RemoveSubMesh(unsigned int index);
|
||||
|
||||
bool SetAnimation(const NzAnimation* animation);
|
||||
void Skin(const NzSkeleton* skeleton);
|
||||
|
||||
static const NzVertexDeclaration* GetDeclaration();
|
||||
|
||||
private:
|
||||
void OnResourceCreated(const NzResource* resource, int index) override;
|
||||
|
||||
85
include/Nazara/Utility/Node.hpp
Normal file
85
include/Nazara/Utility/Node.hpp
Normal file
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_NODE_HPP
|
||||
#define NAZARA_NODE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <set>
|
||||
|
||||
class NAZARA_API NzNode
|
||||
{
|
||||
public:
|
||||
NzNode();
|
||||
NzNode(const NzNode& node);
|
||||
virtual ~NzNode();
|
||||
|
||||
NzQuaternionf GetDerivedRotation() const;
|
||||
NzVector3f GetDerivedScale() const;
|
||||
NzVector3f GetDerivedTranslation() const;
|
||||
bool GetInheritRotation() const;
|
||||
bool GetInheritScale() const;
|
||||
bool GetInheritTranslation() const;
|
||||
const NzNode* GetParent() const;
|
||||
NzQuaternionf GetRotation() const;
|
||||
NzVector3f GetScale() const;
|
||||
NzVector3f GetTranslation() const;
|
||||
NzMatrix4f GetTransformMatrix() const;
|
||||
|
||||
NzNode& Interpolate(const NzNode& nodeA, const NzNode& nodeB, float interpolation);
|
||||
|
||||
NzNode& Rotate(const NzQuaternionf& rotation, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
|
||||
NzNode& Scale(const NzVector3f& scale);
|
||||
NzNode& Scale(float scale);
|
||||
NzNode& Scale(float scaleX, float scaleY, float scaleZ);
|
||||
|
||||
NzNode& Translate(const NzVector3f& movement, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
NzNode& Translate(float movementX, float movementY, float movementZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
|
||||
void SetInheritRotation(bool inheritRotation);
|
||||
void SetInheritScale(bool inheritScale);
|
||||
void SetInheritTranslation(bool inheritTranslation);
|
||||
void SetParent(const NzNode* node = nullptr);
|
||||
void SetParent(const NzNode& node);
|
||||
void SetRotation(const NzQuaternionf& quat, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(const NzVector3f& scale, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(float scale, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(float scaleX, float scaleY, float scaleZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetTranslation(const NzVector3f& translation, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetTranslation(float translationX, float translationXY, float translationZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
|
||||
NzNode& operator=(const NzNode& node);
|
||||
|
||||
protected:
|
||||
void AddChild(NzNode* node) const;
|
||||
void Invalidate();
|
||||
void RemoveChild(NzNode* node) const;
|
||||
void UpdateDerived() const;
|
||||
virtual void UpdateMatrix() const;
|
||||
|
||||
mutable std::set<NzNode*> m_childs;
|
||||
mutable NzMatrix4f m_transformMatrix;
|
||||
mutable NzQuaternionf m_derivedRotation;
|
||||
NzQuaternionf m_rotation;
|
||||
NzString m_name;
|
||||
mutable NzVector3f m_derivedTranslation;
|
||||
mutable NzVector3f m_derivedScale;
|
||||
NzVector3f m_scale;
|
||||
NzVector3f m_translation;
|
||||
const NzNode* m_parent;
|
||||
mutable bool m_derivedUpdated;
|
||||
bool m_inheritRotation;
|
||||
bool m_inheritScale;
|
||||
bool m_inheritTranslation;
|
||||
mutable bool m_matrixUpdated;
|
||||
};
|
||||
|
||||
#endif // NAZARA_NODE_HPP
|
||||
29
include/Nazara/Utility/Sequence.hpp
Normal file
29
include/Nazara/Utility/Sequence.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SEQUENCE_HPP
|
||||
#define NAZARA_SEQUENCE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
struct NzSequence
|
||||
{
|
||||
NzString name;
|
||||
unsigned int firstFrame;
|
||||
unsigned int frameCount;
|
||||
unsigned int frameRate;
|
||||
};
|
||||
|
||||
struct NzSequenceJoint
|
||||
{
|
||||
NzQuaternionf rotation;
|
||||
NzVector3f scale;
|
||||
NzVector3f translation;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SEQUENCE_HPP
|
||||
62
include/Nazara/Utility/SkeletalMesh.hpp
Normal file
62
include/Nazara/Utility/SkeletalMesh.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SKELETALMESH_HPP
|
||||
#define NAZARA_SKELETALMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzSkeleton;
|
||||
|
||||
struct NzVertexWeight
|
||||
{
|
||||
std::vector<unsigned int> weights;
|
||||
};
|
||||
|
||||
struct NzWeight
|
||||
{
|
||||
float weight;
|
||||
unsigned int jointIndex;
|
||||
};
|
||||
|
||||
struct NzSkeletalMeshImpl;
|
||||
|
||||
class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
||||
{
|
||||
public:
|
||||
NzSkeletalMesh(const NzMesh* parent);
|
||||
virtual ~NzSkeletalMesh();
|
||||
|
||||
bool Create(NzVertexBuffer* vertexBuffer, unsigned int weightCount);
|
||||
void Destroy();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
nzAnimationType GetAnimationType() const final;
|
||||
void* GetBindPoseBuffer();
|
||||
const void* GetBindPoseBuffer() const;
|
||||
const NzIndexBuffer* GetIndexBuffer() const override;
|
||||
const NzVertexBuffer* GetVertexBuffer() const override;
|
||||
NzVertexWeight* GetVertexWeight(unsigned int vertexIndex = 0);
|
||||
const NzVertexWeight* GetVertexWeight(unsigned int vertexIndex = 0) const;
|
||||
NzWeight* GetWeight(unsigned int weightIndex = 0);
|
||||
const NzWeight* GetWeight(unsigned int weightIndex = 0) const;
|
||||
unsigned int GetWeightCount() const;
|
||||
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
||||
void Skin();
|
||||
void Skin(const NzSkeleton* skeleton);
|
||||
|
||||
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
|
||||
private:
|
||||
NzSkeletalMeshImpl* m_impl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SKELETALMESH_HPP
|
||||
53
include/Nazara/Utility/Skeleton.hpp
Normal file
53
include/Nazara/Utility/Skeleton.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SKELETON_HPP
|
||||
#define NAZARA_SKELETON_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct NzSkeletonImpl;
|
||||
|
||||
class NAZARA_API NzSkeleton
|
||||
{
|
||||
friend NzJoint;
|
||||
|
||||
public:
|
||||
NzSkeleton() = default;
|
||||
NzSkeleton(const NzSkeleton& skeleton);
|
||||
~NzSkeleton();
|
||||
|
||||
bool Create(unsigned int jointCount);
|
||||
void Destroy();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
NzJoint* GetJoint(const NzString& jointName);
|
||||
NzJoint* GetJoint(unsigned int index);
|
||||
const NzJoint* GetJoint(const NzString& jointName) const;
|
||||
const NzJoint* GetJoint(unsigned int index) const;
|
||||
NzJoint* GetJoints();
|
||||
const NzJoint* GetJoints() const;
|
||||
unsigned int GetJointCount() const;
|
||||
int GetJointIndex(const NzString& jointName) const;
|
||||
|
||||
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation);
|
||||
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount);
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzSkeleton& operator=(const NzSkeleton& skeleton);
|
||||
|
||||
private:
|
||||
void InvalidateJointMap();
|
||||
void UpdateJointMap() const;
|
||||
|
||||
NzSkeletonImpl* m_impl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SKELETON_HPP
|
||||
@@ -15,37 +15,30 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzStaticMesh(const NzMesh* parent);
|
||||
NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
virtual ~NzStaticMesh();
|
||||
|
||||
bool Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
bool Create(NzVertexBuffer* vertexBuffer);
|
||||
void Destroy();
|
||||
|
||||
bool GenerateAABB();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetFrameCount() const;
|
||||
const NzIndexBuffer* GetIndexBuffer() const;
|
||||
nzPrimitiveType GetPrimitiveType() const;
|
||||
const NzVertexBuffer* GetVertexBuffer() const;
|
||||
const NzVertexDeclaration* GetVertexDeclaration() const;
|
||||
const NzAxisAlignedBox& GetAABB() const override;
|
||||
nzAnimationType GetAnimationType() const final;
|
||||
const NzIndexBuffer* GetIndexBuffer() const override;
|
||||
const NzVertexBuffer* GetVertexBuffer() const override;
|
||||
|
||||
bool IsAnimated() const;
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetAABB(const NzAxisAlignedBox& aabb);
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
|
||||
private:
|
||||
void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
|
||||
NzAxisAlignedBox m_aabb;
|
||||
NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
const NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
NzVertexBuffer* m_vertexBuffer = nullptr;
|
||||
const NzVertexDeclaration* m_vertexDeclaration = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_STATICMESH_HPP
|
||||
|
||||
@@ -19,26 +19,30 @@ class NzMesh;
|
||||
|
||||
class NAZARA_API NzSubMesh : public NzResource
|
||||
{
|
||||
friend class NzMesh;
|
||||
friend NzMesh;
|
||||
|
||||
public:
|
||||
NzSubMesh(const NzMesh* parent);
|
||||
virtual ~NzSubMesh();
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
virtual const NzAxisAlignedBox& GetAABB() const = 0;
|
||||
virtual nzAnimationType GetAnimationType() const = 0;
|
||||
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
|
||||
const NzMesh* GetParent() const;
|
||||
virtual nzPrimitiveType GetPrimitiveType() const = 0;
|
||||
nzPrimitiveType GetPrimitiveType() const;
|
||||
unsigned int GetSkinIndex() const;
|
||||
virtual const NzVertexBuffer* GetVertexBuffer() const = 0;
|
||||
virtual const NzVertexDeclaration* GetVertexDeclaration() const = 0;
|
||||
unsigned int GetVertexCount() const;
|
||||
virtual unsigned int GetVertexCount() const;
|
||||
|
||||
virtual bool IsAnimated() const = 0;
|
||||
|
||||
void SetMaterialIndex(unsigned int matIndex);
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
|
||||
protected:
|
||||
virtual void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation) = 0;
|
||||
|
||||
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
|
||||
const NzMesh* m_parent;
|
||||
unsigned int m_matIndex;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SUBMESH_HPP
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
class NAZARA_API NzVertexBuffer : public NzResource
|
||||
{
|
||||
public:
|
||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
|
||||
~NzVertexBuffer();
|
||||
|
||||
@@ -27,6 +28,7 @@ class NAZARA_API NzVertexBuffer : public NzResource
|
||||
unsigned int GetStartVertex() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
const NzVertexDeclaration* GetVertexDeclaration() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
|
||||
@@ -38,6 +40,7 @@ class NAZARA_API NzVertexBuffer : public NzResource
|
||||
|
||||
private:
|
||||
NzBuffer* m_buffer;
|
||||
const NzVertexDeclaration* m_vertexDeclaration;
|
||||
bool m_ownsBuffer;
|
||||
unsigned int m_startVertex;
|
||||
unsigned int m_vertexCount;
|
||||
|
||||
113
include/Nazara/Utility/VertexStruct.hpp
Normal file
113
include/Nazara/Utility/VertexStruct.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VERTEXSTRUCT_HPP
|
||||
#define NAZARA_VERTEXSTRUCT_HPP
|
||||
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
struct NzVertexStruct_XY
|
||||
{
|
||||
NzVector2f position;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XY_Color : public NzVertexStruct_XY
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
struct NzVertexStruct_XYZ
|
||||
{
|
||||
NzVector3f position;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Color : public NzVertexStruct_XYZ
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal : public NzVertexStruct_XYZ
|
||||
{
|
||||
NzVector3f normal;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_Color : public NzVertexStruct_XYZ_Normal
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
struct NzVertexStruct_XYZ_UV : public NzVertexStruct_XYZ
|
||||
{
|
||||
NzVector2f uv;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_UV_Color : public NzVertexStruct_XYZ_UV
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV : public NzVertexStruct_XYZ_Normal
|
||||
{
|
||||
NzVector2f uv;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_Color : public NzVertexStruct_XYZ_Normal_UV
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_Tangent : public NzVertexStruct_XYZ_Normal_UV
|
||||
{
|
||||
NzVector3f tangent;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_Tangent_Color : public NzVertexStruct_XYZ_Normal_UV_Tangent
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
struct NzVertexStruct_XYZ_UV_UV2 : public NzVertexStruct_XYZ_UV
|
||||
{
|
||||
NzVector2f uv2;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_UV_UV2_Color : public NzVertexStruct_XYZ_UV_UV2
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_UV2 : public NzVertexStruct_XYZ_Normal_UV
|
||||
{
|
||||
NzVector2f uv2;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_UV2_Color : public NzVertexStruct_XYZ_Normal_UV_UV2
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_UV2_Tangent : public NzVertexStruct_XYZ_Normal_UV_UV2
|
||||
{
|
||||
NzVector3f tangent;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
struct NzVertexStruct_XYZ_Normal_UV_UV2_Tangent_Color : public NzVertexStruct_XYZ_Normal_UV_UV2_Tangent
|
||||
{
|
||||
NzVector3f color;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXSTRUCT_HPP
|
||||
Reference in New Issue
Block a user