mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-16 14:22:24 +08:00
+ added parsing of dependencies for objects
+ added fbos parsing from effect files ~ cleaned up effect parsing code ~ support for texture target parsing in materials for texture render targets ~ changed way of modifying textures from passes to a more abstracted way ~ moved shader constants to it's own namespace Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
e32bc4d6f1
commit
5e94fc7bab
@ -98,14 +98,17 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Objects/CParticle.cpp
|
||||
src/WallpaperEngine/Core/Objects/CParticle.h
|
||||
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CFBO.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp
|
||||
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantFloat.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantFloat.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector3.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector3.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantInteger.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantInteger.cpp
|
||||
|
||||
src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp
|
||||
src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h
|
||||
|
@ -36,6 +36,7 @@ CObject* CObject::fromJSON (json data)
|
||||
auto angles_it = data.find ("angles");
|
||||
auto name_it = data.find ("name");
|
||||
auto effects_it = data.find ("effects");
|
||||
auto dependencies_it = data.find ("dependencies");
|
||||
|
||||
bool visible = true;
|
||||
|
||||
@ -128,6 +129,17 @@ CObject* CObject::fromJSON (json data)
|
||||
}
|
||||
}
|
||||
|
||||
if (dependencies_it != data.end () && (*dependencies_it).is_array () == true)
|
||||
{
|
||||
auto cur = (*dependencies_it).begin ();
|
||||
auto end = (*dependencies_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
object->insertDependency (*cur);
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -156,6 +168,11 @@ const std::vector<Objects::CEffect*>& CObject::getEffects () const
|
||||
return this->m_effects;
|
||||
}
|
||||
|
||||
const std::vector<irr::u32>& CObject::getDependencies () const
|
||||
{
|
||||
return this->m_dependencies;
|
||||
}
|
||||
|
||||
bool CObject::isVisible ()
|
||||
{
|
||||
return this->m_visible;
|
||||
@ -169,4 +186,8 @@ const int CObject::getId () const
|
||||
void CObject::insertEffect (Objects::CEffect* effect)
|
||||
{
|
||||
this->m_effects.push_back (effect);
|
||||
}
|
||||
void CObject::insertDependency (irr::u32 dependency)
|
||||
{
|
||||
this->m_dependencies.push_back (dependency);
|
||||
}
|
@ -25,6 +25,7 @@ namespace WallpaperEngine::Core
|
||||
template<class T> bool is () { return this->m_type == T::Type; }
|
||||
|
||||
const std::vector<Objects::CEffect*>& getEffects () const;
|
||||
const std::vector<irr::u32>& getDependencies () const;
|
||||
const int getId () const;
|
||||
|
||||
const irr::core::vector3df& getOrigin () const;
|
||||
@ -45,6 +46,7 @@ namespace WallpaperEngine::Core
|
||||
);
|
||||
|
||||
void insertEffect (Objects::CEffect* effect);
|
||||
void insertDependency (irr::u32 dependency);
|
||||
private:
|
||||
std::string m_type;
|
||||
|
||||
@ -56,5 +58,6 @@ namespace WallpaperEngine::Core
|
||||
irr::core::vector3df m_angles;
|
||||
|
||||
std::vector<Objects::CEffect*> m_effects;
|
||||
std::vector<irr::u32> m_dependencies;
|
||||
};
|
||||
};
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
#include "WallpaperEngine/Core/Objects/CImage.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector3.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantInteger.h"
|
||||
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
||||
@ -46,6 +46,7 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
auto preview_it = content.find ("preview");
|
||||
auto passes_it = content.find ("passes");
|
||||
auto dependencies_it = content.find ("dependencies");
|
||||
auto fbos_it = content.find ("fbos");
|
||||
|
||||
if (name_it == content.end ())
|
||||
{
|
||||
@ -85,35 +86,18 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
object
|
||||
);
|
||||
|
||||
auto cur = (*passes_it).begin ();
|
||||
auto end = (*passes_it).end ();
|
||||
CEffect::materialsFromJSON (passes_it, effect);
|
||||
CEffect::dependencyFromJSON (dependencies_it, effect);
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
if (fbos_it != content.end ())
|
||||
{
|
||||
auto materialfile = (*cur).find ("material");
|
||||
|
||||
if (materialfile == (*cur).end ())
|
||||
{
|
||||
throw std::runtime_error ("Effect pass must have a material file");
|
||||
}
|
||||
|
||||
effect->insertMaterial (
|
||||
Images::CMaterial::fromFile ((*materialfile).get <std::string> ().c_str ())
|
||||
);
|
||||
}
|
||||
|
||||
cur = (*dependencies_it).begin ();
|
||||
end = (*dependencies_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
effect->insertDependency (*cur);
|
||||
CEffect::fbosFromJSON (fbos_it, effect);
|
||||
}
|
||||
|
||||
if (effectpasses_it != data.end ())
|
||||
{
|
||||
cur = (*effectpasses_it).begin ();
|
||||
end = (*effectpasses_it).end ();
|
||||
auto cur = (*effectpasses_it).begin ();
|
||||
auto end = (*effectpasses_it).end ();
|
||||
|
||||
for (int passNumber = 0; cur != end; cur ++, passNumber ++)
|
||||
{
|
||||
@ -149,19 +133,19 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
|
||||
CImage* image = object->as <CImage> ();
|
||||
|
||||
texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ()->begin ());
|
||||
texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ());
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = *texturesCur;
|
||||
}
|
||||
|
||||
std::vector<std::string>* passTextures = (*passCur)->getTextures ();
|
||||
std::vector<std::string> passTextures = (*passCur)->getTextures ();
|
||||
|
||||
if (textureNumber < passTextures->size ())
|
||||
passTextures->at (textureNumber) = texture;
|
||||
if (textureNumber < passTextures.size ())
|
||||
(*passCur)->setTexture (textureNumber, texture);
|
||||
else
|
||||
passTextures->push_back (texture);
|
||||
(*passCur)->insertTexture (texture);
|
||||
|
||||
textureNumber ++;
|
||||
}
|
||||
@ -169,43 +153,12 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
|
||||
if (combos_it != (*cur).end ())
|
||||
{
|
||||
auto comboCur = (*combos_it).begin ();
|
||||
auto comboEnd = (*combos_it).end ();
|
||||
|
||||
for (; comboCur != comboEnd; comboCur ++)
|
||||
{
|
||||
(*passCur)->insertCombo (comboCur.key (), *comboCur);
|
||||
}
|
||||
CEffect::combosFromJSON (combos_it, *passCur);
|
||||
}
|
||||
|
||||
if (constants_it != (*cur).end ())
|
||||
{
|
||||
auto constantCur = (*constants_it).begin ();
|
||||
auto constantEnd = (*constants_it).end ();
|
||||
|
||||
for (; constantCur != constantEnd; constantCur ++)
|
||||
{
|
||||
Effects::CShaderConstant* constant = nullptr;
|
||||
|
||||
if ((*constantCur).is_number_float () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantFloat ((*constantCur).get <irr::f32> ());
|
||||
}
|
||||
else if ((*constantCur).is_number_integer () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantInteger ((*constantCur).get <irr::s32> ());
|
||||
}
|
||||
else if ((*constantCur).is_string () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantVector3 (WallpaperEngine::Core::ato3vf (*constantCur));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error ("unknown shader constant type");
|
||||
}
|
||||
|
||||
(*passCur)->insertConstant (constantCur.key (), constant);
|
||||
}
|
||||
CEffect::constantsFromJSON (constants_it, *passCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,6 +167,101 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
return effect;
|
||||
}
|
||||
|
||||
void CEffect::combosFromJSON (json::const_iterator combos_it, Core::Objects::Images::Materials::CPassess* pass)
|
||||
{
|
||||
auto cur = (*combos_it).begin ();
|
||||
auto end = (*combos_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
pass->insertCombo (cur.key (), *cur);
|
||||
}
|
||||
}
|
||||
|
||||
void CEffect::constantsFromJSON (json::const_iterator constants_it, Core::Objects::Images::Materials::CPassess* pass)
|
||||
{
|
||||
auto cur = (*constants_it).begin ();
|
||||
auto end = (*constants_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
Effects::Constants::CShaderConstant* constant = nullptr;
|
||||
|
||||
if ((*cur).is_number_float () == true)
|
||||
{
|
||||
constant = new Effects::Constants::CShaderConstantFloat ((*cur).get <irr::f32> ());
|
||||
}
|
||||
else if ((*cur).is_number_integer () == true)
|
||||
{
|
||||
constant = new Effects::Constants::CShaderConstantInteger ((*cur).get <irr::s32> ());
|
||||
}
|
||||
else if ((*cur).is_string () == true)
|
||||
{
|
||||
constant = new Effects::Constants::CShaderConstantVector3 (WallpaperEngine::Core::ato3vf (*cur));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error ("unknown shader constant type");
|
||||
}
|
||||
|
||||
pass->insertConstant (cur.key (), constant);
|
||||
}
|
||||
}
|
||||
|
||||
void CEffect::fbosFromJSON (json::const_iterator fbos_it, CEffect* effect)
|
||||
{
|
||||
auto cur = (*fbos_it).begin ();
|
||||
auto end = (*fbos_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
effect->insertFBO (
|
||||
Effects::CFBO::fromJSON (*cur)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void CEffect::dependencyFromJSON (json::const_iterator dependencies_it, CEffect* effect)
|
||||
{
|
||||
auto cur = (*dependencies_it).begin ();
|
||||
auto end = (*dependencies_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
effect->insertDependency (*cur);
|
||||
}
|
||||
}
|
||||
|
||||
void CEffect::materialsFromJSON (json::const_iterator passes_it, CEffect* effect)
|
||||
{
|
||||
auto cur = (*passes_it).begin ();
|
||||
auto end = (*passes_it).end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
auto materialfile = (*cur).find ("material");
|
||||
auto target = (*cur).find ("target");
|
||||
|
||||
if (materialfile == (*cur).end ())
|
||||
{
|
||||
throw std::runtime_error ("Effect pass must have a material file");
|
||||
}
|
||||
|
||||
if (target == (*cur).end ())
|
||||
{
|
||||
effect->insertMaterial (
|
||||
Images::CMaterial::fromFile ((*materialfile).get <std::string> ().c_str ())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
effect->insertMaterial (
|
||||
Images::CMaterial::fromFile ((*materialfile).get <std::string> ().c_str (), *target)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string>& CEffect::getDependencies () const
|
||||
{
|
||||
return this->m_dependencies;
|
||||
@ -224,6 +272,27 @@ const std::vector<Images::CMaterial*>& CEffect::getMaterials () const
|
||||
return this->m_materials;
|
||||
}
|
||||
|
||||
const std::vector<Effects::CFBO*>& CEffect::getFbos () const
|
||||
{
|
||||
return this->m_fbos;
|
||||
}
|
||||
|
||||
Effects::CFBO* CEffect::findFBO (const std::string& name)
|
||||
{
|
||||
auto cur = this->m_fbos.begin ();
|
||||
auto end = this->m_fbos.end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->getName () == name)
|
||||
{
|
||||
return (*cur);
|
||||
}
|
||||
}
|
||||
|
||||
throw std::runtime_error ("cannot find fbo named " + name);
|
||||
}
|
||||
|
||||
void CEffect::insertDependency (const std::string& dep)
|
||||
{
|
||||
this->m_dependencies.push_back (dep);
|
||||
@ -232,4 +301,9 @@ void CEffect::insertDependency (const std::string& dep)
|
||||
void CEffect::insertMaterial (Images::CMaterial* material)
|
||||
{
|
||||
this->m_materials.push_back (material);
|
||||
}
|
||||
|
||||
void CEffect::insertFBO (Effects::CFBO* fbo)
|
||||
{
|
||||
this->m_fbos.push_back (fbo);
|
||||
}
|
@ -3,7 +3,8 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CFBO.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
|
||||
@ -31,9 +32,20 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
const std::vector<std::string>& getDependencies () const;
|
||||
const std::vector<Images::CMaterial*>& getMaterials () const;
|
||||
const std::vector<Effects::CFBO*>& getFbos () const;
|
||||
|
||||
Effects::CFBO* findFBO (const std::string& name);
|
||||
protected:
|
||||
static void constantsFromJSON (json::const_iterator constants_it, Core::Objects::Images::Materials::CPassess* pass);
|
||||
static void combosFromJSON (json::const_iterator combos_it, Core::Objects::Images::Materials::CPassess* pass);
|
||||
static void fbosFromJSON (json::const_iterator fbos_it, CEffect* effect);
|
||||
static void dependencyFromJSON (json::const_iterator dependencies_it, CEffect* effect);
|
||||
static void materialsFromJSON (json::const_iterator passes_it, CEffect* effect);
|
||||
|
||||
void insertDependency (const std::string& dep);
|
||||
void insertMaterial (Images::CMaterial* material);
|
||||
void insertFBO (Effects::CFBO* fbo);
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
@ -43,5 +55,6 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
std::vector<std::string> m_dependencies;
|
||||
std::vector<Images::CMaterial*> m_materials;
|
||||
std::vector<Effects::CFBO*> m_fbos;
|
||||
};
|
||||
}
|
||||
|
40
src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp
Normal file
40
src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "CFBO.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
CFBO::CFBO (std::string name, irr::f32 scale, std::string format) :
|
||||
m_name (std::move(name)),
|
||||
m_scale (scale),
|
||||
m_format(std::move(format))
|
||||
{
|
||||
}
|
||||
|
||||
CFBO* CFBO::fromJSON (json data)
|
||||
{
|
||||
auto name_it = data.find ("name");
|
||||
auto scale_it = data.find ("scale");
|
||||
auto format_it = data.find ("format");
|
||||
|
||||
return new CFBO (
|
||||
*name_it,
|
||||
*scale_it,
|
||||
*format_it
|
||||
);
|
||||
}
|
||||
|
||||
const std::string& CFBO::getName () const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const irr::f32& CFBO::getScale () const
|
||||
{
|
||||
return this->m_scale;
|
||||
}
|
||||
|
||||
const std::string& CFBO::getFormat () const
|
||||
{
|
||||
return this->m_format;
|
||||
}
|
28
src/WallpaperEngine/Core/Objects/Effects/CFBO.h
Normal file
28
src/WallpaperEngine/Core/Objects/Effects/CFBO.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
class CFBO
|
||||
{
|
||||
public:
|
||||
CFBO (std::string name, irr::f32 scale, std::string format);
|
||||
|
||||
static CFBO* fromJSON (json data);
|
||||
|
||||
const std::string& getName () const;
|
||||
const irr::f32& getScale () const;
|
||||
const std::string& getFormat () const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
irr::f32 m_scale;
|
||||
std::string m_format;
|
||||
};
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
CShaderConstant::CShaderConstant (std::string type) :
|
||||
m_type (std::move(type))
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
class CShaderConstant
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
#include "CShaderConstantFloat.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
|
||||
CShaderConstantFloat::CShaderConstantFloat (irr::f32 value) :
|
@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
class CShaderConstantFloat : public CShaderConstant
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
#include "CShaderConstantInteger.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
|
||||
CShaderConstantInteger::CShaderConstantInteger (irr::s32 value) :
|
@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
class CShaderConstantInteger : public CShaderConstant
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
#include "CShaderConstantVector3.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
|
||||
CShaderConstantVector3::CShaderConstantVector3 (irr::core::vector3df value) :
|
@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
class CShaderConstantVector3 : public CShaderConstant
|
||||
{
|
@ -7,16 +7,32 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Images;
|
||||
|
||||
CMaterial::CMaterial ()
|
||||
CMaterial::CMaterial () :
|
||||
m_target ("")
|
||||
{
|
||||
}
|
||||
|
||||
CMaterial* CMaterial::fromFile (irr::io::path filename)
|
||||
CMaterial* CMaterial::fromFile (const irr::io::path& filename)
|
||||
{
|
||||
return fromJSON (
|
||||
json::parse (WallpaperEngine::FileSystem::loadFullFile (filename))
|
||||
);
|
||||
}
|
||||
CMaterial* CMaterial::fromFile (const irr::io::path& filename, const std::string& target)
|
||||
{
|
||||
return fromJSON (
|
||||
json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)), target
|
||||
);
|
||||
}
|
||||
|
||||
CMaterial* CMaterial::fromJSON (json data, const std::string& target)
|
||||
{
|
||||
CMaterial* material = fromJSON (data);
|
||||
|
||||
material->setTarget (target);
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
CMaterial* CMaterial::fromJSON (json data)
|
||||
{
|
||||
@ -35,7 +51,7 @@ CMaterial* CMaterial::fromJSON (json data)
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
material->insertPass (
|
||||
Materials::CPassess::fromJSON (*cur)
|
||||
Materials::CPassess::fromJSON (*cur)
|
||||
);
|
||||
}
|
||||
|
||||
@ -47,7 +63,21 @@ void CMaterial::insertPass (Materials::CPassess* mass)
|
||||
this->m_passes.push_back (mass);
|
||||
}
|
||||
|
||||
void CMaterial::setTarget (const std::string& target)
|
||||
{
|
||||
this->m_target = target;
|
||||
}
|
||||
|
||||
const std::vector <Materials::CPassess*>& CMaterial::getPasses () const
|
||||
{
|
||||
return this->m_passes;
|
||||
}
|
||||
const std::string& CMaterial::getTarget () const
|
||||
{
|
||||
return this->m_target;
|
||||
}
|
||||
|
||||
const bool CMaterial::hasTarget () const
|
||||
{
|
||||
return this->m_target.empty () == false;
|
||||
}
|
@ -12,15 +12,22 @@ namespace WallpaperEngine::Core::Objects::Images
|
||||
class CMaterial
|
||||
{
|
||||
public:
|
||||
static CMaterial* fromFile (irr::io::path filename);
|
||||
static CMaterial* fromFile (const irr::io::path& filename);
|
||||
static CMaterial* fromJSON (json data);
|
||||
static CMaterial* fromFile (const irr::io::path& filename, const std::string& target);
|
||||
static CMaterial* fromJSON (json data, const std::string& target);
|
||||
|
||||
void insertPass (Materials::CPassess* mass);
|
||||
|
||||
const std::vector <Materials::CPassess*>& getPasses () const;
|
||||
const std::string& getTarget () const;
|
||||
const bool hasTarget () const;
|
||||
protected:
|
||||
CMaterial ();
|
||||
|
||||
void setTarget (const std::string& target);
|
||||
private:
|
||||
std::vector <Materials::CPassess*> m_passes;
|
||||
std::string m_target;
|
||||
};
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CPassess.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
using namespace WallpaperEngine::Core::Objects::Images::Materials;
|
||||
|
||||
CPassess::CPassess (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, std::string shader) :
|
||||
@ -110,14 +110,19 @@ void CPassess::insertTexture (const std::string& texture)
|
||||
this->m_textures.push_back (texture);
|
||||
}
|
||||
|
||||
void CPassess::setTexture (int index, const std::string& texture)
|
||||
{
|
||||
this->m_textures.at (index) = texture;
|
||||
}
|
||||
|
||||
void CPassess::insertCombo (const std::string& name, int value)
|
||||
{
|
||||
this->m_combos.insert (std::pair <std::string, int> (name, value));
|
||||
}
|
||||
|
||||
std::vector<std::string>* CPassess::getTextures ()
|
||||
const std::vector<std::string>& CPassess::getTextures () const
|
||||
{
|
||||
return &this->m_textures;
|
||||
return this->m_textures;
|
||||
}
|
||||
|
||||
const std::map<std::string, CShaderConstant*>& CPassess::getConstants () const
|
||||
|
@ -2,7 +2,12 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Objects
|
||||
{
|
||||
class CEffect;
|
||||
};
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Images::Materials
|
||||
{
|
||||
@ -10,11 +15,12 @@ namespace WallpaperEngine::Core::Objects::Images::Materials
|
||||
|
||||
class CPassess
|
||||
{
|
||||
friend class Core::Objects::CEffect;
|
||||
public:
|
||||
static CPassess* fromJSON (json data);
|
||||
|
||||
std::vector<std::string>* getTextures ();
|
||||
const std::map<std::string, Effects::CShaderConstant*>& getConstants () const;
|
||||
const std::vector<std::string>& getTextures () const;
|
||||
const std::map<std::string, Effects::Constants::CShaderConstant*>& getConstants () const;
|
||||
|
||||
const std::map<std::string, int>& getCombos () const;
|
||||
const std::string& getShader () const;
|
||||
@ -24,12 +30,13 @@ namespace WallpaperEngine::Core::Objects::Images::Materials
|
||||
const std::string& getDepthWrite () const;
|
||||
|
||||
void insertCombo (const std::string& name, int value);
|
||||
void insertConstant (const std::string& name, Effects::CShaderConstant* constant);
|
||||
void insertConstant (const std::string& name, Effects::Constants::CShaderConstant* constant);
|
||||
|
||||
protected:
|
||||
CPassess (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, std::string shader);
|
||||
|
||||
void insertTexture (const std::string& texture);
|
||||
void setTexture (int index, const std::string& texture);
|
||||
|
||||
private:
|
||||
std::string m_blending;
|
||||
@ -39,6 +46,6 @@ namespace WallpaperEngine::Core::Objects::Images::Materials
|
||||
std::string m_shader;
|
||||
std::vector<std::string> m_textures;
|
||||
std::map<std::string, int> m_combos;
|
||||
std::map<std::string, Core::Objects::Effects::CShaderConstant*> m_constants;
|
||||
std::map<std::string, Core::Objects::Effects::Constants::CShaderConstant*> m_constants;
|
||||
};
|
||||
}
|
||||
|
@ -10,14 +10,14 @@
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2Pointer.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantInteger.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector3.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
@ -128,11 +128,11 @@ void CImage::generateMaterial ()
|
||||
|
||||
void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass, Core::Objects::CEffect* effect)
|
||||
{
|
||||
std::vector<std::string>* textures = pass->getTextures ();
|
||||
std::vector<std::string> textures = pass->getTextures ();
|
||||
irr::video::SMaterial material;
|
||||
|
||||
auto texturesCur = textures->begin ();
|
||||
auto texturesEnd = textures->end ();
|
||||
auto texturesCur = textures.begin ();
|
||||
auto texturesEnd = textures.end ();
|
||||
|
||||
for (int textureNumber = 0; texturesCur != texturesEnd; texturesCur ++, textureNumber ++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user