[osg-users] Problem using osg::ColorMatrix

Rahul Jain rahulj at darshan3d.com
Mon Jul 28 07:40:27 PDT 2008


Hi all,
I am trying to use OpenFL color matrix functionality through
osg::ColorMatrix but not able to do so. When i apply this to a node
|(cessna.osg) i do not see any effect. I am pasting the code below for
you guys to have a look.
I don't  know what am i doing wrong in this simple piece of code .
cheers RJ


int main(int argc, char** argv)
{
    osg::MatrixTransform* cessnaMT = new osg::MatrixTransform;

    
    osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
    cessnaMT->addChild(cessna);

     // Set color matrix
    osg::ColorMatrix* colorMatrix = new osg::ColorMatrix;
    const osg::Matrix cm (0.15, 0.0, 0.0, 0.0,
                          0.0,  0.3, 0.0, 0.0,
                          0.05, 0.0, 0.0, 0.0,
                          0.0,  0.0, 0.0, 1.0);

    colorMatrix->setMatrix(cm);

    cessnaMT->getOrCreateStateSet()->setAttributeAndModes(colorMatrix,
             osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

    osgViewer::Viewer viewer;

    // add model to viewer.
    viewer.setSceneData(cessnaMT);

    viewer.run();

    return 0;

}



More information about the osg-users mailing list