[GEM-dev] model bug: ignores normals in obj file
Claude Heiland-Allen
claude at mathr.co.uk
Tue Mar 26 19:33:57 CET 2013
Hi,
I was frustratedly trying to get smooth shading to work. Eventually I
discovered a bug in [model]. It seems on initialisation it forcibly
sets the smooth property (to 0.5, if unset, to a value in [0..1] if
set), which results in a call to glmVertexNormals(), which *overwrites*
the normals read from the .obj file with some calculated from
vertex/face positions. They can then not be recovered or used. My
quick hack is below, I didn't test it much. It might break expected
behaviour for other models that don't specify normals.
Before and after patching modelOBJ.cpp to avoid forcing "smooth":
http://mathr.co.uk/misc/2013-03-26_urchin_torus.png
http://mathr.co.uk/misc/2013-03-26_urchin_torus_smooth.png
Claude
diff --git a/plugins/modelOBJ/modelOBJ.cpp b/plugins/modelOBJ/modelOBJ.cpp
index 4ff9d9e..be79716 100644
--- a/plugins/modelOBJ/modelOBJ.cpp
+++ b/plugins/modelOBJ/modelOBJ.cpp
@@ -63,11 +63,13 @@ bool modelOBJ :: open(const std::string&name, const
gem::Pro
glmFacetNormals (m_model);
+/*
gem::Properties props=requestprops;
if(gem::Properties::UNSET==requestprops.type("smooth")) {
props.set("smooth", 0.5);
}
setProperties(props);
+*/
glmTexture(m_model, m_textype, 1,1);
m_rebuild=true;
--
http://mathr.co.uk
More information about the GEM-dev
mailing list