Merge branch 'master' into master
commit
538bc95499
|
@ -211,15 +211,9 @@ inline void SetMaterialTextureProperty(std::vector<int>& embeddedTexIdxs, Asset&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glTF2Importer::ImportMaterials(glTF2::Asset& r)
|
static aiMaterial* ImportMaterial(std::vector<int>& embeddedTexIdxs, Asset& r, Material& mat)
|
||||||
{
|
{
|
||||||
mScene->mNumMaterials = unsigned(r.materials.Size());
|
aiMaterial* aimat = new aiMaterial();
|
||||||
mScene->mMaterials = new aiMaterial*[mScene->mNumMaterials];
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mScene->mNumMaterials; ++i) {
|
|
||||||
aiMaterial* aimat = mScene->mMaterials[i] = new aiMaterial();
|
|
||||||
|
|
||||||
Material& mat = r.materials[i];
|
|
||||||
|
|
||||||
if (!mat.name.empty()) {
|
if (!mat.name.empty()) {
|
||||||
aiString str(mat.name);
|
aiString str(mat.name);
|
||||||
|
@ -268,6 +262,21 @@ void glTF2Importer::ImportMaterials(glTF2::Asset& r)
|
||||||
|
|
||||||
SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR);
|
SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return aimat;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glTF2Importer::ImportMaterials(glTF2::Asset& r)
|
||||||
|
{
|
||||||
|
const unsigned int numImportedMaterials = unsigned(r.materials.Size());
|
||||||
|
Material defaultMaterial;
|
||||||
|
|
||||||
|
mScene->mNumMaterials = numImportedMaterials + 1;
|
||||||
|
mScene->mMaterials = new aiMaterial*[mScene->mNumMaterials];
|
||||||
|
mScene->mMaterials[numImportedMaterials] = ImportMaterial(embeddedTexIdxs, r, defaultMaterial);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < numImportedMaterials; ++i) {
|
||||||
|
mScene->mMaterials[i] = ImportMaterial(embeddedTexIdxs, r, r.materials[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +488,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
||||||
if (prim.material) {
|
if (prim.material) {
|
||||||
aim->mMaterialIndex = prim.material.GetIndex();
|
aim->mMaterialIndex = prim.material.GetIndex();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
aim->mMaterialIndex = mScene->mNumMaterials - 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,6 +512,9 @@ void glTF2Importer::ImportCameras(glTF2::Asset& r)
|
||||||
|
|
||||||
aiCamera* aicam = mScene->mCameras[i] = new aiCamera();
|
aiCamera* aicam = mScene->mCameras[i] = new aiCamera();
|
||||||
|
|
||||||
|
// cameras point in -Z by default, rest is specified in node transform
|
||||||
|
aicam->mLookAt = aiVector3D(0.f,0.f,-1.f);
|
||||||
|
|
||||||
if (cam.type == Camera::Perspective) {
|
if (cam.type == Camera::Perspective) {
|
||||||
|
|
||||||
aicam->mAspect = cam.cameraProperties.perspective.aspectRatio;
|
aicam->mAspect = cam.cameraProperties.perspective.aspectRatio;
|
||||||
|
|
Loading…
Reference in New Issue