namespace changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#ifndef FILE_MATERIAL_PROVIDER
|
#ifndef FILE_MATERIAL_PROVIDER
|
||||||
#define FILE_MATERIAL_PROVIDER
|
#define FILE_MATERIAL_PROVIDER
|
||||||
|
|
||||||
|
#include <filament/gltfio/MaterialProvider.h>
|
||||||
#include <filament/Texture.h>
|
#include <filament/Texture.h>
|
||||||
#include <filament/TextureSampler.h>
|
#include <filament/TextureSampler.h>
|
||||||
#include <math/mat4.h>
|
#include <math/mat4.h>
|
||||||
@@ -8,31 +9,34 @@
|
|||||||
#include <math/vec4.h>
|
#include <math/vec4.h>
|
||||||
#include <math/mat3.h>
|
#include <math/mat3.h>
|
||||||
#include <math/norm.h>
|
#include <math/norm.h>
|
||||||
|
#include "Log.hpp"
|
||||||
|
|
||||||
namespace polyvox {
|
namespace flutter_filament {
|
||||||
class FileMaterialProvider : public MaterialProvider {
|
|
||||||
|
|
||||||
Material* _m;
|
|
||||||
const Material* _ms[1];
|
class FileMaterialProvider : public filament::gltfio::MaterialProvider {
|
||||||
Texture* mDummyTexture = nullptr;
|
|
||||||
|
filament::Material* _m;
|
||||||
|
const filament::Material* _ms[1];
|
||||||
|
filament::Texture* mDummyTexture = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileMaterialProvider(Engine* engine, const void* const data, const size_t size) {
|
FileMaterialProvider(filament::Engine* engine, const void* const data, const size_t size) {
|
||||||
_m = Material::Builder()
|
_m = filament::Material::Builder()
|
||||||
.package(data, size)
|
.package(data, size)
|
||||||
.build(*engine);
|
.build(*engine);
|
||||||
_ms[0] = _m;
|
_ms[0] = _m;
|
||||||
unsigned char texels[4] = {};
|
unsigned char texels[4] = {};
|
||||||
mDummyTexture = Texture::Builder()
|
mDummyTexture = filament::Texture::Builder()
|
||||||
.width(1).height(1)
|
.width(1).height(1)
|
||||||
.format(Texture::InternalFormat::RGBA8)
|
.format(filament::Texture::InternalFormat::RGBA8)
|
||||||
.build(*engine);
|
.build(*engine);
|
||||||
Texture::PixelBufferDescriptor pbd(texels, sizeof(texels), Texture::Format::RGBA,
|
filament::Texture::PixelBufferDescriptor pbd(texels, sizeof(texels), filament::Texture::Format::RGBA,
|
||||||
Texture::Type::UBYTE);
|
filament::Texture::Type::UBYTE);
|
||||||
mDummyTexture->setImage(*engine, 0, std::move(pbd));
|
mDummyTexture->setImage(*engine, 0, std::move(pbd));
|
||||||
}
|
}
|
||||||
|
|
||||||
filament::MaterialInstance* createMaterialInstance(MaterialKey* config, UvMap* uvmap,
|
filament::MaterialInstance* createMaterialInstance(filament::gltfio::MaterialKey* config, filament::gltfio::UvMap* uvmap,
|
||||||
const char* label = "material", const char* extras = nullptr) {
|
const char* label = "material", const char* extras = nullptr) {
|
||||||
|
|
||||||
auto getUvIndex = [uvmap](uint8_t srcIndex, bool hasTexture) -> int {
|
auto getUvIndex = [uvmap](uint8_t srcIndex, bool hasTexture) -> int {
|
||||||
@@ -40,14 +44,14 @@ namespace polyvox {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto instance = _m->createInstance();
|
auto instance = _m->createInstance();
|
||||||
math::mat3f identity;
|
filament::math::mat3f identity;
|
||||||
instance->setParameter("baseColorUvMatrix", identity);
|
instance->setParameter("baseColorUvMatrix", identity);
|
||||||
instance->setParameter("normalUvMatrix", identity);
|
instance->setParameter("normalUvMatrix", identity);
|
||||||
|
|
||||||
instance->setParameter("baseColorIndex", getUvIndex(config->baseColorUV, config->hasBaseColorTexture));
|
instance->setParameter("baseColorIndex", getUvIndex(config->baseColorUV, config->hasBaseColorTexture));
|
||||||
instance->setParameter("normalIndex", getUvIndex(config->normalUV, config->hasNormalTexture));
|
instance->setParameter("normalIndex", getUvIndex(config->normalUV, config->hasNormalTexture));
|
||||||
if(config->hasNormalTexture) {
|
if(config->hasNormalTexture) {
|
||||||
TextureSampler sampler;
|
filament::TextureSampler sampler;
|
||||||
instance->setParameter("normalMap", mDummyTexture, sampler);
|
instance->setParameter("normalMap", mDummyTexture, sampler);
|
||||||
instance->setParameter("baseColorMap", mDummyTexture, sampler);
|
instance->setParameter("baseColorMap", mDummyTexture, sampler);
|
||||||
} else {
|
} else {
|
||||||
@@ -60,7 +64,7 @@ namespace polyvox {
|
|||||||
/**
|
/**
|
||||||
* Creates or fetches a compiled Filament material corresponding to the given config.
|
* Creates or fetches a compiled Filament material corresponding to the given config.
|
||||||
*/
|
*/
|
||||||
virtual Material* getMaterial(MaterialKey* config, UvMap* uvmap, const char* label = "material") {
|
virtual filament::Material* getMaterial(filament::gltfio::MaterialKey* config, filament::gltfio::UvMap* uvmap, const char* label = "material") {
|
||||||
return _m;
|
return _m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user