HI Sonya,
When you scale in OpenGL by the normal gets scaled as well so when OpenGL
(fixed function pipeline) lights the vertices it does the computation
against the missized normal assuming it's still a length of 1.0.
The way to address this is to enable GL_NORMALIZE or GL_RESCALE, if you
look at the Transform header or associated docs you'll see a paragraph on
this issue:
/** A Transform is a group node for which all children are transformed by
* a 4x4 matrix. It is often used for positioning objects within a scene,
* producing trackball functionality or for animation.
*
* Transform itself does not provide set/get functions, only the interface
* for defining what the 4x4 transformation is. Subclasses, such as
* MatrixTransform and PositionAttitudeTransform support the use of an
* osg::Matrix or a osg::Vec3/osg::Quat respectively.
*
* Note: If the transformation matrix scales the subgraph then the normals
* of the underlying geometry will need to be renormalized to be unit
* vectors once more. This can be done transparently through OpenGL's
* use of either GL_NORMALIZE and GL_RESCALE_NORMAL modes. For further
* background reading see the glNormalize documentation in the OpenGL
* Reference Guide (the blue book). To enable it in the OSG, you simply
* need to attach a local osg::StateSet to the osg::Transform, and set
* the appropriate mode to ON via
* stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
*/
class OSG_EXPORT Transform : public Group
{
..
Robert.
On 23 July 2014 07:09, Sonya Blade <[email protected]> wrote:
> Dear All,
>
> I observe very weird results of rendered object in the scene after I apply
> matrix
> transformation. Before applying the MT everything works as I expected and
> rendering results are satisfying see the 1st loaded image. But when apply
> the MT the loaded shape surface becomes excessively illuminated, as if
> normals are inaccurately calculated or probably something else. The
> scenario is same if apply the transformation via PositionAttitudeTransform,
> I directly modify the composite viewer example, code that corresponds to
> that scene is as follow.
>
> 1st image :http://tinypic.com/r/2lmuljs/8
> 2nd image :http://tinypic.com/r/6g9181/8
>
> /// rootnode and loadedModel are defined in global scope
> osg::MatrixTransform* rootnode;
> osg::Node* loadedModel;
>
> //Where the first initialization happens at the PickHandler Right Button
> Click
>
> loadedModel =
> osgDB::readNodeFile(".........../sys/test.obj");
>
> //loadedModel->getOrCreateStateSet()->setMode(GL_LIGHTING,
> osg::StateAttribute::ON);
>
> osg::ref_ptr<osg::MatrixTransform> transformation1 =
> new osg::MatrixTransform;
> transformation1->addChild(loadedModel);
>
> transformation1->setMatrix(osg::Matrix::scale(0.4,4,0.4));
>
> rootnode->addChild(transformation1);
>
> What is the malfuncitoning here causing such a illuminaition intensity, I
> never get it rendered as damaged cessna at the upper view ?
>
> Regards,
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org