mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-15 13:52:23 +08:00

+ Basic parsing for object's effects (missing passes specified in the scene.json) Signed-off-by: Alexis Maiquez <almamu@almamu.com>
53 lines
1.0 KiB
C++
53 lines
1.0 KiB
C++
#include "material.h"
|
|
|
|
#include <irrlicht/irrlicht.h>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "../../../fs/utils.h"
|
|
|
|
using namespace wp::core::objects::images;
|
|
|
|
material::material ()
|
|
{
|
|
}
|
|
|
|
material* material::fromFile (irr::io::path filename)
|
|
{
|
|
return fromJSON (
|
|
json::parse (wp::fs::utils::loadFullFile (filename))
|
|
);
|
|
}
|
|
|
|
material* material::fromJSON (json data)
|
|
{
|
|
json::const_iterator passes_it = data.find ("passes");
|
|
|
|
if (passes_it == data.end ())
|
|
{
|
|
throw std::runtime_error ("Material must have at least one pass");
|
|
}
|
|
|
|
material* material = new class material ();
|
|
|
|
json::const_iterator cur = (*passes_it).begin ();
|
|
json::const_iterator end = (*passes_it).end ();
|
|
|
|
for (; cur != end; cur ++)
|
|
{
|
|
material->insertPass (
|
|
materials::passes::fromJSON (*cur)
|
|
);
|
|
}
|
|
|
|
return material;
|
|
}
|
|
|
|
void material::insertPass (materials::passes* mass)
|
|
{
|
|
this->m_passes.push_back (mass);
|
|
}
|
|
|
|
std::vector <materials::passes*>* material::getPasses ()
|
|
{
|
|
return &this->m_passes;
|
|
} |