Commit 7e526c3b authored by Robert Menzel's avatar Robert Menzel

made normal creation the default iff no mesh normals were provided

parent 055481bf
......@@ -31,8 +31,9 @@ SharedGeometryData loadGeometryData(const std::string& _filename);
// library specific load
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Loads from a Wavefront OBJ file. If _computeNormals, face normals are computed from geometry
SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _computeNormals = false);
//! Loads from a Wavefront OBJ file. If _computeNormals and the mesh had no normals stored,
//! face normals are computed from the geometry
SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _computeNormals = true);
///////////////////////////////////////////////////////////////////////////////////////////////////
// library specific save
......
......@@ -264,14 +264,17 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
}
}
if(_computeNormals && primitiveType != GL_TRIANGLES)
{
warning() << "computing OBJ normals is only supported for models with faces" << std::endl;
_computeNormals = false;
}
else if(_computeNormals)
{
hasNormals = true;
if (!hasNormals && _computeNormals) {
// perform own per-face normal creation only if the model had no own normals!
if(primitiveType != GL_TRIANGLES)
{
warning() << "computing OBJ normals is only supported for models with faces" << std::endl;
_computeNormals = false;
}
else
{
hasNormals = true;
}
}
// all data are read from the file. construct an ArrayBuffer from the data
......@@ -347,11 +350,6 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
data->setSize(abDataElements * sizeof(GLfloat));
data->setData((GLubyte*)abData);
if(_computeNormals)
{
debug() << "TODO: implement _computeNormals" << std::endl;
}
return data;
}
......
......@@ -428,7 +428,7 @@ bool saveTextureDataToQT( const SharedTextureData &_data, const std::string &_fi
error() << "scan lines of image data are not 32bit aligned, QT will not be able to handle that" << std::endl;
return false;
}
} else if (glFormat == GL_RGBA) {
} else if (glFormat == GL_RGBA || glFormat == GL_BGRA) {
format = QImage::Format_ARGB32;
} else {
error() << "unsupported OpenGL format" << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment