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;
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2013-03-26 19:33, Claude Heiland-Allen wrote:
Hi,
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); +*/
this does a bit too much, as it effectively disables "smooth" (and other properties even if they *are* set).
i've just pushed a changeset, that will only try to automatically smooth if the model doesn't yet contain normals. i hope this is backwards compatible.
fgamsdr IOhannes