Added cubemap helpers for Image/Texture

Former-commit-id: 3c0dfb9e9b78369b8a552a55f2c70b978e626ce9
This commit is contained in:
Lynix
2013-04-07 02:08:08 +02:00
parent 633b3bb7ba
commit 4afe078e9d
5 changed files with 423 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2013 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_CUBEMAPPARAMS_HPP
#define NAZARA_CUBEMAPPARAMS_HPP
#include <Nazara/Math/Vector2.hpp>
struct NzCubemapParams
{
/*
La position de chaque face dans la cubemap
Les indices ici seront multipliés à la taille d'une face pour obtenir le coin haut-gauche de la zone.
Si la taille d'une face est 0, elle sera calculée via max(width, height)/4.
Par défaut, cela suit ce layout :
U
L F R B
D
Si ce n'est pas le cas, à vous de repositionner les faces correctement.
*/
NzVector2ui backPosition = NzVector2ui(3, 1);
NzVector2ui downPosition = NzVector2ui(1, 2);
NzVector2ui forwardPosition = NzVector2ui(1, 1);
NzVector2ui leftPosition = NzVector2ui(0, 1);
NzVector2ui rightPosition = NzVector2ui(2, 1);
NzVector2ui upPosition = NzVector2ui(1, 0);
unsigned int faceSize = 0;
};
#endif // NAZARA_CUBEMAPPARAMS_HPP

View File

@@ -16,6 +16,7 @@
#include <Nazara/Math/Cube.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/CubemapParams.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
@@ -90,10 +91,17 @@ class NAZARA_API NzImage : public NzResource
bool IsCubemap() const;
bool IsValid() const;
// Load
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
// LoadCubemap
bool LoadCubemapFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
bool LoadCubemapFromImage(const NzImage& image, const NzCubemapParams& params = NzCubemapParams());
bool LoadCubemapFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
bool LoadCubemapFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
void SetLevelCount(nzUInt8 levelCount);
bool SetPixelColor(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);