git-svn-id: svn://db.shs.com.ru/libs@686 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <assimp/material.h>
|
||||
|
||||
QString fromAiString (const aiString & s) {return QString::fromLocal8Bit(s.C_Str());}
|
||||
QColor fromAiColor (const aiColor4D & c) {return QColor::fromRgbF(piClamp(c.r, 0.f, 1.f), piClamp(c.g, 0.f, 1.f), piClamp(c.b, 0.f, 1.f));}
|
||||
QVector3D fromAiVector3D(const aiVector3D & v) {return QVector3D(v.x, v.y, v.z);}
|
||||
Vector3i fromAiFace (const aiFace & v) {return Vector3i(v.mIndices[0], v.mIndices[1], v.mIndices[2]);}
|
||||
QMatrix4x4 fromAiMatrix4D(const aiMatrix4x4 & v) {return QMatrix4x4(v.a1, v.a2, v.a3, v.a4,
|
||||
@@ -87,7 +88,7 @@ QColor aiMatColor(const aiMaterial * m, const char * key, uint s0, uint s1, cons
|
||||
aiReturn r = m->Get(key, s0, s1, col);
|
||||
//qDebug() << key << r << col.r << col.g << col.b;
|
||||
if (r != aiReturn_SUCCESS) return def;
|
||||
return QColor::fromRgbF(col.r, col.g, col.b);
|
||||
return fromAiColor(col);
|
||||
}
|
||||
float aiMatFloat(const aiMaterial * m, const char * key, uint s0, uint s1, float def = 0.f) {
|
||||
float ret;
|
||||
@@ -107,11 +108,17 @@ Material * assimpMaterial(const aiMaterial * m) {
|
||||
Material * ret = new Material();
|
||||
ret->name = fromAiString(const_cast<aiMaterial*>(m)->GetName());
|
||||
//qDebug() << "mat" << ret->name;
|
||||
//for (int i = 0; i < m->mNumProperties; ++i)
|
||||
// qDebug()<< fromAiString(m->mProperties[i]->mKey);
|
||||
//for (int i = 0; i < m->mNumProperties; ++i) {
|
||||
// qDebug()<< fromAiString(m->mProperties[i]->mKey);// << "=" << aiMatFloat(m, m->mProperties[i]->mKey.C_Str(), 0, 0);
|
||||
//}
|
||||
ret->color_diffuse = aiMatColor(m, AI_MATKEY_COLOR_DIFFUSE);
|
||||
ret->color_specular = aiMatColor(m, AI_MATKEY_COLOR_SPECULAR);
|
||||
ret->color_emission = aiMatColor(m, AI_MATKEY_COLOR_EMISSIVE);
|
||||
float shine = aiMatFloat(m, AI_MATKEY_SHININESS, -1.f);
|
||||
if (shine >= 0) {
|
||||
ret->map_roughness.color_amount = 1.f - (shine / 100.f);
|
||||
//qDebug() << "shine" << shine;
|
||||
}
|
||||
ret->map_diffuse .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
ret->map_normal .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_NORMALS(0));
|
||||
ret->map_specular .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_SPECULAR(0));
|
||||
|
||||
Reference in New Issue
Block a user