Remove references to ambient, use the requested alpha.

This commit is contained in:
Andrzej Kapolka 2013-10-04 10:53:19 -07:00
parent 51c868fd28
commit b281facf45
3 changed files with 14 additions and 21 deletions

View file

@ -118,8 +118,10 @@ bool BlendFace::render(float alpha) {
}
// apply material properties
glMaterialfv(GL_FRONT, GL_DIFFUSE, (const float*)&mesh.diffuseColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&mesh.specularColor);
glm::vec4 diffuse = glm::vec4(mesh.diffuseColor, alpha);
glm::vec4 specular = glm::vec4(mesh.specularColor, alpha);
glMaterialfv(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&specular);
glMaterialf(GL_FRONT, GL_SHININESS, mesh.shininess);
glMultMatrixf((const GLfloat*)&mesh.transform);

View file

@ -348,9 +348,8 @@ void printNode(const FBXNode& node, int indent) {
class Material {
public:
glm::vec4 ambient;
glm::vec4 diffuse;
glm::vec4 specular;
glm::vec3 diffuse;
glm::vec3 specular;
float shininess;
};
@ -588,26 +587,20 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
}
}
} else if (object.name == "Material") {
Material material = { glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), 96.0f };
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), 96.0f };
foreach (const FBXNode& subobject, object.children) {
if (subobject.name == "Properties70") {
foreach (const FBXNode& property, subobject.children) {
if (property.name == "P") {
if (property.properties.at(0) == "AmbientColor") {
material.ambient = glm::vec4(property.properties.at(4).value<double>(),
if (property.properties.at(0) == "DiffuseColor") {
material.diffuse = glm::vec3(property.properties.at(4).value<double>(),
property.properties.at(5).value<double>(),
property.properties.at(6).value<double>(), 1.0f);
} else if (property.properties.at(0) == "DiffuseColor") {
material.diffuse = glm::vec4(property.properties.at(4).value<double>(),
property.properties.at(5).value<double>(),
property.properties.at(6).value<double>(), 1.0f);
property.properties.at(6).value<double>());
} else if (property.properties.at(0) == "SpecularColor") {
material.specular = glm::vec4(property.properties.at(4).value<double>(),
material.specular = glm::vec3(property.properties.at(4).value<double>(),
property.properties.at(5).value<double>(),
property.properties.at(6).value<double>(), 1.0f);
property.properties.at(6).value<double>());
} else if (property.properties.at(0) == "Shininess") {
material.shininess = property.properties.at(4).value<double>();
@ -687,7 +680,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
continue;
}
Material material = materials.value(childID);
mesh.ambientColor = material.ambient;
mesh.diffuseColor = material.diffuse;
mesh.specularColor = material.specular;
mesh.shininess = material.shininess;

View file

@ -51,9 +51,8 @@ public:
bool isEye;
glm::vec4 ambientColor;
glm::vec4 diffuseColor;
glm::vec4 specularColor;
glm::vec3 diffuseColor;
glm::vec3 specularColor;
float shininess;
QByteArray diffuseFilename;