Former-commit-id: 3878bde4d067ef921783f256b582af8f6463c19b [formerly 029a8e9081b66daf20a78ba7331a496d89145f44]
Former-commit-id: 47009b49149da0186169afc538618f2ab2973f89
This commit is contained in:
Lynix
2016-06-09 08:49:14 +02:00
161 changed files with 7841 additions and 637 deletions

View File

@@ -7,6 +7,10 @@
namespace Nz
{
/*!
* \brief Constructs a Billboard object by default
*/
inline Billboard::Billboard()
{
SetColor(Color::White);
@@ -15,6 +19,12 @@ namespace Nz
SetSize(64.f, 64.f);
}
/*!
* \brief Constructs a Billboard object with a reference to a material
*
* \param material Reference to a material
*/
inline Billboard::Billboard(MaterialRef material)
{
SetColor(Color::White);
@@ -23,6 +33,12 @@ namespace Nz
SetSize(64.f, 64.f);
}
/*!
* \brief Constructs a Billboard object with a pointer to a texture
*
* \param texture Pointer to a texture
*/
inline Billboard::Billboard(Texture* texture)
{
SetColor(Color::White);
@@ -31,6 +47,12 @@ namespace Nz
SetTexture(texture, true);
}
/*!
* \brief Constructs a Billboard object by assignation
*
* \param billboard Billboard to copy into this
*/
inline Billboard::Billboard(const Billboard& billboard) :
InstancedRenderable(billboard),
m_color(billboard.m_color),
@@ -41,31 +63,61 @@ namespace Nz
{
}
/*!
* \brief Gets the color of the billboard
* \return Current color
*/
inline const Color& Billboard::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the material of the billboard
* \return Current material
*/
inline const MaterialRef& Billboard::GetMaterial() const
{
return m_material;
}
/*!
* \brief Gets the rotation of the billboard
* \return Current rotation
*/
inline float Billboard::GetRotation() const
{
return m_rotation;
}
/*!
* \brief Gets the size of the billboard
* \return Current size
*/
inline const Vector2f& Billboard::GetSize() const
{
return m_size;
}
/*!
* \brief Sets the color of the billboard
*
* \param color Color for the billboard
*/
inline void Billboard::SetColor(const Color& color)
{
m_color = color;
}
/*!
* \brief Sets the default material of the billboard (just default material)
*/
inline void Billboard::SetDefaultMaterial()
{
MaterialRef material = Material::New();
@@ -75,6 +127,13 @@ namespace Nz
SetMaterial(std::move(material));
}
/*!
* \brief Sets the material of the billboard
*
* \param material Material for the billboard
* \param resizeBillboard Should billboard be resized to the material size (diffuse map)
*/
inline void Billboard::SetMaterial(MaterialRef material, bool resizeBillboard)
{
m_material = std::move(material);
@@ -86,25 +145,51 @@ namespace Nz
}
}
/*!
* \brief Sets the rotation of the billboard
*
* \param rotation Rotation for the billboard
*/
inline void Billboard::SetRotation(float rotation)
{
m_rotation = rotation;
m_sinCos.Set(std::sin(m_rotation), std::cos(m_rotation));
}
/*!
* \brief Sets the size of the billboard
*
* \param size Size for the billboard
*/
inline void Billboard::SetSize(const Vector2f& size)
{
m_size = size;
// On invalide la bounding box
// We invalidate the bounding volume
InvalidateBoundingVolume();
}
/*!
* \brief Sets the size of the billboard
*
* \param sizeX Size in X for the billboard
* \param sizeY Size in Y for the billboard
*/
inline void Billboard::SetSize(float sizeX, float sizeY)
{
SetSize(Vector2f(sizeX, sizeY));
}
/*!
* \brief Sets the texture of the billboard
*
* \param texture Texture for the billboard
* \param resizeBillboard Should billboard be resized to the texture size
*/
inline void Billboard::SetTexture(TextureRef texture, bool resizeBillboard)
{
if (!m_material)
@@ -118,6 +203,13 @@ namespace Nz
m_material->SetDiffuseMap(std::move(texture));
}
/*!
* \brief Sets the current billboard with the content of the other one
* \return A reference to this
*
* \param billboard The other Billboard
*/
inline Billboard& Billboard::operator=(const Billboard& billboard)
{
InstancedRenderable::operator=(billboard);
@@ -131,6 +223,13 @@ namespace Nz
return *this;
}
/*!
* \brief Creates a new billboard from the arguments
* \return A reference to the newly created billboard
*
* \param args Arguments for the billboard
*/
template<typename... Args>
BillboardRef Billboard::New(Args&&... args)
{

View File

@@ -7,6 +7,13 @@
namespace Nz
{
/*!
* \brief Creates a new color background from the arguments
* \return A reference to the newly created color background
*
* \param args Arguments for the color background
*/
template<typename... Args>
ColorBackgroundRef ColorBackground::New(Args&&... args)
{

View File

@@ -27,23 +27,28 @@
#ifndef NAZARA_CONFIG_GRAPHICS_HPP
#define NAZARA_CONFIG_GRAPHICS_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
/*!
* \defgroup graphics (NazaraGraphics) Graphics module
* Graphics/System module including classes to handle graphical elements...
*/
// À partir de combien d'instances d'un même mesh/matériau l'instancing doit-il être utilisé ?
/// Each modification of a paramater of the module needs a recompilation of the unit
// How much instances are need of a same mesh/material to enable instancing ?
#define NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT 10
// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower)
#define NAZARA_GRAPHICS_MANAGE_MEMORY 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
// Activate the security tests based on the code (Advised for development)
#define NAZARA_GRAPHICS_SAFE 1
/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code
/// Each modification of a parameter following implies a modification (often minor) of the code
// Le nombre maximum de lumières qu'un shader standard supportera
// The maximum number of lights in a standard shader
#define NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS 3
/// Vérification des valeurs et types de certaines constantes
/// Checking the values and types of certain constants
#include <Nazara/Graphics/ConfigCheck.hpp>
#if defined(NAZARA_STATIC)

View File

@@ -7,12 +7,12 @@
#ifndef NAZARA_CONFIG_CHECK_GRAPHICS_HPP
#define NAZARA_CONFIG_CHECK_GRAPHICS_HPP
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
/// This file is used to check the constant values defined in Config.hpp
#include <type_traits>
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
// We fore the value of MANAGE_MEMORY in debug
#if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY
#undef NAZARA_GRAPHICS_MANAGE_MEMORY
#define NAZARA_GRAPHICS_MANAGE_MEMORY 0

View File

@@ -2,7 +2,7 @@
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
// We suppose that Debug.hpp is already included, same goes for Config.hpp
#if NAZARA_GRAPHICS_MANAGE_MEMORY
#undef delete
#undef new

View File

@@ -29,7 +29,7 @@ namespace Nz
float GetBrightThreshold() const;
Texture* GetTexture(unsigned int i) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
bool Resize(const Vector2ui& dimensions);
void SetBlurPassCount(unsigned int passCount);

View File

@@ -23,7 +23,7 @@ namespace Nz
DeferredDOFPass();
virtual ~DeferredDOFPass();
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
bool Resize(const Vector2ui& dimensions);
protected:

View File

@@ -21,7 +21,7 @@ namespace Nz
DeferredFXAAPass();
virtual ~DeferredFXAAPass();
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
protected:
RenderStates m_states;

View File

@@ -21,7 +21,7 @@ namespace Nz
DeferredFinalPass();
virtual ~DeferredFinalPass();
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
protected:
RenderStates m_states;

View File

@@ -21,7 +21,7 @@ namespace Nz
DeferredFogPass();
virtual ~DeferredFogPass();
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
protected:
RenderStates m_states;

View File

@@ -21,7 +21,7 @@ namespace Nz
virtual ~DeferredForwardPass();
void Initialize(DeferredRenderTechnique* technique);
bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const;
bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const;
protected:
const ForwardRenderTechnique* m_forwardTechnique;

View File

@@ -21,7 +21,7 @@ namespace Nz
DeferredGeometryPass();
virtual ~DeferredGeometryPass();
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
bool Resize(const Vector2ui& dimensions);
protected:

View File

@@ -28,7 +28,7 @@ namespace Nz
bool IsLightMeshesDrawingEnabled() const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const;
protected:
LightUniforms m_directionalLightUniforms;

View File

@@ -38,7 +38,7 @@ namespace Nz
bool IsEnabled() const;
virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const = 0;
virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const = 0;
virtual bool Resize(const Vector2ui& GBufferSize);
DeferredRenderPass& operator=(const DeferredRenderPass&) = delete;

View File

@@ -67,7 +67,7 @@ namespace Nz
};
std::map<RenderPassType, std::map<int, std::unique_ptr<DeferredRenderPass>>, RenderPassComparator> m_passes;
ForwardRenderTechnique m_forwardTechnique; // Doit être initialisé avant la RenderQueue
ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue
DeferredRenderQueue m_renderQueue;
mutable RenderBufferRef m_depthStencilBuffer;
mutable RenderTexture m_GBufferRTT;

View File

@@ -6,6 +6,14 @@
namespace Nz
{
/*!
* \brief Checks whether the material is suitable to fit in the render queue
* \return true If it is the case
*
* \param material Material to verify
*/
bool DepthRenderQueue::IsMaterialSuitable(const Material* material) const
{
NazaraAssert(material, "Invalid material");

View File

@@ -128,7 +128,7 @@ namespace Nz
SceneNodeType_Max = SceneNodeType_User
};
// Ces paramètres sont indépendants du matériau: ils peuvent être demandés à tout moment
// These parameters are independant of the material: they can not be asked for the moment
enum ShaderFlags
{
ShaderFlags_None = 0,
@@ -139,7 +139,7 @@ namespace Nz
ShaderFlags_TextureOverlay = 0x08,
ShaderFlags_VertexColor = 0x10,
ShaderFlags_Max = ShaderFlags_VertexColor*2-1
ShaderFlags_Max = ShaderFlags_VertexColor * 2 - 1
};
}

View File

@@ -159,6 +159,7 @@ namespace Nz
std::map<int, Layer> layers;
private:
BillboardData* GetBillboardData(int renderOrder, const Material* material, unsigned int count);
Layer& GetLayer(int i); ///TODO: Inline
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);

View File

@@ -31,7 +31,7 @@ namespace Nz
AbstractRenderQueue* GetRenderQueue() override;
RenderTechniqueType GetType() const override;
void SetMaxLightPassPerObject(unsigned int passCount);
void SetMaxLightPassPerObject(unsigned int maxLightPassPerObject);
static bool Initialize();
static void Uninitialize();
@@ -70,11 +70,11 @@ namespace Nz
LightUniforms lightUniforms;
bool hasLightUniforms;
/// Moins coûteux en mémoire que de stocker un LightUniforms par index de lumière,
/// à voir si ça fonctionne chez tout le monde
int lightOffset; // "Distance" entre Lights[0].type et Lights[1].type
/// Less costly in memory than storing a LightUniforms by index of light,
/// this may not work everywhere
int lightOffset; // "Distance" between Lights[0].type and Lights[1].type
// Autre uniformes
// Other uniforms
int eyePosition;
int sceneAmbient;
int textureOverlay;

View File

@@ -6,6 +6,16 @@
namespace Nz
{
/*!
* \brief Sens the uniforms for light
*
* \param shader Shader to send uniforms to
* \param uniforms Uniforms to send
* \param index Index of the light
* \param uniformOffset Offset for the uniform
* \param availableTextureUnit Unit texture available
*/
inline void ForwardRenderTechnique::SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset, UInt8 availableTextureUnit) const
{
// If anyone got a better idea..
@@ -104,6 +114,14 @@ namespace Nz
}
}
/*!
* \brief Computes the score for directional light
* \return 0.f
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline float ForwardRenderTechnique::ComputeDirectionalLightScore(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light)
{
NazaraUnused(object);
@@ -113,18 +131,42 @@ namespace Nz
return 0.f;
}
/*!
* \brief Computes the score for point light
* \return Distance to the light
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline float ForwardRenderTechnique::ComputePointLightScore(const Spheref& object, const AbstractRenderQueue::PointLight& light)
{
///TODO: Compute a score depending on the light luminosity
return object.SquaredDistance(light.position);
}
/*!
* \brief Computes the score for spot light
* \return Distance to the light
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline float ForwardRenderTechnique::ComputeSpotLightScore(const Spheref& object, const AbstractRenderQueue::SpotLight& light)
{
///TODO: Compute a score depending on the light luminosity and spot direction
return object.SquaredDistance(light.position);
}
/*!
* \brief Checks whether the directional light is suitable for the computations
* \return true if light is enoughly close
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline bool ForwardRenderTechnique::IsDirectionalLightSuitable(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light)
{
NazaraUnused(object);
@@ -134,12 +176,28 @@ namespace Nz
return true;
}
/*!
* \brief Checks whether the point light is suitable for the computations
* \return true if light is enoughly close
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline bool ForwardRenderTechnique::IsPointLightSuitable(const Spheref& object, const AbstractRenderQueue::PointLight& light)
{
// If the object is too far away from this point light, there is not way it could light it
return object.SquaredDistance(light.position) <= light.radius * light.radius;
}
/*!
* \brief Checks whether the spot light is suitable for the computations
* \return true if light is enoughly close
*
* \param object Sphere symbolising the object
* \param light Light to compute
*/
inline bool ForwardRenderTechnique::IsSpotLightSuitable(const Spheref& object, const AbstractRenderQueue::SpotLight& light)
{
///TODO: Exclude spot lights based on their direction and outer angle?

View File

@@ -4,6 +4,12 @@
namespace Nz
{
/*!
* \brief Constructs a InstancedRenderable object by assignation
*
* \param renderable InstancedRenderable to copy into this
*/
inline InstancedRenderable::InstancedRenderable(const InstancedRenderable& renderable) :
RefCounted(),
m_boundingVolume(renderable.m_boundingVolume),
@@ -11,22 +17,43 @@ namespace Nz
{
}
/*!
* \brief Ensures that the bounding volume is up to date
*/
inline void InstancedRenderable::EnsureBoundingVolumeUpdated() const
{
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
}
/*!
* \brief Invalidates the bounding volume
*/
inline void InstancedRenderable::InvalidateBoundingVolume()
{
m_boundingVolumeUpdated = false;
}
/*!
* \brief Invalidates the instance data based on flags
*
* \param flags Flags to invalidate
*/
inline void InstancedRenderable::InvalidateInstanceData(UInt32 flags)
{
OnInstancedRenderableInvalidateData(this, flags);
}
/*!
* \brief Sets the current instanced renderable with the content of the other one
* \return A reference to this
*
* \param renderable The other InstancedRenderable
*/
inline InstancedRenderable& InstancedRenderable::operator=(const InstancedRenderable& renderable)
{
m_boundingVolume = renderable.m_boundingVolume;
@@ -35,6 +62,10 @@ namespace Nz
return *this;
}
/*!
* \brief Updates the bounding volume
*/
inline void InstancedRenderable::UpdateBoundingVolume() const
{
MakeBoundingVolume();

View File

@@ -7,6 +7,10 @@
namespace Nz
{
/*!
* \brief Constructs a Light object by default
*/
inline Light::Light(const Light& light) :
Renderable(light),
m_color(light.m_color),
@@ -28,6 +32,12 @@ namespace Nz
{
}
/*!
* \brief Enables shadow casting
*
* \param castShadows Should shadows be cast
*/
inline void Light::EnableShadowCasting(bool castShadows)
{
if (m_shadowCastingEnabled != castShadows)
@@ -37,72 +47,141 @@ namespace Nz
}
}
/*!
* \brief Ensures that the shadow map is up to date
*/
inline void Light::EnsureShadowMapUpdate() const
{
if (!m_shadowMapUpdated)
UpdateShadowMap();
}
/*!
* \brief Gets the ambient factor
* \return Current ambient factor
*/
inline float Light::GetAmbientFactor() const
{
return m_ambientFactor;
}
/*!
* \brief Gets the light attenuation (in 1 / R^2)
* \return Attenuation
*/
inline float Light::GetAttenuation() const
{
return m_attenuation;
}
/*!
* \brief Gets the color of the light
* \return Light color
*/
inline Color Light::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the diffuse factor
* \return Current diffuse factor
*/
inline float Light::GetDiffuseFactor() const
{
return m_diffuseFactor;
}
/*!
* \brief Gets the inner angle in spot light
* \return Inner angle
*/
inline float Light::GetInnerAngle() const
{
return m_innerAngle;
}
/*!
* \brief Gets the cosine inner angle in spot light
* \return Cosine inner angle
*/
inline float Light::GetInnerAngleCosine() const
{
return m_innerAngleCosine;
}
/*!
* \brief Gets the inverse of the radius
* \return Inverse of the radius
*/
inline float Light::GetInvRadius() const
{
return m_invRadius;
}
/*!
* \brief Gets the type of the light
* \return Light type
*/
inline LightType Light::GetLightType() const
{
return m_type;
}
/*!
* \brief Gets the outer angle in spot light
* \return Outer angle
*/
inline float Light::GetOuterAngle() const
{
return m_outerAngle;
}
/*!
* \brief Gets the cosine outer angle in spot light
* \return Cosine outer angle
*/
inline float Light::GetOuterAngleCosine() const
{
return m_outerAngleCosine;
}
/*!
* \brief Gets the tangent outer angle in spot light
* \return Tangent outer angle
*/
inline float Light::GetOuterAngleTangent() const
{
return m_outerAngleTangent;
}
/*!
* \brief Gets the radius of the light
* \return Light radius
*/
inline float Light::GetRadius() const
{
return m_radius;
}
/*!
* \brief Gets the shadow map
* \return Reference to the shadow map texture
*/
inline TextureRef Light::GetShadowMap() const
{
EnsureShadowMapUpdate();
@@ -110,47 +189,97 @@ namespace Nz
return m_shadowMap;
}
/*!
* \brief Gets the format of the shadow map
* \return Shadow map format
*/
inline PixelFormatType Light::GetShadowMapFormat() const
{
return m_shadowMapFormat;
}
/*!
* \brief Gets the size of the shadow map
* \return Shadow map size
*/
inline const Vector2ui& Light::GetShadowMapSize() const
{
return m_shadowMapSize;
}
/*!
* \brief Checks whether the shadow casting is enabled
* \return true If it is the case
*/
inline bool Light::IsShadowCastingEnabled() const
{
return m_shadowCastingEnabled;
}
/*!
* \brief Sets the ambient factor
*
* \param factor Ambient factor
*/
inline void Light::SetAmbientFactor(float factor)
{
m_ambientFactor = factor;
}
/*!
* \brief Sets the light attenuation (in 1 / R^2)
*
* \param attenuation Light attenuation
*/
inline void Light::SetAttenuation(float attenuation)
{
m_attenuation = attenuation;
}
/*!
* \brief Sets the color of the light
*
* \param color Light color
*/
inline void Light::SetColor(const Color& color)
{
m_color = color;
}
/*!
* \brief Sets the diffuse factor
*
* \param factor Diffuse factor
*/
inline void Light::SetDiffuseFactor(float factor)
{
m_diffuseFactor = factor;
}
/*!
* \brief Sets the inner angle in spot light
* \return innerAngle Inner angle
*/
inline void Light::SetInnerAngle(float innerAngle)
{
m_innerAngle = innerAngle;
m_innerAngleCosine = std::cos(DegreeToRadian(m_innerAngle));
}
/*!
* \brief Sets the type of light
*
* \param type Light type
*/
inline void Light::SetLightType(LightType type)
{
m_type = type;
@@ -158,6 +287,13 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the outer angle in spot light
* \return outerAngle Outer angle
*
* \remark Invalidates the bounding volume
*/
inline void Light::SetOuterAngle(float outerAngle)
{
m_outerAngle = outerAngle;
@@ -167,6 +303,13 @@ namespace Nz
InvalidateBoundingVolume();
}
/*!
* \brief Sets the radius of the light
* \return radius Light radius
*
* \remark Invalidates the bounding volume
*/
inline void Light::SetRadius(float radius)
{
m_radius = radius;
@@ -176,6 +319,15 @@ namespace Nz
InvalidateBoundingVolume();
}
/*!
* \brief Sets the shadow map format
*
* \param shadowFormat Shadow map format
*
* \remark Invalidates the shadow map
* \remark Produces a NazaraAssert if format is not a depth type
*/
inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat)
{
NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format");
@@ -185,6 +337,15 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the size of the shadow map
*
* \param size Shadow map size
*
* \remark Invalidates the shadow map
* \remark Produces a NazaraAssert if size is zero
*/
inline void Light::SetShadowMapSize(const Vector2ui& size)
{
NazaraAssert(size.x > 0 && size.y > 0, "Shadow map size must have a positive size");
@@ -194,6 +355,15 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the current light with the content of the other one
* \return A reference to this
*
* \param light The other Light
*
* \remark Invalidates the shadow map
*/
inline Light& Light::operator=(const Light& light)
{
Renderable::operator=(light);
@@ -218,6 +388,10 @@ namespace Nz
return *this;
}
/*!
* \brief Invalidates the shadow map
*/
inline void Light::InvalidateShadowMap()
{
m_shadowMapUpdated = false;

View File

@@ -151,7 +151,7 @@ namespace Nz
inline Material& operator=(const Material& material);
static MaterialRef GetDefault();
inline static MaterialRef GetDefault();
template<typename... Args> static MaterialRef New(Args&&... args);
// Signals:
@@ -163,7 +163,7 @@ namespace Nz
{
const Shader* shader;
UberShaderInstance* uberInstance = nullptr;
int uniforms[MaterialUniform_Max+1];
int uniforms[MaterialUniform_Max + 1];
};
void Copy(const Material& material);
@@ -187,7 +187,7 @@ namespace Nz
TextureRef m_normalMap;
TextureRef m_specularMap;
UberShaderConstRef m_uberShader;
mutable ShaderInstance m_shaders[ShaderFlags_Max+1];
mutable ShaderInstance m_shaders[ShaderFlags_Max + 1];
bool m_alphaTestEnabled;
bool m_depthSortingEnabled;
bool m_lightingEnabled;

View File

@@ -7,11 +7,21 @@
namespace Nz
{
/*!
* \brief Constructs a Material object by default
*/
inline Material::Material()
{
Reset();
}
/*!
* \brief Constructs a Material object by assignation
*
* \param material Material to copy into this
*/
inline Material::Material(const Material& material) :
RefCounted(),
Resource(material)
@@ -19,11 +29,26 @@ namespace Nz
Copy(material);
}
/*!
* \brief Destructs the object and calls OnMaterialRelease
*
* \see OnMaterialRelease
*/
inline Material::~Material()
{
OnMaterialRelease(this);
}
/*!
* \brief Enables a renderer parameter
*
* \param renderParameter Parameter for the rendering
* \param enable Should the parameter be enabled
*
* \remark Produces a NazaraAssert if enumeration is invalid
*/
inline void Material::Enable(RendererParameter renderParameter, bool enable)
{
NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum");
@@ -31,6 +56,14 @@ namespace Nz
m_states.parameters[renderParameter] = enable;
}
/*!
* \brief Enables the alpha test
*
* \param alphaTest Should the parameter be enabled
*
* \remark Invalidates the shaders
*/
inline void Material::EnableAlphaTest(bool alphaTest)
{
m_alphaTestEnabled = alphaTest;
@@ -38,12 +71,26 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Enables the depth sorting
*
* \param depthSorting Should the parameter be enabled
*/
inline void Material::EnableDepthSorting(bool depthSorting)
{
// Has no influence on shaders
m_depthSortingEnabled = depthSorting;
}
/*!
* \brief Enables the lighting
*
* \param lighting Should the parameter be enabled
*
* \remark Invalidates the shaders
*/
inline void Material::EnableLighting(bool lighting)
{
m_lightingEnabled = lighting;
@@ -51,12 +98,26 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Enables the shadow casting
*
* \param castShadows Should shadow casting be enabled
*/
inline void Material::EnableShadowCasting(bool castShadows)
{
// Has no influence on shaders
m_shadowCastingEnabled = castShadows;
}
/*!
* \brief Enables the shadow on receiving object
*
* \param receiveShadow Should receiving object have shadows enabled
*
* \remark Invalidates the shaders
*/
inline void Material::EnableShadowReceive(bool receiveShadows)
{
m_shadowReceiveEnabled = receiveShadows;
@@ -64,6 +125,14 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Enables the transformation
*
* \param transform Should the parameter be enabled
*
* \remark Invalidates the shaders
*/
inline void Material::EnableTransform(bool transform)
{
m_transformEnabled = transform;
@@ -71,91 +140,183 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Gets the alpha map
* \return Constant reference to the current texture
*/
inline const TextureRef& Material::GetAlphaMap() const
{
return m_alphaMap;
}
/*!
* \brief Gets the alpha threshold
* \return The threshold value for the alpha
*/
inline float Material::GetAlphaThreshold() const
{
return m_alphaThreshold;
}
/*!
* \brief Gets the ambient color
* \return Ambient color
*/
inline Color Material::GetAmbientColor() const
{
return m_ambientColor;
}
/*!
* \brief Gets the function to compare depth
* \return Function comparing the depth of two materials
*/
inline RendererComparison Material::GetDepthFunc() const
{
return m_states.depthFunc;
}
/*!
* \brief Gets the depth material
* \return Constant reference to the depth material
*/
inline const MaterialRef& Material::GetDepthMaterial() const
{
return m_depthMaterial;
}
/*!
* \brief Gets the diffuse color
* \return Diffuse color
*/
inline Color Material::GetDiffuseColor() const
{
return m_diffuseColor;
}
/*!
* \brief Gets the diffuse sampler
* \return Reference to the current texture sampler for the diffuse
*/
inline TextureSampler& Material::GetDiffuseSampler()
{
return m_diffuseSampler;
}
/*!
* \brief Gets the diffuse sampler
* \return Constant reference to the current texture sampler for the diffuse
*/
inline const TextureSampler& Material::GetDiffuseSampler() const
{
return m_diffuseSampler;
}
/*!
* \brief Gets the diffuse map
* \return Constant reference to the texture
*/
const TextureRef& Material::GetDiffuseMap() const
{
return m_diffuseMap;
}
/*!
* \brief Gets the dst in blend
* \return Function for dst blending
*/
inline BlendFunc Material::GetDstBlend() const
{
return m_states.dstBlend;
}
/*!
* \brief Gets the emissive map
* \return Constant reference to the texture
*/
inline const TextureRef& Material::GetEmissiveMap() const
{
return m_emissiveMap;
}
/*!
* \brief Gets the face culling
* \return Current face culling side
*/
inline FaceSide Material::GetFaceCulling() const
{
return m_states.faceCulling;
}
/*!
* \brief Gets the face filling
* \return Current face filling
*/
inline FaceFilling Material::GetFaceFilling() const
{
return m_states.faceFilling;
}
/*!
* \brief Gets the height map
* \return Constant reference to the texture
*/
inline const TextureRef& Material::GetHeightMap() const
{
return m_heightMap;
}
/*!
* \brief Gets the normal map
* \return Constant reference to the texture
*/
inline const TextureRef& Material::GetNormalMap() const
{
return m_normalMap;
}
/*!
* \brief Gets the render states
* \return Constant reference to the render states
*/
inline const RenderStates& Material::GetRenderStates() const
{
return m_states;
}
/*!
* \brief Gets the shader of this material
* \return Constant pointer to the ubershader used
*/
inline const UberShader* Material::GetShader() const
{
return m_uberShader;
}
/*!
* \brief Gets the shader instance based on the flag
* \return Constant pointer to the ubershader instance
*
* \param flags Flag of the shader
*/
inline const UberShaderInstance* Material::GetShaderInstance(UInt32 flags) const
{
const ShaderInstance& instance = m_shaders[flags];
@@ -165,81 +326,165 @@ namespace Nz
return instance.uberInstance;
}
/*!
* \brief Gets the shininess
* \return Current shininess
*/
inline float Material::GetShininess() const
{
return m_shininess;
}
/*!
* \brief Gets the specular color
* \return Specular color
*/
inline Color Material::GetSpecularColor() const
{
return m_specularColor;
}
/*!
* \brief Gets the specular map
* \return Constant reference to the texture
*/
inline const TextureRef& Material::GetSpecularMap() const
{
return m_specularMap;
}
/*!
* \brief Gets the specular sampler
* \return Reference to the current texture sampler for the specular
*/
inline TextureSampler& Material::GetSpecularSampler()
{
return m_specularSampler;
}
/*!
* \brief Gets the specular sampler
* \return Constant reference to the current texture sampler for the specular
*/
inline const TextureSampler& Material::GetSpecularSampler() const
{
return m_specularSampler;
}
/*!
* \brief Gets the src in blend
* \return Function for src blending
*/
inline BlendFunc Material::GetSrcBlend() const
{
return m_states.srcBlend;
}
/*!
* \brief Checks whether this material has an alpha map
* \return true If it is the case
*/
inline bool Material::HasAlphaMap() const
{
return m_alphaMap.IsValid();
}
/*!
* \brief Checks whether this material has a depth material
* \return true If it is the case
*/
inline bool Material::HasDepthMaterial() const
{
return m_depthMaterial.IsValid();
}
/*!
* \brief Checks whether this material has a diffuse map
* \return true If it is the case
*/
inline bool Material::HasDiffuseMap() const
{
return m_diffuseMap.IsValid();
}
/*!
* \brief Checks whether this material has a emissive map
* \return true If it is the case
*/
inline bool Material::HasEmissiveMap() const
{
return m_emissiveMap.IsValid();
}
/*!
* \brief Checks whether this material has a height map
* \return true If it is the case
*/
inline bool Material::HasHeightMap() const
{
return m_heightMap.IsValid();
}
/*!
* \brief Checks whether this material has a normal map
* \return true If it is the case
*/
inline bool Material::HasNormalMap() const
{
return m_normalMap.IsValid();
}
/*!
* \brief Checks whether this material has a specular map
* \return true If it is the case
*/
inline bool Material::HasSpecularMap() const
{
return m_specularMap.IsValid();
}
/*!
* \brief Checks whether this material has alpha test enabled
* \return true If it is the case
*/
inline bool Material::IsAlphaTestEnabled() const
{
return m_alphaTestEnabled;
}
/*!
* \brief Checks whether this material has depth sorting enabled
* \return true If it is the case
*/
inline bool Material::IsDepthSortingEnabled() const
{
return m_depthSortingEnabled;
}
/*!
* \brief Checks whether this material has the render parameter enabled
* \return true If it is the case
*
* \param parameter Parameter for the rendering
*
* \remark Produces a NazaraAssert if enumeration is invalid
*/
inline bool Material::IsEnabled(RendererParameter parameter) const
{
NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum");
@@ -247,41 +492,93 @@ namespace Nz
return m_states.parameters[parameter];
}
/*!
* \brief Checks whether this material has lightning enabled
* \return true If it is the case
*/
inline bool Material::IsLightingEnabled() const
{
return m_lightingEnabled;
}
/*!
* \brief Checks whether this material cast shadow
* \return true If it is the case
*/
inline bool Material::IsShadowCastingEnabled() const
{
return m_shadowCastingEnabled;
}
/*!
* \brief Checks whether this material receive shadow
* \return true If it is the case
*/
inline bool Material::IsShadowReceiveEnabled() const
{
return m_shadowReceiveEnabled;
}
/*!
* \brief Checks whether this material has transformation enabled
* \return true If it is the case
*/
inline bool Material::IsTransformEnabled() const
{
return m_transformEnabled;
}
/*!
* \brief Loads the material from file
* \return true if loading is successful
*
* \param filePath Path to the file
* \param params Parameters for the material
*/
inline bool Material::LoadFromFile(const String& filePath, const MaterialParams& params)
{
return MaterialLoader::LoadFromFile(this, filePath, params);
}
/*!
* \brief Loads the material from memory
* \return true if loading is successful
*
* \param data Raw memory
* \param size Size of the memory
* \param params Parameters for the material
*/
inline bool Material::LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params)
{
return MaterialLoader::LoadFromMemory(this, data, size, params);
}
/*!
* \brief Loads the material from stream
* \return true if loading is successful
*
* \param stream Stream to the material
* \param params Parameters for the material
*/
inline bool Material::LoadFromStream(Stream& stream, const MaterialParams& params)
{
return MaterialLoader::LoadFromStream(this, stream, params);
}
/*!
* \brief Sets the alpha map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetAlphaMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -299,6 +596,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the alpha map with a reference to a texture
* \return true If successful
*
* \param alphaMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetAlphaMap(TextureRef alphaMap)
{
m_alphaMap = std::move(alphaMap);
@@ -306,31 +612,69 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the alpha threshold
*
* \param alphaThreshold Threshold for the alpha
*/
inline void Material::SetAlphaThreshold(float alphaThreshold)
{
m_alphaThreshold = alphaThreshold;
}
/*!
* \brief Sets the color for ambient
*
* \param ambient Color for ambient
*/
inline void Material::SetAmbientColor(const Color& ambient)
{
m_ambientColor = ambient;
}
/*!
* \brief Sets the depth functor
*
* \param depthFunc
*/
inline void Material::SetDepthFunc(RendererComparison depthFunc)
{
m_states.depthFunc = depthFunc;
}
/*!
* \brief Sets the depth material
* \return true If successful
*
* \param depthMaterial Material for depth
*/
inline void Material::SetDepthMaterial(MaterialRef depthMaterial)
{
m_depthMaterial = std::move(depthMaterial);
}
/*!
* \brief Sets the color for diffuse
*
* \param diffuse Color for diffuse
*/
inline void Material::SetDiffuseColor(const Color& diffuse)
{
m_diffuseColor = diffuse;
}
/*!
* \brief Sets the diffuse map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetDiffuseMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -348,6 +692,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the diffuse map with a reference to a texture
* \return true If successful
*
* \param diffuseMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetDiffuseMap(TextureRef diffuseMap)
{
m_diffuseMap = std::move(diffuseMap);
@@ -355,16 +708,35 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the diffuse sampler
*
* \param sampler Diffuse sample
*/
inline void Material::SetDiffuseSampler(const TextureSampler& sampler)
{
m_diffuseSampler = sampler;
}
/*!
* \brief Sets the dst in blend
*
* \param func Function for dst blending
*/
inline void Material::SetDstBlend(BlendFunc func)
{
m_states.dstBlend = func;
}
/*!
* \brief Sets the emissive map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetEmissiveMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -382,6 +754,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the emissive map with a reference to a texture
* \return true If successful
*
* \param emissiveMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetEmissiveMap(TextureRef emissiveMap)
{
m_emissiveMap = std::move(emissiveMap);
@@ -389,16 +770,35 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the face culling
*
* \param faceSide Face to cull
*/
inline void Material::SetFaceCulling(FaceSide faceSide)
{
m_states.faceCulling = faceSide;
}
/*!
* \brief Sets the face filling
*
* \param filling Face to fill
*/
inline void Material::SetFaceFilling(FaceFilling filling)
{
m_states.faceFilling = filling;
}
/*!
* \brief Sets the height map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetHeightMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -416,6 +816,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the height map with a reference to a texture
* \return true If successful
*
* \param heightMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetHeightMap(TextureRef heightMap)
{
m_heightMap = std::move(heightMap);
@@ -423,6 +832,13 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the normal map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetNormalMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -440,6 +856,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the normal map with a reference to a texture
* \return true If successful
*
* \param normalMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetNormalMap(TextureRef normalMap)
{
m_normalMap = std::move(normalMap);
@@ -447,11 +872,25 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the render states
*
* \param states States for the rendering
*/
inline void Material::SetRenderStates(const RenderStates& states)
{
m_states = states;
}
/*!
* \brief Sets the shader with a constant reference to a ubershader
*
* \param uberShader Uber shader to apply
*
* \remark Invalidates the shaders
*/
inline void Material::SetShader(UberShaderConstRef uberShader)
{
m_uberShader = std::move(uberShader);
@@ -459,6 +898,13 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the shader by name
* \return true If successful
*
* \param uberShaderName Named shader
*/
inline bool Material::SetShader(const String& uberShaderName)
{
UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName);
@@ -469,16 +915,35 @@ namespace Nz
return true;
}
/*!
* \brief Sets the shininess of the material
*
* \param shininess Value of the shininess
*/
inline void Material::SetShininess(float shininess)
{
m_shininess = shininess;
}
/*!
* \brief Sets the color for specular
*
* \param specular Color
*/
inline void Material::SetSpecularColor(const Color& specular)
{
m_specularColor = specular;
}
/*!
* \brief Sets the specular map by name
* \return true If successful
*
* \param textureName Named texture
*/
inline bool Material::SetSpecularMap(const String& textureName)
{
TextureRef texture = TextureLibrary::Query(textureName);
@@ -496,6 +961,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the specular map with a reference to a texture
* \return true If successful
*
* \param specularMap Texture
*
* \remark Invalidates the shaders
*/
inline void Material::SetSpecularMap(TextureRef specularMap)
{
m_specularMap = std::move(specularMap);
@@ -503,16 +977,35 @@ namespace Nz
InvalidateShaders();
}
/*!
* \brief Sets the specular sampler
*
* \param sampler Specular sample
*/
inline void Material::SetSpecularSampler(const TextureSampler& sampler)
{
m_specularSampler = sampler;
}
/*!
* \brief Sets the src in blend
*
* \param func Function for src blending
*/
inline void Material::SetSrcBlend(BlendFunc func)
{
m_states.srcBlend = func;
}
/*!
* \brief Sets the current material with the content of the other one
* \return A reference to this
*
* \param material The other Material
*/
inline Material& Material::operator=(const Material& material)
{
Resource::operator=(material);
@@ -521,17 +1014,33 @@ namespace Nz
return *this;
}
/*!
* \brief Gets the default material
* \return Reference to the default material
*/
inline MaterialRef Material::GetDefault()
{
return s_defaultMaterial;
}
/*!
* \brief Invalidates the shaders
*/
inline void Material::InvalidateShaders()
{
for (ShaderInstance& instance : m_shaders)
instance.uberInstance = nullptr;
}
/*!
* \brief Creates a new material from the arguments
* \return A reference to the newly created material
*
* \param args Arguments for the material
*/
template<typename... Args>
MaterialRef Material::New(Args&&... args)
{

View File

@@ -68,8 +68,6 @@ namespace Nz
bool SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material);
void SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material);
virtual void SetMesh(Mesh* mesh);
bool SetSequence(const String& sequenceName);
void SetSequence(unsigned int sequenceIndex);
void SetSkin(unsigned int skin);
void SetSkinCount(unsigned int skinCount);

View File

@@ -7,6 +7,13 @@
namespace Nz
{
/*!
* \brief Creates a new Model from the arguments
* \return A reference to the newly created model
*
* \param args Arguments for the model
*/
template<typename... Args>
ModelRef Model::New(Args&&... args)
{

View File

@@ -62,16 +62,16 @@ namespace Nz
/*
** -Lynix:
** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas
** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile.
** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir !
** It would be also possible to precise the stride by an independant way, what I don't allow
** to decomplexify the interface of something I consider useless.
** If you think that could be useful, don't hesitate to make me aware !
*/
};
Component m_components[ParticleComponent_Max+1];
Component m_components[ParticleComponent_Max + 1];
unsigned int m_stride;
static ParticleDeclaration s_declarations[ParticleLayout_Max+1];
static ParticleDeclaration s_declarations[ParticleLayout_Max + 1];
static ParticleDeclarationLibrary::LibraryMap s_library;
};
}

View File

@@ -7,10 +7,20 @@
namespace Nz
{
/*!
* \brief Gets a pointer to iterate through same components
* \return SparsePtr pointing to same components
*
* \param component Component to get in the declaration
*
* \remark The same components are not continguous but separated by sizeof(ParticleSize)
* \remark Produces a NazaraError if component is disabled
*/
template <typename T>
SparsePtr<T> ParticleMapper::GetComponentPtr(ParticleComponent component)
{
// Ensuite le composant qui nous intéresse
// Then the component that are interesting
bool enabled;
ComponentType type;
unsigned int offset;
@@ -18,7 +28,7 @@ namespace Nz
if (enabled)
{
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
///TODO: Check the ratio between the type of the attribute and the template type ?
return SparsePtr<T>(m_ptr + offset, m_declaration->GetStride());
}
else
@@ -28,10 +38,20 @@ namespace Nz
}
}
/*!
* \brief Gets a pointer to iterate through same components
* \return SparsePtr pointing to same components
*
* \param component Component to get in the declaration
*
* \remark The same components are not continguous but separated by sizeof(ParticleSize)
* \remark Produces a NazaraError if component is disabled
*/
template <typename T>
SparsePtr<const T> ParticleMapper::GetComponentPtr(ParticleComponent component) const
{
// Ensuite le composant qui nous intéresse
// Then the component that are interesting
bool enabled;
ComponentType type;
unsigned int offset;
@@ -39,7 +59,7 @@ namespace Nz
if (enabled)
{
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
///TODO: Check the ratio between the type of the attribute and the template type ?
return SparsePtr<const T>(m_ptr + offset, m_declaration->GetStride());
}
else

View File

@@ -4,17 +4,31 @@
namespace Nz
{
/*!
* \brief Ensures that the bounding volume is up to date
*/
inline void Renderable::EnsureBoundingVolumeUpdated() const
{
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
}
/*!
* \brief Invalidates the bounding volume
*/
inline void Renderable::InvalidateBoundingVolume()
{
m_boundingVolumeUpdated = false;
}
/*!
* \brief Updates the bounding volume by a matrix
*
* \param transformMatrix Matrix transformation for our bounding volume
*/
inline void Renderable::UpdateBoundingVolume() const
{
MakeBoundingVolume();

View File

@@ -7,31 +7,62 @@
namespace Nz
{
/*!
* \brief Gets the movement offset
* \return Offset of the movement
*/
inline const Vector3f& Nz::SkyboxBackground::GetMovementOffset() const
{
return m_movementOffset;
}
/*!
* \brief Gets the movement scale
* \return Scale of the movement
*/
inline float SkyboxBackground::GetMovementScale() const
{
return m_movementScale;
}
/*!
* \brief Gets the texture of the background
* \return Texture of the background
*/
inline const TextureRef& SkyboxBackground::GetTexture() const
{
return m_texture;
}
/*!
* \brief Gets the texture sampler of the background
* \return A reference to the texture sampler of the background
*/
inline TextureSampler& SkyboxBackground::GetTextureSampler()
{
return m_sampler;
}
/*!
* \brief Gets the texture sampler of the background
* \return A constant reference to the texture sampler of the background
*/
inline const TextureSampler& SkyboxBackground::GetTextureSampler() const
{
return m_sampler;
}
/*!
* \brief Sets the movement offset
*
* \param offset Offset of the movement
*/
inline void SkyboxBackground::SetMovementOffset(const Vector3f& offset)
{
NazaraAssert(std::isfinite(offset.x) && std::isfinite(offset.y) && std::isfinite(offset.z), "Offset must be a finite vector");
@@ -39,6 +70,12 @@ namespace Nz
m_movementOffset = offset;
}
/*!
* \brief Sets the movement scale
*
* \param scale Scale of the movement
*/
inline void SkyboxBackground::SetMovementScale(float scale)
{
NazaraAssert(std::isfinite(scale), "Scale must be a finite value");
@@ -46,6 +83,12 @@ namespace Nz
m_movementScale = scale;
}
/*!
* \brief Sets the texture of the background
*
* \param cubemapTexture Texture of the background
*/
inline void SkyboxBackground::SetTexture(TextureRef cubemapTexture)
{
NazaraAssert(!cubemapTexture || cubemapTexture->IsValid(), "Invalid texture");
@@ -54,11 +97,24 @@ namespace Nz
m_texture = std::move(cubemapTexture);
}
/*!
* \brief Sets the texture sampler of the background
*
* \param sampler Texture sampler of the background
*/
void SkyboxBackground::SetTextureSampler(const TextureSampler& sampler)
{
m_sampler = sampler;
}
/*!
* \brief Creates a new skybox background from the arguments
* \return A reference to the newly created skybox background
*
* \param args Arguments for the skybox background
*/
template<typename... Args>
SkyboxBackgroundRef SkyboxBackground::New(Args&&... args)
{

View File

@@ -8,6 +8,10 @@
namespace Nz
{
/*!
* \brief Constructs a Sprite object by default
*/
inline Sprite::Sprite() :
m_color(Color::White),
m_textureCoords(0.f, 0.f, 1.f, 1.f),
@@ -16,6 +20,12 @@ namespace Nz
SetDefaultMaterial();
}
/*!
* \brief Constructs a Sprite object with a reference to a material
*
* \param material Reference to a material
*/
inline Sprite::Sprite(MaterialRef material) :
m_color(Color::White),
m_textureCoords(0.f, 0.f, 1.f, 1.f),
@@ -24,6 +34,12 @@ namespace Nz
SetMaterial(std::move(material), true);
}
/*!
* \brief Constructs a Sprite object with a pointer to a texture
*
* \param texture Pointer to a texture
*/
inline Sprite::Sprite(Texture* texture) :
m_color(Color::White),
m_textureCoords(0.f, 0.f, 1.f, 1.f),
@@ -32,6 +48,12 @@ namespace Nz
SetTexture(texture, true);
}
/*!
* \brief Constructs a Sprite object by assignation
*
* \param sprite Sprite to copy into this
*/
inline Sprite::Sprite(const Sprite& sprite) :
InstancedRenderable(sprite),
m_color(sprite.m_color),
@@ -41,26 +63,52 @@ namespace Nz
{
}
/*!
* \brief Gets the color of the sprite
* \return Current color
*/
inline const Color& Sprite::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the material of the sprite
* \return Current material
*/
inline const MaterialRef& Sprite::GetMaterial() const
{
return m_material;
}
/*!
* \brief Gets the size of the sprite
* \return Current size
*/
inline const Vector2f& Sprite::GetSize() const
{
return m_size;
}
/*!
* \brief Gets the texture coordinates of the sprite
* \return Current texture coordinates
*/
inline const Rectf& Sprite::GetTextureCoords() const
{
return m_textureCoords;
}
/*!
* \brief Sets the color of the billboard
*
* \param color Color for the billboard
*/
inline void Sprite::SetColor(const Color& color)
{
m_color = color;
@@ -68,6 +116,10 @@ namespace Nz
InvalidateVertices();
}
/*!
* \brief Sets the default material of the sprite (just default material)
*/
inline void Sprite::SetDefaultMaterial()
{
MaterialRef material = Material::New();
@@ -77,6 +129,13 @@ namespace Nz
SetMaterial(std::move(material));
}
/*!
* \brief Sets the material of the sprite
*
* \param material Material for the sprite
* \param resizeSprite Should sprite be resized to the material size (diffuse map)
*/
inline void Sprite::SetMaterial(MaterialRef material, bool resizeSprite)
{
m_material = std::move(material);
@@ -88,6 +147,12 @@ namespace Nz
}
}
/*!
* \brief Sets the size of the sprite
*
* \param size Size for the sprite
*/
inline void Sprite::SetSize(const Vector2f& size)
{
m_size = size;
@@ -97,11 +162,25 @@ namespace Nz
InvalidateVertices();
}
/*!
* \brief Sets the size of the sprite
*
* \param sizeX Size in X for the sprite
* \param sizeY Size in Y for the sprite
*/
inline void Sprite::SetSize(float sizeX, float sizeY)
{
SetSize(Vector2f(sizeX, sizeY));
}
/*!
* \brief Sets the texture of the sprite
*
* \param texture Texture for the sprite
* \param resizeSprite Should sprite be resized to the texture size
*/
inline void Sprite::SetTexture(TextureRef texture, bool resizeSprite)
{
if (!m_material)
@@ -115,12 +194,27 @@ namespace Nz
m_material->SetDiffuseMap(std::move(texture));
}
/*!
* \brief Sets the texture coordinates of the sprite
*
* \param coords Texture coordinates
*/
inline void Sprite::SetTextureCoords(const Rectf& coords)
{
m_textureCoords = coords;
InvalidateVertices();
}
/*!
* \brief Sets the texture rectangle of the sprite
*
* \param rect Rectangles symbolizing the size of the texture
*
* \remark Produces a NazaraAssert if material is invalid
* \remark Produces a NazaraAssert if material has no diffuse map
*/
inline void Sprite::SetTextureRect(const Rectui& rect)
{
NazaraAssert(m_material, "Sprite has no material");
@@ -128,12 +222,19 @@ namespace Nz
Texture* diffuseMap = m_material->GetDiffuseMap();
float invWidth = 1.f/diffuseMap->GetWidth();
float invHeight = 1.f/diffuseMap->GetHeight();
float invWidth = 1.f / diffuseMap->GetWidth();
float invHeight = 1.f / diffuseMap->GetHeight();
SetTextureCoords(Rectf(invWidth*rect.x, invHeight*rect.y, invWidth*rect.width, invHeight*rect.height));
SetTextureCoords(Rectf(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height));
}
/*!
* \brief Sets the current sprite with the content of the other one
* \return A reference to this
*
* \param sprite The other Sprite
*/
inline Sprite& Sprite::operator=(const Sprite& sprite)
{
InstancedRenderable::operator=(sprite);
@@ -143,18 +244,29 @@ namespace Nz
m_textureCoords = sprite.m_textureCoords;
m_size = sprite.m_size;
// On ne copie pas les sommets finaux car il est très probable que nos paramètres soient modifiés et qu'ils doivent être régénérés de toute façon
// We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated
InvalidateBoundingVolume();
InvalidateVertices();
return *this;
}
/*!
* \brief Invalidates the vertices
*/
inline void Sprite::InvalidateVertices()
{
InvalidateInstanceData(0);
}
/*!
* \brief Creates a new sprite from the arguments
* \return A reference to the newly created sprite
*
* \param args Arguments for the sprite
*/
template<typename... Args>
SpriteRef Sprite::New(Args&&... args)
{

View File

@@ -7,6 +7,10 @@
namespace Nz
{
/*!
* \brief Constructs a TextSprite object by default
*/
inline TextSprite::TextSprite() :
m_color(Color::White),
m_scale(1.f)
@@ -14,12 +18,24 @@ namespace Nz
SetDefaultMaterial();
}
/*!
* \brief Constructs a TextSprite object with a drawer
*
* \param drawer Drawer used to compose text on the sprite
*/
inline TextSprite::TextSprite(const AbstractTextDrawer& drawer) :
TextSprite()
{
Update(drawer);
}
/*!
* \brief Constructs a TextSprite object by assignation
*
* \param sprite TextSprite to copy into this
*/
inline TextSprite::TextSprite(const TextSprite& sprite) :
InstancedRenderable(sprite),
m_renderInfos(sprite.m_renderInfos),
@@ -40,6 +56,10 @@ namespace Nz
}
}
/*!
* \brief Clears the data
*/
inline void TextSprite::Clear()
{
m_atlases.clear();
@@ -48,21 +68,42 @@ namespace Nz
m_renderInfos.clear();
}
/*!
* \brief Gets the color of the text sprite
* \return Current color
*/
inline const Color& TextSprite::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the material of the text sprite
* \return Current material
*/
inline const MaterialRef& TextSprite::GetMaterial() const
{
return m_material;
}
/*!
* \brief Gets the current scale of the text sprite
* \return Current scale
*/
inline float TextSprite::GetScale() const
{
return m_scale;
}
/*!
* \brief Sets the color of the text sprite
*
* \param color Color for the text sprite
*/
inline void TextSprite::SetColor(const Color& color)
{
m_color = color;
@@ -70,6 +111,11 @@ namespace Nz
InvalidateVertices();
}
/*!
* \brief Sets the default material of the text sprite (just default material)
*/
inline void TextSprite::SetDefaultMaterial()
{
MaterialRef material = Material::New();
@@ -83,11 +129,23 @@ namespace Nz
SetMaterial(material);
}
/*!
* \brief Sets the material of the text sprite
*
* \param material Material for the text sprite
*/
inline void TextSprite::SetMaterial(MaterialRef material)
{
m_material = std::move(material);
}
/*!
* \brief Sets the current scale of the text sprite
*
* \param scale Scale of the text sprite
*/
inline void TextSprite::SetScale(float scale)
{
m_scale = scale;
@@ -95,10 +153,12 @@ namespace Nz
InvalidateVertices();
}
inline void TextSprite::InvalidateVertices()
{
InvalidateInstanceData(0);
}
/*!
* \brief Sets the current text sprite with the content of the other one
* \return A reference to this
*
* \param text sprite The other TextSprite
*/
inline TextSprite& TextSprite::operator=(const TextSprite& text)
{
@@ -130,6 +190,22 @@ namespace Nz
return *this;
}
/*!
* \brief Invalidates the vertices
*/
inline void TextSprite::InvalidateVertices()
{
InvalidateInstanceData(0);
}
/*!
* \brief Creates a new text sprite from the arguments
* \return A reference to the newly created text sprite
*
* \param args Arguments for the text sprite
*/
template<typename... Args>
TextSpriteRef TextSprite::New(Args&&... args)
{

View File

@@ -7,11 +7,22 @@
namespace Nz
{
/*!
* \brief Gets the texture of the background
* \return Texture of the background
*/
inline const TextureRef& TextureBackground::GetTexture() const
{
return m_texture;
}
/*!
* \brief Sets the texture of the background
*
* \param texture Texture of the background
*/
inline void TextureBackground::SetTexture(TextureRef texture)
{
NazaraAssert(!texture || texture->IsValid(), "Invalid texture");
@@ -19,6 +30,13 @@ namespace Nz
m_texture = std::move(texture);
}
/*!
* \brief Creates a new texture background from the arguments
* \return A reference to the newly created texture background
*
* \param args Arguments for the texture background
*/
template<typename... Args>
TextureBackgroundRef TextureBackground::New(Args&&... args)
{