mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
assimp: Support importing alpha mode from glTF files
This commit is contained in:
parent
9248182a0b
commit
b254e5b7ba
@ -21,9 +21,11 @@
|
|||||||
#include "geomTriangles.h"
|
#include "geomTriangles.h"
|
||||||
#include "pnmFileTypeRegistry.h"
|
#include "pnmFileTypeRegistry.h"
|
||||||
#include "pnmImage.h"
|
#include "pnmImage.h"
|
||||||
|
#include "alphaTestAttrib.h"
|
||||||
#include "materialAttrib.h"
|
#include "materialAttrib.h"
|
||||||
#include "textureAttrib.h"
|
#include "textureAttrib.h"
|
||||||
#include "cullFaceAttrib.h"
|
#include "cullFaceAttrib.h"
|
||||||
|
#include "transparencyAttrib.h"
|
||||||
#include "ambientLight.h"
|
#include "ambientLight.h"
|
||||||
#include "directionalLight.h"
|
#include "directionalLight.h"
|
||||||
#include "spotlight.h"
|
#include "spotlight.h"
|
||||||
@ -43,6 +45,10 @@
|
|||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
|
#ifndef AI_MATKEY_GLTF_ALPHAMODE
|
||||||
|
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::ostringstream;
|
using std::ostringstream;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -502,6 +508,19 @@ load_material(size_t index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Alpha mode.
|
||||||
|
aiString alpha_mode;
|
||||||
|
if (AI_SUCCESS == mat.Get(AI_MATKEY_GLTF_ALPHAMODE, alpha_mode)) {
|
||||||
|
if (strcmp(alpha_mode.C_Str(), "MASK") == 0) {
|
||||||
|
PN_stdfloat cutoff = 0.5;
|
||||||
|
mat.Get(AI_MATKEY_GLTF_ALPHACUTOFF, cutoff);
|
||||||
|
state = state->add_attrib(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, cutoff));
|
||||||
|
}
|
||||||
|
else if (strcmp(alpha_mode.C_Str(), "BLEND") == 0) {
|
||||||
|
state = state->add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// And let's not forget the textures!
|
// And let's not forget the textures!
|
||||||
CPT(TextureAttrib) tattr = DCAST(TextureAttrib, TextureAttrib::make());
|
CPT(TextureAttrib) tattr = DCAST(TextureAttrib, TextureAttrib::make());
|
||||||
CPT(TexMatrixAttrib) tmattr;
|
CPT(TexMatrixAttrib) tmattr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user